-
并行复制
- 社区版5.6中新增
- 并行是指从库多线程apply binlog
- 库级别并行应用binlog,同一个库数据更改还是串行的(5.7版并行复制基于事务组)
设置
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线程数量并没有改变,因为没有重新启动slave
mysql> show processlist\G
*************************** 1. row ***************************
Id: 15
User: system user
Host:
db: NULL
Command: Connect
Time: 59458
State: Waiting for master to send event
Info: NULL
*************************** 2. row ***************************
Id: 16
User: system user
Host:
db: NULL
Command: 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: NULL
Command: Query
Time: 0
State: init
Info: show processlist
3 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)