MongoDB custom boot service bootup script

Source: Internet
Author: User
Tags mongodb server

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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.