mysql 5.7开启并行复制
时间:2019-08-23 16:28 来源:linux.it.net.cn 作者:IT
开启多线程复制,默认关键的参数有两个:
mysql> show variables like 'slave_parallel_%';
+------------------------+---------------+
| Variable_name | Value |
+------------------------+---------------+
| slave_parallel_type | database |
| slave_parallel_workers | 0 |
+------------------------+---------------+
2 rows in set (0.00 sec)
slave-parallel-type 默认值为database
slave-parallel-workers 默认值为0
在线开启:
mysql> stop slave sql_thread;
Query OK, 0 rows affected (0.07 sec)
mysql> set global slave_parallel_type='LOGICAL_CLOCK';
Query OK, 0 rows affected (0.00 sec)
mysql> set global slave_parallel_workers=4;
Query OK, 0 rows affected (0.00 sec)
mysql> start slave sql_thread;
Query OK, 0 rows affected (0.06 sec)
优化选项:
启用table模式是因为如果在多线程模式下,会频繁更新master.info文件,消耗代价过高,并且此值也不是非常准确
master_info_repository=table 对应的表为mysql.slave_master_info
relay_log_recovery=on
relay_log_info_repository=table 对应的表为mysql.slave_relay_log_info
说了这么多,要开启enhanced multi-threaded slave其实很简单,只需根据如下设置:
# slave
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=16
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON (责任编辑:IT)
开启多线程复制,默认关键的参数有两个: mysql> show variables like 'slave_parallel_%'; +------------------------+---------------+ | Variable_name | Value | +------------------------+---------------+ | slave_parallel_type | database | | slave_parallel_workers | 0 | +------------------------+---------------+ 2 rows in set (0.00 sec) slave-parallel-type 默认值为database slave-parallel-workers 默认值为0 在线开启: mysql> stop slave sql_thread; Query OK, 0 rows affected (0.07 sec) mysql> set global slave_parallel_type='LOGICAL_CLOCK'; Query OK, 0 rows affected (0.00 sec) mysql> set global slave_parallel_workers=4; Query OK, 0 rows affected (0.00 sec) mysql> start slave sql_thread; Query OK, 0 rows affected (0.06 sec) 优化选项: 启用table模式是因为如果在多线程模式下,会频繁更新master.info文件,消耗代价过高,并且此值也不是非常准确 master_info_repository=table 对应的表为mysql.slave_master_info relay_log_recovery=on relay_log_info_repository=table 对应的表为mysql.slave_relay_log_info 说了这么多,要开启enhanced multi-threaded slave其实很简单,只需根据如下设置: # slave slave-parallel-type=LOGICAL_CLOCK slave-parallel-workers=16 master_info_repository=TABLE relay_log_info_repository=TABLE relay_log_recovery=ON (责任编辑:IT) |