今天研究MongoDB,搭建時候發(fā)現(xiàn)源碼包沒提供啟動腳本,便順手寫了一個方便使用。
成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比漢南網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式漢南網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋漢南地區(qū)。費(fèi)用合理售后完善,10年實(shí)體公司更值得信賴。
[root@controller mongodb]# cat /etc/init.d/mongodb #!/bin/bash # author: baishaohua # mongodb boot shell MGDB_PATH="/usr/local/mongodb" MGDB_CONF="${MGDB_PATH}/etc/mongodb.conf" cd ${MGDB_PATH} MGDB_START(){ if [ ` ps -ef|grep 'mongod -f'|grep -v grep|wc -l` > 0 ];then echo "MongoDB already start" exit 1 fi ${MGDB_PATH}/bin/mongod -f ${MGDB_CONF} if [ $? -eq 0 ];then echo -n "MongoDB start " echo -n "[" echo -ne "\033[32m" echo -n "Successful" echo -ne "\e[0m" echo "]" else echo "MongoDB start failed" fi } MGDB_STOP(){ ${MGDB_PATH}/bin/mongod -f ${MGDB_CONF} --shutdown if [ $? -eq 0 ];then echo -n "MongoDB stop " echo -n "[" echo -ne "\033[32m" echo -n "Successful" echo -ne "\e[0m" echo "]" else echo "MongoDB stop failed" fi } MGDB_STATUS(){ ps -ef|grep 'mongod -f'|grep -v grep if [ $? != 0 ];then echo "MongoDB is STOP" fi } case "$1" in start) MGDB_START ;; stop) MGDB_STOP ;; status) MGDB_STATUS ;; restart) MGDB_STOP MGDB_START ;; *) echo $"Usage: $0 { start | stop | status | restart }" exit 1 esac