#!/bin/bash # some defaults def_mon_data_path=mondata def_mon_data_file="mon\$mon" def_mon_port=6789 def_num_mon=3 def_num_osd=1 def_num_mds=1 def_osd_dev=dev/osd\$osd SCRIPT_BIN=`dirname $0` . $SCRIPT_BIN/ceph_common.sh let debug=0 let do_init=0 let select_mon=0 let select_mds=0 let select_osd=0 let localhost=0 let noselection=1 norestart="" valgrind="" MON_ADDR="" usage="usage: $0 init [option]... [mon] [mds] [osd]\n" usage=$usage"options:\n" usage=$usage"\t-m ip:port\t\tspecify monitor address\n" usage=$usage"\t--conf_file filename\n" usage_exit() { printf "$usage" exit } while [ $# -ge 1 ]; do case $1 in -l | --localhost ) localhost=1 ;; --norestart ) norestart="--norestart" ;; mon | cmon ) select_mon=1 noselection=0 ;; mds | cmds ) select_mds=1 noselection=0 ;; osd | cosd ) select_osd=1 noselection=0 ;; init ) do_init=1 ;; * ) usage_exit esac shift done [ $do_init -eq 0 ] && usage_exit [ "$startup_conf_file" == "" ] && startup_conf_file="startup.conf" CCONF="$CCONF_BIN --conf_file $startup_conf_file" if [ $noselection -eq 1 ]; then select_mon=1 select_mds=1 select_osd=1 fi get_val CEPH_NUM_MON "$CEPH_NUM_MON" global num_mon $def_num_mon get_val CEPH_NUM_OSD "$CEPH_NUM_OSD" global "osd num" $def_num_osd get_val CEPH_NUM_MDS "$CEPH_NUM_MDS" global num_mds $def_num_mds ARGS="-f" if [ $debug -eq 0 ]; then CMON_ARGS="--debug_mon 10 --debug_ms 1" COSD_ARGS="" CMDS_ARGS="--debug_ms 1" else echo "** going verbose **" CMON_ARGS="--lockdep 1 --debug_mon 20 --debug_ms 1 --debug_paxos 20" COSD_ARGS="--lockdep 1 --debug_osd 25 --debug_journal 20 --debug_filestore 10 --debug_ms 1" # --debug_journal 20 --debug_osd 20 --debug_filestore 20 --debug_ebofs 20 CMDS_ARGS="--lockdep 1 --mds_cache_size 500 --mds_log_max_segments 2 --debug_ms 1 --debug_mds 20 --mds_thrash_fragments 0 --mds_thrash_exports 1" fi # get_val MON_HOST "$MON_HOST" global "mon host" "" # [ "$MON_HOST" != "" ] && get_val MON_PORT "$MON_PORT" global "mon port" "" # [ "$MON_PORT" != "" ] && MON_ADDR=$MON_HOST:$MON_PORT if [ "$MON_ADDR" != "" ]; then CMON_ARGS=$CMON_ARGS" -m "$MON_ADDR COSD_ARGS=$COSD_ARGS" -m "$MON_ADDR CMDS_ARGS=$CMDS_ARGS" -m "$MON_ADDR fi # lockdep everywhere? # export CEPH_ARGS="--lockdep 1" $SUDO rm -f core* test -d out || mkdir out $SUDO rm -f out/* test -d gmon && $SUDO rm -rf gmon/* # figure machine's ip if [ $localhost -eq 1 ]; then IP="127.0.0.1" else HOSTNAME=`hostname` echo hostname $HOSTNAME IP=`host $HOSTNAME | grep 'has address' | cut -d ' ' -f 4` fi echo "ip $IP" if [ `echo $IP | grep '^127\\.'` ] then echo echo "WARNING: hostname resolves to loopback; remote hosts will not be able to" echo " connect. either adjust /etc/hosts, or edit this script to use your" echo " machine's real IP." echo fi [ "$CEPH_BIN" == "" ] && CEPH_BIN=. [ "$MON_PORT" == "" ] && MON_PORT=$def_mon_port [ "$MON_HOST" == "" ] && MON_HOST=$IP #mon if [ $select_mon -eq 1 ]; then $CEPH_BIN/osdmaptool --clobber --createsimple 4 .ceph_osdmap # --pgbits 2 str="$CEPH_BIN/monmaptool --create --clobber" for mon in `seq 0 $((CEPH_NUM_MON-1))`; do get_conf mon_data_path $def_mon_data_path "mon data path" mon$mon mon global get_conf mon_data_file $def_mon_data_file "mon data file" mon$mon mon global get_conf conf_file $startup_conf_file "conf file" mon$mon mon global get_conf MON_PORT $MON_PORT "mon port" mon$mon mon global get_conf CEPH_HOST $MON_HOST "mon host" mon$mon mon global # build a fresh fs monmap, mon fs # $CEPH_BIN/monmaptool --create --clobber --print .ceph_monmap str=$str" --add $CEPH_HOST:$(($MON_PORT+$mon))" done str=$str" --print .ceph_monmap" echo $str $str for mon in `seq 0 $((CEPH_NUM_MON-1))`; do $CEPH_BIN/mkmonfs --clobber mondata/mon$mon --mon $mon --monmap .ceph_monmap --osdmap .ceph_osdmap done fi #osd if [ $select_osd -eq 1 ]; then for osd in `seq 0 $((CEPH_NUM_OSD-1))` do get_conf_bool use_sudo 0 sudo osd$osd osd global get_conf osd_dev $def_osd_dev "osd dev" osd$osd osd global get_conf conf_file $startup_conf_file "conf file" osd$osd osd global get_conf MON_PORT $MON_PORT "mon port" osd$osd osd global get_conf CEPH_HOST $MON_HOST "mon host" osd$osd osd global [ "$use_sudo" != "0" ] && SUDO="sudo" || SUDO="" get_conf ssh_host "" "ssh host" osd$osd osd global [ "$ssh_host" != "" ] && SSH_HOST="ssh $ssh_host" || SSH_HOST="" get_conf cd_path "" "ssh path" osd$osd osd global [ "$ssh_host" != "" ] && CD_PATH="cd $cd_path \\;" || CD_PATH="" echo mkfs osd$osd $SSH_HOST $CD_PATH \ $SUDO $CEPH_BIN/cosd --mkfs_for_osd $osd $osd_dev done fi