Maison > Article > base de données > Tutoriel d'exemple de soumission de groupe MySQL5.7 et de réplication parallèle
mysql> show global variables like '%group_commit%';+-----------------------------------------+-------+| Variable_name | Value |+-----------------------------------------+-------+| binlog_group_commit_sync_delay | 0 || binlog_group_commit_sync_no_delay_count | 0 |+-----------------------------------------+-------+2 rows in set (0.00 sec)
[root@mxqmongodb2 log]# mysqlbinlog mysql-bin.000005 |grep last_committed #170607 11:24:57 server id 353306 end_log_pos 876350 CRC32 0x92093332 GTID last_committed=654 sequence_number=655#170607 11:24:58 server id 353306 end_log_pos 880406 CRC32 0x344fdf71 GTID last_committed=655 sequence_number=656#170607 11:24:58 server id 353306 end_log_pos 888700 CRC32 0x4ba2b05b GTID last_committed=656 sequence_number=657#170607 11:24:58 server id 353306 end_log_pos 890675 CRC32 0xf8a8ad64 GTID last_committed=657 sequence_number=658#170607 11:24:58 server id 353306 end_log_pos 892770 CRC32 0x127f9cdd GTID last_committed=658 sequence_number=659#170607 11:24:58 server id 353306 end_log_pos 894757 CRC32 0x518abd93 GTID last_committed=659 sequence_number=660#170607 11:37:46 server id 353306 end_log_pos 895620 CRC32 0x99174f95 GTID last_committed=660 sequence_number=661#170607 11:37:51 server id 353306 end_log_pos 895897 CRC32 0xb4ffc341 GTID last_committed=661 sequence_number=662#170607 11:38:00 server id 353306 end_log_pos 896174 CRC32 0x6bcbc492 GTID last_committed=662 sequence_number=663#170607 11:39:40 server id 353306 end_log_pos 896365 CRC32 0x1fe16c7c GTID last_committed=663 sequence_number=664
[root@mxqmongodb2 log]# mysqlbinlog mysql-bin.000008|grep last_commit #170609 10:11:07 server id 353306 end_log_pos 75629 CRC32 0xd54f2604 GTID last_committed=269 sequence_number=270#170609 10:13:03 server id 353306 end_log_pos 75912 CRC32 0x43675b14 GTID last_committed=270 sequence_number=271#170609 10:13:24 server id 353306 end_log_pos 76195 CRC32 0x4f843438 GTID last_committed=270 sequence_number=272
#MTS slave-parallel-type=LOGICAL_CLOCK slave-parallel-workers=8 #太多的线程会增加线程间同步的开销,建议4-8个slave线程 master_info_repository=TABLErelay_log_info_repository=TABLErelay_log_recovery=ONslave-parallel-type有两个之,DATABASE和LOGICAL_CLOCK,DATABASE: 默认值,兼容5.6以schema维度的并行复制, LOGICAL_CLOCK: MySQL 5.7基于组提交的并行复制机制。
En résumé, la réplication parallèle de MySQL5.7 est basée sur le commit de groupe de la bibliothèque principale et la configuration des paramètres suivants de la bibliothèque esclave : mysql> affiche des variables comme '% slave_para%';
+------------------------+---------------+| Variable_name | Value |+------------------------+---------------+| slave_parallel_type | LOGICAL_CLOCK || slave_parallel_workers | 8 |+------------------------+---------------+2 rows in set (0.01 sec)
Pour utiliser la réplication parallèle de MySQL5.7, vous devez d'abord définir binlog_group_commit_sync_delay supérieur à 0 dans la bibliothèque principale, puis définissez le fil dans la bibliothèque esclave Numéros et méthodes associées. Ce que nous avons défini ci-dessus est 8, et vous pouvez voir dans la bibliothèque esclave que
mysql> show processlist;+----+-------------+--------------------+------+---------+--------+--------------------------------------------------------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+-------------+--------------------+------+---------+--------+--------------------------------------------------------+------------------+| 1 | system user | | NULL | Connect | 373198 | Waiting for master to send event | NULL || 2 | system user | | NULL | Connect | 1197 | Slave has read all relay log; waiting for more updates | NULL || 4 | system user | | NULL | Connect | 4292 | Waiting for an event from Coordinator | NULL || 5 | system user | | NULL | Connect | 373198 | Waiting for an event from Coordinator | NULL || 6 | system user | | NULL | Connect | 373198 | Waiting for an event from Coordinator | NULL || 7 | system user | | NULL | Connect | 373198 | Waiting for an event from Coordinator | NULL || 8 | system user | | NULL | Connect | 373198 | Waiting for an event from Coordinator | NULL || 9 | system user | | NULL | Connect | 373198 | Waiting for an event from Coordinator | NULL || 10 | system user | | NULL | Connect | 373198 | Waiting for an event from Coordinator | NULL || 11 | system user | | NULL | Connect | 373198 | Waiting for an event from Coordinator | NULL || 16 | root | 10.103.16.34:37263 | NULL | Query | 0 | starting | show processlist |+----+-------------+--------------------+------+---------+--------+--------------------------------------------------------+------------------+
la bibliothèque esclave aura huit threads en attente de traitement des transactions, au lieu d'un seul.
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!