ceph启动脚本
放在/etc/init.d/目录下,用法如下:
- root@u253:~# /etc/init.d/ceph
- === mon.a ===
- usage: /etc/init.d/ceph [options] {start|stop|restart} [mon|osd|mds]...
- -c ceph.conf
- --valgrind run via valgrind
- --hostname [hostname] override hostname lookup
源码如下:
- 文件名:ceph
- #!/bin/sh
- # Start/stop ceph daemons
- # chkconfig:
- ### BEGIN INIT INFO
- # Provides: ceph
- # Default-Start:
- # Default-Stop:
- # Required-Start: $remote_fs $named $network $time
- # Required-Stop: $remote_fs $named $network $time
- # Short-Description: Start Ceph distributed file system daemons at boot time
- # Description: Enable Ceph distributed file system services.
- ### END INIT INFO
- # if we start up as ./mkcephfs, assume everything else is in the
- # current directory too.
- if [ `dirname $` = "." ] && [ $PWD != "/etc/init.d" ]; then
- BINDIR=.
- LIBDIR=.
- ETCDIR=.
- else
- BINDIR=/usr/bin
- LIBDIR=/usr/lib/ceph
- ETCDIR=/etc/ceph
- fi
- usage_exit() {
- echo "usage: $0 [options] {start|stop|restart} [mon|osd|mds]..."
- printf "\t-c ceph.conf\n"
- printf "\t--valgrind\trun via valgrind\n"
- printf "\t--hostname [hostname]\toverride hostname lookup\n"
- exit
- }
- . $LIBDIR/ceph_common.sh
- EXIT_STATUS=
- signal_daemon() {
- name=$
- daemon=$
- pidfile=$
- signal=$
- action=$
- [ -z "$action" ] && action="Stopping"
- echo -n "$action Ceph $name on $host..."
- do_cmd "if [ -e $pidfile ]; then
- pid=`cat $pidfile`
- if [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline ; then
- cmd=\"kill $signal \$pid\"
- echo -n \$cmd...
- \$cmd
- fi
- fi"
- echo done
- }
- daemon_is_running() {
- name=$
- daemon=$
- daemon_id=$
- pidfile=$
- do_cmd "[ -e $pidfile ] || exit 1 # no pid, presumably not running
- pid=\`cat $pidfile\`
- [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline && grep -qwe -i.$daemon_id /proc/\$pid/cmdline && exit # running
- exit # pid is something else" "" "okfail"
- }
- stop_daemon() {
- name=$
- daemon=$
- pidfile=$
- signal=$
- action=$
- [ -z "$action" ] && action="Stopping"
- echo -n "$action Ceph $name on $host..."
- do_cmd "while [ 1 ]; do
- [ -e $pidfile ] || break
- pid=\`cat $pidfile\`
- while [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline ; do
- cmd=\"kill $signal \$pid\"
- echo -n \$cmd...
- \$cmd
- sleep
- continue
- done
- break
- done"
- echo done
- }
- ## command line options
- options=
- version=
- dovalgrind=
- docrun=
- allhosts=
- debug=
- monaddr=
- dobtrfs=
- dobtrfsumount=
- verbose=
- while echo $ | grep -q '^-'; do # FIXME: why not '^-'?
- case $ in
- -v | --verbose)
- verbose=
- ;;
- --valgrind)
- dovalgrind=
- ;;
- --novalgrind)
- dovalgrind=
- ;;
- --allhosts | -a)
- allhosts=;
- ;;
- --restart)
- docrun=
- ;;
- --norestart)
- docrun=
- ;;
- -m )
- [ -z "$2" ] && usage_exit
- options="$options $1"
- shift
- MON_ADDR=$
- ;;
- --btrfs)
- dobtrfs=
- ;;
- --nobtrfs)
- dobtrfs=
- ;;
- --btrfsumount)
- dobtrfsumount=
- ;;
- --conf | -c)
- [ -z "$2" ] && usage_exit
- options="$options $1"
- shift
- conf=$
- ;;
- --hostname )
- [ -z "$2" ] && usage_exit
- options="$options $1"
- shift
- hostname=$
- ;;
- *)
- echo unrecognized option \'$1\'
- usage_exit
- ;;
- esac
- options="$options $1"
- shift
- done
- verify_conf
- command=$
- [ -n "$*" ] && shift
- get_name_list "$@"
- for name in $what; do
- type=`echo $name | cut -c -` # e.g. 'mon', if $item is 'mon1'
- id=`echo $name | cut -c - | sed 's/^\\.//'`
- num=$id
- name="$type.$id"
- get_conf auto_start "" "auto start"
- if [ -z "$@" ] || [ "$@" = "mds" ]; then
- if [ "$auto_start" = "no" ] || [ "$auto_start" = "false" ] || [ "$auto_start" = "" ]; then
- continue
- fi
- fi
- check_host || continue
- get_conf pid_file "/var/run/ceph/$type.$id.pid" "pid file"
- [ -n "$pid_file" ] && do_cmd "mkdir -p "`dirname $pid_file`
- get_conf log_dir "" "log dir"
- get_conf log_sym_dir "" "log sym dir"
- [ -n "$log_dir" ] && do_cmd "mkdir -p $log_dir"
- [ -n "$log_sym_dir" ] && do_cmd "mkdir -p $log_sym_dir"
- # start, and already running? (do this check early to avoid unnecessary work!)
- if [ "$command" = "start" ]; then
- if daemon_is_running $name ceph-$type $id $pid_file; then
- echo "Starting Ceph $name on $host...already running"
- continue
- fi
- fi
- # binary?
- binary="$BINDIR/ceph-$type"
- if [ "$command" = "start" ]; then
- get_conf copy_executable_to "" "copy executable to"
- if [ -n "$copy_executable_to" ]; then
- scp $binary "$host:$copy_executable_to"
- binary="$copy_executable_to"
- fi
- fi
- cmd="$binary -i $id"
- # conf file
- if [ "$host" = "$hostname" ]; then
- cur_conf=$conf
- else
- if echo $pushed_to | grep -v -q " $host "; then
- scp -q $conf $host:/tmp/ceph.conf.$$
- pushed_to="$pushed_to $host "
- fi
- cur_conf="/tmp/ceph.conf.$$"
- fi
- cmd="$cmd -c $cur_conf"
- if echo $name | grep -q ^osd; then
- 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 `
- fi
- # do lockfile, if RH
- get_conf lockfile "/var/lock/subsys/ceph" "lock file"
- lockdir=`dirname $lockfile`
- if [ ! -d "$lockdir" ]; then
- lockfile=""
- fi
- case "$command" in
- start)
- # Increase max_open_files, if the configuration calls for it.
- get_conf max_open_files "" "max open files"
- if [ $max_open_files != "" ]; then
- # Note: Don't try to do math with these numbers, because POSIX shells
- # can't do 64-bit math (natively). Just treat them as strings.
- cur=`ulimit -n`
- if [ "x$max_open_files" != "x$cur" ]; then
- ulimit -n $max_open_files
- fi
- fi
- # build final command
- wrap=""
- runmode=""
- runarg=""
- [ -z "$crun" ] && get_conf_bool crun "" "restart on core dump"
- [ "$crun" -eq ] && wrap="$BINDIR/ceph-run"
- [ -z "$dovalgrind" ] && get_conf_bool valgrind "" "valgrind"
- [ -n "$valgrind" ] && wrap="$wrap valgrind $valgrind"
- [ -n "$wrap" ] && runmode="-f &" && runarg="-f"
- cmd="$wrap $cmd $runmode"
- if [ $dobtrfs -eq ] && [ -n "$btrfs_devs" ]; then
- get_conf pre_mount "true" "pre mount command"
- get_conf btrfs_opt "noatime" "btrfs options"
- [ -n "$btrfs_opt" ] && btrfs_opt="-o $btrfs_opt"
- [ -n "$pre_mount" ] && do_cmd "$pre_mount"
- echo Mounting Btrfs on $host:$btrfs_path
- do_root_cmd "modprobe btrfs ; btrfsctl -a ; egrep -q '^[^ ]+ $btrfs_path' /proc/mounts || mount -t btrfs $btrfs_opt $first_dev $btrfs_path"
- fi
- echo Starting Ceph $name on $host...
- get_conf pre_start_eval "" "pre start eval"
- [ -n "$pre_start_eval" ] && $pre_start_eval
- get_conf pre_start "" "pre start command"
- get_conf post_start "" "post start command"
- [ -n "$pre_start" ] && do_cmd "$pre_start"
- do_cmd "$cmd" $runarg
- [ -n "$post_start" ] && do_cmd "$post_start"
- [ -n "$lockfile" ] && [ "$?" -eq ] && touch $lockfile
- ;;
- stop)
- get_conf pre_stop "" "pre stop command"
- get_conf post_stop "" "post stop command"
- [ -n "$pre_stop" ] && do_cmd "$pre_stop"
- stop_daemon $name ceph-$type $pid_file
- [ -n "$post_stop" ] && do_cmd "$post_stop"
- [ -n "$lockfile" ] && [ "$?" -eq ] && rm -f $lockfile
- if [ $dobtrfsumount -eq ] && [ -n "$btrfs_devs" ]; then
- echo Unmounting Btrfs on $host:$btrfs_path
- do_root_cmd "umount $btrfs_path || true"
- fi
- ;;
- status)
- if daemon_is_running $name ceph-$type $id $pid_file; then
- echo "$name: running..."
- elif [ -e "$pid_file" ]; then
- # daemon is dead, but pid file still exists
- echo "$name: dead."
- EXIT_STATUS=
- else
- # daemon is dead, and pid file is gone
- echo "$name: not running."
- EXIT_STATUS=
- fi
- ;;
- ssh)
- $ssh
- ;;
- forcestop)
- get_conf pre_forcestop "" "pre forcestop command"
- get_conf post_forcestop "" "post forcestop command"
- [ -n "$pre_forcestop" ] && do_cmd "$pre_forcestop"
- stop_daemon $name ceph-$type $pid_file -
- [ -n "$post_forcestop" ] && do_cmd "$post_forcestop"
- [ -n "$lockfile" ] && [ "$?" -eq ] && rm -f $lockfile
- ;;
- killall)
- echo "killall ceph-$type on $host"
- do_cmd "pkill ^ceph-$type || true"
- [ -n "$lockfile" ] && [ "$?" -eq ] && rm -f $lockfile
- ;;
- force-reload | reload)
- signal_daemon $name ceph-$type $pid_file - "Reloading"
- ;;
- restart)
- $ $options stop $name
- $ $options start $name
- ;;
- cleanlogs)
- echo removing logs
- if [ -n "$log_sym_dir" ]; then
- do_cmd "for f in $log_sym_dir/$type.$id.*; do rm -f \`readlink \$f\` ; rm -f \$f ; done ; rm -f $log_dir/$type.$id.*"
- fi
- [ -n "$log_dir" ] && do_cmd "rm -f $log_dir/$type.$id.*"
- ;;
- cleanalllogs)
- echo removing all logs
- [ -n "$log_sym_dir" ] && do_cmd "rm -f $log_sym_dir/* || true"
- [ -n "$log_dir" ] && do_cmd "rm -f $log_dir/* || true"
- ;;
- *)
- usage_exit
- ;;
- esac
- done
- exit $EXIT_STATUS
344$47TSA@MPG[85WR.jpg)
ceph启动脚本的更多相关文章
- logstash服务启动脚本
logstash服务启动脚本 最近在弄ELK,发现logstash没有sysv类型的服务启动脚本,于是按照网上一个老外提供的模板自己进行修改 #添加用户 useradd logstash -M -s ...
- 改进uwsgi启动脚本,使其支持多个独立配置文件
最近在研究flask,在架设运行环境的时候犯了难.因为我想把每个独立的应用像NGINX处理多个网站那样,每个应用单独一个配置文件.而网上流传的uwsgi启动脚本都只支持单个配置文件.虽然有文章说可以把 ...
- linux nginx 启动脚本
linux nginx 启动脚本 [root@webtest76 ~]# vi /etc/init.d/nginx #!/bin/bash # nginx Startup script for the ...
- busybox rootfs 启动脚本分析(二)
上次分析了busybox的启动脚本,这次分析一下init.d中一些脚本的内容. 参考链接 http://www.cnblogs.com/helloworldtoyou/p/6169678.html h ...
- Tomcat启动脚本
记录一个比较好的tomcat启动脚本,截取<OneinStack>,修改如下两个参数即可用. 使用之前修改下面2个参数: #Location of JAVA_HOME (bin files ...
- Linux Runlevel 启动 脚本
Linux 操作系统自从开始启动至启动完毕需要经历几个不同的阶段,这几个阶段就叫做 Runlevel,同样,当Linux操作系统关闭时也要经历另外几个不同的 Runlevel,下面详细介绍一下 Run ...
- [Tomcat 源码分析系列] (二) : Tomcat 启动脚本-catalina.bat
概述 Tomcat 的三个最重要的启动脚本: startup.bat catalina.bat setclasspath.bat 上一篇咱们分析了 startup.bat 脚本 这一篇咱们来分析 ca ...
- [Tomcat 源码分析系列] (一) : Tomcat 启动脚本-startup.bat
概述 我们通常使用 Tomcat 中的 startup.bat 来启动 Tomcat. 但是这其中干了一些什么事呢? 大家都知道一个 Java 程序需要启动的话, 肯定需要 main 方法, 那么这个 ...
- 关于Ubuntu运行级别、开机启动脚本的说明
关于Ubuntu运行级别.开机启动脚本的说明 目录简介 1.1介绍Ubuntu下面的自启动脚本目录 1.2 Linux操作系统运行级别的概念 1.3关于操作系统自启脚本的启动顺序 1.4 Lin ...
随机推荐
- [LeetCode]题解(python):010-Regular Expression Matching
题目来源: https://leetcode.com/problems/regular-expression-matching/ 题意分析: 这道题目定义了两个正则表达式规则.’.’代表任意字符,’* ...
- J2SE知识点摘记(十五)
1. 字节流和字符流的转换 以字符为导向的stream基本上有与之相对应的以字节为导向的Stream,两个对应类实现的功能相同,只是操作时的导向不同 字节输入流转换为字符输入流: Inp ...
- Android应用中使用自定义文字
在Android系统中可以很方便的修改字体样式.系统提供了三种样式,分别是sans,serif,monospace.可以在xml布局文件中通过 android:typeface="[sans ...
- TF卡速度测试对比 Class数越高速度越快
存储卡(TF卡)是手机扩展存储的大杀器,让你多装n部学习资料,多装n个外语听力练习.除了装东西外,存储卡性能不佳也会影响手机的整体性能以及体验的.本文主要针对Android手机,我是懒人,但我讨厌懒人 ...
- firemonkey打开子窗体
procedure TForm1.Button1Click(Sender: TObject);varChildForm: TForm2;beginChildForm := TForm2.Create( ...
- Swift语言iOS8的蓝牙Bluetooth解析
开发中央步骤: 1.添加CoreBluetooth.framework框架到你的工程 2.继承两个协议:CBCentralManagerDelegate和CBPeripheralDelegate 个人 ...
- C#Excel导出导入
using System; using System.Collections.Generic; using NPOI; using NPOI.HPSF; using NPOI.HSSF; using ...
- English - 定冠词和不定冠词(a an the) 的区别
不定冠词表示泛指,定冠词表示特指. 不定冠词a (an)与数词one 同源,是"一个"的意思.a用于辅音音素前,一般读作[e],而an则用于元音音素前,一般读做[en]. 1) 表 ...
- MySQL 5.7 重置root默认密码
http://www.cnblogs.com/jym-sunshine/p/5314101.html mysql5.7.11修改root默认密码 知道 MySQL 出了5.7了,并且网上说性能提高 ...
- hdu4099
要想通这个题目应该很容易,由于斐波纳契数在近100项之后很大,早就超出long long了.而输入最长的序列才40个数字,所以大约保留前50位,前40位是没有误差的!!!其实,想想我们判断double ...