Linux – How to auto-start MongoDB on CentOS reboot

automationcentoscentos5linuxmongodb

How do I setup MongoDB so that it will start back up automatically after a server reboot? This is on CentOS 5.5.

I start it with the following command, but if the server reboots, I have to login to SSH and run that again to get it going (not that big of a deal really, but would be nice to know that this isn't necessary if I don't have access to the server).

./mongod –config ./mongodb.config
–fork –logpath /var/log/mongodb.log –logappend

Best Answer

Your best bet is to install the rpms provided by 10gen (makers of mongodb)

http://www.mongodb.org/display/DOCS/CentOS+and+Fedora+Packages

That will install a init.d script for you that you can run

//mongod service

chkconfig mongod on
Related Topic