mongodb设置开机启动

mongodb设置开机启动

   小白     2020年1月11日 00:34     1565    

1、编写启动脚本

cd /lib/systemd/system

vim mongodb.service

[Unit]

Description=mongodb

After=network.target remote-fs.target nss-lookup.target

 

[Service]

Type=forking

ExecStart=/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf

ExecReload=/bin/kill -s HUP $MAINPID

ExecStop=/usr/local/mongodb/bin/mongod --shutdown --config /usr/local/mongodb/bin/mongodb.conf

PrivateTmp=true

 

[Install]

WantedBy=multi-user.target

 

2、设置脚本

将这个放到/lib/systemd/system/mongodb.service

或者/usr/lib/systemd/system/mongdb.service

只要在其中一个添上,另一个目录中就会存在

加载配置好的脚本

systemctl daemon-reload

启停 mongodb

systemctl start/stop mongodb.service

设置开机启动

systemctl enable mongodb.service

 

文章评论

0

其他文章