本文共 3929 字,大约阅读时间需要 13 分钟。
并行复制
设置
set global slave_parallel_workers=10;设置sql线程数为10
步骤:
#从库mysql> show variables like '%slave_par%';+------------------------+-------+| Variable_name | Value |+------------------------+-------+| slave_parallel_workers | 0 |#关闭状态+------------------------+-------+1 row in set (0.00 sec)mysql> set global slave_parallel_workers=10;Query OK, 0 rows affected (0.00 sec)#查看线程,SQL线程数量并没有改变,因为没有重新启动slavemysql> show processlist\G*************************** 1. row *************************** Id: 15 User: system user Host: db: NULLCommand: Connect Time: 59458 State: Waiting for master to send event Info: NULL*************************** 2. row *************************** Id: 16 User: system user Host: db: NULLCommand: Connect Time: 59550 State: Slave has read all relay log; waiting for the slave I/O thread to update it Info: NULL*************************** 3. row *************************** Id: 17 User: root Host: localhost db: NULLCommand: Query Time: 0 State: init Info: show processlist3 rows in set (0.00 sec)mysql> stop slave;Query OK, 0 rows affected (0.00 sec)mysql> start slave;Query OK, 0 rows affected, 1 warning (0.02 sec)mysql> show processlist;+----+-------------+-----------+------+---------+------+-----------------------------------------------------------------------------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+-------------+-----------+------+---------+------+-----------------------------------------------------------------------------+------------------+| 17 | root | localhost | NULL | Query | 0 | init | show processlist || 18 | system user | | NULL | Connect | 8 | Waiting for master to send event | NULL || 19 | system user | | NULL | Connect | 8 | Slave has read all relay log; waiting for the slave I/O thread to update it | NULL || 20 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL || 21 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL || 22 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL || 23 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL || 24 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL || 25 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL || 26 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL || 27 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL || 28 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL || 29 | system user | | NULL | Connect | 8 | Waiting for an event from Coordinator | NULL |+----+-------------+-----------+------+---------+------+-----------------------------------------------------------------------------+------------------+13 rows in set (0.00 sec)
转载地址:http://aopox.baihongyu.com/