[摘要]status --orig_master_host=host --orig_master_ip=ip --orig_master_port=port --new_master_host=host -...
status --orig_master_host=host --orig_master_ip=ip --
orig_master_port=port --new_master_host=host --new_master_ip=ip --new_master_port=port\n";
}
chmod 777 /etc/masterha/app1/
配置文件测试:
# masterha_check_ssh --conf=/etc/masterha/app1.cnf
Thu May 26 23:25:35 2016 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Thu May 26 23:25:35 2016 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Thu May 26 23:25:35 2016 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Thu May 26 23:25:35 2016 - [info] Starting SSH connection tests..
Thu May 26 23:25:35 2016 - [debug]
Thu May 26 23:25:35 2016 - [debug] Connecting via SSH from root@192.168.1.21(192.168.1.21:22) to root@192.168.1.22(192.168.1.22:22)..
Thu May 26 23:25:35 2016 - [debug] ok.
Thu May 26 23:25:35 2016 - [debug] Connecting via SSH from root@192.168.1.21(192.168.1.21:22) to root@192.168.1.23(192.168.1.23:22)..
Thu May 26 23:25:35 2016 - [debug] ok.
Thu May 26 23:25:36 2016 - [debug]
Thu May 26 23:25:35 2016 - [debug] Connecting via SSH from root@192.168.1.22(192.168.1.22:22) to root@192.168.1.21(192.168.1.21:22)..
Thu May 26 23:25:35 2016 - [debug] ok.
Thu May 26 23:25:35 2016 - [debug] Connecting via SSH from root@192.168.1.22(192.168.1.22:22) to root@192.168.1.23(192.168.1.23:22)..
Thu May 26 23:25:36 2016 - [debug] ok.
Thu May 26 23:25:36 2016 - [debug]
Thu May 26 23:25:36 2016 - [debug] Connecting via SSH from root@192.168.1.23(192.168.1.23:22) to root@192.168.1.21(192.168.1.21:22)..
Thu May 26 23:25:36 2016 - [debug] ok.
Thu May 26 23:25:36 2016 - [debug] Connecting via SSH from root@192.168.1.23(192.168.1.23:22) to root@192.168.1.22(192.168.1.22:22)..
Thu May 26 23:25:36 2016 - [debug] ok.
Thu May 26 23:25:36 2016 - [info] All SSH connection tests passed successfully.
#masterha_check_repl --conf=/etc/masterha/app1.cnf
Thu May 26 22:52:30 2016 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Thu May 26 22:52:30 2016 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Thu May 26 22:52:30 2016 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Thu May 26 22:52:30 2016 - [info] MHA::MasterMonitor version 0.56.
Thu May 26 22:52:31 2016 - [info] GTID failover mode = 1
Thu May 26 22:52:31 2016 - [info] Dead Servers:
Thu May 26 22:52:31 2016 - [info] Alive Servers:
Thu May 26 22:52:31 2016 - [info] 192.168.1.21(192.168.1.21:3306)
Thu May 26 22:52:31 2016 - [info] 192.168.1.22(192.168.1.22:3306)
Thu May 26 22:52:31 2016 - [info] 192.168.1.23(192.168.1.23:3306)
Thu May 26 22:52:31 2016 - [info] Alive Slaves:
Thu May 26 22:52:31 2016 - [info] 192.168.1.22(192.168.1.22:3306) Version=5.6.28-log (oldest major version between slaves) log-bin:enabled
Thu May 26 22:52:31 2016 - [info] GTID ON
Thu May 26 22:52:31 2016 - [info] Replicating from 192.168.1.21(192.168.1.21:3306)
Thu May 26 22:52:31 2016 - [info] Primary candidate for the new Master (candidate_master is set)
Thu May 26 22:52:31 2016 - [info] 192.168.1.23(192.168.1.23:3306) Version=5.6.28-log (oldest major version between slaves) log-bin:enabled
Thu May 26 22:52:31 2016 - [info] GTID ON
Thu May 26 22:52:31 2016 - [info] Replicating from 192.168.1.21(192.168.1.21:3306)
Thu May 26 22:52:31 2016 - [info] Not candidate for the new Master (no_master is set)
Thu May 26 22:52:31 2016 - [info] Current Alive Master: 192.168.1.21(192.168.1.21:3306)
Thu May 26 22:52:31 2016 - [info] Checking slave configurations..
Thu May 26 22:52:31 2016 - [info] read_only=1 is not set on slave 192.168.1.22(192.168.1.22:3306).
Thu May 26 22:52:31 2016 - [info] read_only=1 is not set on slave 192.168.1.23(192.168.1.23:3306).
Thu May 26 22:52:31 2016 - [info] Checking replication filtering settings..
Thu May 26 22:52:31 2016 - [info] binlog_do_db= , binlog_ignore_db=
Thu May 26 22:52:31 2016 - [info] Replication filtering check ok.
Thu May 26 22:52:31 2016 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking.
Thu May 26 22:52:31 2016 - [info] HealthCheck: SSH to 192.168.1.23 is reachable.
Thu May 26 22:52:31 2016 - [info] Binlog server 192.168.1.23 is reachable.
Thu May 26 22:52:31 2016 - [info] Checking recovery script configurations on 192.168.1.23(192.168.1.23:3306)..
Thu May 26 22:52:31 2016 - [info] Executing command: save_binary_logs --command=test --start_pos=4
--binlog_dir=/mysql/backup/binlog --output_file=/etc/masterha/app1/save_binary_logs_test --manager_version=0.56 --start_file=mysql-bin.000004
Thu May 26 22:52:31 2016 - [info] Connecting to root@192.168.1.23(192.168.1.23:22)..
Creating /etc/masterha/app1 if not exists.. ok.
Checking output directory is accessible or not..
ok.
Binlog found at /mysql/backup/binlog, up to mysql-bin.000004
Thu May 26 22:52:31 2016 - [info] Binlog setting check done.
Thu May 26 22:52:31 2016 - [info] Checking SSH publickey authentication settings on the current master..
Thu May 26 22:52:31 2016 - [info] HealthCheck: SSH to 192.168.1.21 is reachable.
Thu May 26 22:52:31 2016 - [info]
192.168.1.21(192.168.1.21:3306) (current master)
+--192.168.1.22(192.168.1.22:3306)
+--192.168.1.23(192.168.1.23:3306)
Thu May 26 22:52:31 2016 - [info] Checking replication health on 192.168.1.22..
Thu May 26 22:52:31 2016 - [info] ok.
Thu May 26 22:52:31 2016 - [info] Checking replication health on 192.168.1.23..
Thu May 26 22:52:31 2016 - [info] ok.
Thu May 26 22:52:31 2016 - [info] Checking master_ip_failover_script status:
Thu May 26 22:52:31 2016 - [info] /etc/masterha/app1/master_ip_failover --command=status --ssh_user=root
--orig_master_host=192.168.1.21 --orig_master_ip=192.168.1.21 --orig_master_port=3306
IN script TEST====/sbin/ifconfig eth1:1 down==/sbin/ifconfig eth1:1 192.168.1.20;/sbin/arping -I eth1 -c 3 -s 192.168.1.20 192.168.1.1 >/dev/null 2>&1===
Checking the Status of the script.. OK
Thu May 26 22:52:34 2016 - [info] OK.
Thu May 26 22:52:34 2016 - [warning] shutdown_script is not defined.
Thu May 26 22:52:34 2016 - [info] Got exit code 0 (Not master dead).
MySQL Replication Health is OK.
MHA启动及关闭
nohup masterha_manager --conf=/etc/masterha/app1.cnf > /etc/masterha/app1/manager.log < /dev/null 2>&1 &
检查是否启动:
masterha_check_status --conf=/etc/masterha/app1.cnf
app1 (pid:11447) is running(0:PING_OK), master:192.168.1.21
停止Mha:
masterha_stop --conf=/etc/masterha/app1.cnf
Stopped app1 successfully.
[3]+ Exit 1 nohup masterha_manager --conf=/etc/masterha/app1.cnf > /etc/masterha/app1/manager.log < /dev/null 2>&1
测试:
说明,每次测试完成后,需要清理/etc/masterha/app1下的日志,然后启动Mha manager.
1:关闭mysql1上的mysql,查看从库从那里同步,以及mha日志输出
2:恢复mysql1为mysql2的slave,change master语句可以在/etc/masterha/app1/manager.log里找到。
在配置GTID复制时候遇到 1032错误,用以下方法解决
mysql> show global variables like '%gtid%';
+---------------------------------+------------------------------------------------------------------------------------+
关键词:Mysql GTID Mha设置办法的示例代码分享