init.d for ubuntu

3,437 views
Skip to first unread message

karikrishni

unread,
Jun 26, 2009, 2:41:42 PM6/26/09
to mongodb-user
Hi All,

Anybody having init.d/mongo script to start and stop the mongo server?
If you have, could you please post it to me.

Sorry, I don't much about linux system.

Regards,

Krish

Kristina Chodorow

unread,
Jun 26, 2009, 2:57:24 PM6/26/09
to mongod...@googlegroups.com
This is the init.d script that will be in the apt-get package: http://groups.google.com/group/mongodb-user/web/mongodb.  It expects mongod to be in /usr/bin (if it's not, just change line 50).   It will create dbs in /var/lib/mongodb (if you'd like them to be somewhere else, change line 51).

Put the "mongodb" script in /etc/init.d and run:

$ useradd mongodb

Then, to start at stop the db:

sudo /etc/init.d/mongodb start
sudo /etc/init.d/mongodb stop

Let me know if you have any problems!

Kunthar

unread,
Jun 27, 2009, 1:16:01 PM6/27/09
to mongod...@googlegroups.com
Here is attached my version uses start-stop daemon.
Everything is configurable and base dir is /opt/mongodb
Stop sends signal 2 ctrl+c gently.
Log is not redirected, anyone knows how to redirect with start-stop
daemon drop me a line.

Peace
\|/ Kunth
mongod

karikrishni

unread,
Jun 28, 2009, 12:11:18 PM6/28/09
to mongodb-user
Hi Kristina, Kunthar,

I could not start the db with both the script. But I am sure something
wrong with my system.

Where I can see the log files? I am not getting any error messages but
mongodb could not start.

I use Ubuntu 9.

I will give one more try before seeking help.

Thank you both for script.

Regards,

Gopal

On Jun 27, 10:16 pm, Kunthar <kunt...@gmail.com> wrote:
> Here is attached my version uses start-stop daemon.
> Everything is configurable and base dir is /opt/mongodb
> Stop sends signal 2 ctrl+c gently.
> Log is not redirected, anyone knows how to redirect with start-stop
> daemon drop me a line.
>
> Peace
> \|/ Kunth
>
> On Fri, Jun 26, 2009 at 9:57 PM, Kristina Chodorow<krist...@10gen.com> wrote:
> > This is the init.d script that will be in the apt-get package:
> >http://groups.google.com/group/mongodb-user/web/mongodb. It expects mongod
> > to be in /usr/bin (if it's not, just change line 50).   It will create dbs
> > in /var/lib/mongodb (if you'd like them to be somewhere else, change line
> > 51).
>
> > Put the "mongodb" script in /etc/init.d and run:
>
> > $ useradd mongodb
>
> > Then, to start at stop the db:
>
> > sudo /etc/init.d/mongodb start
> > sudo /etc/init.d/mongodb stop
>
> > Let me know if you have any problems!
>
> > On Fri, Jun 26, 2009 at 2:41 PM, karikrishni <karikris...@gmail.com> wrote:
>
> >> Hi All,
>
> >> Anybody having init.d/mongo script to start and stop the mongo server?
> >> If you have, could you please post it to me.
>
> >> Sorry, I don't much about linux system.
>
> >> Regards,
>
> >> Krish
>
>
>
>  mongod
> 6KViewDownload

Kunthar

unread,
Jun 28, 2009, 2:44:34 PM6/28/09
to mongod...@googlegroups.com
did you run from console beforehand?
$mongo_dir/bin/mongod --dbpath /your/path --noauth

Kristina Chodorow

unread,
Jun 29, 2009, 10:05:28 AM6/29/09
to mongod...@googlegroups.com
If you aren't getting any output, I'm guessing mongod isn't where the scripts are expecting it to be.  Can you run:

$ which mongod

If you downloaded the binary from the website, I'm guessing mongod isn't on your path, it's somewhere like /home/youruser/mongo-0.9.5/bin/mongod.  In this case, change line 50 of my script to:

DAEMON=/home/youruser/mongo-0.9.5/bin/mongod

For Kunthar's script, run:

export MONGOPATH=/home/youruser/mongo-0.9.5

Finally, make sure the data directory exists.  For my script, do

$ mkdir /var/lib/mongodb

for Kunthar's, do

$ mkdir $MONGOPATH/data

karikrishni

unread,
Jun 30, 2009, 2:55:20 PM6/30/09
to mongodb-user
Hi Kristina,

It works. There was issue in mapping the right path.

Is it safe to run the cron job for every 5 minutes to start the
mongodb in case of any crash? I have a similar cron job for pylons/
paster server. I wonder mongodb require any such options.

What can you suggest?

Thanks in advance.

--

Krish

On Jun 29, 7:05 pm, Kristina Chodorow <krist...@10gen.com> wrote:
> If you aren't getting any output, I'm guessing mongod isn't where the
> scripts are expecting it to be.  Can you run:
>
> $ which mongod
>
> If you downloaded the binary from the website, I'm guessing mongod isn't on
> your path, it's somewhere like /home/youruser/mongo-0.9.5/bin/mongod.  In
> this case, change line 50 of my script to:
>
> DAEMON=/home/youruser/mongo-0.9.5/bin/mongod
>
> For Kunthar's script, run:
>
> export MONGOPATH=/home/youruser/mongo-0.9.5
>
> Finally, make sure the data directory exists.  For my script, do
>
> $ mkdir /var/lib/mongodb
>
> for Kunthar's, do
>
> $ mkdir $MONGOPATH/data
>
> On Sun, Jun 28, 2009 at 2:44 PM, Kunthar <kunt...@gmail.com> wrote:
>
> > did you run from console beforehand?
> > $mongo_dir/bin/mongod --dbpath /your/path --noauth
>

Kunthar

unread,
Jun 30, 2009, 3:56:32 PM6/30/09
to mongod...@googlegroups.com
Really wondering the rest of the guys running mongo for a long time :)

