Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Systemd Service Script for Mongod On Ubuntu 15.04, 15.10, 16.04 Xenial
[Unit]
Description=High-performance, schema-free document-oriented database
Documentation=man:mongod(1)
After=network.target
[Service]
Type=forking
User=mongodb
Group=mongodb
RuntimeDirectory=mongod
PIDFile=/var/run/mongod/mongod.pid
ExecStart=/usr/bin/mongod -f /etc/mongod.conf --pidfilepath /var/run/mongod/mongod.pid --fork
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
@benileo
Copy link
Author

benileo commented Nov 3, 2015

File path needs to be /lib/systemd/system/mongod.service

$ systemctl enable mongod.service
$ systemctl start mongod.service

@matthallamew
Copy link

matthallamew commented Jan 29, 2016

Thank you for this!

@iam3fun
Copy link

iam3fun commented Feb 23, 2016

thanks :)

@tsologub
Copy link

tsologub commented Mar 15, 2016

many thanks!!

@d0k1
Copy link

d0k1 commented Mar 23, 2016

Thanks for solution!

@marksmeets
Copy link

marksmeets commented Apr 1, 2016

if your data is on an nfs mounted directory, use
After=nfs-client.target

@ruixiangTan
Copy link

ruixiangTan commented Apr 22, 2016

thanks, man. you just saved my day!

@benileo
Copy link
Author

benileo commented Jun 4, 2016

You are all very welcome! I find it astonishing that @mongodb still does not have support for Ubuntu 14.04+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment