Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm (still) a novice on Linux, and trying to figure out how to make mongodb start when server boots on Linux?

I'm using Amazon EC2 "default" Linux instance (no Ubuntu).

share|improve this question
add comment

1 Answer

You have to put a startup script into /etc/init.d or one of those rc.x.d folders (depending on the fact under which circumstances you want to start mongod).

So ideally you put a startup script into etc/init.d/ and symlink it to the appropriate rc.x.d folders. Those rc folders mean the following as of the supplied link at the bottom:

  • Runlevel 0 is when you turn your computer off.
  • Runlevel 1 is single user mode
  • Runlevel 2 is multi user mode w/o NFS
  • Runlevel 3 is multi user mode w/NFS
  • Runlevel 4 is reserved for different vendors to define
  • Runlevel 5 is GUI mode.
  • Runlevel 6 is when you reboot your computer.

The startup script itself can be as easy as:

#!/bin/sh
/path/to/mongod #if you have mongod copied to some linux well known place you may only use mongod

To start a default configured mongod process, but you may want to configure it through additional parameters you can get from MongoDB - Command Line Parameters.

When you want to start mongodb only when a given user logs in you may want to add the startup script code into your .bash_profile of the corresponding user.

More can be found in this thread: Where do you place shutdown scripts?

share|improve this answer
1  
What does the thread say? Where exactly should you put them? Please include all necessary info here. –  slhck Jun 5 '12 at 8:21
add comment

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.