Mongodb monit无法读取mongod.lock
我正在为mongo(ubuntu)编写一个脚本。脚本如下Mongodb monit无法读取mongod.lock,mongodb,ubuntu,monit,Mongodb,Ubuntu,Monit,我正在为mongo(ubuntu)编写一个脚本。脚本如下 check process mongodb with pidfile "/var/lib/mongodb/mongod.lock" start program = "/sbin/start mongodb" stop program = "/sbin/stop mongodb" 但是我得到了错误日志 monit: Error reading pid from file '/var/lib/mongodb/mongod.loc
check process mongodb
with pidfile "/var/lib/mongodb/mongod.lock"
start program = "/sbin/start mongodb"
stop program = "/sbin/stop mongodb"
但是我得到了错误日志
monit: Error reading pid from file '/var/lib/mongodb/mongod.lock'
请告诉我是否有解决此问题的monit方法。我在使用MongoDB时遇到了相同的错误,这解决了我的问题:
chown-R mongod:mongod/var/lib/mongodb
Monit需要一个pid文件(包含mongod进程的pid),因此您必须在启动mongod时创建它
#!/bin/bash
mongod &
echo "$!" > /var/run/mongod.pid
并将/var/run/mongodb.pid设置为pidfile有点晚,但我在这里找到了pid文件:
/var/run/mongodb.pid
谢谢您的响应。此外,我还发现了另一种在启动mongo服务时创建pid文件的方法,即在mongo配置文件(/etc/mongod.conf)中创建pid文件。只需添加pid文件位置,如下所示:pidfilepath=/var/run/mongodb/mongod.pid