开启多线程复制,默认关键的参数有两个:

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