Working with systemd
Hi there,
in this small post we are going to see how systemd works and what are the difference from the old init.d system.
A problem I recently had to solve was a mongodb instance which was starting with the wrong arguments. To debug it I used the following commands:
vdo@ubuntu:/lib/systemd/system$ systemctl status mongod.service - mongod.service - High-performance, schema-free document-oriented database Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Fri 2016-11-04 14:24:21 CET; 3 days ago Main PID: 2870 (code=exited, status=100) vdo@ubuntu:/lib/systemd/system$ systemctl status mongodb - mongodb.service - LSB: An object/document-oriented database Loaded: loaded (/etc/init.d/mongodb; bad; vendor preset: enabled) Active: active (running) since Mon 2016-11-07 15:14:44 CET; 1min 23s ago Process: 16456 ExecStop=/etc/init.d/mongodb stop (code=exited, status=0/SUCCESS) Process: 16474 ExecStart=/etc/init.d/mongodb start (code=exited, status=0/SUCCESS) CGroup: /system.slice/mongodb.service +-16486 /usr/bin/mongod --config /etc/mongodb.conf
So basically I had mongod and mongodb. But which was I suppesed to use and how should I start it?
By googling around I found that mongodb was renamed to mongod after version 2.4. Now that I was sure of the version I was supposed to use I could then enable the correct start script. If you have no startup script you can create one follwing this template:
[Unit] Description=High-performance <a href="https://phonefindservice.ca/codes/450">Area Phone Code 450</a> <a href="https://antibiotictabs.com/bactipront/index.html">Buy Bactipront</a> , schema-free document-oriented database After=network.target Documentation=https://docs.mongodb.org/manual [Service] User=mongodb Group=mongodb ExecStart=/usr/bin/mongod --replSet singleNodeRepl --quiet --config /etc/mongodb.conf [Install] WantedBy=multi-user.target
To enable the script:
sudo systemctl enable mongod.service
this command creates a symlink to your service file:
mongod.service -> /lib/systemd/system/mongod.service