How do I start mongodb with the system as a service? (not a trick question!)

58 views
Skip to first unread message

Aaron Paluzzi

unread,
Sep 8, 2018, 5:15:08 PM9/8/18
to mongodb-user
So I'm using Mongodb on a raspberry pi and on a ubuntu VM.  I can very easily start Mongodb with.. 

mongod -dbpath /home/user/data/db

But I can't seem to get mongodb to start as a service.  I've seen the following command:

sudo service mongod start

But it returns the following:
Failed to start mongod.service: Unit mongod.service not found.

I've also seen:
sudo service mongodb start

And this does not return an error, but when I use:  ps -edaf | grep mongo | grep -v grep

There is no feedback.  Mongodb hasn't started.


So what gives?  Starting a database as a service shouldn't be rocket science.  This isn't just an issue for the Raspberry pi.  I'm running into this via the Ubuntu VM.  What gives here?  I've checked the /etc/mongodb.conf file and it's correct.  Any help would be appreciated.

Robert Cochran

unread,
Sep 8, 2018, 5:31:54 PM9/8/18
to mongodb-user
Hi!

It would help if you always remember to quote the following information:

1. Version of MongoDB you are using
2. Version of Ubuntu you are using
3. Which model, exactly, of the Raspberry Pi you are using. There are a bunch of models.

If you are using Ubuntu 16.04 or later, the operating system uses systemd to manage services. It sounds like your system might be using systemd.

So:

sudo systemctl status mongod

If this shows good information about the mongod service, then to start the service manually:

sudo systemctl start mongod

If you want it to start automatically on system startup, then:

sudo systemctl enable mongod

That should help.

If none of the above works, you will probably have to look into the specifics for your operating system for how to start services.

There are a lot of places online that give basic information like this. It is not a "MongoDB issue". It is an "operating system issue." Googling on "ubuntu start system services" can get you a lot of help fast.

Thanks

Bob

Trieu Le

unread,
Sep 10, 2018, 10:51:30 AM9/10/18
to mongodb-user
Hi,

You can also using Crontab in order to make mongodb auto start every your board start up.
Beside it you can use an nodejs application such as mongo monitoring apps to control and monitoring your service.

kumar kishore

unread,
Sep 10, 2018, 6:46:38 PM9/10/18
to mongod...@googlegroups.com
 Not sure, will it work for ubuntu, add service then start db
sudo systemctl enable mongod
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/eab26a95-0828-43ee-ac85-b6bc504979e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Thanks & Regards

Pannala

Mobile: 2019-126-126


Reply all
Reply to author
Forward
0 new messages