CHANGE MASTER TO命令用于slave配置连接master的信息,例如master host、master port等。
关于CHANGE MASTER TO命令,总结几点使用心得。
测试版本:5.7.21
两种情况的测试:
首先设置slave_net_timeout为50:
mysql> set global slave_net_timeout=50;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'slave_net_timeout';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| slave_net_timeout | 50 |
+-------------------+-------+
1 row in set (0.00 sec)
接着change master to
change master to MASTER_HOST='127.0.0.1', MASTER_PORT=3306;
查看hearbeat,可以看到heartbeat变为了slave_net_timeout的一半,25:
mysql> select * from mysql.slave_master_info\G
*************************** 1. row ***************************
... ...
Heartbeat: 25
... ...
1 row in set (0.00 sec)
首先设置slave_net_timeout为80:
mysql> set global slave_net_timeout=80;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'slave_net_timeout';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| slave_net_timeout | 80 |
+-------------------+-------+
1 row in set (0.00 sec)
接着change master to
change master to MASTER_CONNECT_RETRY=100;
查看heartbeat, 仍然是25,没有变化:
mysql> select * from mysql.slave_master_info\G
*************************** 1. row ***************************
... ...
Connect_retry: 100
... ...
Heartbeat: 25
... ...