Marius Rugan

unread,
Jul 2, 2009, 7:14:18 AM7/2/09
to mongod...@googlegroups.com
On Tue, Jun 30, 2009 at 10:56 PM, Kunthar <kun...@gmail.com> wrote:

Really wondering the rest of the guys running mongo for a long time :)
 

./mongod --dbpath /var/lib/mongodb --noauth -v --cpu inside a screen session :)

David M

unread,
Jul 16, 2009, 12:40:11 PM7/16/09
to mongodb-user
I have just set this up on CentOS 5.2. Calling the init script output
this error:

./mongodb: line 58: /lib/lsb/init-functions: No such file or directory

I installed redhat-lsb which fixed this error, but now I get:

/etc/init.d/mongodb: line 180: log_daemon_msg: command not found

Having searched around, it seems these are part of the lsb functions;
but they are already installed:

Package redhat-lsb-3.1-12.3.EL.el5.centos.x86_64 already installed and
latest version
Package redhat-lsb-3.1-12.3.EL.el5.centos.i386 already installed and
latest version

Any suggestions?

Mitch Pirtle

unread,
Jul 16, 2009, 3:37:17 PM7/16/09
to mongod...@googlegroups.com
I ran into the exact same problem using RHEL5 - the version provided
is not current, and lacks several methods in the helper libraries.

One thing I've been meaning to do is rewrite the init scripts to be
compatible with older versions of init-functions but I am buried in a
mad dash to the finish line (just like all other website projects).

-- Mitch

Vikas Gupta

unread,
Sep 30, 2015, 8:26:24 PM9/30/15
to mongodb-user, karik...@gmail.com
Hi Kristina,KariKrishni


Could you please share your script?

The setup at my project is seems quite different. So, just need help to achieve the same.

Thanks in advance!

Stephen Steneker

unread,
Oct 1, 2015, 12:22:57 AM10/1/15
to mongodb-user, karik...@gmail.com
On Thursday, 1 October 2015 10:26:24 UTC+10, Vikas Gupta wrote:

Hi Vikas,

The discussion you are replying to is from 2009 (!) .. so things have definitely changed since then :).

In future please start a new discussion with details of your specific environment and question.

As a starting point for installing MongoDB and running `mongod` as service, please see the installation guides in the MongoDB manual:
 http://docs.mongodb.org/manual/installation/#installation-guides

Thanks,
Stephen
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages