Skip to content

Commit 2b2a848

Browse files
author
xiaobing.song
committed
readme
1 parent ee3a01b commit 2b2a848

File tree

2 files changed

+346
-0
lines changed

2 files changed

+346
-0
lines changed

install-single-host-dgw.sh

Lines changed: 341 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,341 @@
1+
#!/bin/bash
2+
3+
function usage()
4+
{
5+
# turn off echo
6+
set +x
7+
8+
# BOOLEAN_VALUES is copied from src/daos/set_boolean.sh because it may not be available. The idea is that
9+
# this script is completely standalone until the repo/branch is set
10+
local BOOLEAN_VALUES="T[RUE]|Y[ES]|F[ALSE]|N[O]|1|0"
11+
echo ""
12+
echo "./install-single-host-dgw.sh"
13+
echo -e "\t-h --help"
14+
echo -e "\t-db --daos-branch=<git-branch-to-use> default=libds3"
15+
echo -e "\t-cb --ceph-branch=<git-branch-to-use> default=add-daos-rgw-sal"
16+
echo -e "\t-dp --daos-path=<git-clone-path> default=/opt/daos"
17+
echo -e "\t-cp --ceph-path=<git-clone-path> default=/opt/ceph"
18+
echo -e "\t-dr --daos-repo=<git-repo> default=https://github.com/daos-stack/daos"
19+
echo -e "\t-cr --ceph-repo=<git-repo> default=https://github.com/zalsader/ceph"
20+
echo -e "\t-cbp --ccache-build-path=<ccache-build-path> default=/opt/ccache-build"
21+
echo -e "\t-cc --ccache-path=<ccache-path> default=/opt/ccache"
22+
echo -e "\t-ep --enable-passwordless-sudo=$BOOLEAN_VALUES default=true"
23+
echo ""
24+
}
25+
26+
function ceph_get()
27+
{
28+
# wget --output-document=folder_free_space.sh https://github.com/zalsader/ceph/blob/docker-build/src/daos/folder_free_space.sh?raw=true
29+
while (( $# )); do
30+
local output_file=$(basename -- $1)
31+
local repo_path=$1
32+
wget --output-document=${output_file} $CEPH_REPO/blob/$CEPH_BRANCH/${repo_path}?raw=true
33+
CLEANUP_FILES+=( ${output_file} )
34+
shift
35+
done
36+
}
37+
38+
function free_space_check()
39+
{
40+
declare -n CHECK_PATH=$1
41+
if [[ ! -d $CHECK_PATH ]]; then
42+
if [[ ! -w $(dirname $CHECK_PATH) ]]; then
43+
sudo chmod 777 $(dirname $CHECK_PATH)
44+
fi
45+
mkdir -p $CHECK_PATH
46+
fi
47+
local FREE_SPACE=$(folder_free_space $CHECK_PATH)
48+
if [ $FREE_SPACE -lt $2 ]; then
49+
echo "Not enough free disk space for $CHECK_PATH, requires a minimum of $2, found $FREE_SPACE"
50+
exit 1
51+
fi
52+
}
53+
54+
function set_passwordless_sudo()
55+
{
56+
if [[ $PASSWORDLESS_SUDO == true ]]; then
57+
sudo cp /etc/sudoers /etc/sudoers.txt
58+
sudo chmod 666 /etc/sudoers.txt
59+
echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers.txt
60+
sudo chmod 110 /etc/sudoers.txt
61+
sudo mv /etc/sudoers.txt /etc/sudoers
62+
fi
63+
}
64+
65+
function assign_path()
66+
{
67+
declare -n ASSIGN_PATH=$1
68+
set +e
69+
grep "$1" ~/.bashrc
70+
if [[ ! $? == 0 ]]; then
71+
echo "export $1=$ASSIGN_PATH" >> ~/.bashrc
72+
fi
73+
set -e
74+
export $1=$ASSIGN_PATH
75+
}
76+
77+
function append_ccache_source_date()
78+
{
79+
set +e
80+
grep "SOURCE_DATE_EPOCH" ~/.bashrc
81+
if [[ ! $? == 0 ]]; then
82+
echo "export SOURCE_DATE_EPOCH=946684800" >> ~/.bashrc
83+
fi
84+
set -e
85+
export SOURCE_DATE_EPOCH=946684800
86+
}
87+
88+
function use_gcc11()
89+
{
90+
set +e
91+
sudo dnf install gcc-toolset-11 -y
92+
grep "gcc-toolset-11" ~/.bashrc
93+
if [[ ! $? == 0 ]]; then
94+
echo "source scl_source enable gcc-toolset-11" >> ~/.bashrc
95+
fi
96+
set -e
97+
source scl_source enable gcc-toolset-11
98+
}
99+
100+
function search_first_word_and_append_to_ccache()
101+
{
102+
local first_word=$(echo $1 | cut -d " " -f 1)
103+
set +e
104+
grep "^${first_word}" /etc/ccache.conf
105+
if [[ ! $? == 0 ]]; then
106+
sudo bash -c "echo \"$1\" >> /etc/ccache.conf"
107+
fi
108+
set -e
109+
}
110+
111+
function install_powertools()
112+
{
113+
sudo dnf install dnf-plugins-core -y
114+
sudo dnf config-manager --set-enabled powertools
115+
sudo dnf -y module enable javapackages-tools
116+
sudo dnf install epel-release -y
117+
}
118+
119+
function create_daos_certificates()
120+
{
121+
pushd /tmp
122+
$DAOS_PATH/install/lib64/daos/certgen/gen_certificates.sh
123+
sudo mkdir -p /etc/daos/certs/clients
124+
sudo cp /tmp/daosCA/certs/* /etc/daos/certs/.
125+
sudo cp /tmp/daosCA/certs/agent.crt /etc/daos/certs/clients/agent.crt
126+
sudo rm -rf /tmp/daosCA
127+
popd
128+
}
129+
130+
function setup_hugepages()
131+
{
132+
set +e
133+
grep -E "vm.nr_hugepages.*=.*[0-9]+" /etc/sysctl.conf
134+
if [[ ! $? == 0 ]]; then
135+
sudo bash -c 'echo "vm.nr_hugepages = 512" >> /etc/sysctl.conf'
136+
REBOOT_REQUIRED=true
137+
else
138+
local huge_pages_config=`grep -E "vm.nr_hugepages.*=.*[0-9]+" /etc/sysctl.conf`
139+
local huge_pages_count=`echo "$huge_pages_config" | grep -oE "[0-9]+"`
140+
echo "huge_pages_count=$huge_pages_count huge_pages_config=$huge_pages_config"
141+
if [ "$huge_pages_count" -lt 512 ]; then
142+
sudo sed -iE "s/vm.nr_hugepages[ \t]*=[ \t]*[0-9]*/vm.nr_hugepages = 512/" /etc/sysctl.conf
143+
REBOOT_REQUIRED=true
144+
fi
145+
fi
146+
set -e
147+
}
148+
149+
function build_daos()
150+
{
151+
pushd $(dirname -- $DAOS_PATH)
152+
if [[ ! -e $DAOS_PATH/README.md ]]; then
153+
git clone --recurse-submodules $DAOS_REPO --branch $DAOS_BRANCH
154+
fi
155+
assign_path DAOS_PATH
156+
cd $DAOS_PATH
157+
# allow dnf to assume "y"
158+
sudo dnf --assumeyes install dnf-plugins-core
159+
sudo dnf config-manager --save --setopt=assumeyes=True
160+
sudo ./utils/scripts/install-el8.sh
161+
sudo yum install python3-scons -y
162+
sudo pip3 install meson==0.59.2 ninja pyelftools distro
163+
scons-3 --config=force --build-deps=yes install
164+
popd
165+
166+
# get the DAOS yaml files
167+
ceph_get src/daos/docker/daos/docker_daos_agent.yml src/daos/docker/daos/docker_daos_control.yml src/daos/docker/daos/docker_daos_server.yml
168+
169+
# don't use yq as it makes unintended changes & removes comments
170+
FABRIC_INTERFACE=$(ip a l | grep -m 1 BROADCAST | cut -d " " -f 2 | sed "s/:$//")
171+
sed -i "s/fabric_iface:.*$/fabric_iface: $FABRIC_INTERFACE/" docker_daos_server.yml
172+
173+
mkdir -p $DAOS_PATH/daos/install/etc/
174+
cp docker_daos_server.yml $DAOS_PATH/install/etc/daos_server.yml
175+
cp docker_daos_agent.yml $DAOS_PATH/install/etc/daos_agent.yml
176+
cp docker_daos_control.yml $DAOS_PATH/install/etc/daos_control.yml
177+
create_daos_certificates
178+
179+
setup_hugepages
180+
}
181+
182+
build_ccache()
183+
{
184+
sudo mkdir -p $CCACHE_BUILD_PATH
185+
sudo chmod 777 $CCACHE_BUILD_PATH
186+
pushd $CCACHE_BUILD_PATH
187+
wget https://github.com/ccache/ccache/releases/download/v4.6.1/ccache-4.6.1.tar.xz
188+
tar -xf ccache-4.6.1.tar.xz
189+
cd ccache-4.6.1/
190+
mkdir -p build
191+
cd build
192+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc -DZSTD_FROM_INTERNET=ON -DHIREDIS_FROM_INTERNET=ON ..
193+
make
194+
sudo make install
195+
popd
196+
sudo mkdir -p $CCACHE_PATH
197+
sudo chmod -R 777 $CCACHE_PATH
198+
}
199+
200+
function starlet_workaround()
201+
{
202+
# as a workaround for xmlstarlet being removed from the el8 repo, we've stored the Seagate repo
203+
set +e
204+
sudo dnf provides xmlstarlet
205+
local dnf_result=$?
206+
set -e
207+
if [[ ! $dnf_result == 0 ]]; then
208+
starlet_manually_installed=true
209+
sed -i "/xmlstarlet/d" ceph.spec.in
210+
sudo pip3 install -U pip
211+
sudo pip3 install -U setuptools
212+
sudo pip3 install xmlstarlet
213+
fi
214+
}
215+
216+
function build_ceph()
217+
{
218+
pushd $(dirname -- $CEPH_PATH)
219+
if [[ ! -e $CEPH_PATH/README.md ]]; then
220+
git clone --recurse $CEPH_REPO --branch $CEPH_BRANCH
221+
fi
222+
assign_path CEPH_PATH
223+
cd $CEPH_PATH
224+
starlet_workaround
225+
./install-deps.sh
226+
if [[ $starlet_manually_installed == true ]]; then
227+
git restore ceph.spec.in
228+
fi
229+
sudo yum install ccache -y
230+
search_first_word_and_append_to_ccache "max_size = 25G"
231+
search_first_word_and_append_to_ccache "sloppiness = time_macros"
232+
search_first_word_and_append_to_ccache "run_second_cpp = true"
233+
append_ccache_source_date
234+
cmake3 -GNinja -DPC_DAOS_INCLUDEDIR=${DAOS_PATH}/install/include -DPC_DAOS_LIBDIR=${DAOS_PATH}/install/lib64 -DWITH_PYTHON3=3.6 -DWITH_RADOSGW_DAOS=YES -DWITH_CCACHE=ON -DENABLE_GIT_VERSION=OFF -B build
235+
cd build
236+
ninja vstart
237+
ceph_get src/daos/docker/ceph/ceph.sed
238+
RGW=1 ../src/vstart.sh -d -n
239+
../src/stop.sh
240+
sed -i -f ceph.sed ceph.conf
241+
popd
242+
}
243+
244+
# Defaults
245+
CCACHE_BUILD_PATH='/opt/ccache-build'
246+
CCACHE_PATH='/opt/ccache'
247+
CEPH_BRANCH='add-daos-rgw-sal'
248+
DAOS_BRANCH='libds3'
249+
CEPH_PATH='/opt/ceph'
250+
DAOS_PATH='/opt/daos'
251+
CLEANUP_FILES=()
252+
CEPH_REPO='https://github.com/zalsader/ceph'
253+
DAOS_REPO='https://github.com/daos-stack/daos'
254+
REBOOT_REQUIRED=false
255+
PASSWORDLESS_SUDO=true
256+
257+
# Read args
258+
while (( $# ))
259+
do
260+
PARAM=`echo $1 | awk -F= '{print $1}'`
261+
VALUE=`echo $1 | awk -F= '{print $2}'`
262+
case $PARAM in
263+
-h | --help)
264+
usage
265+
exit 0
266+
;;
267+
-db | --daos-branch)
268+
DAOS_BRANCH=$VALUE
269+
;;
270+
-cb | --ceph-branch)
271+
CEPH_BRANCH=$VALUE
272+
;;
273+
-dp | --daos-path)
274+
# eval is to expand ~
275+
eval DAOS_PATH=$VALUE
276+
;;
277+
-cp | --ceph-path)
278+
# eval is to expand ~
279+
eval CEPH_PATH=$VALUE
280+
;;
281+
-cbp | --ccache-build-path)
282+
# eval is to expand ~
283+
eval CCACHE_BUILD_PATH=$VALUE
284+
;;
285+
-cc | --ccache-path)
286+
# eval is to expand ~
287+
eval CCACHE_PATH=$VALUE
288+
;;
289+
-dr | --daos-repo)
290+
DAOS_REPO=$VALUE
291+
;;
292+
-cr | --ceph-repo)
293+
CEPH_REPO=$VALUE
294+
;;
295+
-ep | --enable-passwordless-sudo)
296+
# lets hope it actually finds the shell script
297+
ceph_get src/daos/set_boolean.sh
298+
source ./set_boolean.sh
299+
set_boolean PASSWORDLESS_SUDO $VALUE
300+
;;
301+
*)
302+
echo "Unknown option $1"
303+
usage
304+
exit 1
305+
;;
306+
esac
307+
shift
308+
done
309+
310+
# Fail on errors
311+
set -e
312+
# Debug
313+
set -x
314+
# Main
315+
ceph_get src/daos/folder_free_space.sh
316+
source ./folder_free_space.sh
317+
set_passwordless_sudo
318+
free_space_check DAOS_PATH 10000000
319+
free_space_check CEPH_PATH 70000000
320+
DAOS_STORAGE='/tmp'
321+
free_space_check DAOS_STORAGE 5000000
322+
starlet_manually_installed=false
323+
324+
# install packages & install the latest
325+
sudo dnf install openssl git jq net-tools iproute -y
326+
sudo dnf update -y
327+
328+
use_gcc11
329+
install_powertools
330+
build_daos
331+
build_ccache
332+
build_ceph
333+
334+
# cleanup files downloaded during the script (before the reboot)
335+
rm -f ${CLEANUP_FILES[@]}
336+
337+
if [[ $REBOOT_REQUIRED == true ]]; then
338+
echo -e "*** WARNING ***"
339+
read -p "Reboot is required. Press enter to reboot now or ^C to cancel and reboot later"
340+
sudo reboot
341+
fi

readme

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ ceph支持daos后端(rgw, s3), src/rgw/rgw_sal_daos.cc, https://github.com/ceph/
2727

2828

2929

30+
从源分支(上游分支)拉取并合并
31+
git remote set-url upstream https://github.com/ceph/ceph.git
32+
git remote add upstream https://github.com/ceph/ceph.git
33+
git fetch upstream
34+
git merge upstream/master

0 commit comments

Comments
 (0)