0

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).

1 Answer 1

0

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?

1
  • 1
    What does the thread say? Where exactly should you put them? Please include all necessary info here.
    – slhck
    Jun 5, 2012 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .