mongodb 的启动脚本

mongod启动脚本

/etc/init.d/mongod

 1 #!/bin/bash
 2
 3 # mongod - Startup script for mongod
 4
 5 # chkconfig: 35 85 15
 6 # description: Mongo is a scalable, document-oriented database.
 7 # processname: mongod
 8 # config: /etc/mongod.conf
 9 # pidfile: /var/run/mongo/mongo.pid
10
11 . /etc/rc.d/init.d/functions
12
13 # things from mongod.conf get there by mongod reading it
14
15
16 # NOTE: if you change any OPTIONS here, you get what you pay for:
17 # this script assumes all options are in the config file.
18 CONFIGFILE="/etc/mongod.conf"
19 OPTIONS=" -f $CONFIGFILE"
20 SYSCONFIG="/etc/sysconfig/mongod"
21
22 # FIXME: 1.9.x has a --shutdown flag that parses the config file and
23 # shuts down the correct running pid, but that‘s unavailable in 1.8
24 # for now.  This can go away when this script stops supporting 1.8.
25 DBPATH=`awk -F= ‘/^dbpath=/{print $2}‘ "$CONFIGFILE"`
26 mongod=${MONGOD-/usr/bin/mongod}
27
28 MONGO_USER=mongod
29 MONGO_GROUP=mongod
30
31 . "$SYSCONFIG" || true
32
33 start()
34 {
35   echo -n $"Starting mongod: "
36   daemon --user "$MONGO_USER" $mongod $OPTIONS
37   RETVAL=$?
38   echo
39   [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
40 }
41
42 stop()
43 {
44   echo -n $"Stopping mongod: "
45   killproc -p "$DBPATH"/mongod.lock -d 300 /usr/bin/mongod
46   RETVAL=$?
47   echo
48   [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod
49 }
50
51 restart () {
52     stop
53     start
54 }
55
56 ulimit -n 12000
57 RETVAL=0
58
59 case "$1" in
60   start)
61     start
62     ;;
63   stop)
64     stop
65     ;;
66   restart|reload|force-reload)
67     restart
68     ;;
69   condrestart)
70     [ -f /var/lock/subsys/mongod ] && restart || :
71     ;;
72   status)
73     status $mongod
74     RETVAL=$?
75     ;;
76   *)
77     echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
78     RETVAL=1
79 esac
80
81 exit $RETVAL

/etc/mongod.conf

 1 # mongo.conf
 2
 3 #where to log
 4 logpath=/data/logs/mongodb/mongod.log
 5
 6 logappend=true
 7
 8 # fork and run in background
 9 fork = true
10
11 #port = 27017
12
13 dbpath=/data/db1
14
15 # Disables write-ahead journaling
16 # nojournal = true
17
18 # Enables periodic logging of CPU utilization and I/O wait
19 #cpu = true
20
21 # Turn on/off security.  Off is currently the default
22 #noauth = true
23 #auth = true
24
25 # Verbose logging output.
26 #verbose = true
27
28 # Inspect all client data for validity on receipt (useful for
29 # developing drivers)
30 #objcheck = true
31
32 # Enable db quota management
33 #quota = true
34
35 # Set oplogging level where n is
36 #   0=off (default)
37 #   1=W
38 #   2=R
39 #   3=both
40 #   7=W+some reads
41 #oplog = 0
42
43 # Ignore query hints
44 #nohints = true
45
46 # Disable the HTTP interface (Defaults to localhost:27018).
47 #nohttpinterface = true
48
49 # Turns off server-side scripting.  This will result in greatly limited
50 # functionality
51 #noscripting = true
52
53 # Turns off table scans.  Any query that would do a table scan fails.
54 #notablescan = true
55
56 # Disable data file preallocation.
57 #noprealloc = true
58
59 # Specify .ns file size for new databases.
60 # nssize = <size>
61
62 # Accout token for Mongo monitoring server.
63 #mms-token = <token>
64
65 # Server name for Mongo monitoring server.
66 #mms-name = <server-name>
67
68 # Ping interval for Mongo monitoring server.
69 #mms-interval = <seconds>
70
71 # Replication Options
72
73 # in replicated mongo databases, specify here whether this is a slave or master
74 #slave = true
75 #source = master.example.com
76 # Slave only: specify a single database to replicate
77 #only = master.example.com
78 # or
79 #master = true
80 #source = slave.example.com
81 replSet = share1
82 shardsvr = true

mongos 启动脚本

/etc/init.d/mongos

 1 #!/bin/bash
 2
 3 # mongos - Startup script for mongos
 4
 5 # chkconfig: 35 85 15
 6 # description: Mongo is a scalable, document-oriented database.
 7 # processname: mongod
 8 # config: /etc/mongos.conf
 9
