Loading editor...
#!/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
Copy the above to the CP script/etc/init. d/MongoDB and the installation path of the mango database is/usr/local/MongoDB, the data directory is the data directory, and the log file is logs.