[英]How to auto-restart Mongodb in Ubuntu 16.04
I can't figure out how to auto-restart mongodb on Ubuntu 16.04 in the event that it crashes due to memory-pressure. 我无法弄清楚如何在Ubuntu 16.04上因内存压力崩溃而自动重启mongodb。
I'm using supervisord for other scripts etc, but mongod is through systemctl and I'm not sure how that ties into it. 我正在使用supervisord用于其他脚本等,但mongod是通过systemctl而我不确定它是如何与它相关联的。
Figured it out: 弄清楚了:
sudo vim /lib/systemd/system/mongod.service
sudo vim /lib/systemd/system/mongod.service
Restart=always
under service
Restart=always
在service
sudo systemctl daemon-reload
sudo systemctl daemon-reload
Now whenever mongod gets killed. 现在每当mongod被杀。 It'll get respawned by systemctl.
它会被systemctl重生。
When you install mongoDB
just run systemctl enable mongod.service
on terminal. 当您安装
mongoDB
只需在终端上运行systemctl enable mongod.service
。
This will make your mongoDB service auto-start on every restart. 这将使您的mongoDB服务在每次重启时自动启动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.