10
11 . /etc/rc.d/init.d/functions
12
13 # things from mongos.conf get there by mongos reading it
14
15
16 # NOTE: if you change any OPTIONS here, you get what you pay for:
17 # this script assumes all options are in the config file.
18 CONFIGFILE="/etc/mongos.conf"
19 OPTIONS=" -f $CONFIGFILE"
20 #SYSCONFIG="/etc/sysconfig/mongos"
21
22 # FIXME: 1.9.x has a --shutdown flag that parses the config file and
23 # shuts down the correct running pid, but that‘s unavailable in 1.8
24 # for now.  This can go away when this script stops supporting 1.8.
25 DBPATH=`awk -F= ‘/^logpath=/{print $2}‘ "$CONFIGFILE"`
26 mongos=${MONGOS-/usr/bin/mongos}
27
28 MONGO_USER=mongod
29 MONGO_GROUP=mongod
30
31 #. "$SYSCONFIG" || true
32
33 start()
34 {
35   echo -n $"Starting mongos: "
36   daemon --user "$MONGO_USER" $mongos $OPTIONS
37   RETVAL=$?
38   echo
39   [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongos
40 }
41
42 stop()
43 {
44   echo -n $"Stopping mongos: "
45   killproc -p "$DBPATH"/mongos.lock -t30 -TERM /usr/bin/mongos
46   RETVAL=$?
47   echo
48   [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongos
49 }
50
51 restart () {
52     stop
53     start
54 }
55
56 ulimit -n 12000
57 RETVAL=0
58
59 case "$1" in
60   start)
61     start
62     ;;
63   stop)
64     stop
65     ;;
66   restart|reload|force-reload)
67     restart
68     ;;
69   condrestart)
70     [ -f /var/lock/subsys/mongos ] && restart || :
71     ;;
72   status)
73     status $mongos
74     RETVAL=$?
75     ;;
76   *)
77     echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
78     RETVAL=1
79 esac
80
81 exit $RETVAL

/etc/mongos.conf

1 configdb=xx.xx.xx.xx:port,xx.xx.xx.xx:port,xx.xx.xx.xx:port
2 logpath=/data/logs/mongodb/mongos.log
3 port=27018
4 fork=true
5 logappend=true

文件打包下载

时间: 2024-11-05 18:51:43

mongodb 的启动脚本的相关文章

mongodb服务启动脚本

#!/bin/sh # #mongod - Startup script for mongod # # chkconfig: - 85 15 # description: Mongodb database. # processname: mongod # Source function library   . /etc/rc.d/init.d/functions # things from mongod.conf get there by mongod reading it # OPTIONS

mongodb的启动脚本!

#!/bin/sh #chkconfig: 2345 80 90 #description: mongodb start() {/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/bin/mongod -f /usr/local/mongodb-linux-x86_64-rhel70-3.6.6/bin/mongodb.conf} stop() {/usr/local/mongodb-linux-x86_64-rhel70-3.6.6/bin/mongod

mongodb安装脚本/启动脚本/配置文件

安装脚本 #!/bin/bash  #author: QingFeng #qq: 530035210 #blog: http://my.oschina.net/pwd/blog  #自动安装mongodb和初始化配置 #缺省的配置如下   logdir=/data/log/shell          #日志路径 log=$logdir/shell.log            #日志文件  is_font=1                #终端是否打印日志: 1打印 0不打印  is_log

ELK相关启动脚本

elasticsearch启动脚本 #!/bin/bash # Description:Elasticsearch ORS SERVER ES_HOME=/usr/local/elasticsearch-5.0.0 PID=$(jps | grep Elasticsearch | awk '{print $1}') ES_STOP=$ES_HOME/bin/shutdown.sh ES_START=$ES_HOME/bin/startup.sh #Necessary environment va

启动脚本_《UNIX/LINUX 系统管理技术手册 第四版》

1.init 是系统引导起来之后第一个运行的进程,是系统最重要的守护进程,进程号始终为1. 2.随着机器的引导,init从运行级0开始,一级一级往上运行到/etc/inittab中所设置的默认运行级.当机器关闭时,将以相反顺序执行同样的处理过程. 3.启动脚本的主要文件位于/etc/init.d这个目录下面,每个脚本负责一个守护进程或者系统的某个特定方面. 4.为了实现不同运行级别下需要运行那些脚本(并带什么参数,K开头停止.S开头启动),当系统进入到一个新的运行级别时,不是直接在init.d目

real server 的一个启动脚本例子

real server 的vip 启动脚本 #!/bin/bash #chkconfig: 2345 50 50 #description: real server init script VIP=192.168.80.80 case $1 in "start") echo "starting real server ..." ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up echo &quo

第5章3节《MonkeyRunner源码剖析》Monkey原理分析-启动运行: 启动脚本(原创)

天地会珠海分舵注:本来这一系列是准备出一本书的,详情请见早前博文"寻求合作伙伴编写<深入理解 MonkeyRunner>书籍".但因为诸多原因,没有如愿.所以这里把草稿分享出来,所以错误在所难免.有需要的就参考下吧,转发的话还请保留每篇文章结尾的出处等信息. 本节我们先看下Monkey是怎么启动起来的.在今后分析到MonkeyRunner的原理的时候我们会看到客户端是通过ADB往Android目标测试机器发送一个"monkey -port 12345"的

linux shell 之尝试编写 企业级 启动脚本

企业Shell面试题10:开发企业级MySQL启动脚本 说明: MySQL启动命令为: 1 /bin/sh mysqld_safe --pid-file=$mysqld_pid_file_path 2>&1 >/dev/null & 停止命令逻辑脚本为: 1 2 3 4 5 6 mysqld_pid=`cat "$mysqld_pid_file_path"` if (kill -0 $mysqld_pid 2>/dev/null)   then    

mysql,mairadb启动脚本

# mysql 启动脚本,一直使用mariadb,data目录一直不对,启动一直出错,自己编写的一个小脚本 # 适用于el6 systemd脚本  如果用ansible 使用service启动会报错,可以将service定义成脚本然后再使用ansible启动服务 #!/bin/bash # MySQL daemon start/stop script. #   Name:mysql 启动脚本 #   Version Number:1.0.5 #   Type:检测服务状态 #   Languag