您的位置:首页 > 博客中心 > 数据库 >

mongodb 的启动脚本

时间:2022-03-14 01:45

 

 

/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

 

热门排行

今日推荐

热门手游