mysql和mariadb对比_MySQL并发复制系列三:MySQL和MariaDB实现对比
MariaDB 10通過@@binlog_commit_wait_count and @@binlog_commit_wait_usec 兩個參數設置,既事務commit階段的時候至少等binlog_commit_wait_usec毫秒直到有binlog_commit_wait_count個數時進行一次組提交,來提高每組事務中的事務數量,并可以通過查詢狀態變量@@binlog_commit和@@binlog_group_commit來查參數來查看當前binary log group commit比例。
MySQL5.7通過引入?binlog_group_commit_sync_delay和 binlog_group_commit_sync_no_delay_count參數即提高binary log組提交并發數量,既MySQL等待binlog_group_commit_sync_delay毫秒的時間直到binlog_group_commit_sync_no_delay_count個數時進行一次組提交。
實現:
Binary Log Group Commit在MySQL 5.7和MariaDB 10 中是默認開啟不需要配置任何信息,且在binary log中標記的組提交信息依賴于GTID,而MySQL和MariaDB的GTID組成和實現方式不一樣,這里我們簡單梳理下。
在MySQL 5.7版本由于Binary Log Group Commit是默認開啟的,所以即使你不開啟gtid_mode在配置文件中,binary log的內容中同樣也有GTID 信息只不過標記的信息是"ANONYMOUS"
>????show binlog events in 'mysql-bin.000004';截取一段信息
1.? ...............
| mysql-bin.000004 | 3571 | Anonymous_Gtid | ? ? 15112 | ? ? ? ?3636 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS' ? ? ? ? ?|
2.? | mysql-bin.000004 | 3636 | Query ? ? ? ? ?| ? ? 15112 | ? ? ? ?3712 | BEGIN ? ? ? ? ? ? ? ? ? |
3.? | mysql-bin.000004 | 3712 | Rows_query ? ? | ? ? 15112 | ? ? ? ?3763 | # INSERT INTO t1 () VALUES () ? ? ? ? ? ? ? ? |
4.? | mysql-bin.000004 | 3763 | Table_map ? ? ?| ? ? 15112 | ? ? ? ?3807 | table_id: 108 (db2.t1) ? ? ? ? ? ? ? ? ? ? ? ?|
5.? | mysql-bin.000004 | 3807 | Write_rows ? ? | ? ? 15112 | ? ? ? ?3847 | table_id: 108 flags: STMT_END_F ? ? ? ? ? ? ? |
6.? | mysql-bin.000004 | 3847 | Xid ? ? ? ? ? ?| ? ? 15112 | ? ? ? ?3878 | COMMIT /* xid=33 */ ? ? ? ? ? ? ? ? ? ? ? ? ? |
.................
>???? mysqlbinlog -vvv mysql-bin.00004 | less
1.? #151231 14:34:03 server id 15112 ?end_log_pos 2408 CRC32 0x5586fe71 ? ? Anonymous_GTID?last_committed=6?? ? ? ?sequence_number=8
2.? SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
3.? # at 2408
4.? #151231 14:34:03 server id 15112 ?end_log_pos 2484 CRC32 0x748efb17 ? ? Query ? thread_id=11 ? ?exec_time=0 ? ? error_code=0
5.? SET TIMESTAMP=1451543643/*!*/;
6.? BEGIN
7.? ..
MariaDB的GTID同樣也是默認開啟且GTID是由Domain ID、Server ID和transaction Sequence Number組成:
圖3 MariaDB GTID組成
>????show binlog events in 'mysql-bin.000003';截取一段信息
1.? .......
| mysql-bin.000003 | ?335 | Gtid ? ? ? ? ? ? ?| ? ? 15102 | ? ? ? ? 377 | BEGIN GTID 0-15102-64139 ? ? ? ? ? ? ? ? ? ? ?|
2.? | mysql-bin.000003 | ?377 | Table_map ? ? ? ? | ? ? 15102 | ? ? ? ? 434 | table_id: 18 (test.sbtest1) ? ? ? ? ? ? ? ? ? |
3.? | mysql-bin.000003 | ?434 | Write_rows_v1 ? ? | ? ? 15102 | ? ? ? ? 657 | table_id: 18 flags: STMT_END_F ? ? ? ? ? ? ? ?|
4.? | mysql-bin.000003 | ?657 | Xid ? ? ? ? ? ? ? | ? ? 15102 | ? ? ? ? 688 | COMMIT /* xid=16 */ ? ? ? ? ? ? ? ? ? ? ? ? ? |
5.? | mysql-bin.000003 | ?688 | Gtid ? ? ? ? ? ? ?| ? ? 15102 | ? ? ? ? 732 | BEGIN GTID 0-15102-64140 cid=20 ? ? ? ? ? ? ? |
6.? | mysql-bin.000003 | ?732 | Table_map ? ? ? ? | ? ? 15102 | ? ? ? ? 789 | table_id: 19 (test.sbtest6) ? ? ? ? ? ? ? ? ? |
7.? | mysql-bin.000003 | ?789 | Write_rows_v1 ? ? | ? ? 15102 | ? ? ? ?1012 | table_id: 19 flags: STMT_END_F ? ? ? ? ? ? ? ?|
8.? | mysql-bin.000003 | 1012 | Xid ? ? ? ? ? ? ? | ? ? 15102 | ? ? ? ?1043 | COMMIT /* xid=20 */ ? ? ? ? ? ? ? ? ? ? ? ? ? |
9.? | mysql-bin.000003 | 1043 | Gtid ? ? ? ? ? ? ?| ? ? 15102 | ? ? ? ?1087 | BEGIN GTID 0-15102-64141 cid=20 ? ? ? ? ? ? ? |
10. | mysql-bin.000003 | 1087 | Table_map ? ? ? ? | ? ? 15102 | ? ? ? ?1145 | table_id: 20 (test.sbtest12) ? ? ? ? ? ? ? ? ?|
11. | mysql-bin.000003 | 1145 | Write_rows_v1 ? ? | ? ? 15102 | ? ? ? ?1368 | table_id: 20 flags: STMT_END_F ? ? ? ? ? ? ? ?|
12. | mysql-bin.000003 | 1368 | Xid ? ? ? ? ? ? ? | ? ? 15102 | ? ? ? ?1399 | COMMIT /* xid=21 */ ? ? ? ? ? ? ? ? ? ? ? ? ? |
......
>????mysqlbinlog -vvv mysql-bin.00003 ?| less
1.???? .......
2.???? # at 1754
3.? #160104 15:16:46 server id 15102 ?end_log_pos 1798 CRC32 0x26104c0b ? ??GTID 0-15102-64143 cid=20?trans
4.? /*!100001 SET @@session.gtid_seq_no=64143*//*!*/;
5.? BEGIN
6.? /*!*/;
7.? # at 1798
8.? #160104 15:16:46 server id 15102 ?end_log_pos 1856 CRC32 0x2c994f5a ? ? Table_map: `test`.`sbtest12` mapped to number 20
9.? # at 1856
10. #160104 15:16:46 server id 15102 ?end_log_pos 2079 CRC32 0x02b5a694 ? ? Write_rows: table id 20 flags: STMT_END_F
11.
12.? BINLOG '
13.? .........
結論:
MySQL 5.7 / MariaDB 10的parallel replication都是基于主庫上Binary Log Group Commit。
MySQL: ?主庫并發提交的事務group commit寫入binary log日志中,當事務被標記的?last_committed=N的值相同時(通過binlog_group_commit_sync_delay、?binlog_group_commit_sync_no_delay_count參數設置提高并發事務數量),可以在slave節點并發回放主庫提交的事務。
MariaDB: 主庫并發提交的事務group commit寫入binary log日志中,當事務被標記的?cid=N?的值相同時(通過?binlog_commit_wait_count、binlog_commit_wait_usec參數設置提高并發事務數量),可以在slave節點并發回放主庫提交的事務。
Reference:http://geek.rohitkalhans.com/2013/09/enhancedMTS-deepdive.html
總結
以上是生活随笔為你收集整理的mysql和mariadb对比_MySQL并发复制系列三:MySQL和MariaDB实现对比的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: spark 集群单词统计_最近Kafka
- 下一篇: ssh mysql转发_ssh转发代理: