关闭复制

1
2
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)

设置并发同步类型为逻辑时钟方式

1
2
mysql> set global slave_parallel_type=logical_clock;
Query OK, 0 rows affected (0.00 sec)

默认是datebase,每个线程只能处理一个数据库

配置成基于逻辑时钟的方式

配置并发线程数:

1
2
mysql> set global slave_parallel_workers=32;
Query OK, 0 rows affected (0.00 sec)

查看结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
mysql> show variables like 'slave_parallel_type';
+---------------------+---------------+
| Variable_name       | Value         |
+---------------------+---------------+
| slave_parallel_type | LOGICAL_CLOCK |
+---------------------+---------------+
1 row in set (0.00 sec)
mysql> show variables like 'slave_parallel_workers';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| slave_parallel_workers | 32    |
+------------------------+-------+
1 row in set (0.00 sec)
mysql> start slave;
Query OK, 0 rows affected (0.04 sec)
mysql> show processlist;
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
| Id | User        | Host      | db   | Command | Time | State                                                  | Info             |
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
| 20 | root        | localhost | NULL | Query   |    0 | starting                                               | show processlist |
| 21 | system user |           | NULL Connect |    5 | Waiting for master to send event                       | NULL             |
| 22 | system user |           | NULL Connect |    5 | Slave has read all relay log; waiting for more updates | NULL             |
| 23 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 24 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 25 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 26 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 27 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 28 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 29 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 30 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 31 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 32 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 33 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 34 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 35 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 36 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 37 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 38 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 39 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 40 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 41 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 42 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 43 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 44 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 45 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 46 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 47 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 48 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 49 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 50 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 51 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 52 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 53 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
| 54 | system user |           | NULL Connect |    5 | Waiting for an event from Coordinator                  | NULL             |
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
35 rows in set (0.00 sec)

如果要永久生效,需要修改配置文件

1
2
slave_parallel_workers=32
slave_parallel_type=logical_clock