ceph启动脚本

放在/etc/init.d/目录下,用法如下:

1 root@u253:~# /etc/init.d/ceph 
2 === mon.a === 
3 usage: /etc/init.d/ceph [options] {start|stop|restart} [mon|osd|mds]...
4     -c ceph.conf
5     --valgrind    run via valgrind
6     --hostname [hostname]    override hostname lookup

源码如下:

  1 文件名:ceph
  2 #!/bin/sh
  3 # Start/stop ceph daemons
  4 # chkconfig: 2345 60 80
  5 
  6 ### BEGIN INIT INFO
  7 # Provides:          ceph
  8 # Default-Start:     2 3 5
  9 # Default-Stop:      0 1 6
 10 # Required-Start:    $remote_fs $named $network $time
 11 # Required-Stop:     $remote_fs $named $network $time
 12 # Short-Description: Start Ceph distributed file system daemons at boot time
 13 # Description:       Enable Ceph distributed file system services.
 14 ### END INIT INFO
 15 
 16 # if we start up as ./mkcephfs, assume everything else is in the
 17 # current directory too.
 18 if [ `dirname $0` = "." ] && [ $PWD != "/etc/init.d" ]; then
 19     BINDIR=.
 20     LIBDIR=.
 21     ETCDIR=.
 22 else
 23     BINDIR=/usr/bin
 24     LIBDIR=/usr/lib/ceph
 25     ETCDIR=/etc/ceph
 26 fi
 27 
 28 usage_exit() {
 29     echo "usage: $0 [options] {start|stop|restart} [mon|osd|mds]..."
 30     printf "\t-c ceph.conf\n"
 31     printf "\t--valgrind\trun via valgrind\n"
 32     printf "\t--hostname [hostname]\toverride hostname lookup\n"
 33     exit
 34 }
 35 
 36 . $LIBDIR/ceph_common.sh
 37 
 38 EXIT_STATUS=0
 39 
 40 signal_daemon() {
 41     name=$1
 42     daemon=$2
 43     pidfile=$3
 44     signal=$4
 45     action=$5
 46     [ -z "$action" ] && action="Stopping"
 47     echo -n "$action Ceph $name on $host..."
 48     do_cmd "if [ -e $pidfile ]; then
 49         pid=`cat $pidfile`
 50         if [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline ; then
 51         cmd=\"kill $signal \$pid\"
 52         echo -n \$cmd...
 53         \$cmd
 54         fi
 55     fi"
 56     echo done
 57 }
 58 
 59 daemon_is_running() {
 60     name=$1
 61     daemon=$2
 62     daemon_id=$3
 63     pidfile=$4
 64     do_cmd "[ -e $pidfile ] || exit 1   # no pid, presumably not running
 65     pid=\`cat $pidfile\`
 66     [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline && grep -qwe -i.$daemon_id /proc/\$pid/cmdline && exit 0 # running
 67         exit 1  # pid is something else" "" "okfail"
 68 }
 69 
 70 stop_daemon() {
 71     name=$1
 72     daemon=$2
 73     pidfile=$3
 74     signal=$4
 75     action=$5
 76     [ -z "$action" ] && action="Stopping"
 77     echo -n "$action Ceph $name on $host..."
 78     do_cmd "while [ 1 ]; do 
 79     [ -e $pidfile ] || break
 80     pid=\`cat $pidfile\`
 81     while [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline ; do
 82         cmd=\"kill $signal \$pid\"
 83         echo -n \$cmd...
 84         \$cmd
 85         sleep 1
 86         continue
 87     done
 88     break
 89     done"
 90     echo done
 91 }
 92 
 93 ## command line options
 94 options=
 95 
 96 version=0
 97 dovalgrind=
 98 docrun=
 99 allhosts=0
100 debug=0
101 monaddr=
102 dobtrfs=1
103 dobtrfsumount=0
104 verbose=0
105 
106 while echo $1 | grep -q '^-'; do     # FIXME: why not '^-'?
107 case $1 in
108     -v | --verbose)
109         verbose=1
110         ;;
111     --valgrind)
112         dovalgrind=1
113         ;;
114     --novalgrind)
115         dovalgrind=0
116         ;;
117     --allhosts | -a)
118         allhosts=1;
119         ;;
120     --restart)
121         docrun=1
122         ;;
123     --norestart)
124         docrun=0
125         ;;
126     -m )
127         [ -z "$2" ] && usage_exit
128         options="$options $1"
129         shift
130         MON_ADDR=$1
131         ;;
132     --btrfs)
133         dobtrfs=1
134         ;;
135     --nobtrfs)
136         dobtrfs=0
137         ;;
138     --btrfsumount)
139         dobtrfsumount=1
140         ;;
141     --conf | -c)
142         [ -z "$2" ] && usage_exit
143         options="$options $1"
144         shift
145         conf=$1
146         ;;
147     --hostname )
148         [ -z "$2" ] && usage_exit
149         options="$options $1"
150         shift
151         hostname=$1
152             ;;
153     *)
154         echo unrecognized option \'$1\'
155         usage_exit
156         ;;
157 esac
158 options="$options $1"
159 shift
160 done
161 
162 verify_conf
163 
164 command=$1
165 [ -n "$*" ] && shift
166 
167 get_name_list "$@"
168 
169 for name in $what; do
170     type=`echo $name | cut -c 1-3`   # e.g. 'mon', if $item is 'mon1'
171     id=`echo $name | cut -c 4- | sed 's/^\\.//'`
172     num=$id
173     name="$type.$id"
174 
175     get_conf auto_start "" "auto start"
176     if [ -z "$@" ] || [ "$@" = "mds" ]; then
177     if [ "$auto_start" = "no" ] || [ "$auto_start" = "false" ] || [ "$auto_start" = "0" ]; then
178         continue
179     fi
180     fi
181 
182     check_host || continue
183 
184     get_conf pid_file "/var/run/ceph/$type.$id.pid" "pid file"
185     [ -n "$pid_file" ] && do_cmd "mkdir -p "`dirname $pid_file`
186 
187     get_conf log_dir "" "log dir"
188     get_conf log_sym_dir "" "log sym dir"
189     [ -n "$log_dir" ] && do_cmd "mkdir -p $log_dir"
190     [ -n "$log_sym_dir" ] && do_cmd "mkdir -p $log_sym_dir"
191 
192     # start, and already running?  (do this check early to avoid unnecessary work!)
193     if [ "$command" = "start" ]; then
194     if daemon_is_running $name ceph-$type $id $pid_file; then
195         echo "Starting Ceph $name on $host...already running"
196         continue
197     fi
198     fi
199 
200     # binary?
201     binary="$BINDIR/ceph-$type"
202     if [ "$command" = "start" ]; then
203     get_conf copy_executable_to "" "copy executable to"
204     if [ -n "$copy_executable_to" ]; then
205         scp $binary "$host:$copy_executable_to"
206         binary="$copy_executable_to"
207     fi
208     fi
209 
210     cmd="$binary -i $id"
211 
212     # conf file
213     if [ "$host" = "$hostname" ]; then
214     cur_conf=$conf
215     else
216     if echo $pushed_to | grep -v -q " $host "; then
217         scp -q $conf $host:/tmp/ceph.conf.$$
218         pushed_to="$pushed_to $host "
219     fi
220     cur_conf="/tmp/ceph.conf.$$"
221     fi
222     cmd="$cmd -c $cur_conf"
223 
224     if echo $name | grep -q ^osd; then
225     get_conf osd_data "" "osd data"
226     get_conf btrfs_path "$osd_data" "btrfs path"  # mount point defaults so osd data
227     get_conf btrfs_devs "" "btrfs devs"
228     first_dev=`echo $btrfs_devs | cut '-d ' -f 1`
229     fi
230 
231     # do lockfile, if RH
232     get_conf lockfile "/var/lock/subsys/ceph" "lock file"
233     lockdir=`dirname $lockfile`
234     if [ ! -d "$lockdir" ]; then
235     lockfile=""
236     fi
237 
238     case "$command" in
239     start)
240             # Increase max_open_files, if the configuration calls for it.
241             get_conf max_open_files "0" "max open files"
242             if [ $max_open_files != "0" ]; then
243                 # Note: Don't try to do math with these numbers, because POSIX shells
244                 # can't do 64-bit math (natively). Just treat them as strings.
245                 cur=`ulimit -n`
246                 if [ "x$max_open_files" != "x$cur" ]; then
247                     ulimit -n $max_open_files
248                 fi
249             fi
250 
251             # build final command
252         wrap=""
253         runmode=""
254         runarg=""
255         
256         [ -z "$crun" ] && get_conf_bool crun "0" "restart on core dump"
257         [ "$crun" -eq 1 ] && wrap="$BINDIR/ceph-run"
258         
259         [ -z "$dovalgrind" ] && get_conf_bool valgrind "" "valgrind"
260         [ -n "$valgrind" ] && wrap="$wrap valgrind $valgrind"
261         
262         [ -n "$wrap" ] && runmode="-f &" && runarg="-f"
263 
264         cmd="$wrap $cmd $runmode"
265         
266         if [ $dobtrfs -eq 1 ] && [ -n "$btrfs_devs" ]; then
267         get_conf pre_mount "true" "pre mount command"
268         get_conf btrfs_opt "noatime" "btrfs options"
269         [ -n "$btrfs_opt" ] && btrfs_opt="-o $btrfs_opt"
270         [ -n "$pre_mount" ] && do_cmd "$pre_mount"
271         echo Mounting Btrfs on $host:$btrfs_path
272         do_root_cmd "modprobe btrfs ; btrfsctl -a ; egrep -q '^[^ ]+ $btrfs_path' /proc/mounts || mount -t btrfs $btrfs_opt $first_dev $btrfs_path"
273         fi
274         echo Starting Ceph $name on $host...
275         get_conf pre_start_eval "" "pre start eval"
276         [ -n "$pre_start_eval" ] && $pre_start_eval
277         get_conf pre_start "" "pre start command"
278         get_conf post_start "" "post start command"
279         [ -n "$pre_start" ] && do_cmd "$pre_start"
280         do_cmd "$cmd" $runarg
281         [ -n "$post_start" ] && do_cmd "$post_start"
282         [ -n "$lockfile" ] && [ "$?" -eq 0 ] && touch $lockfile
283         ;;
284     
285     stop)
286         get_conf pre_stop "" "pre stop command"
287         get_conf post_stop "" "post stop command"
288         [ -n "$pre_stop" ] && do_cmd "$pre_stop"
289         stop_daemon $name ceph-$type $pid_file
290         [ -n "$post_stop" ] && do_cmd "$post_stop"
291         [ -n "$lockfile" ] && [ "$?" -eq 0 ] && rm -f $lockfile
292         if [ $dobtrfsumount -eq 1 ] && [ -n "$btrfs_devs" ]; then
293         echo Unmounting Btrfs on $host:$btrfs_path
294         do_root_cmd "umount $btrfs_path || true"
295         fi
296         ;;
297 
298     status)
299         if daemon_is_running $name ceph-$type $id $pid_file; then
300                 echo "$name: running..."
301             elif [ -e "$pid_file" ]; then
302                 # daemon is dead, but pid file still exists
303                 echo "$name: dead."
304                 EXIT_STATUS=1
305             else
306                 # daemon is dead, and pid file is gone
307                 echo "$name: not running."
308                 EXIT_STATUS=3
309             fi
310         ;;
311 
312     ssh)
313         $ssh
314         ;;
315 
316     forcestop)
317         get_conf pre_forcestop "" "pre forcestop command"
318         get_conf post_forcestop "" "post forcestop command"
319         [ -n "$pre_forcestop" ] && do_cmd "$pre_forcestop"
320         stop_daemon $name ceph-$type $pid_file -9
321         [ -n "$post_forcestop" ] && do_cmd "$post_forcestop"
322         [ -n "$lockfile" ] && [ "$?" -eq 0 ] && rm -f $lockfile
323         ;;
324         
325     killall)
326         echo "killall ceph-$type on $host"
327         do_cmd "pkill ^ceph-$type || true"
328         [ -n "$lockfile" ] && [ "$?" -eq 0 ] && rm -f $lockfile
329         ;;
330     
331     force-reload | reload)
332         signal_daemon $name ceph-$type $pid_file -1 "Reloading"
333         ;;
334 
335     restart)
336         $0 $options stop $name
337         $0 $options start $name
338         ;;
339 
340     cleanlogs)
341         echo removing logs
342         if [ -n "$log_sym_dir" ]; then
343         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.*"
344         fi
345         [ -n "$log_dir" ] && do_cmd "rm -f $log_dir/$type.$id.*"
346         ;;
347 
348     cleanalllogs)
349         echo removing all logs
350         [ -n "$log_sym_dir" ] && do_cmd "rm -f $log_sym_dir/* || true"
351         [ -n "$log_dir" ] && do_cmd "rm -f $log_dir/* || true"
352         ;;
353 
354     *)
355         usage_exit
356         ;;
357     esac
358 done
359 
360 exit $EXIT_STATUS

 

转载于:https://www.cnblogs.com/chris-cp/p/4886040.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/262665.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

全修CALL

PUSH -1PUSH 0PUSH 0CALL 005A8690ADD ESP,0Cbp send,点全修CTRLf9一直返回到没有参数 基本上这个返回就是 功能CALL 0012EB08 005869B2 返回到 elementc.005869B2 来自 elementc.0058E8A00012EB1C 00588B1F 返回到 elementc.00588B1F 来自 elementc.005869800012EB28 …

.NET框架类库中的命名空间

.NET 框架类库是一个由 Microsoft .NET 框架 SDK 中包含的类、接口和值类型组成的库。 该库提供对系统功能的访问,并且被设计为 .NET 框架应用程序、组件和控件的生成基础。 .NET 框架类库提供下列命名空间: l Microsoft.CSharp 包含支持用 C# 语言进行…

OSChina 周六乱弹 —— 这个版本的小红帽听说过吗?

2019独角兽企业重金招聘Python工程师标准>>> 想想当年刚出来工作的时候,小小编还真是单纯,以为广阔天地大有作为,可是呢。。。 上热门:刚出来工作的时候,大人千叮万嘱社会很复杂,要学会控制自己…

XML解析

一、解析xml的两种方式 1、 其中,xml文件被解析之后产生的dom树可能是原xml文件内存的成千上万倍,所以占内存;一般是服务器端; 2、sax逐行读取解析的方式,读一行释放一行,移动端采用; 其中&…

Arcgis Server初学笔记(一)

什么是Arcgis Server(以下简称AS)? AS是一个基于web的企业级GIS解决方案。AS为创建和管理基于服务器的GIS应用提供了一个高效的框架平台。AS宿主了各种GIS资源,并把他们作为服务发送到客户端。Accgis Server架构 AS是一个分布系统,…

XML解析——Jsoup解析器

一、Jsoup解析器快速入门案例 Docement对象,文本对象,包含着各个Dom树结构 1、引入Jsoup解析器的jar包放在lib文件夹下后,写java代码 其中, 二、Jsoup对象 1、Jsoup解析器解析xml和html的有关对象 其中,通过统计资源定…

Linux下MPlayer的安装

Linux下MPlayer的安装 收藏 mplayer是linux下播放速度最快(正确安装了显卡驱动),支持媒体格式最多的播放器之一 ,它几乎能播放所有的win媒体文件!下面介绍它的安装方法: 安装大前提: 要编译这个软件,确认你系统安装了相应的XFree…

jQuery缓存数据——仿Map

2019独角兽企业重金招聘Python工程师标准>>> 最近在工作中遇到了这样一个情景。有些数据是从后台读取的,但是我暂时不需要展示在页面上,那怎么办呀?——缓存呀。今天我就来分享一下我所了解的Jquery缓存数据的方法。 首先分享1篇博…

【摘抄】百度分词算法详解:查询处理以及分词技术

随着搜索经济的崛起,人们开始越加关注全球各大搜索引擎的性能、技术和日流量。作为企业,会根据搜索引擎的知名度以及日流量来选择是否要投放广告等;作为 普通网民,会根据搜索引擎的性能和技术来选择自己喜欢的引擎查找资料&#x…

Jsoup快速查询

一、selector选择器 二、Xpath查询 转载于:https://www.cnblogs.com/wmqiang/p/11568184.html

ShellAPI 调用搜索引擎

//调用搜索引擎 uses ShellAPI;//google web searchprocedure TForm1.Button1Click(Sender: TObject);var SearchStr:PWideChar; SearchEngineStr:string;begin SearchEngineStr:http://search.yahoo.com/search?p; SearchStr:PWideChar(SearchEngineStr Edit1.Text); …

read name 和 read 在 Bash 中的区别

read 带一个参数和不带参数的区别是什么,我本以为仅仅是被赋值的变量的名字不同而已: $ read name 1 $ echo "$name" 1 $ read 1 $ echo "$REPLY" 1 当没有指定变量名时,read 会给默认的变量 REPLY 赋值,仅此…

李开复:2009地图与移动搜索快速增长

新浪科技讯 2月20日下午消息,谷歌大中华区总裁李开复今日召开媒体见面会,探讨谷歌2009年的发展重点和方向,李开复称地图与移动搜索将会迅速成长。以下为文字实录: 李开复:Google每次有员工大会,会把在北京、…

Qt SD卡 文件系统挂载、文件预览

/*********************************************************************************** Qt SD卡 文件系统挂载、文件预览* 声明:* 1. 验证挂载SD卡;* 2. QTreeView显示文件系统文件;* 3. UI线程、普通…

c# 文件压缩、解压及下载

C#打包文件夹成zip格式(包括文件夹和子文件夹下的所有文件) C# 文件压缩与解压(ZIP格式) asp.net实现文件夹及文件压缩,并实现下载转载于:https://www.cnblogs.com/myparamita/archive/2012/06/04/2534206.html

Servlet生命周期和方法

一、五个生命周期方法,有三个很重要,初始化方法、提供服务方法和销毁方法 1、三个主要方法 2、另外两个重写的成员方法只做了解 二、生命周期详解 其中,每次刷新页面都是一次对servlet访问; 页面访问,根据域名找到主机…

如何查看端口被占用

最近在做有关WCF的系统,可能是在方法回调的过程中会默认通过TCP:80端口,报错为80端口被占用,然而我又不知道什么程序占用了80端口,上网一找,没想真不少人碰到我一样的问题,嘿嘿。 run "net…

centos7 搭建Docker Registry

registry2.x版本比1版本的速度快而且加了认证环境规划&#xff1a;192.168.0.167Registry192.168.0.168client192.168.0.1671.安装并启动docker#添加yum源 [rootRegistry ~]# sudo tee /etc/yum.repos.d/docker.repo <<-EOF [dockerrepo] nameDocker Repository baseurl …

Servlet3.0注解配置访问路径和urlParttern配置

一、Servlet用注解配置访问路径 二、IDEA的tomcat相关配置 其中&#xff0c;第一点的配置文件&#xff0c;直接在IDEA的可视化操作界面修改就可以改掉配置文件中内容&#xff1b; 三、urlParttern配置 其中&#xff0c;* 时通配符&#xff0c;优先级最低&#xff1b; 转载于:ht…

现货黄金入门知识普及一:图形分析之K线理论

&#xff2b;线又称阴阳线、棒线、红黑线或蜡烛线&#xff0c;最早起源于日本德川幕府时代的米市交易&#xff0c;经过二百多年的演进&#xff0c;现已广泛应用于证券市场的技术分析中&#xff0c;成为技术分析中的最基本的方法之一&#xff0c;从而形成了现在具有完整形式和分…