[mha@n-op-209 etc]$ masterha_check_repl
Fri Mar 25 12:13:19 2016 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Fri Mar 25 12:13:19 2016 - [info] Reading application default configuration from /usr/local/mha-manager/etc/test.conf..
Fri Mar 25 12:13:19 2016 - [info] Reading server configuration from /usr/local/mha-manager/etc/test.conf..
Fri Mar 25 12:13:19 2016 - [info] MHA::MasterMonitor version 0.56.
MHA Monitor的版本信息
Fri Mar 25 12:13:20 2016 - [info] GTID failover mode = 0
MySQL的GTID设置,我们是关闭的
Fri Mar 25 12:13:20 2016 - [info] Dead Servers:
挂掉的主机列表(ok,这里没有)
Fri Mar 25 12:13:20 2016 - [info] Alive Servers:
Fri Mar 25 12:13:20 2016 - [info] 10.20.64.202(10.20.64.202:3306)
Fri Mar 25 12:13:20 2016 - [info] 10.20.64.203(10.20.64.203:3306)
Fri Mar 25 12:13:20 2016 - [info] 10.20.64.204(10.20.64.204:3306)
Fri Mar 25 12:13:20 2016 - [info] 10.20.64.210(10.20.64.210:3306)
存活的主机列表,是的没错,我们的4个节点都是活着的
Fri Mar 25 12:13:20 2016 - [info] Alive Slaves:
以下为从节点的详细信息
Fri Mar 25 12:13:20 2016 - [info] 10.20.64.203(10.20.64.203:3306) Version=5.6.27-76.0-log (oldest major version between slaves) log-bin:enabled
检测binlog是否开启
Fri Mar 25 12:13:20 2016 - [info] Replicating from 10.20.64.202(10.20.64.202:3306)
检测自己是哪个节点的从库
Fri Mar 25 12:13:20 2016 - [info] Primary candidate for the new Master (candidate_master is set)
第一个新主候选者身份
Fri Mar 25 12:13:20 2016 - [info] 10.20.64.204(10.20.64.204:3306) Version=5.6.27-76.0-log (oldest major version between slaves) log-bin:enabled
Fri Mar 25 12:13:20 2016 - [info] Replicating from 10.20.64.202(10.20.64.202:3306)
Fri Mar 25 12:13:20 2016 - [info] Primary candidate for the new Master (candidate_master is set)
第二个新主候选者身份
(与第一个同级别竞选新主,与检测顺序无关)
Fri Mar 25 12:13:20 2016 - [info] 10.20.64.210(10.20.64.210:3306) Version=5.6.27-76.0-log (oldest major version between slaves) log-bin:enabled
Fri Mar 25 12:13:20 2016 - [info] Replicating from 10.20.64.202(10.20.64.202:3306)
Fri Mar 25 12:13:20 2016 - [info] Not candidate for the new Master (no_master is set)
非候选者身份,永远不会成为新主库
Fri Mar 25 12:13:20 2016 - [info] Current Alive Master: 10.20.64.202(10.20.64.202:3306)
识别当前主库
Fri Mar 25 12:13:20 2016 - [info] Checking slave configurations..
连接从库实例,检测从库配置
Fri Mar 25 12:13:20 2016 - [info] read_only=1 is not set on slave 10.20.64.203(10.20.64.203:3306).
这里会检测read_only参数,如果从库没有用这个参数控制外部写入,mha会打印一个info出来
(如果read_only=1,mha不会打印任何关于read only的信息)
Fri Mar 25 12:13:20 2016 - [warning] relay_log_purge=0 is not set on slave 10.20.64.203(10.20.64.203:3306).
这里还会检测relay_log_purge参数,如果从库不自动删除relay log,mha会打印一个warning
(如果relay_log_purge=0,mha不会打印任何关于relay log purge的信息)
Fri Mar 25 12:13:20 2016 - [info] read_only=1 is not set on slave 10.20.64.204(10.20.64.204:3306).
Fri Mar 25 12:13:20 2016 - [warning] relay_log_purge=0 is not set on slave 10.20.64.204(10.20.64.204:3306).
Fri Mar 25 12:13:20 2016 - [info] read_only=1 is not set on slave 10.20.64.210(10.20.64.210:3306).
Fri Mar 25 12:13:20 2016 - [warning] relay_log_purge=0 is not set on slave 10.20.64.210(10.20.64.210:3306).
(总结:如果所有从库read_only=1 and relay_log_purge=0,这块不会打印任何内容)
Fri Mar 25 12:13:20 2016 - [info] Checking replication filtering settings..
连接从库实例,检测从库同步过滤配置
Fri Mar 25 12:13:20 2016 - [info] binlog_do_db= , binlog_ignore_db=
Fri Mar 25 12:13:20 2016 - [info] Replication filtering check ok.
Fri Mar 25 12:13:20 2016 - [info] GTID (with auto-pos) is not supported
检测GTID,我们的实例没有使用GTID同步,所以这里显示不支持
Fri Mar 25 12:13:20 2016 - [info] Starting SSH connection tests..
Fri Mar 25 12:13:23 2016 - [info] All SSH connection tests passed successfully.
这里开始了排列组合式的ssh检测,这里只显示成功与否
(你也可以使用
Fri Mar 25 12:13:23 2016 - [info] Checking MHA Node version..
Fri Mar 25 12:13:24 2016 - [info] Version check ok.
检测MHA的节点版本
Fri Mar 25 12:13:24 2016 - [info] Checking SSH publickey authentication settings on the current master..
Fri Mar 25 12:13:24 2016 - [info] HealthCheck: SSH to 10.20.64.202 is reachable.
检测主库SSH通信
Fri Mar 25 12:13:24 2016 - [info] Master MHA Node version is 0.56.
显示主库MHA节点版本(这个打印顺序也是醉了)
Fri Mar 25 12:13:24 2016 - [info] Checking recovery script configurations on 10.20.64.202(10.20.64.202:3306)..
检测主库恢复脚本执行是否正常
Fri Mar 25 12:13:24 2016 - [info] Executing command: save_binary_logs
使用节点脚本save_binary_logs,观察其工作是否正常,下面是脚本输出
Fri Mar 25 12:13:24 2016 - [info] Connecting to mha@10.20.64.202(10.20.64.202:22)..
Creating /usr/local/mha-node/apps/test if not exists.. ok.
检测应用项目目录是否存在,如果不存在MHA会自动创建
Checking output directory is accessible or not..
ok.
检测binlog输出存放目录访问情况
Binlog found at /data/mysqldata/3306/binlog, up to mysql-bin.000001
找到指定的binlog
Fri Mar 25 12:13:24 2016 - [info] Binlog setting check done.
到此binlog配置检测完成
Fri Mar 25 12:13:24 2016 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
检测从库SSH通信,并且检测所有从库恢复脚本配置情况,下面的命令将逐个检测
Fri Mar 25 12:13:24 2016 - [info] Executing command : apply_diff_relay_logs
使用节点脚本apply_diff_relay_logs,观察其工作是否正常,下面是脚本输出
Fri Mar 25 12:13:24 2016 - [info] Connecting to mha@10.20.64.203(10.20.64.203:22)..
Checking slave recovery environment settings..
Relay log found at /data/mysqldata/3306/binlog, up to relay-bin.000003
找到指定的relay log
Temporary relay log file is /data/mysqldata/3306/binlog/relay-bin.000003
目前临时的relay log文件名
Testing mysql connection and privileges..Warning: Using a password on the command line interface can be insecure.
done.
测试连接和访问权限,警告:在命令行输入密码是不安全的
Testing mysqlbinlog output.. done.
使用mysqlbinlog命令测试relay log内容输出是否正常
Cleaning up test file(s).. done.
清理测试临时文件
(到此node1检测完毕)
以此类推
Fri Mar 25 12:13:25 2016 - [info] Executing command : apply_diff_relay_logs
Fri Mar 25 12:13:25 2016 - [info] Connecting to mha@10.20.64.204(10.20.64.204:22)..
Checking slave recovery environment settings..
Relay log found at /data/mysqldata/3306/binlog, up to relay-bin.000002
Temporary relay log file is /data/mysqldata/3306/binlog/relay-bin.000002
Testing mysql connection and privileges..Warning: Using a password on the command line interface can be insecure.
done.
Testing mysqlbinlog output.. done.
Cleaning up test file(s).. done.
(到此node2检测完毕)
Fri Mar 25 12:13:25 2016 - [info] Executing command : apply_diff_relay_logs
Fri Mar 25 12:13:25 2016 - [info] Connecting to mha@10.20.64.210(10.20.64.210:22)..
Creating directory /usr/local/mha-node/apps/test.. done.
Checking slave recovery environment settings..
Relay log found at /data/mysqldata/3306/binlog, up to relay-bin.000002
Temporary relay log file is /data/mysqldata/3306/binlog/relay-bin.000002
Testing mysql connection and privileges..Warning: Using a password on the command line interface can be insecure.
done.
Testing mysqlbinlog output.. done.
Cleaning up test file(s).. done.
(到此node3检测完毕)
Fri Mar 25 12:13:25 2016 - [info] Slaves settings check done.
到此从库binlog、relay log配置检测完毕
Fri Mar 25 12:13:25 2016 - [info]
10.20.64.202(10.20.64.202:3306) (current master) (test master)
+
+
+
根据配置文件,以树形显示1个主库,2个候选人从库,1个非候选人从库
下面是从库同步检测
Fri Mar 25 12:13:25 2016 - [info] Checking replication health on 10.20.64.203..
Fri Mar 25 12:13:25 2016 - [info] ok.
(node1同步正常)
Fri Mar 25 12:13:25 2016 - [info] Checking replication health on 10.20.64.204..
Fri Mar 25 12:13:25 2016 - [info] ok.
(node2同步正常)
Fri Mar 25 12:13:25 2016 - [info] Checking replication health on 10.20.64.210..
Fri Mar 25 12:13:25 2016 - [info] ok.
(node3同步正常)
Fri Mar 25 12:13:25 2016 - [warning] master_ip_failover_script is not defined.
警告:未定义master_ip_failover_script脚本
(因为我们的配置中注意注释了这行,将来使用自定义的脚本替换原生脚本)
Fri Mar 25 12:13:25 2016 - [warning] shutdown_script is not defined.
警告:未定义shutdown_script脚本
(因为我们的配置中注意注释了这行,将来使用自定义的脚本替换原生脚本)
Fri Mar 25 12:13:25 2016 - [info] Got exit code 0 (Not master dead).
本脚本赶回0值(主库没挂)
(PS:原生脚本打印很简单易懂,0值表示无错误返回)
MySQL Replication Health is OK.
同步很健康
至此检测完毕