默认情况下process如下
mysql> show processlist;
+----+-------------+-----------+--------+---------+-------+--------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+-----------+--------+---------+-------+--------------------------------------------------------+------------------+
| 8 | system user | | NULL | Connect | 70100 | Waiting for master to send event | NULL |//IO线程
| 9 | system user | | NULL | Connect | 57345 | Slave has read all relay log; waiting for more updates | NULL |//中继线程,单线程
| 10 | root | localhost | master | Query | 0 | starting | show processlist |
+----+-------------+-----------+--------+---------+-------+--------------------------------------------------------+------------------+
3 rows in set (0.00 sec)
开启并行复制,编辑slave的/etc/my.cnf,新增如下信息
slave-parallel-type=LOGICAL_CLOCK//设置通过组提交,database是几个数据库就起几个线程,当只有一个数据库时,一个线程不够,所以引入组复制,一组一个线程
slave-parallel-workers=16 //并行复制sql线程数
master_info_repository=TABLE //data/mysql里的master.info和relay-log.info以表的形式存到数据库中
relay_log_info_repository=TABLE
relay_log_recovery=ON//激活中继日志
重启mysql后再次进入mysql查看
mysql> show processlist;
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
| 1 | system user | | NULL | Connect | 36 | Waiting for master to send event | NULL |
| 2 | system user | | NULL | Connect | 35 | Slave has read all relay log; waiting for more updates | NULL |
| 3 | system user | | NULL | Connect | 36 | Waiting for an event from Coordinator | NULL |
| 4 | system user | | NULL | Connect | 36 | Waiting for an event from Coordinator | NULL |
| 5 | system user | | NULL | Connect | 36 | Waiting for an event from Coordinator | NULL |
| 6 | system user | | NULL | Connect | 36 | Waiting for an event from Coordinator | NULL |
| 8 | root | localhost | NULL | Query | 0 | starting | show processlist |
+----+-------------+-----------+------+---------+------+--------------------------------------------------------+------------------+
7 rows in set (0.00 sec)
可以看到,多了四条数据,这四条数据代表4个sql线程为协程线程,等待转发
网友评论