我正在尝试创建一个monit配置文件来监视mongodb是否正在运行。
这是我的配置文件。
check process mongod with pidfile /var/run/mongodb/mongod.pid
group mongodb
start program = "/sbin/start mongod"
stop program = "/sbin/stop mongod"
if failed host 127.0.0.1 port 27017 protocol http
and request "/" with timeout 10 seconds then restart port response time FAILED to [localhost]:27017 type TCP/IP protocol HTTP我检查并验证了mongodb的运行情况。事件尝试使用curl连接到mongodb。下面是我执行的用于验证到mongo的http连接的命令。
curl -v localhost:27017这是我得到的输出。
* Rebuilt URL to: localhost:27017/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 27017 (#0)
> GET / HTTP/1.1
> Host: localhost:27017
> User-Agent: curl/7.58.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Connection: close
< Content-Type: text/plain
< Content-Length: 85
<
It looks like you are trying to access MongoDB over HTTP on the native driver port.
* Closing connection 0不知道我做错了什么。
相同的配置文件在ubuntu14.4上工作,但它不能运行ubuntu18.4。
发布于 2019-05-04 02:42:52
由于某种原因,我对MongoDB在CentOS 6.10上的反应是错误的。
用新协议检查修正,在Monit中实现
if failed host 127.0.0.1 port 27017 protocol mongodb
then restart注意新协议名mongodb
这样做很好
https://serverfault.com/questions/956284
复制相似问题