Rumah > pangkalan data > tutorial mysql > MHA masterha_check_repl 检测过程

MHA masterha_check_repl 检测过程

WBOY
Lepaskan: 2016-06-07 16:07:36
asal
1129 orang telah melayarinya

MHA部署及配置是否OK,我们可以借助于MHA自带的masterha_check_ssh以及masterha_check_repl脚本来检测。masterha_check_repl检测

MHA部署及配置是否OK,,我们可以借助于MHA自带的masterha_check_ssh以及masterha_check_repl脚本来检测。masterha_check_repl检测是保证MHA成功切换的重要一步。本文主要描述了masterha_check_repl这个检测脚本到底做了些什么事情。有助于更好的理解MHA的相关原理及过程等。

1、当前的主从环境
[root@vdbsrv1 ~]# more /etc/hosts
127.0.0.1    localhost.localdomain localhost
192.168.1.6  vdbsrv1  #master
192.168.1.7  vdbsrv2  #slave1
192.168.1.8  vdbsrv3  #slave2
192.168.1.12 vdbsrv4  #manager

###os环境
[root@vdbsrv4 ~]# more /etc/issue
CentOS release 5.9 (Final)
Kernel \r on an \m

###mysql环境
[root@vdbsrv4 ~]# mysql -e "show variables like 'version'"
+---------------+------------+
| Variable_name | Value      |
+---------------+------------+
| version      | 5.6.22-log |
+---------------+------------+

[root@vdbsrv4 ~]# masterha_manager --version
masterha_manager version 0.56.

 

2、当前的MHA配置信息
[root@vdbsrv4 ~]$ more /etc/masterha/app1.cnf
[server default]
manager_workdir=/var/log/masterha/app1
manager_log=/var/log/masterha/app1/manager.log

user=mha
password=xxx
ssh_user=root
repl_user=repl 
repl_password=repl 
ping_interval=1
shutdown_script=""
master_ip_online_change_script=""
report_script=""
master_ip_failover_script=/tmp/master_ip_failover
 
[server1]
hostname=vdbsrv1
master_binlog_dir=/data/mysqldata

[server2]
hostname=vdbsrv2
master_binlog_dir=/data/mysqldata

[server3]
hostname=vdbsrv3
master_binlog_dir=/data/mysqldata/
#candidate_master=1

 

3、masterha_check_repl检测步骤
a、读取配置文件
b、检测配置文件中列出的mysql服务器(识别主从)
c、检测从库配置信息
    read_only参数
    relay_log_purge参数
    复制过滤规则
d、ssh等效性验证
e、检测主库保存binlog脚本(save_binary_logs) ,主要是用于在master死掉后从binlog读取日志
f、检测各从库能否apply差量binlog(apply_diff_relay_logs)
g、检测IP切换,如果有部署脚本

 

