ubuntu articles --- mongo starts automatically

ubuntu articles --- mongo starts automatically

One: install mongo

For details, see the ubuntu article - steps to install mongoDB

Two: Write configuration files

# 1.进入该目录下
cd /lib/systemd/system
# 2.创建并编写文件
vim mongodb.service 

The content is as follows:

[Unit]
Description=mongod process control system for UNIX
Documentation=111
After=network.target

[Service]
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf
KillMode=process
Restart=on-failure
RestartSec=50s

[Install]
WantedBy=multi-user.target

Three: Execute the command

sudo systemctl daemon-reload
sudo systemctl start mongodb
sudo systemctl status mongodb

The result is as follows:
insert image description here

Guess you like

Origin blog.csdn.net/m0_46825740/article/details/130132326