Mongodb 啟動關閉指令碼並設定開機自動啟動Mongodb
配置檔案內容:
[root@yoon etc]# cat mongod.conf
logpath=/export/log/mongodb.log
logappend=true
fork = true
dbpath=/export/data/db
pidfilepath = /export/mongodb/etc/mongodb.pid
rest = true
httpinterface = true
port = 27017
指令碼如下:
[root@yoon ~]# cd /etc/init.d/
[root@yoon init.d]# vi mongod
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 80 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
#config: /export/mongodb/etc/mongod.conf
# pidfile: /export/mongodb/etc/mongodb.pid
source /etc/rc.d/init.d/functions
# things from mongod.conf get there by mongod reading it
if [ $(id -u) != "0" ]; then
echo "Permission Denied! Please use root to run again!"
exit 1
fi
test -d /export/mongodb || (mkdir -p /export/mongodb ; chown mongod:mongod /export/mongodb)
# NOTE: if you change any OPTIONS here, you get what you pay for:
# this script assumes all options are in the config file.
CONFIGFILE="/export/mongodb/etc/mongod.conf"
SYSCONFIG="/etc/sysconfig/mongod"
export PATH=$PATH:/export/mongodb/bin/
DBPATH=`awk -F= '/^dbpath/{print $2}' "$CONFIGFILE"`
OPTIONS=" --config $CONFIGFILE"
mongod=${MONGOD-/export/mongodb/bin/mongod}
echo "db path is: "$DBPATH
echo $mongod
MONGO_USER=mongodb
MONGO_GROUP=mongodb
[ -f "$SYSCONFIG" ] && source "$SYSCONFIG"
super() {
su - $MONGO_USER -c "PATH=$PATH:/export/mongodb/bin/; $*"
}
start()
{
echo -n $"Starting mongod: "
# echo -n "$MONGO_USER" "numactl --interleave=all"
# daemon --user "$MONGO_USER" "numactl --interleave=all" $mongod $OPTIONS
# daemon --user "$MONGO_USER" $mongod $OPTIONS
#
# su - $MONGO_USER -c "$mongod $OPTIONS" -m -p
# su - $MONGO_USER
# $mongod $OPTIONS
daemon --user "$MONGO_USER" "numactl --interleave=all" $mongod $OPTIONS
# super $mongod $OPTIONS
echo $mongod$OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
}
stop()
{
echo -n $"Stopping mongod: "
killproc -p "$DBPATH"/mongod.lock -d 300 /export/mongodb/bin/mongod
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod
}
restart () {
stop
start
}
ulimit -n 12000
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/mongod ] && restart || :
;;
status)
status $mongod
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
RETVAL=1
esac
exit $RETVAL
==========================================
[root@yoon ~]# service mongod start
[root@yoon ~]# service mongod stop
===============================================
設定開機自動啟動Mongodb
[root@yoon ~]# chkconfig --add mongod
[root@yoon ~]# chkconfig mongod on
[root@yoon ~]# chkconfig mongod --list
mongod 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@yoon etc]# cat mongod.conf
logpath=/export/log/mongodb.log
logappend=true
fork = true
dbpath=/export/data/db
pidfilepath = /export/mongodb/etc/mongodb.pid
rest = true
httpinterface = true
port = 27017
指令碼如下:
[root@yoon ~]# cd /etc/init.d/
[root@yoon init.d]# vi mongod
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 80 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
#config: /export/mongodb/etc/mongod.conf
# pidfile: /export/mongodb/etc/mongodb.pid
source /etc/rc.d/init.d/functions
# things from mongod.conf get there by mongod reading it
if [ $(id -u) != "0" ]; then
echo "Permission Denied! Please use root to run again!"
exit 1
fi
test -d /export/mongodb || (mkdir -p /export/mongodb ; chown mongod:mongod /export/mongodb)
# NOTE: if you change any OPTIONS here, you get what you pay for:
# this script assumes all options are in the config file.
CONFIGFILE="/export/mongodb/etc/mongod.conf"
SYSCONFIG="/etc/sysconfig/mongod"
export PATH=$PATH:/export/mongodb/bin/
DBPATH=`awk -F= '/^dbpath/{print $2}' "$CONFIGFILE"`
OPTIONS=" --config $CONFIGFILE"
mongod=${MONGOD-/export/mongodb/bin/mongod}
echo "db path is: "$DBPATH
echo $mongod
MONGO_USER=mongodb
MONGO_GROUP=mongodb
[ -f "$SYSCONFIG" ] && source "$SYSCONFIG"
super() {
su - $MONGO_USER -c "PATH=$PATH:/export/mongodb/bin/; $*"
}
start()
{
echo -n $"Starting mongod: "
# echo -n "$MONGO_USER" "numactl --interleave=all"
# daemon --user "$MONGO_USER" "numactl --interleave=all" $mongod $OPTIONS
# daemon --user "$MONGO_USER" $mongod $OPTIONS
#
# su - $MONGO_USER -c "$mongod $OPTIONS" -m -p
# su - $MONGO_USER
# $mongod $OPTIONS
daemon --user "$MONGO_USER" "numactl --interleave=all" $mongod $OPTIONS
# super $mongod $OPTIONS
echo $mongod$OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod
}
stop()
{
echo -n $"Stopping mongod: "
killproc -p "$DBPATH"/mongod.lock -d 300 /export/mongodb/bin/mongod
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod
}
restart () {
stop
start
}
ulimit -n 12000
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload|force-reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/mongod ] && restart || :
;;
status)
status $mongod
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
RETVAL=1
esac
exit $RETVAL
==========================================
[root@yoon ~]# service mongod start
[root@yoon ~]# service mongod stop
===============================================
設定開機自動啟動Mongodb
[root@yoon ~]# chkconfig --add mongod
[root@yoon ~]# chkconfig mongod on
[root@yoon ~]# chkconfig mongod --list
mongod 0:off 1:off 2:on 3:on 4:on 5:on 6:off
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28939273/viewspace-1795900/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- AIX 開機自啟動指令碼設定AI指令碼
- Ubuntu 設定開機自啟動指令碼Ubuntu指令碼
- 設定msyqlphp-fpm開機自動啟動指令碼PHP指令碼
- Orale自動啟動以及關閉指令碼_linux指令碼Linux
- linux開機自動啟動指令碼Linux指令碼
- mongodb啟動MongoDB
- ubuntu 設定Path 開機啟動指令碼Ubuntu指令碼
- 關閉windows更新、設定自啟動、提高開發機效能Windows
- 開機自啟動Powershell指令碼指令碼
- Linux下Oracle隨機自動啟動指令碼設定LinuxOracle隨機指令碼
- linux設定開機自啟動指令碼的最佳方式Linux指令碼
- Linux下的MongoDB安裝&啟動&關閉LinuxMongoDB
- ubuntu14 設定開機啟動指令碼Ubuntu指令碼
- Mongodb開啟與關閉MongoDB
- mongodb 啟動故障MongoDB
- 開啟或關閉時自動設定service_names
- Mongodb總結1-啟動和Shell指令碼MongoDB指令碼
- SHELL指令碼實現Oracle自啟動與關閉指令碼Oracle
- mongoDB非正常關閉後無法啟動問題MongoDB
- ubuntu-18.04 設定開機啟動指令碼Ubuntu指令碼
- Nginx設定成服務並開機自動啟動的配置詳解Nginx
- win 開機自動輸入密碼 並設定 cmder 開機自啟執行密碼
- 定時自動開啟和關閉Azure虛擬機器虛擬機
- centos 自動啟動指令碼和自啟動服務CentOS指令碼
- Linux 新增指令碼開機自啟動Linux指令碼
- win10開機自啟動程式關閉方法_win10怎麼關閉開機啟動項Win10
- MongoDB配置與啟動MongoDB
- mongodb 啟動報錯MongoDB
- rhel as3下自動啟動和關閉oracle的指令碼S3Oracle指令碼
- MongoDB系列一:MongoDB安裝、啟動關閉服務、客戶端連線MongoDB客戶端
- 電腦開機自動啟動的軟體怎麼關閉 win10關掉開機啟動項Win10
- win10開機啟動項怎麼設定關閉Win10
- 資料庫自動啟動關閉資料庫
- Ubuntu自動啟動配置指令碼Ubuntu指令碼
- 網路卡自動啟動指令碼指令碼
- Linux下新增自定義指令碼到開機自啟動,標準rpm,舉例:設定Apache自啟動Linux指令碼Apache
- MySQL 多例項啟動和關閉指令碼MySql指令碼
- informix 資料庫啟動關閉指令碼ORM資料庫指令碼