Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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
share|improve this answer
    
The community edition binaries of MongoDB don't support SSL so I wouldn't consider "install the rpms" to be a "best bet". To be suitable for anything but tinkering MongoDB must be re-compiled with SSL enabled. @larsks answer is better for this question. –  Paul Jul 11 at 18:44

You need to write an "init script" to start the service when the system boots. A quick Google search for "writing init scripts redhat" will turn up several useful references. This seemed like a reasonable start:

If you want a quick-and-dirty solution, you can simply add your command to the end of /etc/rc.d/rc.local, which gets executed after all the other init scripts have completed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.