Auto start: mongodb on ubuntu 16.x LTS
Auto start: mongodb on ubuntu 16.x LTS
create a service script
(in this example the name of the service is Mongodb)
nano /lib/systemd/system/mongodb.service
File content should be
[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target[Service]
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
User=mongodb
Group=mongodb
StandardOutput=syslog
StandardError=syslog[Install]
WantedBy=multi-user.target
Now to start mongodb:
sudo systemctl start mongodb
To stop mongodb service use:
sudo systemctl stop mongodb
To enable mongodb on startup
sudo systemctl enable mongodb.service
If you need to refresh the services use:
sudo systemctl daemon-reload
댓글
댓글 쓰기