简介:
MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Facebook公司)开发,是一套优秀的作为MySQL高可用性环境下故障切换和主从提升的高可用软件。在MySQL故障切换过程中,MHA能做到在0~30秒之内自动完成数据库的故障切换操作,并且在进行故障切换的过程中,MHA能在最大程度上保证数据的一致性,以达到真正意义上的高可用。
该软件由两部分组成:MHA Manager(管理节点)和MHA Node(数据节点)。MHA Manager可以单独部署在一台独立的机器上管理多个master-slave集群,也可以部署在一台slave节点上。MHA Node运行在每台MySQL服务器上,MHA Manager会定时探测集群中的master节点,当master出现故障时,它可以自动将最新数据的slave提升为新的master,然后将所有其他的slave重新指向新的master。整个故障转移过程对应用程序完全透明。
在MHA自动故障切换过程中,MHA试图从宕机的主服务器上保存二进制日志,最大程度的保证数据的不丢失,但这并不总是可行的。例如,如果主服务器硬件故障或无法通过ssh访问,MHA没法保存二进制日志,只进行故障转移而丢失了最新的数据。使用MySQL 5.5的半同步复制,可以大大降低数据丢失的风险。MHA可以与半同步复制结合起来。如果只有一个slave已经收到了最新的二进制日志,MHA可以将最新的二进制日志应用于其他所有的slave服务器上,因此可以保证所有节点的数据一致性。
目前MHA主要支持一主多从的架构,要搭建MHA,要求一个复制集群中必须最少有三台数据库服务器,一主二从,即一台充当master,一台充当备用master,另外一台充当从库,因为至少需要三台服务器,出于机器成本的考虑,淘宝也在该基础上进行了改造,目前淘宝TMHA已经支持一主一从。另外对于想快速搭建的可以参考:MHA快速搭建
我们自己使用其实也可以使用1主1从,但是master主机宕机后无法切换,以及无法补全binlog。master的mysqld进程crash后,还是可以切换成功,以及补全binlog的。
在所有node节点安装MHA node所需的perl模块(DBD:mysql)
yum install perl-DBD-MySQL -y
在所有的节点安装mha node
https://github.com/yoshinorim/mha4mysql-manager/wiki/Downloads [[email protected] ~]# cd /application/tools/ [[email protected] tools]# rpm -ivh mha4mysql-node-0.56-0.el6.noarch.rpm [[email protected] ~]# cd /application/tools/ [[email protected] tools]# rpm -ivh mha4mysql-node-0.56-0.el6.noarch.rpm [[email protected] ~]# cd /application/tools/ [[email protected] tools]# rpm -ivh mha4mysql-node-0.56-0.el6.noarch.rpm [[email protected] ~]# cd /application/tools/ [[email protected] tools]# rpm -ivh mha4mysql-node-0.56-0.el6.noarch.rpm
配置SSH登录无密码验证
manager echo -e "\n" | ssh-keygen rsa -N "" ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] master1 echo -e "\n" | ssh-keygen rsa -N "" ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] master2 echo -e "\n" | ssh-keygen rsa -N "" ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] slave echo -e "\n" | ssh-keygen rsa -N "" ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected] ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]
安装MHA Manager软件包
https://github.com/yoshinorim/mha4mysql-manager/wiki/Downloads [[email protected] ~]# yum install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager perl-Time-HiRes -y [[email protected] ~]# cd /application/tools/ [[email protected] tools]# rpm -ivh mha4mysql-manager-0.56-0.el6.noarch.rpm 安装后会在/usr/bin下生成如下脚本文件 rpm -qpl mha4mysql-manager-0.56-0.el6.noarch.rpm /usr/bin/masterha_check_repl /usr/bin/masterha_check_ssh /usr/bin/masterha_check_status /usr/bin/masterha_conf_host /usr/bin/masterha_manager /usr/bin/masterha_master_monitor /usr/bin/masterha_master_switch /usr/bin/masterha_secondary_check /usr/bin/masterha_stop
创建监控用户
master1 grant all privileges on *.* to 'root'@'172.16.1.%' identified by '123456'; flush privileges;
创建MHA的工作目录,并且创建相关配置文件
manager [[email protected] ~]# mkdir -p /etc/masterha [[email protected] ~]# cat /etc/masterha/app1.cnf [server default] manager_workdir=/var/log/masterha/app1.log //设置manager的工作目录 manager_log=/var/log/masterha/app1/manager.log //设置manager的日志 master_binlog_dir=/application/mysql/data //设置master 保存binlog的位置,以便MHA可以找到master的日志,我这里的也就是mysql的数据目录 master_ip_failover_script= /usr/bin/master_ip_failover //设置自动failover时候的切换脚本 master_ip_online_change_script= /usr/bin/master_ip_online_change //设置手动切换时候的切换脚本 password=123456 //设置mysql中root用户的密码,这个密码是前文中创建监控用户的那个密码 user=root //设置监控用户root ping_interval=1 //设置监控主库,发送ping包的时间间隔,默认是3秒,尝试三次没有回应的时候自动进行railover remote_workdir=/tmp //设置远端mysql在发生切换时binlog的保存位置 repl_password=mysql01 //设置复制用户的密码 repl_user=mysql01 //设置复制环境中的复制用户名 report_script=/usr/bin/send_report //设置发生切换后发送的报警的脚本 secondary_check_script=/usr/bin/masterha_secondary_check -s 172.16.1.104 --user=root --master_host=172.16.1.103 --master_ip=172.16.1.103 --master_port=3306 //一旦MHA到master的监控之间出现问题 MHAManager将会判断其它两个slave是否能建立到master3306端口的连接 shutdown_script="" //设置故障发生后关闭故障主机脚本(该脚本的主要作用是关闭主机放在发生脑裂,这里没有使用) ssh_user=root //设置ssh的登录用户名 [server1] hostname=172.16.1.103 port=3306 [server2] hostname=172.16.1.104 port=3306 candidate_master=1 //设置为候选master,如果设置该参数以后,发生主从切换以后将会将此从库提升为主库 check_repl_delay=0 //这个候选主在切换的过程中一定是新的master [server3] hostname=172.16.1.105 port=3306
上面设置的脚本内容
上述脚本需要添加执行权限
chmod +x /usr/bin/master_ip_failover chmod +x /usr/bin/master_ip_online_change chmod +x /usr/bin/send_report master_ip_failover #!/usr/bin/env perl use strict; use warnings FATAL =>'all'; use Getopt::Long; my ( $command, $ssh_user, $orig_master_host, $orig_master_ip, $orig_master_port, $new_master_host, $new_master_ip, $new_master_port ); my $vip = '172.16.1.200/24'; # Virtual IP my $key = "1"; my $ssh_start_vip = "/sbin/ifconfig eth1:$key $vip"; my $ssh_stop_vip = "/sbin/ifconfig eth1:$key down"; my $exit_code = 0; $ssh_user = "root"; GetOptions( 'command=s' => \$command, 'ssh_user=s' => \$ssh_user, 'orig_master_host=s' => \$orig_master_host, 'orig_master_ip=s' => \$orig_master_ip, 'orig_master_port=i' => \$orig_master_port, 'new_master_host=s' => \$new_master_host, 'new_master_ip=s' => \$new_master_ip, 'new_master_port=i' => \$new_master_port, ); exit &main(); sub main { #print "\n\nIN SCRIPT TEST====$ssh_stop_vip==$ssh_start_vip===\n\n"; if ( $command eq "stop" || $command eq "stopssh" ) { # $orig_master_host, $orig_master_ip, $orig_master_port are passed. # If you manage master ip address at global catalog database, # invalidate orig_master_ip here. my $exit_code = 1; eval { print "\n\n\n***************************************************************\n"; print "Disabling the VIP - $vip on old master: $orig_master_host\n"; print "***************************************************************\n\n\n\n"; &stop_vip(); $exit_code = 0; }; if ([email protected]) { warn "Got Error: [email protected]\n"; exit $exit_code; } exit $exit_code; } elsif ( $command eq "start" ) { # all arguments are passed. # If you manage master ip address at global catalog database, # activate new_master_ip here. # You can also grant write access (create user, set read_only=0, etc) here. my $exit_code = 10; eval { print "\n\n\n***************************************************************\n"; print "Enabling the VIP - $vip on new master: $new_master_host \n"; print "***************************************************************\n\n\n\n"; &start_vip(); $exit_code = 0; }; if ([email protected]) { warn [email protected]; exit $exit_code; } exit $exit_code; } elsif ( $command eq "status" ) { print "Checking the Status of the script.. OK \n"; `ssh $ssh_user\@$orig_master_host \" $ssh_start_vip \"`; exit 0; } else { &usage(); exit 1; } } # A simple system call that enable the VIP on the new master sub start_vip() { `ssh $ssh_user\@$new_master_host \" $ssh_start_vip \"`; } # A simple system call that disable the VIP on the old_master sub stop_vip() { `ssh $ssh_user\@$orig_master_host \" $ssh_stop_vip \"`; } sub usage { print "Usage: master_ip_failover –command=start|stop|stopssh|status –orig_master_host=host –orig_master_ip=ip –orig_master_port=po rt –new_master_host=host –new_master_ip=ip –new_master_port=port\n"; }
master_ip_online_change #!/usr/bin/env perl use strict; use warnings FATAL =>'all'; use Getopt::Long; my $vip = '172.16.1.200/24'; # Virtual IP my $key = "1"; my $ssh_start_vip = "/sbin/ifconfig eth1:$key $vip"; my $ssh_stop_vip = "/sbin/ifconfig eth1:$key down"; my $exit_code = 0; $ssh_user = "root"; my ( $command, $orig_master_is_new_slave, $orig_master_host, $orig_master_ip, $orig_master_port, $orig_master_user, $orig_master_password, $orig_master_ssh_user, $new_master_host, $new_master_ip, $new_master_port, $new_master_user, $new_master_password, $new_master_ssh_user, ); GetOptions( 'command=s' => \$command, 'orig_master_is_new_slave' => \$orig_master_is_new_slave, 'orig_master_host=s' => \$orig_master_host, 'orig_master_ip=s' => \$orig_master_ip, 'orig_master_port=i' => \$orig_master_port, 'orig_master_user=s' => \$orig_master_user, 'orig_master_password=s' => \$orig_master_password, 'orig_master_ssh_user=s' => \$orig_master_ssh_user, 'new_master_host=s' => \$new_master_host, 'new_master_ip=s' => \$new_master_ip, 'new_master_port=i' => \$new_master_port, 'new_master_user=s' => \$new_master_user, 'new_master_password=s' => \$new_master_password, 'new_master_ssh_user=s' => \$new_master_ssh_user, ); exit &main(); sub main { #print "\n\nIN SCRIPT TEST====$ssh_stop_vip==$ssh_start_vip===\n\n"; if ( $command eq "stop" || $command eq "stopssh" ) { # $orig_master_host, $orig_master_ip, $orig_master_port are passed. # If you manage master ip address at global catalog database, # invalidate orig_master_ip here. my $exit_code = 1; eval { print "\n\n\n***************************************************************\n"; print "Disabling the VIP - $vip on old master: $orig_master_host\n"; print "***************************************************************\n\n\n\n"; &stop_vip(); $exit_code = 0; }; if ([email protected]) { warn "Got Error: [email protected]\n"; exit $exit_code; } exit $exit_code; } elsif ( $command eq "start" ) { # all arguments are passed. # If you manage master ip address at global catalog database, # activate new_master_ip here. # You can also grant write access (create user, set read_only=0, etc) here. my $exit_code = 10; eval { print "\n\n\n***************************************************************\n"; print "Enabling the VIP - $vip on new master: $new_master_host \n"; print "***************************************************************\n\n\n\n"; &start_vip(); $exit_code = 0; }; if ([email protected]) { warn [email protected]; exit $exit_code; } exit $exit_code; } elsif ( $command eq "status" ) { print "Checking the Status of the script.. OK \n"; `ssh $orig_master_ssh_user\@$orig_master_host \" $ssh_start_vip \"`; exit 0; } else { &usage(); exit 1; } } # A simple system call that enable the VIP on the new master sub start_vip() { `ssh $new_master_ssh_user\@$new_master_host \" $ssh_start_vip \"`; } # A simple system call that disable the VIP on the old_master sub stop_vip() { `ssh $orig_master_ssh_user\@$orig_master_host \" $ssh_stop_vip \"`; } sub usage { print "Usage: master_ip_failover ?command=start|stop|stopssh|status ?orig_master_host=host ?orig_master_ip=ip ?orig_master_port=po rt ?new_master_host=host ?new_master_ip=ip ?new_master_port=port\n"; }
send_report #/bin/bash source /root/.bash_profile orig_master_host=`echo "$1" | awk -F = '{print $2}'` new_master_host=`echo "$2" | awk -F = '{print $2}'` new_slave_hosts=`echo "$3" | awk -F = '{print $2}'` subject=`echo "$4" | awk -F = '{print $2}'` body=`echo "$5" | awk -F = '{print $2}'` #判断日志结尾是否有successfully,有则表示切换成功,成功与否都发邮件。 tac /var/log/masterha/app1/manager.log | sed -n 2p | grep 'successfully' > /dev/null if [ $? -eq 0 ] then echo -e "MHA $subject 主从切换成功\n master:$orig_master_host --> $new_master_host \n $body \n 当前从库:$new_slave_hosts 如果 确定主库可以恢复 请执行 sh /server/scripts/recover.sh 完成主库的恢复 重新作为新主库的从库 重新加入集群"| mail -s "MySQL实例宕掉,MHA $subject 切换成功" [email protected] else echo -e "MHA $subject 主从切换失败\n master:$orig_master_host --> $new_master_host \n $body" | mail -s "MySQL实例宕掉,MHA $subject 切换失败" [email protected] fi
邮件设置
set [email protected] set smtp=smtp.163.com set [email protected] set smtp-auth-password=a625013463 set smtp-auth=login
设置定期清理relay(两台slave服务器,relay_log_purge=0已经写到配置文件中)
[[email protected] ~]# echo '0 5 * * * /usr/bin/purge_relay_logs --user=root --password=123456 --disable_relay_log_purge >> /application/mysql/log/mysql-del-relay.log 2>&1' >> /var/spool/cron/root [[email protected] ~]# crontab -l */5 * * * * /usr/sbin/ntpdate 0.asia.pool.ntp.org >/dev/null 2>&1 0 5 * * * /usr/bin/purge_relay_logs --user=root --password=123456 --disable_relay_log_purge >> /application/mysql/log/mysql-del-relay.log 2>&1 [[email protected] ~]#
检查MHA Manger到所有MHA Node的SSH连接状态
[[email protected] ~]# masterha_check_ssh --conf=/etc/masterha/app1.cnf Sat May 12 14:30:04 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Sat May 12 14:30:04 2018 - [info] Reading application default configuration from /etc/masterha/app1.cnf.. Sat May 12 14:30:04 2018 - [info] Reading server configuration from /etc/masterha/app1.cnf.. Sat May 12 14:30:04 2018 - [info] Starting SSH connection tests.. Sat May 12 14:30:06 2018 - [debug] Sat May 12 14:30:04 2018 - [debug] Connecting via SSH from [email protected](172.16.1.103:22) to [email protected](172.16.1.104:22).. Sat May 12 14:30:05 2018 - [debug] ok. Sat May 12 14:30:05 2018 - [debug] Connecting via SSH from [email protected](172.16.1.103:22) to [email protected](172.16.1.105:22).. Warning: Permanently added '172.16.1.105' (RSA) to the list of known hosts. Sat May 12 14:30:05 2018 - [debug] ok. Sat May 12 14:30:06 2018 - [debug] Sat May 12 14:30:05 2018 - [debug] Connecting via SSH from [email protected](172.16.1.104:22) to [email protected](172.16.1.103:22).. Sat May 12 14:30:05 2018 - [debug] ok. Sat May 12 14:30:05 2018 - [debug] Connecting via SSH from [email protected](172.16.1.104:22) to [email protected](172.16.1.105:22).. Warning: Permanently added '172.16.1.105' (RSA) to the list of known hosts. Sat May 12 14:30:06 2018 - [debug] ok. Sat May 12 14:30:06 2018 - [debug] Sat May 12 14:30:05 2018 - [debug] Connecting via SSH from [email protected](172.16.1.105:22) to [email protected](172.16.1.103:22).. Warning: Permanently added '172.16.1.105' (RSA) to the list of known hosts. Warning: Permanently added '172.16.1.103' (RSA) to the list of known hosts. Sat May 12 14:30:06 2018 - [debug] ok. Sat May 12 14:30:06 2018 - [debug] Connecting via SSH from [email protected](172.16.1.105:22) to [email protected](172.16.1.104:22).. Sat May 12 14:30:06 2018 - [debug] ok. Sat May 12 14:30:06 2018 - [info] All SSH connection tests passed successfully.
检查整个复制环境状况
所有MHA node执行
[[email protected] ~]# ln -s /application/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog [[email protected] ~]# ln -s /application/mysql/bin/mysql /usr/local/bin/mysql [[email protected] ~]#
[[email protected] ~]# masterha_check_repl --conf=/etc/masterha/app1.cnf ......................................... 172.16.1.104(172.16.1.104:3306) (current master) +--172.16.1.105(172.16.1.105:3306) +--172.16.1.103(172.16.1.103:3306) Tue May 29 23:24:13 2018 - [info] Checking replication health on 172.16.1.105.. Tue May 29 23:24:13 2018 - [info] ok. Tue May 29 23:24:13 2018 - [info] Checking replication health on 172.16.1.103.. Tue May 29 23:24:13 2018 - [info] ok. Tue May 29 23:24:13 2018 - [info] Checking master_ip_failover_script status: Tue May 29 23:24:13 2018 - [info] /usr/bin/master_ip_failover --command=status --ssh_user=root --orig_master_host=172.16.1.104 --orig_master_ip=172.16.1.104 --orig_master_port=3306 Checking the Status of the script.. OK Tue May 29 23:24:13 2018 - [info] OK. Tue May 29 23:24:13 2018 - [warning] shutdown_script is not defined. Tue May 29 23:24:13 2018 - [info] Got exit code 0 (Not master dead). MySQL Replication Health is OK.
使用daemontools结合脚本来管理masterha_manager
cd /application/tools wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz tar xvzf daemontools-0.76.tar.gz cd admin/daemontools-0.76 vim src/conf-cc gcc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings -include /usr/include/errno.h This will be used to compile .c files. ./package/install mkdir /service/masterha_app1/ cd /service/masterha_app1/ vim run #!/bin/sh exec nohup masterha_manager --conf=/etc/masterha/app1.cnf --remove_dead_master_conf --ignore_last_failover >> /var/log/masterha/app1/manager.log chmod 755 /service/masterha_app1/run ln -s /application/tools/admin/daemontools/command/svscanboot /usr/bin echo "#MHA-manage" >> /etc/rc.local echo "/usr/local/bin/supervise /service/masterha_app1/&" >> /etc/rc.local 启动MHA-manage svc -u /service/masterha_app1 关闭MHA-manage svc -d /service/masterha_app1
检查MHA Manager的状态
masterha_check_status --conf=/etc/masterha/app1.cnf app1 (pid:1090) is running(0:PING_OK), master:172.16.1.103
模拟主库(172.16.1.103)发生故障,进行自动failover操作。
/etc/init.d/mysql stop Shutting down MySQL.................. SUCCESS!
检查MHA Manager的状态
masterha_check_status --conf=/etc/masterha/app1.cnf app1 (pid:1098) is running(0:PING_OK), master:172.16.1.104
邮箱中收到邮件
故障恢复把当即master作为新master备选加入集群
恢复步骤
(1)在现在的master或者slave使用mysqldump将数据备份,加--master-data=2 -A参数
(2)将备份数来的数据在服务器A上进行恢复,完成后执行flush privileges刷新权限
(3)完成后配置GTID的change master操作,start slave
(4)将主机的信息添加到mha的配置文件中,以便mha manager检测到新的节点主机
(5)使用mha的测试命令进行测试,成功则启动mha程序即可
脚本实现
recover.sh id=`ifconfig eth0 | awk -F "[ :]+" 'NR==2 {print $4}'` MHA_manager=172.16.1.109 if [ $# -eq 0 ] then echo "usage: $0 宕机master—ip 新master-ip slave-ip" exit 0 fi if [ `netstat -lntp | grep 3306 | wc -l` -eq 0 ] then echo "请确定mysql是否能正常启动" exit 1 fi echo "relay_log 定时任务修改" if [ `crontab -l | grep purge_relay_logs | wc -l` -eq 1 ] then echo "定时任务无需修改" else echo '0 5 * * * /usr/bin/purge_relay_logs --user=root --password=123456 --disable_relay_log_purge >> /application/mysql/log/mysql-del-relay.log 2>&1' >> /var/spool/cron/root fi echo "把原master作为新master的备选" relay=`ssh [email protected]$2 "crontab -l | grep purge_relay_logs | wc -l"` if [ $relay -eq 1 ] then ssh [email protected]$2 "sed -i '/purge_relay_logs*/d' /var/spool/cron/root" else echo "$2上rerelay_log定时任务无需修改" fi mysqldump -h $3 -uroot -p123456 --master-data=2 --single-transaction --default-character-set=utf8mb4 -R --triggers -A > /tmp/new_master_data.sql >/dev/null 2>&1 mysql -uroot -p123456 </tmp/new_master_data.sql >/dev/null 2>&1 changmaster="CHANGE MASTER TO MASTER_HOST='"$2"',MASTER_USER='"mysql01"',MASTER_PASSWORD='"mysql01"',MASTER_AUTO_POSITION=1;" mysql -uroot -p123456 -e "`echo $changmaster`" mysql -uroot -p123456 -e "start slave;" >/dev/null 2>&1 echo "把原master作为新master的备选加入集群" ssh [email protected]$MHA_manager "sed -i '/^check_repl_delay*/d' /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "sed -i '/^secondary_check_script*/d' /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "sed -i '/^candidate_master*/d' /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "echo " " >> /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "echo "secondary_check_script=/usr/bin/masterha_secondary_check -s $1 --user=root --master_host=$2 --master_ip=$2 --master_port=3306" >> /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "echo " " >> /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "echo "[server$id]" >> /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "echo "candidate_master=1" >> /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "echo "hostname=$1" >> /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "echo "check_repl_delay=0" >> /etc/masterha/app1.cnf" ssh [email protected]$MHA_manager "echo "port=3306" >> /etc/masterha/app1.cnf"
执行脚本测试
[[email protected] ~]# /etc/init.d/mysql start [[email protected] ~]# sh /server/scripts/recover.sh 172.16.1.103 172.16.1.104 172.16.1.105 relay_log 定时任务修改 定时任务无需修改 把原master作为新master的备选 172.16.1.104上rerelay_log定时任务无需修改 mysql: [Warning] Using a password on the command line interface can be insecure. 把原master作为新master的备选加入集群
检查MHA Manager的状态
masterha_check_status --conf=/etc/masterha/app1.cnf app1 (pid:1098) is running(0:PING_OK), master:172.16.1.104 masterha_check_repl --conf=/etc/masterha/app1.cnf 172.16.1.104(172.16.1.104:3306) (current master) +--172.16.1.105(172.16.1.105:3306) +--172.16.1.103(172.16.1.103:3306) .............................. MySQL Replication Health is OK.
原文地址:http://blog.51cto.com/13712476/2130521