usage_exit() {
echo "usage: $0 [options] {start|stop|restart} [mon|osd|mds]..."
- printf "\t-C cluster.conf\n"
+ printf "\t-c cluster.conf\n"
printf "\t--valgrind\trun via valgrind\n"
exit
}
--nobtrfs)
dobtrfs=0
;;
- --cluster-conf | -C)
+ --conf | -c)
[ "$2" == "" ] && usage_exit
options="$options $1"
shift
type=`echo $name | cut -c 1-3` # e.g. 'mon', if $item is 'mon1'
id=`echo $name | cut -c 4- | sed 's/\\.//'`
num=$id
- sections="$name $type global"
check_host || continue
- get_conf pid_file "/var/run/ceph/$name.pid" "pid file" $sections
- get_conf runtimeconf "$runtime_conf" "conf" $sections
-
- # extract name-specific options from $conf
- if [[ $name =~ "mon" ]]; then
- get_conf mon_data "" "mon data" $sections
- module_opt="$mon_data"
- module_bin="$BINDIR/cmon"
- fi
-
- if [[ $name =~ "mds" ]]; then
- get_conf rank "" "rank" $sections
- get_conf shadow "" "shadow" $sections
- module_opt="$mon_addr_arg"
- module_bin="$BINDIR/cmds $id"
- [[ $rank != "" ]] && $module_bin="$module_bin --rank $mds"
- [[ $shadow != "" ]] && $module_bin="$module_bin --shadow $shadow"
+ cmd="$BINDIR/c$type -i $id"
+
+ # conf file
+ if [[ $host == $hostname ]]; then
+ cmd="$cmd -c $conf"
+ else
+ if [[ ! $pushed_to =~ " $host " ]]; then
+ scp $conf $host:/tmp/ceph.conf.$$
+ pushed_to="$pushed_to $host "
+ fi
+ cmd="$cmd -c /tmp/ceph.conf.$$"
fi
if [[ $name =~ "osd" ]]; then
- get_conf osd_data "" "osd data" $sections
- get_conf osd_journal "" "osd journal" $sections
- [ "$osd_journal" != "" ] && osd_journal_cmd="-j $osd_journal" || osd_journal_cmd=""
- module_opt="$mon_addr_arg $osd_data $osd_journal_cmd"
- module_bin="$BINDIR/cosd"
-
- get_conf btrfs_path "$osd_data" "btrfs path" $sections # mount point defaults so osd data
- get_conf btrfs_devs "" "btrfs devs" $sections
+ get_conf osd_data "" "osd data"
+ get_conf btrfs_path "$osd_data" "btrfs path" # mount point defaults so osd data
+ get_conf btrfs_devs "" "btrfs devs"
first_dev=`echo $btrfs_devs | cut '-d ' -f 1`
fi
- module_opt="-p $pid_file -c $runtimeconf $module_opt"
-
case "$command" in
start)
# build final command
wrap=""
- runflags=""
runmode=""
- get_conf_bool crun "$docrun" "restart on core dump" $sections
+ get_conf_bool crun "$docrun" "restart on core dump"
[[ $crun -eq 1 ]] && wrap="$BINDIR/crun"
- get_conf_bool valgrind "$dovalgrind" "valgrind" $sections
+ get_conf_bool valgrind "$dovalgrind" "valgrind"
[[ $valgrind -eq 1 ]] && wrap="$wrap valgrind"
- [[ $wrap != "" ]] && runflags="-f" && runmode="&"
+ [[ $wrap != "" ]] && runmode="-f &"
- cmd="$wrap $module_bin $runflags $module_opt $runmode"
+ cmd="$wrap $cmd $runmode"
echo Starting ceph $name on $host...
if [ $dobtrfs -eq 1 ]; then
- get_conf pre_mount "true" "pre mount command" $sections
+ get_conf pre_mount "true" "pre mount command"
[[ $pre_mount != "" ]] && do_cmd $pre_mount
do_cmd "mount -t btrfs $first_dev $btrfs_path"
fi
- get_conf pre_start_eval "" "pre start eval" $sections
+ get_conf pre_start_eval "" "pre start eval"
[[ $pre_start_eval != "" ]] && $pre_start_eval
- get_conf pre_start "" "pre start command" $sections
- get_conf post_start "" "post start command" $sections
+ get_conf pre_start "" "pre start command"
+ get_conf post_start "" "post start command"
[[ $pre_start != "" ]] && do_cmd $pre_start
do_cmd "$cmd"
[[ $post_start != "" ]] && do_cmd $post_start
;;
stop)
- get_conf pre_stop "" "pre stop command" $sections
- get_conf post_stop "" "post stop command" $sections
+ get_conf pre_stop "" "pre stop command"
+ get_conf post_stop "" "post stop command"
[[ $pre_stop != "" ]] && do_cmd $pre_stop
stop_daemon $name c$type $pid_file
[[ $post_stop != "" ]] && do_cmd $post_stop
;;
forcestop)
- get_conf pre_forcestop "" "pre forcestop command" $sections
- get_conf post_forcestop "" "post forcestop command" $sections
+ get_conf pre_forcestop "" "pre forcestop command"
+ get_conf post_forcestop "" "post forcestop command"
[[ $pre_forcestop != "" ]] && do_cmd $pre_forcestop
stop_daemon $name c$type $pid_file -9
[[ $post_forcestop != "" ]] && do_cmd $post_forcestop
;;
cleanlogs)
- get_conf log_dir "/var/log/ceph" "log dir" $sections
- get_conf log_sym_dir "/var/log/ceph" "log sym dir" $sections
+ get_conf log_dir "/var/log/ceph" "log dir"
+ get_conf log_sym_dir "/var/log/ceph" "log sym dir"
do_cmd "for f in $log_sym_dir/$name*; do rm -f \`readlink \$f\` ; rm -f \$f ; done"
;;
cleanalllogs)
- get_conf log_dir "/var/log/ceph" "log dir" $sections
- get_conf log_sym_dir "/var/log/ceph" "log sym dir" $sections
+ get_conf log_dir "/var/log/ceph" "log dir"
+ get_conf log_sym_dir "/var/log/ceph" "log sym dir"
do_cmd "rm -f $log_dir/* $log_sym_dir/*"
;;
type=`echo $name | cut -c 1-3` # e.g. 'mon', if $name is 'mon1'
id=`echo $name | cut -c 4- | sed 's/\\.//'`
num=$id
- sections="$name $type global"
check_host || continue
- get_conf runtimeconf "$runtime_conf" "conf" $sections
+ get_conf runtimeconf "$runtime_conf" "conf"
- if [[ $ssh = 1 ]] && [[ ! $pushed_to =~ " $host " ]]; then
+ if [[ $ssh != "" ]] && [[ ! $pushed_to =~ " $host " ]]; then
scp $osdmap $host:$osdmap
scp $monmap $host:$monmap
pushed_to="$pushed_to $host "
fi
if [[ $type = "mon" ]]; then
- get_conf mon_data "" "mon data" $sections
+ get_conf mon_data "" "mon data"
do_cmd "$BINDIR/mkmonfs $clobber $mon_data --mon $num --monmap $monmap --osdmap $osdmap"
fi
if [[ $type = "osd" ]]; then
- get_conf osd_path "" "osd data" $sections
- get_conf btrfs_path "$osd_path" "btrfs path" $sections # mount point defaults so osd path
- get_conf btrfs_devs "" "btrfs devs" $sections
+ get_conf osd_path "" "osd data"
+ get_conf btrfs_path "$osd_path" "btrfs path" # mount point defaults so osd path
+ get_conf btrfs_devs "" "btrfs devs"
first_dev=`echo $btrfs_devs | cut '-d ' -f 1`
if [ $mkbtrfs -eq 1 ]; then
valgrind=""
MON_ADDR=""
-conf="workingdir.conf"
-clusterconf="cluster.conf"
+conf="cluster.conf"
usage="usage: $0 [option]... [mon] [mds] [osd]\n"
usage=$usage"options:\n"
fi
if [ $new -eq 1 ]; then
- echo "; generated by vstart.sh on `date`" > $clusterconf
+ cat <<EOF > $conf
+; generated by vstart.sh on `date`
+[global]
+ log dir = out
+ log sym dir = out
+ logger dir = log
+ chdir = ""
+ pid file = out/\$name.pid
+
+EOF
if [ `echo $IP | grep '^127\\.'` ]
then
echo
for f in `seq 0 $((CEPH_NUM_MON-1))`
do
str=$str" --add $IP:$(($CEPH_PORT+$f))"
- echo "[mon$f]" >> $clusterconf
- echo " mon addr = $IP:$(($CEPH_PORT+$f))" >> $clusterconf
+ cat <<EOF >> $conf
+[mon$f]
+ mon data = "dev/mon$f"
+ mon addr = $IP:$(($CEPH_PORT+$f))
+EOF
done
str=$str" --print .ceph_monmap"
echo $str
for f in `seq 0 $((CEPH_NUM_MON-1))`
do
- $CEPH_BIN/mkmonfs --clobber mondata/mon$f --mon $f --monmap .ceph_monmap --osdmap .ceph_osdmap
+ $CEPH_BIN/mkmonfs --clobber dev/mon$f --mon $f --monmap .ceph_monmap --osdmap .ceph_osdmap
done
fi
# start monitors
if [ $start_mon -ne 0 ]; then
for f in `seq 0 $((CEPH_NUM_MON-1))`; do
- echo $valgrind $CEPH_BIN/cmon mondata/mon$f $ARGS $CMON_ARGS
- $valgrind $CEPH_BIN/cmon -p out/mon$f.pid mondata/mon$f $ARGS $CMON_ARGS
+ echo $valgrind $CEPH_BIN/cmon -i $f $ARGS $CMON_ARGS
+ $valgrind $CEPH_BIN/cmon -i $f $ARGS $CMON_ARGS
done
sleep 1
fi
for osd in `seq 0 $((CEPH_NUM_OSD-1))`
do
if [ $new -eq 1 ]; then
+ cat <<EOF >> $conf
+[osd$osd]
+ osd data = dev/osd$osd
+EOF
echo mkfs osd$osd
- $SUDO $CEPH_BIN/cosd $ARGS --mkfs_for_osd $osd dev/osd$osd # --debug_journal 20 --debug_osd 20 --debug_filestore 20 --debug_ebofs 20
+ $SUDO $CEPH_BIN/cosd -i $osd $ARGS --mkfs # --debug_journal 20 --debug_osd 20 --debug_filestore 20 --debug_ebofs 20
fi
echo start osd$osd
- echo $valgrind $SUDO $CEPH_BIN/cosd -m $IP:$CEPH_PORT dev/osd$osd $ARGS $COSD_ARGS
- $valgrind $SUDO $CEPH_BIN/cosd -p out/osd$f.pid -m $IP:$CEPH_PORT dev/osd$osd $ARGS $COSD_ARGS
-# echo valgrind --leak-check=full --show-reachable=yes $CEPH_BIN/cosd dev/osd$osd --debug_ms 1 --debug_osd 20 --debug_filestore 10 --debug_ebofs 20 #1>out/o$osd #& #--debug_osd 40
+ $valgrind $SUDO $CEPH_BIN/cosd -p out/osd$f.pid -m $IP:$CEPH_PORT -i $osd $ARGS $COSD_ARGS
done
fi
if [ $start_mds -eq 1 ]; then
for mds in `seq 0 $((CEPH_NUM_MDS-1))`
do
- echo $valgrind $CEPH_BIN/cmds $ARGS $CMDS_ARGS
- $valgrind $CEPH_BIN/cmds $ARGS $CMDS_ARGS
+ $valgrind $CEPH_BIN/cmds -i $mds $ARGS $CMDS_ARGS
#valgrind --tool=massif $CEPH_BIN/cmds $ARGS --mds_log_max_segments 2 --mds_thrash_fragments 0 --mds_thrash_exports 0 > m #--debug_ms 20
#$CEPH_BIN/cmds -d $ARGS --mds_thrash_fragments 0 --mds_thrash_exports 0 #--debug_ms 20