下文主要给大家带来建立shell脚本检测MySql的AB复制简单步骤,希望这些内容能够带给大家实际用处,这也是我编辑建立shell脚本检测MySql的AB复制简单步骤这篇文章的主要目的。好了,废话不多说,大家直接看下文吧。
1. 建立一个Shell脚本,用于检测MySql的AB复制
vim /usr/local/nagios/libexec/check_mysqlab
#!/bin/bash #========================================= #File: checkmysqlab #Description: #Author: smileliuyb #Modify: smileliuyb #Creation Date: 20130110 #Last Modified: 20130110 #========================================= ipadd=$1 mysql -h $ipadd -u username -ppasswd -e 'stop slave;' &> /dev/null #mysql -h $ipadd -u username -ppasswd -e 'show slave status \G' &> dev/null if [ $? -eq 0 ];then mysql -h $ipadd -u username -ppasswd -e 'start slave;' &> /dev/null num=`mysql -h $ipadd -u amoebauser -pabc -e 'show slave status \G' | grep -c Yes` if [ $num -eq 2 ];then echo "OK"; exit 0; else echo "Error"; exit 2; fi else echo "Error"; exit 2; fi
chown nagios.nagios /usr/local/nagios/libexec/check_mysqlab
chmod a+x /usr/local/nagios/libexec/check_mysqlab
2.配置Nagios,在Nagios中加入新命令调用该脚本
vim /usr/local/nagios/etc/objects/commands.cfg
define command{ command_name check_mysql_ab command_line $USER1$/check_mysqlab $HOSTADDRESS$ }
3.配置Nagios,建立新的被监控对象和被监控服务
vim /usr/local/nagios/etc/objects/localhost.cfg
define host { host_name 192.168.50.62 alias 50.62 address 192.168.50.62 check_command check-host-alive notification_options d,u,r check_interval 1 max_check_attempts 2 contact_groups admins notification_interval 10 notification_period 24x7 }
define service{ host_name 192.168.50.62 service_description mysqlab check_period 24x7 normal_check_interval 2 retry_check_interval 1 max_check_attempts 3 notification_period 24x7 notification_options w,u,c,r check_command check_mysql_ab } 对于以上关于建立shell脚本检测MySql的AB复制简单步骤,大家是不是觉得非常有帮助。如果需要了解更多内容,请继续关注我们的行业资讯,相信你会喜欢上这些内容的。
亿速云「云数据库 MySQL」免部署即开即用,比自行安装部署数据库高出1倍以上的性能,双节点冗余防止单节点故障,数据自动定期备份随时恢复。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。