1.6 配置mysql高可用-slave啟用并行復制

默認情況下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是幾個數(shù)據(jù)庫就起幾個線程,當只有一個數(shù)據(jù)庫時,一個線程不夠,所以引入組復制,一組一個線程
slave-parallel-workers=16 //并行復制sql線程數(shù)
master_info_repository=TABLE //data/mysql里的master.info和relay-log.info以表的形式存到數(shù)據(jù)庫中
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)

可以看到,多了四條數(shù)據(jù),這四條數(shù)據(jù)代表4個sql線程為協(xié)程線程,等待轉發(fā)

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容