문제

I am trying to monitor the MySQL process in another system using Monit. The system is connected to the same network connection as mine. I am using this code (inside the configuration file, monitrc) :

check process mysql with pidfile /var/run/mysqld/mysqld.pid

group database

start program = "/etc/init.d/mysql restart"

stop program = "/etc/init.d/mysql stop"

if failed host 192.168.0.189 port 3306 then restart

if 5 restarts within 5 cycles then timeout

Status appears to be "Not monitored". What seems to be the problem?

도움이 되었습니까?

해결책 2

Solved the problem. Had to change the bindaddress in my.conf file of mysql. Set it to 0.0.0.0 from localhost (127.0.0.1) to allow connections from all hosts in the network.

다른 팁

I'd like to expand this answer, as I had a similar problem.

1) Edit MySQL config (/etc/mysql/my.cnf) and set the bind address to whatever address it should listen to, such as 0.0.0.0 (global address), or an actual IP address. Also note the listening port.

2) Edit monit config file to use the same address as 'host' for the MySQL service. Make sure the port number also matches the MySQL config port.

3) Since I was using iptables rules for my firewall, I had to add the lines to my rules:

# allow connection to monit's http server
-A INPUT -p tcp -m tcp --dport 2812 -j ACCEPT
# allow connect to mysql server
-A INPUT -s <listening address> -p tcp -m tcp --dport <listening port> -j ACCEPT

Then reload the firewall rules:

sudo iptables-reload < /path/to/iptables.rules.file

Lastly, restart monit service, or reload configuration.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top