我使用 monit 5.27.2和 Mariadb 10.5.15在我的 debian 11个服务器。
我的服务器以 Multi-Source Mariadb Replication 。
有时,复制停止,我没有被通知。我还没有看到任何准备好的MONIT的配置来发送此类警报。
在以下查询中可见错误:
SHOW SLAVE STATUS;
这些值特别有趣:
我尚未找到任何使用MONIT直接监视A的结果的方法SQL语句。但是,似乎可以监视命令的返回代码带有版本的带有5.29.0之前的版本(以及命令的输出)。
我可能可以准备一个bash/shell脚本,该脚本将检查SQL语句的输出,然后是MONIT配置,该配置将在问题中向我发送警报。如果这样做,我将在此处发布它。我只是想知道是否已经有一个已知的解决方案。
我希望这可以与MySQL一起使用。
我打算使用这些SQL查询进行测试:
STOP SLAVE;
START SLAVE;
I use Monit 5.27.2 and MariaDB 10.5.15 on my Debian 11 servers.
My servers are set up in Multi-Source MariaDB Replication.
Sometimes, replication stops and I am not notified. I have not seen anywhere a prepared configuration for Monit to send such alerts.
The errors are visible with the following query:
SHOW SLAVE STATUS;
With those values particularly interesting:


I have not found any way to use Monit to monitor directly the result of a SQL statement. However, it seems possible to monitor the return code of a command with versions before Monit 5.29.0 (and the output of a command after).
I can probably prepare a Bash/Shell script that will check the output of the SQL statement and then a Monit config that will send me an alert in case of issue. If I do, I will post this as an answer here. I was just wondering whether there was already a known solution to this.
I expect this to work with MySQL.
I intend to test this with those SQL queries:
STOP SLAVE;
START SLAVE;
发布评论
评论(1)
我按照我的期望工作。我在复制的所有服务器来源上都这样做。
在此处安装
是文件
monit_replication.sh
:使此可执行文件:
添加到
/etc/etc/monit/conf-enabled/mysql
:testing
ran ran ran ran此sql:
重新启动monit:
发现
/var/log/monit.log
:接收到此电子邮件:
这验证了测试。使用此SQL查询恢复复制:
其他解决方案
如果基于MONIT的任何简单解决方案可以提醒我Mariadb上的复制失败,我很乐意接受它作为问题的解决方案。
I got this to work as I expected. I did this on all servers sources of the replication.
Installing
Here is the file
monit_replication.sh
:Made this executable:
Added to
/etc/monit/conf-enabled/mysql
:Testing
Ran this SQL:
Restarted monit:
Found in
/var/log/monit.log
:Received this email:
This validates the test. Restoring replication with this SQL query:
Other solutions
If any simpler solution based on Monit can alert me of a replication failure on MariaDB, I would be happy to accept it as the solution to the question.