4、实际检测过程
[root@vdbsrv4 ~]# masterha_check_repl --conf=/etc/masterha/app1.cnf
Fri Apr 17 18:48:41 2015 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Fri Apr 17 18:48:41 2015 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Fri Apr 17 18:48:41 2015 - [info] Reading server configuration from /etc/masterha/app1.cnf.. ###读取配置文件
Fri Apr 17 18:48:41 2015 - [info] MHA::MasterMonitor version 0.56.
Fri Apr 17 18:48:42 2015 - [info] GTID failover mode = 0
Fri Apr 17 18:48:42 2015 - [info] Dead Servers:  ###开始检测配置文件中列出的mysql服务器(识别主从)
Fri Apr 17 18:48:42 2015 - [info] Alive Servers:
Fri Apr 17 18:48:42 2015 - [info]  vdbsrv1(192.168.1.6:3306)
Fri Apr 17 18:48:42 2015 - [info]  vdbsrv2(192.168.1.7:3306)
Fri Apr 17 18:48:42 2015 - [info]  vdbsrv3(192.168.1.8:3306)
Fri Apr 17 18:48:42 2015 - [info] Alive Slaves:
Fri Apr 17 18:48:42 2015 - [info]  vdbsrv2(192.168.1.7:3306)  Version=5.6.22-log (oldest major version between slaves) log-bin:enabled
Fri Apr 17 18:48:42 2015 - [info]    Replicating from 192.168.1.6(192.168.1.6:3306)
Fri Apr 17 18:48:42 2015 - [info]  vdbsrv3(192.168.1.8:3306)  Version=5.6.22-log (oldest major version between slaves) log-bin:enabled
Fri Apr 17 18:48:42 2015 - [info]    Replicating from 192.168.1.6(192.168.1.6:3306)
Fri Apr 17 18:48:42 2015 - [info] Current Alive Master: vdbsrv1(192.168.1.6:3306)
Fri Apr 17 18:48:42 2015 - [info] Checking slave configurations..  ###检测从库配置信息
Fri Apr 17 18:48:42 2015 - [info]  read_only=1 is not set on slave vdbsrv2(192.168.1.7:3306).
Fri Apr 17 18:48:42 2015 - [warning]  relay_log_purge=0 is not set on slave vdbsrv2(192.168.1.7:3306).
Fri Apr 17 18:48:42 2015 - [info]  read_only=1 is not set on slave vdbsrv3(192.168.1.8:3306).
Fri Apr 17 18:48:42 2015 - [warning]  relay_log_purge=0 is not set on slave vdbsrv3(192.168.1.8:3306).
Fri Apr 17 18:48:42 2015 - [info] Checking replication filtering settings..    ###检测复制过滤规则
Fri Apr 17 18:48:42 2015 - [info]  binlog_do_db= , binlog_ignore_db=
Fri Apr 17 18:48:42 2015 - [info]  Replication filtering check ok.
Fri Apr 17 18:48:42 2015 - [info] GTID (with auto-pos) is not supported
Fri Apr 17 18:48:42 2015 - [info] Starting SSH connection tests..              ###ssh等效性验证
Fri Apr 17 18:48:43 2015 - [info] All SSH connection tests passed successfully.
Fri Apr 17 18:48:43 2015 - [info] Checking MHA Node version..
Fri Apr 17 18:48:44 2015 - [info]  Version check ok.
Fri Apr 17 18:48:44 2015 - [info] Checking SSH publickey authentication settings on the current master..
Fri Apr 17 18:48:44 2015 - [info] HealthCheck: SSH to vdbsrv1 is reachable.
Fri Apr 17 18:48:44 2015 - [info] Master MHA Node version is 0.56.
Fri Apr 17 18:48:44 2015 - [info] Checking recovery script configurations on vdbsrv1(192.168.1.6:3306)..###检测主库保存binlog脚本
Fri Apr 17 18:48:44 2015 - [info]  Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/data/mysqldata
    --output_file=/var/tmp/save_binary_logs_test --manager_version=0.56 --start_file=mysql-bin.000012
Fri Apr 17 18:48:44 2015 - [info]  Connecting to [email protected](vdbsrv1:22)..
  Creating /var/tmp if not exists..    ok.
  Checking output directory is accessible or not..
  ok.
  Binlog found at /data/mysqldata, up to mysql-bin.000012
Fri Apr 17 18:48:44 2015 - [info] Binlog setting check done.  ###以下部分检测各从库能否apply差量binlog
Fri Apr 17 18:48:44 2015 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Fri Apr 17 18:48:44 2015 - [info]  Executing command : apply_diff_relay_logs --command=test --slave_user='mha' --slave_host=vdbsrv2
 --slave_ip=192.168.1.7 --slave_port=3306 --workdir=/var/tmp --target_version=5.6.22-log --manager_version=0.56
 --relay_log_info=/data/mysqldata/relay-log.info  --relay_dir=/data/mysqldata/  --slave_pass=xxx
Fri Apr 17 18:48:44 2015 - [info]  Connecting to [email protected](vdbsrv2:22)..
  Checking slave recovery environment settings..
    Opening /data/mysqldata/relay-log.info ... ok.
    Relay log found at /data/mysqldata, up to vdbsrv2-relay-bin.000006
    Temporary relay log file is /data/mysqldata/vdbsrv2-relay-bin.000006
    Testing mysql connection and privileges.. done.  #Author : Leshami
    Testing mysqlbinlog output.. done.              #Blog  :
    Cleaning up test file(s).. done.
Fri Apr 17 18:48:44 2015 - [info]  Executing command : apply_diff_relay_logs --command=test --slave_user='mha' --slave_host=vdbsrv3
 --slave_ip=192.168.1.8 --slave_port=3306 --workdir=/var/tmp --target_version=5.6.22-log --manager_version=0.56
 --relay_log_info=/data/mysqldata/relay-log.info  --relay_dir=/data/mysqldata/  --slave_pass=xxx
Fri Apr 17 18:48:44 2015 - [info]  Connecting to [email protected](vdbsrv3:22)..
  Checking slave recovery environment settings..
    Opening /data/mysqldata/relay-log.info ... ok.
    Relay log found at /data/mysqldata, up to vdbsrv3-relay-bin.000006
    Temporary relay log file is /data/mysqldata/vdbsrv3-relay-bin.000006
    Testing mysql connection and privileges.. done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Fri Apr 17 18:48:45 2015 - [info] Slaves settings check done.
Fri Apr 17 18:48:45 2015 - [info]
vdbsrv1(192.168.1.6:3306) (current master)
 +--vdbsrv2(192.168.1.7:3306)
 +--vdbsrv3(192.168.1.8:3306)

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan