1、配置三台服务器ssh互信
ssh-keygen -t rsa 一路回车即可
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
c7:2e:ca:e2:c2:3b:30:63:97:b4:62:81:dd:27:e3:f9 root@centos02
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
|.. . |
|....+ . . |
| o.o= S o |
|++ +o o |
|o=o . . . |
| + ..E. . |
| .=..o |
+-----------------+
[iyunv@ansible mysql]#ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.16.80.117
[iyunv@ansible mysql]#ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.16.80.128
[iyunv@ansible mysql]# ssh-copy-id -i /root/.ssh/id_rsa.pub 172.16.80.127
The authenticity of host '172.16.80.127 (172.16.80.127)' can't be established.
RSA key fingerprint is 05:89:5e:3d:2a:c1:ae:90:27:d9:a5:48:4a:ab:b9:79.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.80.127' (RSA) to the list of known hosts. root@172.16.80.127's password:
Now try logging into the machine, with "ssh '172.16.80.127'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
1、通过masterha_check_ssh验证ssh信任登录是否成功,
[iyunv@ansible scripts]# masterha_check_ssh --conf=/etc/mha/app1.cnf
Thu Aug 11 19:29:03 2016 - [info] Reading default configuration from /etc/masterha_default.cnf..
Thu Aug 11 19:29:03 2016 - [info] Reading application default configuration from /etc/mha/app1.cnf..
Thu Aug 11 19:29:03 2016 - [info] Reading server configuration from /etc/mha/app1.cnf..
Thu Aug 11 19:29:03 2016 - [info] Starting SSH connection tests..
Thu Aug 11 19:29:04 2016 - [debug]
Thu Aug 11 19:29:03 2016 - [debug] Connecting via SSH from root@172.16.80.117(172.16.80.117:22) to root@172.16.80.127(172.16.80.127:22)..
Thu Aug 11 19:29:03 2016 - [debug] ok.
Thu Aug 11 19:29:03 2016 - [debug] Connecting via SSH from root@172.16.80.117(172.16.80.117:22) to root@172.16.80.128(172.16.80.128:22)..
Thu Aug 11 19:29:04 2016 - [debug] ok.
Thu Aug 11 19:29:04 2016 - [debug]
Thu Aug 11 19:29:03 2016 - [debug] Connecting via SSH from root@172.16.80.127(172.16.80.127:22) to root@172.16.80.117(172.16.80.117:22)..
Thu Aug 11 19:29:04 2016 - [debug] ok.
Thu Aug 11 19:29:04 2016 - [debug] Connecting via SSH from root@172.16.80.127(172.16.80.127:22) to root@172.16.80.128(172.16.80.128:22)..
Thu Aug 11 19:29:04 2016 - [debug] ok.
Thu Aug 11 19:29:04 2016 - [debug]
Thu Aug 11 19:29:04 2016 - [debug] Connecting via SSH from root@172.16.80.128(172.16.80.128:22) to root@172.16.80.117(172.16.80.117:22)..
Thu Aug 11 19:29:04 2016 - [debug] ok.
Thu Aug 11 19:29:04 2016 - [debug] Connecting via SSH from root@172.16.80.128(172.16.80.128:22) to root@172.16.80.127(172.16.80.127:22)..
Thu Aug 11 19:29:04 2016 - [debug] ok.
Thu Aug 11 19:29:04 2016 - [info] All SSH connection tests passed successfully.
2、masterha_check_repl验证mysql复制是否成功
masterha_check_repl --conf=/etc/mha/app1.cnf
[iyunv@ansible scripts]# masterha_check_repl --conf=/etc/mha/app1.cnf
Thu Aug 11 19:31:53 2016 - [info] Reading default configuration from /etc/masterha_default.cnf..
Thu Aug 11 19:31:53 2016 - [info] Reading application default configuration from /etc/mha/app1.cnf..
Thu Aug 11 19:31:53 2016 - [info] Reading server configuration from /etc/mha/app1.cnf..
Thu Aug 11 19:31:53 2016 - [info] MHA::MasterMonitor version 0.56.
Thu Aug 11 19:31:54 2016 - [info] GTID failover mode = 0
Thu Aug 11 19:31:54 2016 - [info] Dead Servers:
Thu Aug 11 19:31:54 2016 - [info] Alive Servers:
Thu Aug 11 19:31:54 2016 - [info] 172.16.80.117(172.16.80.117:3306)
Thu Aug 11 19:31:54 2016 - [info] 172.16.80.127(172.16.80.127:3306)
Thu Aug 11 19:31:54 2016 - [info] 172.16.80.128(172.16.80.128:3306)
Thu Aug 11 19:31:54 2016 - [info] Alive Slaves:
Thu Aug 11 19:31:54 2016 - [info] 172.16.80.127(172.16.80.127:3306) Version=5.5.49-log (oldest major version between slaves) log-bin:enabled
Thu Aug 11 19:31:54 2016 - [info] Replicating from 172.16.80.117(172.16.80.117:3306)
Thu Aug 11 19:31:54 2016 - [info] Primary candidate for the new Master (candidate_master is set)
Thu Aug 11 19:31:54 2016 - [info] 172.16.80.128(172.16.80.128:3306) Version=5.5.49-log (oldest major version between slaves) log-bin:enabled
Thu Aug 11 19:31:54 2016 - [info] Replicating from 172.16.80.117(172.16.80.117:3306)
Thu Aug 11 19:31:54 2016 - [info] Not candidate for the new Master (no_master is set)
Thu Aug 11 19:31:54 2016 - [info] Current Alive Master: 172.16.80.117(172.16.80.117:3306)
Thu Aug 11 19:31:54 2016 - [info] Checking slave configurations..
Thu Aug 11 19:31:54 2016 - [warning] relay_log_purge=0 is not set on slave 172.16.80.127(172.16.80.127:3306).
Thu Aug 11 19:31:54 2016 - [warning] relay_log_purge=0 is not set on slave 172.16.80.128(172.16.80.128:3306).
Thu Aug 11 19:31:54 2016 - [info] Checking replication filtering settings..
Thu Aug 11 19:31:54 2016 - [info] binlog_do_db= , binlog_ignore_db=
Thu Aug 11 19:31:54 2016 - [info] Replication filtering check ok.
Thu Aug 11 19:31:54 2016 - [info] GTID (with auto-pos) is not supported
Thu Aug 11 19:31:54 2016 - [info] Starting SSH connection tests..
Thu Aug 11 19:31:56 2016 - [info] All SSH connection tests passed successfully.
Thu Aug 11 19:31:56 2016 - [info] Checking MHA Node version..
Thu Aug 11 19:31:56 2016 - [info] Version check ok.
Thu Aug 11 19:31:56 2016 - [info] Checking SSH publickey authentication settings on the current master..
Thu Aug 11 19:31:57 2016 - [info] HealthCheck: SSH to 172.16.80.117 is reachable.
Thu Aug 11 19:31:57 2016 - [info] Master MHA Node version is 0.56.
Thu Aug 11 19:31:57 2016 - [info] Checking recovery script configurations on 172.16.80.117(172.16.80.117:3306)..
Thu Aug 11 19:31:57 2016 - [info] Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/application/mysql/data --output_file=/var/tmp/save_binary_logs_test --manager_version=0.56 --start_file=mysql-bin.000001
Thu Aug 11 19:31:57 2016 - [info] Connecting to root@172.16.80.117(172.16.80.117:22)..
Creating /var/tmp if not exists.. ok.
Checking output directory is accessible or not..
ok.
Binlog found at /application/mysql/data, up to mysql-bin.000001
Thu Aug 11 19:31:57 2016 - [info] Binlog setting check done.
Thu Aug 11 19:31:57 2016 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Thu Aug 11 19:31:57 2016 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='root' --slave_host=172.16.80.127 --slave_ip=172.16.80.127 --slave_port=3306 --workdir=/var/tmp --target_version=5.5.49-log --manager_version=0.56 --relay_log_info=/application/mysql/data/relay-log.info --relay_dir=/application/mysql/data/ --slave_pass=xxx
Thu Aug 11 19:31:57 2016 - [info] Connecting to root@172.16.80.127(172.16.80.127:22)..
Checking slave recovery environment settings..
Opening /application/mysql/data/relay-log.info ... ok.
Relay log found at /application/mysql/data, up to mysql-relay-bin.000002
Temporary relay log file is /application/mysql/data/mysql-relay-bin.000002
Testing mysql connection and privileges.. done.
Testing mysqlbinlog output.. done.
Cleaning up test file(s).. done.
Thu Aug 11 19:31:58 2016 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='root' --slave_host=172.16.80.128 --slave_ip=172.16.80.128 --slave_port=3306 --workdir=/var/tmp --target_version=5.5.49-log --manager_version=0.56 --relay_log_info=/application/mysql/data/relay-log.info --relay_dir=/application/mysql/data/ --slave_pass=xxx
Thu Aug 11 19:31:58 2016 - [info] Connecting to root@172.16.80.128(172.16.80.128:22)..
Checking slave recovery environment settings..
Opening /application/mysql/data/relay-log.info ... ok.
Relay log found at /application/mysql/data, up to mysql-relay-bin.000002
Temporary relay log file is /application/mysql/data/mysql-relay-bin.000002
Testing mysql connection and privileges.. done.
Testing mysqlbinlog output.. done.
Cleaning up test file(s).. done.
Thu Aug 11 19:31:58 2016 - [info] Slaves settings check done.
Thu Aug 11 19:31:58 2016 - [info]
172.16.80.117(172.16.80.117:3306) (current master)
+--172.16.80.127(172.16.80.127:3306)
+--172.16.80.128(172.16.80.128:3306)
Thu Aug 11 19:31:58 2016 - [info] Checking replication health on 172.16.80.127..
Thu Aug 11 19:31:58 2016 - [info] ok.
Thu Aug 11 19:31:58 2016 - [info] Checking replication health on 172.16.80.128..
Thu Aug 11 19:31:58 2016 - [info] ok.
Thu Aug 11 19:31:58 2016 - [info] Checking master_ip_failover_script status:
Thu Aug 11 19:31:58 2016 - [info] /etc/mha/scripts/master_ip_failover --command=status --ssh_user=root --orig_master_host=172.16.80.117 --orig_master_ip=172.16.80.117 --orig_master_port=3306
IN SCRIPT TEST====/sbin/ifconfig eth0:1 down==/sbin/ifconfig eth0:1 172.16.80.200/24===
Checking the Status of the script.. OK
Thu Aug 11 19:31:58 2016 - [info] OK.
Thu Aug 11 19:31:58 2016 - [warning] shutdown_script is not defined.
Thu Aug 11 19:31:58 2016 - [info] Got exit code 0 (Not master dead).