CenterOS7下设置mongoDB自启动

一 、在/lib/systemd/system/目录下新建mongodb.service文件,内容如下

[Unit]

Description=mongodb

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

[Service]

Type=forking

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

ExecReload=/bin/kill -s HUP $MAINPID

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

PrivateTmp=true

[Install]

WantedBy=multi-user.targe

二、设置权限

chmod 754 mongodb.service

三、启动关闭服务,设置开机启动

#启动服务

systemctl start mongodb.service  

#关闭服务  

systemctl stop mongodb.service  

#开机启动  

systemctl enable mongodb.service

猜你喜欢

转载自blog.csdn.net/weixin_40596190/article/details/82839044