使用systemctl 来管理 mongod

使用systemctl 来管理 mongod 
 
cat <<EOF > /usr/lib/systemd/system/mongodb.service
[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/mongodb/bin/mongod --config /etc/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/usr/local/mongodb/bin/mongod --shutdown --config /etc/mongodb.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target
EOF


#添加可执行权限:
chmod 755 /usr/lib/systemd/system/mongodb.service


#重载 systemctl units
systemctl daemon-reload


#设置为开机自启动
systemctl enable mongodb.service

 

 

 

posted @ 2021-06-29 14:04  屠魔的少年  阅读(7)  评论(0)    收藏  举报