mm appl]# /usr/bin/masterha_check_status --conf=/etc/appl.cnf
appl is stopped(2:NOT_RUNNING).
注意:
a、切换之后需要删除手工删除/masterha/app1/app1.failover.complete,才能进行第二次测试
b、一旦发生切换管理进程将会退出,无法进行再次测试,需将故障数据库加入到MHA环境中来
c、原主节点重新加入到MHA时只能设置为slave
手工删除appl.failover.complete,启动MHA
[root@mmm appl]# rm -f appl.failover.complete
重新启动MHA
[root@mmm appl]# nohup /usr/bin/masterha_manager --conf=/etc/appl.cnf &
[1] 9659
[root@mmm appl]# nohup: appending output to `nohup.out'
查看MHA状态
[root@mmm appl]# /usr/bin/masterha_check_status --conf=/etc/appl.cnf
appl (pid:9659) is running(0:PING_OK), master:192.168.3.28
6.主节点启动mysql服务,keepalived服务,同时配置成新master(原backupMySQL)的从库
[root@node1 ~]# service mysql start
Starting MySQL. [ OK ]
[root@node1 ~]# service keepalived start
Starting keepalived: [ OK ]
[root@node1 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 5.5.17-log MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
通过查询只读库节点错误日志文件可以得到刚切换到新master的日志文件及位置
140729 17:03:29 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='192.168.3.27', master_port='3306', master_log_file=''
, master_log_pos='4'. New state master_host='192.168.3.28', master_port='3306', master_log_file='mysql-bin.000011', master_log_pos='107'.
mysql> change master to
-> master_host='192.168.3.28',
-> master_user='repl',
-> master_password='repl_pwd',
-> master_log_file='mysql-bin.000011',
-> master_log_pos=107;
Query OK, 0 rows affected (0.01 sec)
mysql> slave start;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.3.28
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000011
Read_Master_Log_Pos: 216
Relay_Log_File: pid-relay-bin.000002
Relay_Log_Pos: 362
Relay_Master_Log_File: mysql-bin.000011
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 216
Relay_Log_Space: 516
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 28
1 row in set (0.00 sec)
7.停止新mastermysql(原backupMySQL)mysql服务
[root@node2 keepalived]# service mysql stop
Shutting down MySQL... [ OK ]
[root@node2 keepalived]# service keepalived status
keepalived dead but subsys locked
可见mysql服务停止后,keepalived服务也停止了
--查询MasterMySQL
登陆mysql,test库下的student表不存在,数据同步成功。
mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| deadlocks |
| test1 |
+----------------+
2 rows in set (0.00 sec)
mysq