(2) 设置 switchType="2" 与slaveThreshold="100"
“Mycat心跳检查语句配置为 show slave status ,dataHost 上定义两个新属性: switchType="2" 与slaveThreshold="100",此时意味着开启MySQL主从复制状态绑定的读写分离与切换机制。Mycat心跳机制通过检测 show slave status 中的 "Seconds_Behind_Master", "Slave_IO_Running", "Slave_SQL_Running" 三个字段来确定当前主从同步的状态以及Seconds_Behind_Master主从复制时延。“
190 主数据库 写入
mysql> use itstyle;
mysql> select * from person;
+-----+------+
| age | NAME |
+-----+------+
| 1 | zhangsan |
+-----+------+
1 row in set (0.00 sec)
显示用户姓名为zhangsan
190 从数据库 读取
mysql> use itstyle;
mysql> select * from person;
+-----+------+
| age | NAME |
+-----+------+
| 1 |lisi |
+-----+------+
1 row in set (0.00 sec)
190 主数据库 写入
mysql> use itstyle;
mysql> select * from person;
+-----+------+
| age | NAME |
+-----+------+
| 1 | zhangsan |
+-----+------+
1 row in set (0.00 sec)
显示用户姓名为zhangsan
190 从数据库 读取
mysql> use itstyle;
mysql> select * from person;
+-----+------+
| age | NAME |
+-----+------+
| 1 |lisi |
+-----+------+
1 row in set (0.00 sec)