]>
Commit | Line | Data |
---|---|---|
11fdf7f2 | 1 | #!/usr/bin/env bash |
7c673cae FG |
2 | |
3 | # abort on failure | |
4 | set -e | |
5 | ||
6 | if [ -n "$VSTART_DEST" ]; then | |
7 | SRC_PATH=`dirname $0` | |
8 | SRC_PATH=`(cd $SRC_PATH; pwd)` | |
9 | ||
10 | CEPH_DIR=$SRC_PATH | |
11 | CEPH_BIN=${PWD}/bin | |
12 | CEPH_LIB=${PWD}/lib | |
13 | ||
14 | CEPH_CONF_PATH=$VSTART_DEST | |
15 | CEPH_DEV_DIR=$VSTART_DEST/dev | |
16 | CEPH_OUT_DIR=$VSTART_DEST/out | |
11fdf7f2 | 17 | CEPH_ASOK_DIR=$VSTART_DEST/out |
7c673cae FG |
18 | fi |
19 | ||
11fdf7f2 TL |
20 | get_cmake_variable() { |
21 | local variable=$1 | |
22 | grep "$variable" CMakeCache.txt | cut -d "=" -f 2 | |
23 | } | |
24 | ||
7c673cae FG |
25 | # for running out of the CMake build directory |
26 | if [ -e CMakeCache.txt ]; then | |
27 | # Out of tree build, learn source location from CMakeCache.txt | |
11fdf7f2 | 28 | CEPH_ROOT=$(get_cmake_variable ceph_SOURCE_DIR) |
7c673cae FG |
29 | CEPH_BUILD_DIR=`pwd` |
30 | [ -z "$MGR_PYTHON_PATH" ] && MGR_PYTHON_PATH=$CEPH_ROOT/src/pybind/mgr | |
11fdf7f2 TL |
31 | CEPH_MGR_PY_VERSION_MAJOR=$(get_cmake_variable MGR_PYTHON_VERSION | cut -d '.' -f1) |
32 | if [ -n "$CEPH_MGR_PY_VERSION_MAJOR" ]; then | |
33 | CEPH_PY_VERSION_MAJOR=${CEPH_MGR_PY_VERSION_MAJOR} | |
34 | else | |
35 | if [ $(get_cmake_variable WITH_PYTHON2) = ON ]; then | |
36 | CEPH_PY_VERSION_MAJOR=2 | |
37 | else | |
38 | CEPH_PY_VERSION_MAJOR=3 | |
39 | fi | |
40 | fi | |
7c673cae FG |
41 | fi |
42 | ||
43 | # use CEPH_BUILD_ROOT to vstart from a 'make install' | |
44 | if [ -n "$CEPH_BUILD_ROOT" ]; then | |
45 | [ -z "$CEPH_BIN" ] && CEPH_BIN=$CEPH_BUILD_ROOT/bin | |
46 | [ -z "$CEPH_LIB" ] && CEPH_LIB=$CEPH_BUILD_ROOT/lib | |
47 | [ -z "$EC_PATH" ] && EC_PATH=$CEPH_LIB/erasure-code | |
48 | [ -z "$OBJCLASS_PATH" ] && OBJCLASS_PATH=$CEPH_LIB/rados-classes | |
11fdf7f2 | 49 | # make install should install python extensions into PYTHONPATH |
7c673cae FG |
50 | elif [ -n "$CEPH_ROOT" ]; then |
51 | [ -z "$PYBIND" ] && PYBIND=$CEPH_ROOT/src/pybind | |
52 | [ -z "$CEPH_BIN" ] && CEPH_BIN=$CEPH_BUILD_DIR/bin | |
53 | [ -z "$CEPH_ADM" ] && CEPH_ADM=$CEPH_BIN/ceph | |
54 | [ -z "$INIT_CEPH" ] && INIT_CEPH=$CEPH_BUILD_DIR/bin/init-ceph | |
55 | [ -z "$CEPH_LIB" ] && CEPH_LIB=$CEPH_BUILD_DIR/lib | |
56 | [ -z "$OBJCLASS_PATH" ] && OBJCLASS_PATH=$CEPH_LIB | |
57 | [ -z "$EC_PATH" ] && EC_PATH=$CEPH_LIB | |
58 | fi | |
59 | ||
60 | if [ -z "${CEPH_VSTART_WRAPPER}" ]; then | |
61 | PATH=$(pwd):$PATH | |
62 | fi | |
63 | ||
64 | [ -z "$PYBIND" ] && PYBIND=./pybind | |
65 | ||
11fdf7f2 | 66 | export PYTHONPATH=$PYBIND:$CEPH_LIB/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}:$PYTHONPATH |
7c673cae FG |
67 | export LD_LIBRARY_PATH=$CEPH_LIB:$LD_LIBRARY_PATH |
68 | export DYLD_LIBRARY_PATH=$CEPH_LIB:$DYLD_LIBRARY_PATH | |
31f18b77 FG |
69 | # Suppress logging for regular use that indicated that we are using a |
70 | # development version. vstart.sh is only used during testing and | |
71 | # development | |
72 | export CEPH_DEV=1 | |
7c673cae FG |
73 | |
74 | [ -z "$CEPH_NUM_MON" ] && CEPH_NUM_MON="$MON" | |
75 | [ -z "$CEPH_NUM_OSD" ] && CEPH_NUM_OSD="$OSD" | |
76 | [ -z "$CEPH_NUM_MDS" ] && CEPH_NUM_MDS="$MDS" | |
77 | [ -z "$CEPH_NUM_MGR" ] && CEPH_NUM_MGR="$MGR" | |
78 | [ -z "$CEPH_NUM_FS" ] && CEPH_NUM_FS="$FS" | |
79 | [ -z "$CEPH_NUM_RGW" ] && CEPH_NUM_RGW="$RGW" | |
80 | ||
81 | # if none of the CEPH_NUM_* number is specified, kill the existing | |
82 | # cluster. | |
83 | if [ -z "$CEPH_NUM_MON" -a \ | |
84 | -z "$CEPH_NUM_OSD" -a \ | |
85 | -z "$CEPH_NUM_MDS" -a \ | |
86 | -z "$CEPH_NUM_MGR" ]; then | |
87 | kill_all=1 | |
88 | else | |
89 | kill_all=0 | |
90 | fi | |
91 | ||
92 | [ -z "$CEPH_NUM_MON" ] && CEPH_NUM_MON=3 | |
93 | [ -z "$CEPH_NUM_OSD" ] && CEPH_NUM_OSD=3 | |
94 | [ -z "$CEPH_NUM_MDS" ] && CEPH_NUM_MDS=3 | |
95 | [ -z "$CEPH_NUM_MGR" ] && CEPH_NUM_MGR=1 | |
96 | [ -z "$CEPH_NUM_FS" ] && CEPH_NUM_FS=1 | |
97 | [ -z "$CEPH_MAX_MDS" ] && CEPH_MAX_MDS=1 | |
98 | [ -z "$CEPH_NUM_RGW" ] && CEPH_NUM_RGW=0 | |
99 | ||
100 | [ -z "$CEPH_DIR" ] && CEPH_DIR="$PWD" | |
101 | [ -z "$CEPH_DEV_DIR" ] && CEPH_DEV_DIR="$CEPH_DIR/dev" | |
102 | [ -z "$CEPH_OUT_DIR" ] && CEPH_OUT_DIR="$CEPH_DIR/out" | |
103 | [ -z "$CEPH_RGW_PORT" ] && CEPH_RGW_PORT=8000 | |
104 | [ -z "$CEPH_CONF_PATH" ] && CEPH_CONF_PATH=$CEPH_DIR | |
105 | ||
106 | if [ $CEPH_NUM_OSD -gt 3 ]; then | |
107 | OSD_POOL_DEFAULT_SIZE=3 | |
108 | else | |
109 | OSD_POOL_DEFAULT_SIZE=$CEPH_NUM_OSD | |
110 | fi | |
111 | ||
112 | extra_conf="" | |
113 | new=0 | |
114 | standby=0 | |
115 | debug=0 | |
116 | ip="" | |
117 | nodaemon=0 | |
118 | smallmds=0 | |
119 | short=0 | |
120 | ec=0 | |
121 | hitset="" | |
122 | overwrite_conf=1 | |
123 | cephx=1 #turn cephx on by default | |
11fdf7f2 | 124 | gssapi_authx=0 |
7c673cae | 125 | cache="" |
11fdf7f2 TL |
126 | if [ `uname` = FreeBSD ]; then |
127 | objectstore="filestore" | |
128 | else | |
129 | objectstore="bluestore" | |
130 | fi | |
131 | rgw_frontend="beast" | |
224ce89b | 132 | rgw_compression="" |
7c673cae | 133 | lockdep=${LOCKDEP:-1} |
11fdf7f2 TL |
134 | spdk_enabled=0 #disable SPDK by default |
135 | pci_id="" | |
136 | ||
137 | with_mgr_dashboard=true | |
138 | if [[ "$(get_cmake_variable WITH_MGR_DASHBOARD_FRONTEND)" != "ON" ]] || | |
139 | [[ "$(get_cmake_variable WITH_RBD)" != "ON" ]]; then | |
140 | echo "ceph-mgr dashboard not built - disabling." | |
141 | with_mgr_dashboard=false | |
142 | fi | |
7c673cae | 143 | |
31f18b77 | 144 | filestore_path= |
11fdf7f2 | 145 | kstore_path= |
31f18b77 | 146 | |
7c673cae FG |
147 | VSTART_SEC="client.vstart.sh" |
148 | ||
149 | MON_ADDR="" | |
31f18b77 FG |
150 | DASH_URLS="" |
151 | RESTFUL_URLS="" | |
7c673cae FG |
152 | |
153 | conf_fn="$CEPH_CONF_PATH/ceph.conf" | |
154 | keyring_fn="$CEPH_CONF_PATH/keyring" | |
155 | osdmap_fn="/tmp/ceph_osdmap.$$" | |
156 | monmap_fn="/tmp/ceph_monmap.$$" | |
157 | ||
11fdf7f2 TL |
158 | msgr="21" |
159 | ||
160 | usage="usage: $0 [option]... \nex: MON=3 OSD=1 MDS=1 MGR=1 RGW=1 $0 -n -d\n" | |
7c673cae FG |
161 | usage=$usage"options:\n" |
162 | usage=$usage"\t-d, --debug\n" | |
163 | usage=$usage"\t-s, --standby_mds: Generate standby-replay MDS for each active\n" | |
164 | usage=$usage"\t-l, --localhost: use localhost instead of hostname\n" | |
165 | usage=$usage"\t-i <ip>: bind to specific ip\n" | |
166 | usage=$usage"\t-n, --new\n" | |
167 | usage=$usage"\t-N, --not-new: reuse existing cluster config (default)\n" | |
168 | usage=$usage"\t--valgrind[_{osd,mds,mon,rgw}] 'toolname args...'\n" | |
169 | usage=$usage"\t--nodaemon: use ceph-run as wrapper for mon/osd/mds\n" | |
170 | usage=$usage"\t--smallmds: limit mds cache size\n" | |
171 | usage=$usage"\t-m ip:port\t\tspecify monitor address\n" | |
172 | usage=$usage"\t-k keep old configuration files\n" | |
173 | usage=$usage"\t-x enable cephx (on by default)\n" | |
174 | usage=$usage"\t-X disable cephx\n" | |
11fdf7f2 TL |
175 | usage=$usage"\t-g --gssapi enable Kerberos/GSSApi authentication\n" |
176 | usage=$usage"\t-G disable Kerberos/GSSApi authentication\n" | |
7c673cae FG |
177 | usage=$usage"\t--hitset <pool> <hit_set_type>: enable hitset tracking\n" |
178 | usage=$usage"\t-e : create an erasure pool\n"; | |
179 | usage=$usage"\t-o config\t\t add extra config parameters to all sections\n" | |
7c673cae FG |
180 | usage=$usage"\t--rgw_port specify ceph rgw http listen port\n" |
181 | usage=$usage"\t--rgw_frontend specify the rgw frontend configuration\n" | |
224ce89b | 182 | usage=$usage"\t--rgw_compression specify the rgw compression plugin\n" |
11fdf7f2 TL |
183 | usage=$usage"\t-b, --bluestore use bluestore as the osd objectstore backend (default)\n" |
184 | usage=$usage"\t-f, --filestore use filestore as the osd objectstore backend\n" | |
185 | usage=$usage"\t-K, --kstore use kstore as the osd objectstore backend\n" | |
7c673cae FG |
186 | usage=$usage"\t--memstore use memstore as the osd objectstore backend\n" |
187 | usage=$usage"\t--cache <pool>: enable cache tiering on pool\n" | |
188 | usage=$usage"\t--short: short object names only; necessary for ext4 dev\n" | |
189 | usage=$usage"\t--nolockdep disable lockdep\n" | |
190 | usage=$usage"\t--multimds <count> allow multimds with maximum active count\n" | |
11fdf7f2 TL |
191 | usage=$usage"\t--without-dashboard: do not run using mgr dashboard\n" |
192 | usage=$usage"\t--bluestore-spdk <vendor>:<device>: enable SPDK and specify the PCI-ID of the NVME device\n" | |
193 | usage=$usage"\t--msgr1: use msgr1 only\n" | |
194 | usage=$usage"\t--msgr2: use msgr2 only\n" | |
195 | usage=$usage"\t--msgr21: use msgr2 and msgr1\n" | |
7c673cae FG |
196 | |
197 | usage_exit() { | |
198 | printf "$usage" | |
199 | exit | |
200 | } | |
201 | ||
202 | while [ $# -ge 1 ]; do | |
203 | case $1 in | |
204 | -d | --debug ) | |
205 | debug=1 | |
206 | ;; | |
207 | -s | --standby_mds) | |
208 | standby=1 | |
209 | ;; | |
210 | -l | --localhost ) | |
211 | ip="127.0.0.1" | |
212 | ;; | |
213 | -i ) | |
214 | [ -z "$2" ] && usage_exit | |
215 | ip="$2" | |
216 | shift | |
217 | ;; | |
218 | -e ) | |
219 | ec=1 | |
220 | ;; | |
221 | --new | -n ) | |
222 | new=1 | |
223 | ;; | |
224 | --not-new | -N ) | |
225 | new=0 | |
226 | ;; | |
227 | --short ) | |
228 | short=1 | |
229 | ;; | |
11fdf7f2 TL |
230 | --msgr1 ) |
231 | msgr="1" | |
232 | ;; | |
233 | --msgr2 ) | |
234 | msgr="2" | |
235 | ;; | |
236 | --msgr21 ) | |
237 | msgr="21" | |
238 | ;; | |
7c673cae FG |
239 | --valgrind ) |
240 | [ -z "$2" ] && usage_exit | |
241 | valgrind=$2 | |
242 | shift | |
243 | ;; | |
244 | --valgrind_args ) | |
245 | valgrind_args="$2" | |
246 | shift | |
247 | ;; | |
248 | --valgrind_mds ) | |
249 | [ -z "$2" ] && usage_exit | |
250 | valgrind_mds=$2 | |
251 | shift | |
252 | ;; | |
253 | --valgrind_osd ) | |
254 | [ -z "$2" ] && usage_exit | |
255 | valgrind_osd=$2 | |
256 | shift | |
257 | ;; | |
258 | --valgrind_mon ) | |
259 | [ -z "$2" ] && usage_exit | |
260 | valgrind_mon=$2 | |
261 | shift | |
262 | ;; | |
263 | --valgrind_mgr ) | |
264 | [ -z "$2" ] && usage_exit | |
265 | valgrind_mgr=$2 | |
266 | shift | |
267 | ;; | |
268 | --valgrind_rgw ) | |
269 | [ -z "$2" ] && usage_exit | |
270 | valgrind_rgw=$2 | |
271 | shift | |
272 | ;; | |
273 | --nodaemon ) | |
274 | nodaemon=1 | |
275 | ;; | |
276 | --smallmds ) | |
277 | smallmds=1 | |
278 | ;; | |
7c673cae FG |
279 | --rgw_port ) |
280 | CEPH_RGW_PORT=$2 | |
281 | shift | |
282 | ;; | |
283 | --rgw_frontend ) | |
284 | rgw_frontend=$2 | |
285 | shift | |
286 | ;; | |
224ce89b WB |
287 | --rgw_compression ) |
288 | rgw_compression=$2 | |
289 | shift | |
290 | ;; | |
11fdf7f2 TL |
291 | --kstore_path ) |
292 | kstore_path=$2 | |
293 | shift | |
294 | ;; | |
31f18b77 FG |
295 | --filestore_path ) |
296 | filestore_path=$2 | |
297 | shift | |
298 | ;; | |
7c673cae FG |
299 | -m ) |
300 | [ -z "$2" ] && usage_exit | |
301 | MON_ADDR=$2 | |
302 | shift | |
303 | ;; | |
304 | -x ) | |
305 | cephx=1 # this is on be default, flag exists for historical consistency | |
306 | ;; | |
307 | -X ) | |
308 | cephx=0 | |
309 | ;; | |
11fdf7f2 TL |
310 | |
311 | -g | --gssapi) | |
312 | gssapi_authx=1 | |
313 | ;; | |
314 | -G) | |
315 | gssapi_authx=0 | |
316 | ;; | |
317 | ||
7c673cae FG |
318 | -k ) |
319 | if [ ! -r $conf_fn ]; then | |
320 | echo "cannot use old configuration: $conf_fn not readable." >&2 | |
321 | exit | |
322 | fi | |
323 | overwrite_conf=0 | |
324 | ;; | |
325 | --memstore ) | |
11fdf7f2 | 326 | objectstore="memstore" |
7c673cae FG |
327 | ;; |
328 | -b | --bluestore ) | |
11fdf7f2 | 329 | objectstore="bluestore" |
7c673cae | 330 | ;; |
11fdf7f2 TL |
331 | -f | --filestore ) |
332 | objectstore="filestore" | |
333 | ;; | |
334 | -K | --kstore ) | |
335 | objectstore="kstore" | |
336 | ;; | |
7c673cae FG |
337 | --hitset ) |
338 | hitset="$hitset $2 $3" | |
339 | shift | |
340 | shift | |
341 | ;; | |
342 | -o ) | |
343 | extra_conf="$extra_conf $2 | |
344 | " | |
345 | shift | |
346 | ;; | |
347 | --cache ) | |
348 | if [ -z "$cache" ]; then | |
349 | cache="$2" | |
350 | else | |
351 | cache="$cache $2" | |
352 | fi | |
353 | shift | |
354 | ;; | |
355 | --nolockdep ) | |
356 | lockdep=0 | |
357 | ;; | |
358 | --multimds) | |
359 | CEPH_MAX_MDS="$2" | |
360 | shift | |
361 | ;; | |
11fdf7f2 TL |
362 | --without-dashboard) |
363 | with_mgr_dashboard=false | |
364 | ;; | |
365 | --bluestore-spdk ) | |
366 | [ -z "$2" ] && usage_exit | |
367 | pci_id="$2" | |
368 | spdk_enabled=1 | |
369 | shift | |
370 | ;; | |
7c673cae FG |
371 | * ) |
372 | usage_exit | |
373 | esac | |
374 | shift | |
375 | done | |
376 | ||
377 | if [ $kill_all -eq 1 ]; then | |
378 | $SUDO $INIT_CEPH stop | |
379 | fi | |
380 | ||
381 | if [ "$overwrite_conf" -eq 0 ]; then | |
11fdf7f2 | 382 | CEPH_ASOK_DIR=`dirname $($CEPH_BIN/ceph-conf -c $conf_fn --show-config-value admin_socket)` |
c07f9fc5 | 383 | mkdir -p $CEPH_ASOK_DIR |
7c673cae FG |
384 | MON=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_mon 2>/dev/null` && \ |
385 | CEPH_NUM_MON="$MON" | |
386 | OSD=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_osd 2>/dev/null` && \ | |
387 | CEPH_NUM_OSD="$OSD" | |
388 | MDS=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_mds 2>/dev/null` && \ | |
389 | CEPH_NUM_MDS="$MDS" | |
390 | MGR=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_mgr 2>/dev/null` && \ | |
391 | CEPH_NUM_MGR="$MGR" | |
392 | RGW=`$CEPH_BIN/ceph-conf -c $conf_fn --name $VSTART_SEC num_rgw 2>/dev/null` && \ | |
393 | CEPH_NUM_RGW="$RGW" | |
394 | else | |
395 | if [ "$new" -ne 0 ]; then | |
396 | # only delete if -n | |
11fdf7f2 TL |
397 | if [ -e "$conf_fn" ]; then |
398 | asok_dir=`dirname $($CEPH_BIN/ceph-conf -c $conf_fn --show-config-value admin_socket)` | |
399 | rm -- "$conf_fn" | |
400 | if [ $asok_dir != /var/run/ceph ]; then | |
c07f9fc5 | 401 | [ -d $asok_dir ] && rm -f $asok_dir/* && rmdir $asok_dir |
11fdf7f2 TL |
402 | fi |
403 | fi | |
404 | if [ -z "$CEPH_ASOK_DIR" ]; then | |
c07f9fc5 FG |
405 | CEPH_ASOK_DIR=`mktemp -u -d "${TMPDIR:-/tmp}/ceph-asok.XXXXXX"` |
406 | fi | |
7c673cae | 407 | else |
11fdf7f2 TL |
408 | if [ -z "$CEPH_ASOK_DIR" ]; then |
409 | CEPH_ASOK_DIR=`dirname $($CEPH_BIN/ceph-conf -c $conf_fn --show-config-value admin_socket)` | |
410 | fi | |
7c673cae FG |
411 | # -k is implied... (doesn't make sense otherwise) |
412 | overwrite_conf=0 | |
413 | fi | |
414 | fi | |
415 | ||
416 | ARGS="-c $conf_fn" | |
417 | ||
11fdf7f2 TL |
418 | quoted_print() { |
419 | for s in "$@"; do | |
420 | if [[ "$s" =~ \ ]]; then | |
421 | printf -- "'%s' " "$s" | |
422 | else | |
423 | printf -- "$s " | |
424 | fi | |
425 | done | |
426 | printf '\n' | |
427 | } | |
428 | ||
7c673cae | 429 | prunb() { |
11fdf7f2 | 430 | quoted_print "$@" '&' |
7c673cae FG |
431 | "$@" & |
432 | } | |
433 | ||
434 | prun() { | |
11fdf7f2 | 435 | quoted_print "$@" |
7c673cae FG |
436 | "$@" |
437 | } | |
438 | ||
439 | run() { | |
440 | type=$1 | |
441 | shift | |
442 | eval "valg=\$valgrind_$type" | |
443 | [ -z "$valg" ] && valg="$valgrind" | |
444 | ||
445 | if [ -n "$valg" ]; then | |
446 | prunb valgrind --tool="$valg" $valgrind_args "$@" -f | |
447 | sleep 1 | |
448 | else | |
449 | if [ "$nodaemon" -eq 0 ]; then | |
450 | prun "$@" | |
451 | else | |
452 | prunb ./ceph-run "$@" -f | |
453 | fi | |
454 | fi | |
455 | } | |
456 | ||
457 | wconf() { | |
458 | if [ "$overwrite_conf" -eq 1 ]; then | |
459 | cat >> "$conf_fn" | |
460 | fi | |
461 | } | |
462 | ||
11fdf7f2 TL |
463 | get_pci_selector() { |
464 | lspci -mm -n -D -d $pci_id | cut -d' ' -f1 | |
465 | } | |
466 | ||
7c673cae FG |
467 | prepare_conf() { |
468 | local DAEMONOPTS=" | |
469 | log file = $CEPH_OUT_DIR/\$name.log | |
c07f9fc5 | 470 | admin socket = $CEPH_ASOK_DIR/\$name.asok |
7c673cae FG |
471 | chdir = \"\" |
472 | pid file = $CEPH_OUT_DIR/\$name.pid | |
473 | heartbeat file = $CEPH_OUT_DIR/\$name.heartbeat | |
474 | " | |
475 | ||
11fdf7f2 TL |
476 | local mgr_modules="restful iostat" |
477 | if $with_mgr_dashboard; then | |
478 | mgr_modules="dashboard $mgr_modules" | |
479 | fi | |
480 | ||
481 | local msgr_conf='' | |
482 | if [ $msgr -eq 21 ]; then | |
483 | msgr_conf="ms bind msgr2 = true | |
484 | ms bind msgr1 = true | |
485 | "; | |
486 | fi | |
487 | if [ $msgr -eq 2 ]; then | |
488 | msgr_conf="ms bind msgr2 = true | |
489 | ms bind msgr1 = false | |
490 | "; | |
491 | fi | |
492 | if [ $msgr -eq 1 ]; then | |
493 | msgr_conf="ms bind msgr2 = false | |
494 | ms bind msgr1 = true | |
495 | "; | |
496 | fi | |
497 | ||
7c673cae FG |
498 | wconf <<EOF |
499 | ; generated by vstart.sh on `date` | |
500 | [$VSTART_SEC] | |
501 | num mon = $CEPH_NUM_MON | |
502 | num osd = $CEPH_NUM_OSD | |
503 | num mds = $CEPH_NUM_MDS | |
504 | num mgr = $CEPH_NUM_MGR | |
505 | num rgw = $CEPH_NUM_RGW | |
506 | ||
507 | [global] | |
508 | fsid = $(uuidgen) | |
7c673cae | 509 | osd failsafe full ratio = .99 |
11fdf7f2 | 510 | mon osd full ratio = .99 |
c07f9fc5 FG |
511 | mon osd nearfull ratio = .99 |
512 | mon osd backfillfull ratio = .99 | |
7c673cae FG |
513 | erasure code dir = $EC_PATH |
514 | plugin dir = $CEPH_LIB | |
7c673cae FG |
515 | filestore fd cache size = 32 |
516 | run dir = $CEPH_OUT_DIR | |
11fdf7f2 | 517 | crash dir = $CEPH_OUT_DIR |
7c673cae | 518 | enable experimental unrecoverable data corrupting features = * |
11fdf7f2 TL |
519 | osd_crush_chooseleaf_type = 0 |
520 | debug asok assert abort = true | |
521 | $msgr_conf | |
522 | $extra_conf | |
7c673cae FG |
523 | EOF |
524 | if [ "$lockdep" -eq 1 ] ; then | |
525 | wconf <<EOF | |
526 | lockdep = true | |
527 | EOF | |
528 | fi | |
529 | if [ "$cephx" -eq 1 ] ; then | |
530 | wconf <<EOF | |
11fdf7f2 TL |
531 | auth cluster required = cephx |
532 | auth service required = cephx | |
533 | auth client required = cephx | |
7c673cae | 534 | EOF |
11fdf7f2 TL |
535 | elif [ "$gssapi_authx" -eq 1 ] ; then |
536 | wconf <<EOF | |
537 | auth cluster required = gss | |
538 | auth service required = gss | |
539 | auth client required = gss | |
540 | gss ktab client file = $CEPH_DEV_DIR/gss_\$name.keytab | |
541 | EOF | |
542 | else | |
7c673cae FG |
543 | wconf <<EOF |
544 | auth cluster required = none | |
545 | auth service required = none | |
546 | auth client required = none | |
547 | EOF | |
548 | fi | |
549 | if [ "$short" -eq 1 ]; then | |
550 | COSDSHORT=" osd max object name len = 460 | |
551 | osd max object namespace len = 64" | |
552 | fi | |
11fdf7f2 TL |
553 | if [ "$objectstore" == "bluestore" ]; then |
554 | if [ "$spdk_enabled" -eq 1 ]; then | |
555 | if [ "$(get_pci_selector)" == "" ]; then | |
556 | echo "Not find the specified NVME device, please check." | |
557 | exit | |
558 | fi | |
559 | BLUESTORE_OPTS=" bluestore_block_db_path = \"\" | |
560 | bluestore_block_db_size = 0 | |
561 | bluestore_block_db_create = false | |
562 | bluestore_block_wal_path = \"\" | |
563 | bluestore_block_wal_size = 0 | |
564 | bluestore_block_wal_create = false | |
565 | bluestore_spdk_mem = 2048 | |
566 | bluestore_block_path = spdk:$(get_pci_selector)" | |
567 | else | |
568 | BLUESTORE_OPTS=" bluestore block db path = $CEPH_DEV_DIR/osd\$id/block.db.file | |
569 | bluestore block db size = 1073741824 | |
570 | bluestore block db create = true | |
571 | bluestore block wal path = $CEPH_DEV_DIR/osd\$id/block.wal.file | |
572 | bluestore block wal size = 1048576000 | |
573 | bluestore block wal create = true" | |
574 | fi | |
575 | fi | |
7c673cae FG |
576 | wconf <<EOF |
577 | [client] | |
578 | keyring = $keyring_fn | |
579 | log file = $CEPH_OUT_DIR/\$name.\$pid.log | |
c07f9fc5 | 580 | admin socket = $CEPH_ASOK_DIR/\$name.\$pid.asok |
11fdf7f2 | 581 | $extra_conf |
224ce89b | 582 | [client.rgw] |
11fdf7f2 TL |
583 | rgw frontends = $rgw_frontend port=$CEPH_RGW_PORT |
584 | admin socket = ${CEPH_OUT_DIR}/radosgw.${CEPH_RGW_PORT}.asok | |
585 | ; needed for s3tests | |
586 | rgw crypt s3 kms encryption keys = testkey-1=YmluCmJvb3N0CmJvb3N0LWJ1aWxkCmNlcGguY29uZgo= testkey-2=aWIKTWFrZWZpbGUKbWFuCm91dApzcmMKVGVzdGluZwo= | |
587 | rgw crypt require ssl = false | |
588 | ; uncomment the following to set LC days as the value in seconds; | |
589 | ; needed for passing lc time based s3-tests (can be verbose) | |
590 | ; rgw lc debug interval = 10 | |
7c673cae FG |
591 | [mds] |
592 | $DAEMONOPTS | |
7c673cae FG |
593 | mds data = $CEPH_DEV_DIR/mds.\$id |
594 | mds root ino uid = `id -u` | |
595 | mds root ino gid = `id -g` | |
596 | $extra_conf | |
597 | [mgr] | |
7c673cae FG |
598 | mgr data = $CEPH_DEV_DIR/mgr.\$id |
599 | mgr module path = $MGR_PYTHON_PATH | |
7c673cae | 600 | $DAEMONOPTS |
7c673cae FG |
601 | $extra_conf |
602 | [osd] | |
603 | $DAEMONOPTS | |
604 | osd_check_max_object_name_len_on_startup = false | |
605 | osd data = $CEPH_DEV_DIR/osd\$id | |
606 | osd journal = $CEPH_DEV_DIR/osd\$id/journal | |
607 | osd journal size = 100 | |
608 | osd class tmp = out | |
609 | osd class dir = $OBJCLASS_PATH | |
610 | osd class load list = * | |
611 | osd class default list = * | |
92f5a8d4 | 612 | osd fast shutdown = false |
11fdf7f2 | 613 | |
7c673cae FG |
614 | filestore wbthrottle xfs ios start flusher = 10 |
615 | filestore wbthrottle xfs ios hard limit = 20 | |
616 | filestore wbthrottle xfs inodes hard limit = 30 | |
617 | filestore wbthrottle btrfs ios start flusher = 10 | |
618 | filestore wbthrottle btrfs ios hard limit = 20 | |
619 | filestore wbthrottle btrfs inodes hard limit = 30 | |
7c673cae FG |
620 | bluestore fsck on mount = true |
621 | bluestore block create = true | |
11fdf7f2 TL |
622 | $BLUESTORE_OPTS |
623 | ||
624 | ; kstore | |
625 | kstore fsck on mount = true | |
626 | osd objectstore = $objectstore | |
7c673cae FG |
627 | $COSDSHORT |
628 | $extra_conf | |
629 | [mon] | |
11fdf7f2 | 630 | mgr initial modules = $mgr_modules |
7c673cae FG |
631 | $DAEMONOPTS |
632 | $CMONDEBUG | |
633 | $extra_conf | |
634 | mon cluster log file = $CEPH_OUT_DIR/cluster.mon.\$id.log | |
11fdf7f2 | 635 | osd pool default erasure code profile = plugin=jerasure technique=reed_sol_van k=2 m=1 crush-failure-domain=osd |
7c673cae FG |
636 | EOF |
637 | } | |
638 | ||
639 | start_mon() { | |
640 | local MONS="" | |
641 | local count=0 | |
642 | for f in a b c d e f g h i j k l m n o p q r s t u v w x y z | |
643 | do | |
644 | [ $count -eq $CEPH_NUM_MON ] && break; | |
645 | count=$(($count + 1)) | |
646 | if [ -z "$MONS" ]; | |
647 | then | |
648 | MONS="$f" | |
649 | else | |
650 | MONS="$MONS $f" | |
651 | fi | |
652 | done | |
653 | ||
654 | if [ "$new" -eq 1 ]; then | |
655 | if [ `echo $IP | grep '^127\\.'` ] | |
656 | then | |
657 | echo | |
658 | echo "NOTE: hostname resolves to loopback; remote hosts will not be able to" | |
659 | echo " connect. either adjust /etc/hosts, or edit this script to use your" | |
660 | echo " machine's real IP." | |
661 | echo | |
662 | fi | |
663 | ||
664 | prun $SUDO "$CEPH_BIN/ceph-authtool" --create-keyring --gen-key --name=mon. "$keyring_fn" --cap mon 'allow *' | |
11fdf7f2 | 665 | prun $SUDO "$CEPH_BIN/ceph-authtool" --gen-key --name=client.admin \ |
7c673cae FG |
666 | --cap mon 'allow *' \ |
667 | --cap osd 'allow *' \ | |
668 | --cap mds 'allow *' \ | |
669 | --cap mgr 'allow *' \ | |
670 | "$keyring_fn" | |
671 | ||
11fdf7f2 TL |
672 | prun $SUDO "$CEPH_BIN/ceph-authtool" --gen-key --name=client.fs\ |
673 | --cap mon 'allow r' \ | |
674 | --cap osd 'allow rw tag cephfs data=*' \ | |
675 | --cap mds 'allow rwp' \ | |
676 | "$keyring_fn" | |
677 | ||
224ce89b WB |
678 | prun $SUDO "$CEPH_BIN/ceph-authtool" --gen-key --name=client.rgw \ |
679 | --cap mon 'allow rw' \ | |
680 | --cap osd 'allow rwx' \ | |
681 | --cap mgr 'allow rw' \ | |
682 | "$keyring_fn" | |
683 | ||
7c673cae | 684 | # build a fresh fs monmap, mon fs |
11fdf7f2 | 685 | local params=() |
7c673cae | 686 | local count=0 |
11fdf7f2 | 687 | local mon_host="" |
7c673cae FG |
688 | for f in $MONS |
689 | do | |
11fdf7f2 TL |
690 | if [ $msgr -eq 1 ]; then |
691 | A="v1:$IP:$(($CEPH_PORT+$count+1))" | |
692 | fi | |
693 | if [ $msgr -eq 2 ]; then | |
694 | A="v2:$IP:$(($CEPH_PORT+$count+1))" | |
695 | fi | |
696 | if [ $msgr -eq 21 ]; then | |
697 | A="[v2:$IP:$(($CEPH_PORT+$count)),v1:$IP:$(($CEPH_PORT+$count+1))]" | |
698 | fi | |
699 | params+=("--addv" "$f" "$A") | |
700 | mon_host="$mon_host $A" | |
701 | wconf <<EOF | |
7c673cae FG |
702 | [mon.$f] |
703 | host = $HOSTNAME | |
704 | mon data = $CEPH_DEV_DIR/mon.$f | |
7c673cae | 705 | EOF |
11fdf7f2 | 706 | count=$(($count + 2)) |
7c673cae | 707 | done |
11fdf7f2 TL |
708 | wconf <<EOF |
709 | [global] | |
710 | mon host = $mon_host | |
711 | EOF | |
712 | prun "$CEPH_BIN/monmaptool" --create --clobber "${params[@]}" --print "$monmap_fn" | |
7c673cae FG |
713 | |
714 | for f in $MONS | |
715 | do | |
716 | prun rm -rf -- "$CEPH_DEV_DIR/mon.$f" | |
717 | prun mkdir -p "$CEPH_DEV_DIR/mon.$f" | |
718 | prun "$CEPH_BIN/ceph-mon" --mkfs -c "$conf_fn" -i "$f" --monmap="$monmap_fn" --keyring="$keyring_fn" | |
719 | done | |
720 | ||
721 | prun rm -- "$monmap_fn" | |
722 | fi | |
723 | ||
724 | # start monitors | |
725 | for f in $MONS | |
726 | do | |
727 | run 'mon' $CEPH_BIN/ceph-mon -i $f $ARGS $CMON_ARGS | |
728 | done | |
729 | } | |
730 | ||
731 | start_osd() { | |
732 | for osd in `seq 0 $((CEPH_NUM_OSD-1))` | |
733 | do | |
734 | if [ "$new" -eq 1 ]; then | |
735 | wconf <<EOF | |
736 | [osd.$osd] | |
737 | host = $HOSTNAME | |
738 | EOF | |
739 | ||
740 | rm -rf $CEPH_DEV_DIR/osd$osd || true | |
741 | if command -v btrfs > /dev/null; then | |
742 | for f in $CEPH_DEV_DIR/osd$osd/*; do btrfs sub delete $f &> /dev/null || true; done | |
743 | fi | |
31f18b77 FG |
744 | if [ -n "$filestore_path" ]; then |
745 | ln -s $filestore_path $CEPH_DEV_DIR/osd$osd | |
11fdf7f2 TL |
746 | elif [ -n "$kstore_path" ]; then |
747 | ln -s $kstore_path $CEPH_DEV_DIR/osd$osd | |
31f18b77 FG |
748 | else |
749 | mkdir -p $CEPH_DEV_DIR/osd$osd | |
750 | fi | |
7c673cae FG |
751 | |
752 | local uuid=`uuidgen` | |
753 | echo "add osd$osd $uuid" | |
3efd9988 | 754 | OSD_SECRET=$($CEPH_BIN/ceph-authtool --gen-print-key) |
11fdf7f2 TL |
755 | echo "{\"cephx_secret\": \"$OSD_SECRET\"}" > $CEPH_DEV_DIR/osd$osd/new.json |
756 | ceph_adm osd new $uuid -i $CEPH_DEV_DIR/osd$osd/new.json | |
757 | rm $CEPH_DEV_DIR/osd$osd/new.json | |
3efd9988 | 758 | $SUDO $CEPH_BIN/ceph-osd -i $osd $ARGS --mkfs --key $OSD_SECRET --osd-uuid $uuid |
7c673cae FG |
759 | |
760 | local key_fn=$CEPH_DEV_DIR/osd$osd/keyring | |
3efd9988 FG |
761 | cat > $key_fn<<EOF |
762 | [osd.$osd] | |
763 | key = $OSD_SECRET | |
764 | EOF | |
7c673cae FG |
765 | echo adding osd$osd key to auth repository |
766 | ceph_adm -i "$key_fn" auth add osd.$osd osd "allow *" mon "allow profile osd" mgr "allow profile osd" | |
767 | fi | |
31f18b77 | 768 | echo start osd.$osd |
7c673cae FG |
769 | run 'osd' $SUDO $CEPH_BIN/ceph-osd -i $osd $ARGS $COSD_ARGS |
770 | done | |
771 | } | |
772 | ||
773 | start_mgr() { | |
774 | local mgr=0 | |
11fdf7f2 | 775 | local ssl=${DASHBOARD_SSL:-1} |
31f18b77 FG |
776 | # avoid monitors on nearby ports (which test/*.sh use extensively) |
777 | MGR_PORT=$(($CEPH_PORT + 1000)) | |
7c673cae FG |
778 | for name in x y z a b c d e f g h i j k l m n o p |
779 | do | |
780 | [ $mgr -eq $CEPH_NUM_MGR ] && break | |
781 | mgr=$(($mgr + 1)) | |
782 | if [ "$new" -eq 1 ]; then | |
783 | mkdir -p $CEPH_DEV_DIR/mgr.$name | |
784 | key_fn=$CEPH_DEV_DIR/mgr.$name/keyring | |
785 | $SUDO $CEPH_BIN/ceph-authtool --create-keyring --gen-key --name=mgr.$name $key_fn | |
786 | ceph_adm -i $key_fn auth add mgr.$name mon 'allow profile mgr' mds 'allow *' osd 'allow *' | |
7c673cae | 787 | |
11fdf7f2 | 788 | wconf <<EOF |
7c673cae FG |
789 | [mgr.$name] |
790 | host = $HOSTNAME | |
791 | EOF | |
792 | ||
11fdf7f2 TL |
793 | if $with_mgr_dashboard ; then |
794 | local port_option="ssl_server_port" | |
795 | local http_proto="https" | |
796 | if [ "$ssl" == "0" ]; then | |
797 | port_option="server_port" | |
798 | http_proto="http" | |
799 | ceph_adm config set mgr mgr/dashboard/ssl false --force | |
800 | fi | |
801 | ceph_adm config set mgr mgr/dashboard/$name/$port_option $MGR_PORT --force | |
802 | if [ $mgr -eq 1 ]; then | |
803 | DASH_URLS="$http_proto://$IP:$MGR_PORT" | |
804 | else | |
805 | DASH_URLS+=", $http_proto://$IP:$MGR_PORT" | |
806 | fi | |
807 | fi | |
808 | MGR_PORT=$(($MGR_PORT + 1000)) | |
31f18b77 | 809 | |
11fdf7f2 TL |
810 | ceph_adm config set mgr mgr/restful/$name/server_port $MGR_PORT --force |
811 | if [ $mgr -eq 1 ]; then | |
812 | RESTFUL_URLS="https://$IP:$MGR_PORT" | |
813 | else | |
814 | RESTFUL_URLS+=", https://$IP:$MGR_PORT" | |
815 | fi | |
816 | MGR_PORT=$(($MGR_PORT + 1000)) | |
817 | fi | |
31f18b77 | 818 | |
7c673cae FG |
819 | echo "Starting mgr.${name}" |
820 | run 'mgr' $CEPH_BIN/ceph-mgr -i $name $ARGS | |
821 | done | |
31f18b77 | 822 | |
c07f9fc5 FG |
823 | # use tell mgr here because the first mgr might not have activated yet |
824 | # to register the python module commands. | |
11fdf7f2 TL |
825 | if [ "$new" -eq 1 ]; then |
826 | # setting login credentials for dashboard | |
827 | if $with_mgr_dashboard; then | |
828 | ceph_adm tell mgr dashboard ac-user-create admin admin administrator | |
829 | if [ "$ssl" != "0" ]; then | |
830 | if ! ceph_adm tell mgr dashboard create-self-signed-cert; then | |
831 | echo dashboard module not working correctly! | |
832 | fi | |
7c673cae | 833 | fi |
11fdf7f2 | 834 | fi |
7c673cae | 835 | |
11fdf7f2 TL |
836 | if ceph_adm tell mgr restful create-self-signed-cert; then |
837 | SF=`mktemp` | |
838 | ceph_adm restful create-key admin -o $SF | |
839 | RESTFUL_SECRET=`cat $SF` | |
840 | rm $SF | |
841 | else | |
842 | echo MGR Restful is not working, perhaps the package is not installed? | |
7c673cae FG |
843 | fi |
844 | fi | |
11fdf7f2 | 845 | } |
7c673cae | 846 | |
11fdf7f2 | 847 | start_mds() { |
7c673cae FG |
848 | local mds=0 |
849 | for name in a b c d e f g h i j k l m n o p | |
850 | do | |
851 | [ $mds -eq $CEPH_NUM_MDS ] && break | |
852 | mds=$(($mds + 1)) | |
853 | ||
854 | if [ "$new" -eq 1 ]; then | |
855 | prun mkdir -p "$CEPH_DEV_DIR/mds.$name" | |
856 | key_fn=$CEPH_DEV_DIR/mds.$name/keyring | |
857 | wconf <<EOF | |
858 | [mds.$name] | |
859 | host = $HOSTNAME | |
860 | EOF | |
861 | if [ "$standby" -eq 1 ]; then | |
862 | mkdir -p $CEPH_DEV_DIR/mds.${name}s | |
863 | wconf <<EOF | |
864 | mds standby for rank = $mds | |
865 | [mds.${name}s] | |
866 | mds standby replay = true | |
867 | mds standby for name = ${name} | |
868 | EOF | |
869 | fi | |
870 | prun $SUDO "$CEPH_BIN/ceph-authtool" --create-keyring --gen-key --name="mds.$name" "$key_fn" | |
11fdf7f2 | 871 | ceph_adm -i "$key_fn" auth add "mds.$name" mon 'allow profile mds' osd 'allow rw tag cephfs *=*' mds 'allow' mgr 'allow profile mds' |
7c673cae FG |
872 | if [ "$standby" -eq 1 ]; then |
873 | prun $SUDO "$CEPH_BIN/ceph-authtool" --create-keyring --gen-key --name="mds.${name}s" \ | |
874 | "$CEPH_DEV_DIR/mds.${name}s/keyring" | |
875 | ceph_adm -i "$CEPH_DEV_DIR/mds.${name}s/keyring" auth add "mds.${name}s" \ | |
876 | mon 'allow profile mds' osd 'allow *' mds 'allow' mgr 'allow profile mds' | |
877 | fi | |
878 | fi | |
879 | ||
880 | run 'mds' $CEPH_BIN/ceph-mds -i $name $ARGS $CMDS_ARGS | |
881 | if [ "$standby" -eq 1 ]; then | |
882 | run 'mds' $CEPH_BIN/ceph-mds -i ${name}s $ARGS $CMDS_ARGS | |
883 | fi | |
884 | ||
885 | #valgrind --tool=massif $CEPH_BIN/ceph-mds $ARGS --mds_log_max_segments 2 --mds_thrash_fragments 0 --mds_thrash_exports 0 > m #--debug_ms 20 | |
886 | #$CEPH_BIN/ceph-mds -d $ARGS --mds_thrash_fragments 0 --mds_thrash_exports 0 #--debug_ms 20 | |
887 | #ceph_adm mds set max_mds 2 | |
888 | done | |
11fdf7f2 TL |
889 | |
890 | if [ $new -eq 1 ]; then | |
891 | if [ "$CEPH_NUM_FS" -gt "0" ] ; then | |
892 | sleep 5 # time for MDS to come up as standby to avoid health warnings on fs creation | |
893 | if [ "$CEPH_NUM_FS" -gt "1" ] ; then | |
894 | ceph_adm fs flag set enable_multiple true --yes-i-really-mean-it | |
895 | fi | |
896 | ||
897 | local fs=0 | |
898 | for name in a b c d e f g h i j k l m n o p | |
899 | do | |
900 | ceph_adm fs volume create ${name} | |
901 | ceph_adm fs authorize ${name} "client.fs_${name}" / rwp | |
902 | fs=$(($fs + 1)) | |
903 | [ $fs -eq $CEPH_NUM_FS ] && break | |
904 | done | |
905 | fi | |
906 | fi | |
907 | ||
7c673cae FG |
908 | } |
909 | ||
910 | if [ "$debug" -eq 0 ]; then | |
911 | CMONDEBUG=' | |
912 | debug mon = 10 | |
913 | debug ms = 1' | |
7c673cae FG |
914 | else |
915 | echo "** going verbose **" | |
916 | CMONDEBUG=' | |
917 | debug mon = 20 | |
918 | debug paxos = 20 | |
919 | debug auth = 20 | |
920 | debug mgrc = 20 | |
921 | debug ms = 1' | |
7c673cae FG |
922 | fi |
923 | ||
924 | if [ -n "$MON_ADDR" ]; then | |
925 | CMON_ARGS=" -m "$MON_ADDR | |
926 | COSD_ARGS=" -m "$MON_ADDR | |
927 | CMDS_ARGS=" -m "$MON_ADDR | |
928 | fi | |
929 | ||
11fdf7f2 TL |
930 | if [ -z "$CEPH_PORT" ] |
931 | then | |
932 | while [ true ] | |
933 | do | |
934 | CEPH_PORT="$(echo $(( RANDOM % 1000 + 40000 )))" | |
935 | ss -a -n | egrep ":${CEPH_PORT} .+LISTEN" 1>/dev/null 2>&1 || break | |
936 | done | |
7c673cae FG |
937 | fi |
938 | ||
939 | [ -z "$INIT_CEPH" ] && INIT_CEPH=$CEPH_BIN/init-ceph | |
940 | ||
941 | # sudo if btrfs | |
942 | test -d $CEPH_DEV_DIR/osd0/. && test -e $CEPH_DEV_DIR/sudo && SUDO="sudo" | |
943 | ||
944 | prun $SUDO rm -f core* | |
945 | ||
c07f9fc5 | 946 | test -d $CEPH_ASOK_DIR || mkdir $CEPH_ASOK_DIR |
7c673cae FG |
947 | test -d $CEPH_OUT_DIR || mkdir $CEPH_OUT_DIR |
948 | test -d $CEPH_DEV_DIR || mkdir $CEPH_DEV_DIR | |
949 | $SUDO rm -rf $CEPH_OUT_DIR/* | |
950 | test -d gmon && $SUDO rm -rf gmon/* | |
951 | ||
952 | [ "$cephx" -eq 1 ] && [ "$new" -eq 1 ] && test -e $keyring_fn && rm $keyring_fn | |
953 | ||
954 | ||
955 | # figure machine's ip | |
956 | HOSTNAME=`hostname -s` | |
957 | if [ -n "$ip" ]; then | |
958 | IP="$ip" | |
959 | else | |
960 | echo hostname $HOSTNAME | |
961 | if [ -x "$(which ip 2>/dev/null)" ]; then | |
962 | IP_CMD="ip addr" | |
963 | else | |
964 | IP_CMD="ifconfig" | |
965 | fi | |
966 | # filter out IPv6 and localhost addresses | |
967 | IP="$($IP_CMD | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -n1)" | |
968 | # if nothing left, try using localhost address, it might work | |
969 | if [ -z "$IP" ]; then IP="127.0.0.1"; fi | |
970 | fi | |
971 | echo "ip $IP" | |
972 | echo "port $CEPH_PORT" | |
973 | ||
974 | ||
975 | [ -z $CEPH_ADM ] && CEPH_ADM=$CEPH_BIN/ceph | |
976 | ||
977 | ceph_adm() { | |
978 | if [ "$cephx" -eq 1 ]; then | |
979 | prun $SUDO "$CEPH_ADM" -c "$conf_fn" -k "$keyring_fn" "$@" | |
980 | else | |
981 | prun $SUDO "$CEPH_ADM" -c "$conf_fn" "$@" | |
982 | fi | |
983 | } | |
984 | ||
985 | if [ "$new" -eq 1 ]; then | |
986 | prepare_conf | |
987 | fi | |
988 | ||
989 | if [ $CEPH_NUM_MON -gt 0 ]; then | |
990 | start_mon | |
11fdf7f2 TL |
991 | |
992 | echo Populating config ... | |
993 | cat <<EOF | $CEPH_BIN/ceph -c $conf_fn config assimilate-conf -i - | |
994 | [global] | |
995 | osd_pool_default_size = $OSD_POOL_DEFAULT_SIZE | |
996 | osd_pool_default_min_size = 1 | |
997 | mon_pg_warn_min_per_osd = 3 | |
998 | ||
999 | [mon] | |
1000 | mon_osd_reporter_subtree_level = osd | |
1001 | mon_data_avail_warn = 2 | |
1002 | mon_data_avail_crit = 1 | |
1003 | mon_allow_pool_delete = true | |
1004 | ||
1005 | [osd] | |
1006 | osd_scrub_load_threshold = 2000 | |
1007 | osd_debug_op_order = true | |
1008 | osd_debug_misdirected_ops = true | |
1009 | osd_copyfrom_max_chunk = 524288 | |
1010 | ||
1011 | [mds] | |
1012 | mds_debug_frag = true | |
1013 | mds_debug_auth_pins = true | |
1014 | mds_debug_subtrees = true | |
1015 | ||
1016 | EOF | |
1017 | ||
1018 | if [ "$debug" -ne 0 ]; then | |
1019 | echo Setting debug configs ... | |
1020 | cat <<EOF | $CEPH_BIN/ceph -c $conf_fn config assimilate-conf -i - | |
1021 | [mgr] | |
1022 | debug_ms = 1 | |
1023 | debug_mgr = 20 | |
1024 | debug_monc = 20 | |
1025 | debug_mon = 20 | |
1026 | ||
1027 | [osd] | |
1028 | debug_ms = 1 | |
1029 | debug_osd = 25 | |
1030 | debug_objecter = 20 | |
1031 | debug_monc = 20 | |
1032 | debug_mgrc = 20 | |
1033 | debug_journal = 20 | |
1034 | debug_filestore = 20 | |
1035 | debug_bluestore = 20 | |
1036 | debug_bluefs = 20 | |
1037 | debug_rocksdb = 20 | |
1038 | debug_bdev = 20 | |
1039 | debug_reserver = 10 | |
1040 | debug_objclass = 20 | |
1041 | ||
1042 | [mds] | |
1043 | debug_ms = 1 | |
1044 | debug_mds = 20 | |
1045 | debug_monc = 20 | |
1046 | debug_mgrc = 20 | |
1047 | mds_debug_scatterstat = true | |
1048 | mds_verify_scatter = true | |
1049 | EOF | |
1050 | fi | |
7c673cae FG |
1051 | fi |
1052 | ||
c07f9fc5 FG |
1053 | if [ $CEPH_NUM_MGR -gt 0 ]; then |
1054 | start_mgr | |
1055 | fi | |
1056 | ||
7c673cae FG |
1057 | # osd |
1058 | if [ $CEPH_NUM_OSD -gt 0 ]; then | |
1059 | start_osd | |
1060 | fi | |
1061 | ||
1062 | # mds | |
1063 | if [ "$smallmds" -eq 1 ]; then | |
1064 | wconf <<EOF | |
1065 | [mds] | |
1066 | mds log max segments = 2 | |
1067 | mds cache size = 10000 | |
1068 | EOF | |
1069 | fi | |
1070 | ||
1071 | if [ $CEPH_NUM_MDS -gt 0 ]; then | |
1072 | start_mds | |
1073 | fi | |
1074 | ||
1075 | # Don't set max_mds until all the daemons are started, otherwise | |
1076 | # the intended standbys might end up in active roles. | |
1077 | if [ "$CEPH_MAX_MDS" -gt 1 ]; then | |
1078 | sleep 5 # wait for daemons to make it into FSMap before increasing max_mds | |
1079 | fi | |
1080 | fs=0 | |
1081 | for name in a b c d e f g h i j k l m n o p | |
1082 | do | |
1083 | [ $fs -eq $CEPH_NUM_FS ] && break | |
1084 | fs=$(($fs + 1)) | |
1085 | if [ "$CEPH_MAX_MDS" -gt 1 ]; then | |
7c673cae FG |
1086 | ceph_adm fs set "cephfs_${name}" max_mds "$CEPH_MAX_MDS" |
1087 | fi | |
1088 | done | |
1089 | ||
1090 | # mgr | |
1091 | ||
7c673cae FG |
1092 | if [ "$ec" -eq 1 ]; then |
1093 | ceph_adm <<EOF | |
1094 | osd erasure-code-profile set ec-profile m=2 k=2 | |
1095 | osd pool create ec 8 8 erasure ec-profile | |
1096 | EOF | |
1097 | fi | |
1098 | ||
1099 | do_cache() { | |
1100 | while [ -n "$*" ]; do | |
1101 | p="$1" | |
1102 | shift | |
1103 | echo "creating cache for pool $p ..." | |
1104 | ceph_adm <<EOF | |
1105 | osd pool create ${p}-cache 8 | |
1106 | osd tier add $p ${p}-cache | |
1107 | osd tier cache-mode ${p}-cache writeback | |
1108 | osd tier set-overlay $p ${p}-cache | |
1109 | EOF | |
1110 | done | |
1111 | } | |
1112 | do_cache $cache | |
1113 | ||
1114 | do_hitsets() { | |
1115 | while [ -n "$*" ]; do | |
1116 | pool="$1" | |
1117 | type="$2" | |
1118 | shift | |
1119 | shift | |
1120 | echo "setting hit_set on pool $pool type $type ..." | |
1121 | ceph_adm <<EOF | |
1122 | osd pool set $pool hit_set_type $type | |
1123 | osd pool set $pool hit_set_count 8 | |
1124 | osd pool set $pool hit_set_period 30 | |
1125 | EOF | |
1126 | done | |
1127 | } | |
1128 | do_hitsets $hitset | |
1129 | ||
224ce89b | 1130 | do_rgw_create_users() |
7c673cae FG |
1131 | { |
1132 | # Create S3 user | |
1133 | local akey='0555b35654ad1656d804' | |
1134 | local skey='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==' | |
1135 | echo "setting up user testid" | |
1136 | $CEPH_BIN/radosgw-admin user create --uid testid --access-key $akey --secret $skey --display-name 'M. Tester' --email tester@ceph.com -c $conf_fn > /dev/null | |
1137 | ||
1138 | # Create S3-test users | |
1139 | # See: https://github.com/ceph/s3-tests | |
1140 | echo "setting up s3-test users" | |
1141 | $CEPH_BIN/radosgw-admin user create \ | |
1142 | --uid 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef \ | |
1143 | --access-key ABCDEFGHIJKLMNOPQRST \ | |
1144 | --secret abcdefghijklmnopqrstuvwxyzabcdefghijklmn \ | |
1145 | --display-name youruseridhere \ | |
1146 | --email s3@example.com -c $conf_fn > /dev/null | |
1147 | $CEPH_BIN/radosgw-admin user create \ | |
1148 | --uid 56789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01234 \ | |
1149 | --access-key NOPQRSTUVWXYZABCDEFG \ | |
1150 | --secret nopqrstuvwxyzabcdefghijklmnabcdefghijklm \ | |
1151 | --display-name john.doe \ | |
1152 | --email john.doe@example.com -c $conf_fn > /dev/null | |
31f18b77 FG |
1153 | $CEPH_BIN/radosgw-admin user create \ |
1154 | --tenant testx \ | |
1155 | --uid 9876543210abcdef0123456789abcdef0123456789abcdef0123456789abcdef \ | |
1156 | --access-key HIJKLMNOPQRSTUVWXYZA \ | |
1157 | --secret opqrstuvwxyzabcdefghijklmnopqrstuvwxyzab \ | |
1158 | --display-name tenanteduser \ | |
1159 | --email tenanteduser@example.com -c $conf_fn > /dev/null | |
7c673cae FG |
1160 | |
1161 | # Create Swift user | |
1162 | echo "setting up user tester" | |
1163 | $CEPH_BIN/radosgw-admin user create -c $conf_fn --subuser=test:tester --display-name=Tester-Subuser --key-type=swift --secret=testing --access=full > /dev/null | |
1164 | ||
1165 | echo "" | |
1166 | echo "S3 User Info:" | |
1167 | echo " access key: $akey" | |
1168 | echo " secret key: $skey" | |
1169 | echo "" | |
1170 | echo "Swift User Info:" | |
1171 | echo " account : test" | |
1172 | echo " user : tester" | |
1173 | echo " password : testing" | |
1174 | echo "" | |
224ce89b | 1175 | } |
7c673cae | 1176 | |
224ce89b WB |
1177 | do_rgw() |
1178 | { | |
1179 | if [ "$new" -eq 1 ]; then | |
1180 | do_rgw_create_users | |
1181 | if [ -n "$rgw_compression" ]; then | |
1182 | echo "setting compression type=$rgw_compression" | |
1183 | $CEPH_BIN/radosgw-admin zone placement modify -c $conf_fn --rgw-zone=default --placement-id=default-placement --compression=$rgw_compression > /dev/null | |
1184 | fi | |
1185 | fi | |
7c673cae | 1186 | # Start server |
7c673cae FG |
1187 | RGWDEBUG="" |
1188 | if [ "$debug" -ne 0 ]; then | |
1189 | RGWDEBUG="--debug-rgw=20" | |
1190 | fi | |
1191 | ||
11fdf7f2 TL |
1192 | local CEPH_RGW_PORT_NUM="${CEPH_RGW_PORT}" |
1193 | local CEPH_RGW_HTTPS="${CEPH_RGW_PORT: -1}" | |
1194 | if [[ "${CEPH_RGW_HTTPS}" = "s" ]]; then | |
1195 | CEPH_RGW_PORT_NUM="${CEPH_RGW_PORT::-1}" | |
1196 | else | |
1197 | CEPH_RGW_HTTPS="" | |
1198 | fi | |
7c673cae | 1199 | RGWSUDO= |
11fdf7f2 | 1200 | [ $CEPH_RGW_PORT_NUM -lt 1024 ] && RGWSUDO=sudo |
7c673cae | 1201 | n=$(($CEPH_NUM_RGW - 1)) |
224ce89b WB |
1202 | i=0 |
1203 | for rgw in j k l m n o p q r s t u v; do | |
11fdf7f2 TL |
1204 | current_port=$((CEPH_RGW_PORT_NUM + i)) |
1205 | echo start rgw on http${CEPH_RGW_HTTPS}://localhost:${current_port} | |
1206 | run 'rgw' $RGWSUDO $CEPH_BIN/radosgw -c $conf_fn --log-file=${CEPH_OUT_DIR}/radosgw.${current_port}.log --admin-socket=${CEPH_OUT_DIR}/radosgw.${current_port}.asok --pid-file=${CEPH_OUT_DIR}/radosgw.${current_port}.pid ${RGWDEBUG} --debug-ms=1 -n client.rgw "--rgw_frontends=${rgw_frontend} port=${current_port}${CEPH_RGW_HTTPS}" | |
1207 | i=$(($i + 1)) | |
224ce89b | 1208 | [ $i -eq $CEPH_NUM_RGW ] && break |
7c673cae FG |
1209 | done |
1210 | } | |
1211 | if [ "$CEPH_NUM_RGW" -gt 0 ]; then | |
1212 | do_rgw | |
1213 | fi | |
1214 | ||
1215 | echo "started. stop.sh to stop. see out/* (e.g. 'tail -f out/????') for debug output." | |
1216 | ||
31f18b77 | 1217 | echo "" |
11fdf7f2 TL |
1218 | if [ "$new" -eq 1 ]; then |
1219 | if $with_mgr_dashboard; then | |
1220 | echo "dashboard urls: $DASH_URLS" | |
1221 | echo " w/ user/pass: admin / admin" | |
1222 | fi | |
1223 | echo "restful urls: $RESTFUL_URLS" | |
1224 | echo " w/ user/pass: admin / $RESTFUL_SECRET" | |
1225 | echo "" | |
1226 | fi | |
7c673cae FG |
1227 | echo "" |
1228 | echo "export PYTHONPATH=./pybind:$PYTHONPATH" | |
1229 | echo "export LD_LIBRARY_PATH=$CEPH_LIB" | |
1230 | ||
1231 | if [ "$CEPH_DIR" != "$PWD" ]; then | |
1232 | echo "export CEPH_CONF=$conf_fn" | |
1233 | echo "export CEPH_KEYRING=$keyring_fn" | |
1234 | fi | |
31f18b77 FG |
1235 | |
1236 | echo "CEPH_DEV=1" | |
1237 |