Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9872 Discussions

how do I launch MongoDB as a service?

EEdua2
Novice
1,135 Views

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!

0 Kudos
2 Replies
idata
Community Manager
170 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
170 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