测试环境如下:
db1(192.168.49.41) master/ONLINE. Roles: reader(192.168.49.152)
db2(192.168.49.43) master/ONLINE. Roles: reader(192.168.49.153), writer(192.168.49.150)
db3(192.168.49.39) slave/ONLINE. Roles: reader(192.168.49.151)
测试过程:
在db2的test 数据库中建立一个表t
mysql> create table t(id int,uptime datetime);
Query OK, 0 rows affected (0.01 sec)
并插入一条记录
mysql> insert into t values(1,now());
Query OK, 1 row affected (0.00 sec)
mysql> select * from t;
+------+---------------------+
| id | uptime |
+------+---------------------+
| 1 | 2013-11-20 16:54:04 |
+------+---------------------+
1 row in set (0.00 sec)
可以检查在db1和db3上这条记录已经存在,说明这时同步没有问题,接下来进行下面的操作
1.在db3上关闭slave io_thread 进程,以模拟同步延迟的情况
mysql> stop slave io_thread;
Query OK, 0 rows affected (0.00 sec)
2.在db2上再插入一条记录
mysql> insert into t values(2,now());
Query OK, 1 row affected (0.00 sec)
3.在db2上半闭mysql 进程,以模拟数据库服务器突然宕机的情况
4.启动db3上的slave io_thread进程
start slave io_thread;
5.在db3上查看slave status关态
mysql> show slave status \G
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 2073213
Current database: test
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.49.43
Master_User: dba_repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000046
Read_Master_Log_Pos: 1051
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 253
Relay_Master_Log_File: mysql-bin.000046
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
可见这时db3的master已经自动切换到了db2,但是查看test.t表可发现,并没有id为2的记录。但是db2中存在id为2的记录。
结论:
MySQL MMM 高可用配置在大负载切同步存在延迟的情况下如果原master突然无法访问是可能出现数据丢失的情况的
--转自