I have to start my MongoDB server every time the system restarts. How do I configure it to start with my OS? I am on Ubuntu 11.04.
migrated from stackoverflow.com Sep 15 '11 at 7:08This question came from our site for professional and enthusiast programmers. |
|||||
|
|||||
|
If you install MongoDB using the Advanced Packaging Tool (apt) then it'll configure your startup scripts to automatically run Mongo when the system boots. The steps are as follows, first configure apt to be able to download the Mongo package:
Add this line to sources.list then save:
Then download and install Mongo with the apt-get utility:
If you want to make any changes to config, edit your mongodb.conf and restart:
|
|||||
|
|
I had the same "problem" on Debian jessie, and my simple solution is:
I think in Ubuntu it's the same. |
|||||||||||||
|
|
I am using crontab for Ubuntu. It works fine. To be able to edit file
Add this line to the file
The "&" sigh at the end help it to work background. Ctrl + x for exit, press "Y" once prompted. And keep the file name as "crontab". |
||||
|
|
|
If you have installed the MongoDB Community Edition (which is the recommended way since it receives more frequent updates than the package distributed in the Ubuntu package repository) you configure the start / stop behaviour of
If you do not want it to start automatically, replace those 2 lines with
|
||||
|
|
|
Controlling all the init.d service links should be done with the update-rc.d tool i.e. to turn on the mongod daemon in the default runlevels (i.e. turn it on at boot):
See https://help.ubuntu.com/community/UbuntuBootupHowto for more information. This link tells you everything you want to know about how to set programs at boot. |
|||||
|
|
If you install MongoDB with You can also take a look here for an old post that links to an In either case, the basic premise is that you're setting up a service and then configuring to start-stop with the computer. This is pretty common technique for servers, there are lots of tutorials around for doing exactly this. |
|||||
|
|
I have consistently used this post as a starting point to get a new sharding rig up and running. It includes a section on configuring upstart that I've also used. http://joslynesser.com/blog/archives/2010/09/28/mongodb-sharding-guide-server-setup-on-ubuntu-ec2/ |
|||||
|
|
where mongodb is the name of your service |
|||||||||||||
|