Community
cancel
Showing results for 
Search instead for 
Did you mean: 
EEdua2
Novice
1,021 Views

how do I launch MongoDB as a service?

Hi everyone, I've just installed MongoDB 32-bit on the Edison following this tutorial:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-linux/ https://docs.mongodb.com/manual/tutorial/install-mongodb-on-linux/

I lauched the "mongod" and it works, but now I'd like to launch mongod as a service by typing "systemctl start mongodb.service" or something like that. Unfortunately I'm still a linux newbie, I don't know how to do it :c

This is the mongod directory: /home/root/mongodb/mongodb-linux-i686-3.2.6/bin/

Please, help me!

Tags (1)
0 Kudos
2 Replies
idata
Community Manager
56 Views

Hi,

 

 

In order to create services and manage them with systemctl as you mentioned, you need to use systemd. All the services available are located in /lib/systemd/.

 

In order to create a service for mongodb I suggest you to look into the following links:

 

http://gh0stwizard.tk/2013/09/30/mongodb-systemd/

 

http://tom-chapman.uk/2012/12/28/installing-mongodb-on-a-linux-distro-using-systemd-instead-of-initt...

 

http://askubuntu.com/questions/748789/run-mongodb-service-as-daemon-of-systemd-on-ubuntu-15-10

 

https://gist.github.com/chappy84/4400325

 

 

I think these links will help you to create the service. Once the service is created you need to enable it in order to run everytime at boot.

 

 

Regards,

 

Charlie
EEdua2
Novice
56 Views

Thanks for the links Charlie.

I also found this one:

https://www.freedesktop.org/software/systemd/man/systemd.service.html https://www.freedesktop.org/software/systemd/man/systemd.service.html

It explains everything about systemd.service building.

Finally I created the file:

sudo nano /etc/systemd/system/mongod.service

Then for simplicity I wrote:

[Unit]

Description=Mongo is a scalable, document-oriented database.

After=syslog.target network.target

[Service]

ExecStart=/home/root/mongodb/mongodb-linux-i686-3.2.6/bin/mongod

[Install]

WantedBy=multi-user.target

It works!! c:

Reply