編輯器載入中...
#!/bin/bash## mongodb Startup script for the mongodb server## chkconfig: - 64 36# description: MongoDB Database Server## processname: mongodb## Source function library. /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/mongodb ]; then . /etc/sysconfig/mongodbfiprog="mongod"mongod="/usr/local/mongodb/bin/mongod"RETVAL=0start() { echo -n $"Starting $prog: "# daemon $mongod "--fork --logpath /usr/local/mongodb/logs --logappend --port" daemon "/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend --auth --port=27017 --fork" RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /usr/local/mongodb/lock/$prog return $RETVAL}stop() { echo -n $"Stopping $prog: " killproc $prog RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /usr/local/mongodb/lock/$prog return $RETVAL}reload() { echo -n $"Reloading $prog: " killproc $prog -HUP RETVAL=$? echo return $RETVAL}case "$1" instart)start;;stop)stop;;restart)stopstart;;condrestart)if [ -f /var/lock/subsys/$prog ]; thenstopstartfi;;reload)reload;;status)status $mongodRETVAL=$?;;*)echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"RETVAL=1esacexit $RETVAL
以上複製到cp 指令碼 /etc/init.d/mongodb 並且芒果資料庫的安裝路徑為/usr/local/mongodb,資料目錄為data目錄,記錄檔為logs。