MySQL Group Replication(MGR)基于 ?shared-nothing架構(gòu),通過多節(jié)點(diǎn)完整數(shù)據(jù)副本實(shí)現(xiàn)數(shù)據(jù)強(qiáng)一致性,并支持故障自動(dòng)切換與主節(jié)點(diǎn)選舉。自MySQL 8.0.23版本后穩(wěn)定性顯著提升,本文結(jié)合生產(chǎn)實(shí)踐總結(jié)關(guān)鍵優(yōu)化經(jīng)驗(yàn)。

技術(shù)架構(gòu)圖
一、MGR參數(shù)建議與避坑總結(jié)
1、單主模式
建議使用單主模式。MGR依賴Paxos協(xié)議實(shí)現(xiàn)多節(jié)點(diǎn)共識(shí),在多主模式下,每個(gè)事務(wù)需在多數(shù)節(jié)點(diǎn)認(rèn)證(Certify)并排序,容易出現(xiàn)沖突、網(wǎng)絡(luò)抖動(dòng)引起的事務(wù)回滾,并且需跨節(jié)點(diǎn)分析日志,運(yùn)維成本高。另外MGR不檢測(cè)DDL沖突,多主模式下,若不同節(jié)點(diǎn)并發(fā)執(zhí)行DDL和DML,可能破壞表結(jié)構(gòu)或數(shù)據(jù)完整性。
loose-group_replication_single_primary_mode=ON
2、存儲(chǔ)引擎
建議使用InnoDB引擎。 MGR基于Paxos協(xié)議實(shí)現(xiàn)多節(jié)點(diǎn)數(shù)據(jù)強(qiáng)一致性,要求事務(wù)具備原子性(提交或回滾)。InnoDB是MySQL唯一支持完整 ACID 事務(wù)的引擎。另外使用mysql clone插件時(shí),非innodb引擎會(huì)引發(fā)報(bào)錯(cuò)。
default_storage_engine = "InnoDB" # 默認(rèn)使用innodb引擎
disabled_storage_engines = "MyISAM" # 禁用MyISAM引擎
3、強(qiáng)制主鍵
所有表必須要有主鍵或者唯一非空健。 MGR要求 binlog_format=ROW,該格式依賴主鍵高效定位修改行。無主鍵時(shí),ROW 格式可能退化為全表掃描,大幅降低復(fù)制效率。另外在使用mysql clone插件時(shí),無主鍵也會(huì)引發(fā)報(bào)錯(cuò)。
sql_require_primary_key = ON # 所有表必須有主鍵
sql_generate_invisible_primary_key=ON # 自動(dòng)為無主鍵表創(chuàng)建隱式主鍵,8.0.30引入
4、限制大事務(wù)
<1> MGR 心跳機(jī)制敏感,依賴節(jié)點(diǎn)間的周期性心跳(硬編碼5秒)檢測(cè)存活。若事務(wù)處理時(shí)間過長(zhǎng)(如傳輸大事務(wù)阻塞通信線程),節(jié)點(diǎn)可能因未及時(shí)響應(yīng)心跳被誤判為故障,觸發(fā)自動(dòng)驅(qū)逐(group_replication_member_expel_timeout)。
<2> 減輕 XCom 引擎壓力,MGR 的組通信引擎(XCom)為單線程設(shè)計(jì),負(fù)責(zé)事務(wù)消息的分發(fā)與排序。大事務(wù)會(huì)長(zhǎng)時(shí)間占用 XCom 線程,導(dǎo)致心跳消息堆積,觸發(fā)節(jié)點(diǎn)驅(qū)逐。限制事務(wù)大小可以顯著降低單事務(wù)處理時(shí)長(zhǎng),避免 XCom 成為性能瓶頸。
# 默認(rèn)值150MB,但建議調(diào)低在20MB以內(nèi),不要使用大事務(wù)
loose-group_replication_transaction_size_limit = 20M
5、表名大小寫設(shè)置
所有節(jié)點(diǎn)必須統(tǒng)一大小寫規(guī)則。 表名作為元數(shù)據(jù)的一部分,若大小寫不統(tǒng)一,MGR沖突檢測(cè)機(jī)制可能無法正確關(guān)聯(lián)同一張表的數(shù)據(jù)變更,誤判沖突或漏判沖突。
lower_case_table_names = 1
6、隔離級(jí)別
Gap Lock 是 InnoDB 在 REPEATABLE READ 隔離級(jí)別下為防幻讀引入的鎖機(jī)制,其鎖定的是索引記錄之間的“間隙”。然而,Gap Lock 的信息僅在 InnoDB 引擎內(nèi)部維護(hù),無法通過 Write Set 暴露給 MGR 的分布式?jīng)_突檢測(cè)層。因此MGR無法支持gap lock,官方推薦 READ COMMITTED 隔離級(jí)別。
transaction_isolation = 'READ-COMMITTED'
7、禁用壓縮
雖然禁用壓縮會(huì)導(dǎo)致帶寬壓力變大,但是可以消除壓縮/解壓的CPU 開銷,提升事務(wù)處理吞吐量。另外最重要一點(diǎn),禁用壓縮后,DBA可以使用第三方工具(binlog2sql、my2sql等)解析binlog、生成sql本文,這對(duì)dml誤操作后的數(shù)據(jù)恢復(fù)非常有利。
loose-group_replication_compression_threshold=0
8、關(guān)閉流控
流控觸發(fā)時(shí)會(huì)阻塞本地事務(wù)提交,導(dǎo)致業(yè)務(wù)響應(yīng)延遲增加,在高并發(fā)場(chǎng)景下可能引發(fā)吞吐量驟降,應(yīng)用程序無響應(yīng)等問題,甚至對(duì)業(yè)務(wù)有損,權(quán)衡利弊后,建議關(guān)閉。
loose-group_replication_flow_control_mode = "DISABLED"
9、禁用hash_scan算法
參數(shù)slave_rows_search_algorithms用于控制從庫在應(yīng)用binlog時(shí)如何定位數(shù)據(jù)行。當(dāng)表缺少主鍵或者唯一索引,且指定算法為HASH_SCAN時(shí)存在哈希碰撞風(fēng)險(xiǎn),這可能導(dǎo)致從庫誤更新/刪除非目標(biāo)行,造成數(shù)據(jù)不一致。
slave_rows_search_algorithms=INDEX_SCAN,TABLE_SCAN
二、MGR故障切換流程與相關(guān)參數(shù)優(yōu)化
2.1 先看一個(gè)測(cè)試案例
測(cè)試案例中,使用下面兩個(gè)參數(shù)值
group_replication_member_expel_timeout=30
group_replication_unreachable_majority_timeout=80 # 為了便于觀察,暫設(shè)置為80秒
故障測(cè)試前的集群狀態(tài)
root@localhost: 10:24: [(none)]> select MEMBER_HOST,MEMBER_STATE,MEMBER_ROLE,MEMBER_VERSION from performance_schema.replication_group_members;
+----------------+--------------+-------------+----------------+
| MEMBER_HOST | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+----------------+--------------+-------------+----------------+
| node03 | ONLINE | PRIMARY | 8.0.28 |
| node02 | ONLINE | SECONDARY | 8.0.28 |
| node01 | ONLINE | SECONDARY | 8.0.28 |
+----------------+--------------+-------------+----------------+
3 rows in set (0.00 sec)
模擬故障:此時(shí)primary節(jié)點(diǎn)是node3,斷開node3與另外兩個(gè)節(jié)點(diǎn)的網(wǎng)絡(luò),然后觀察日志變化。
日志變化
<1> 5秒后,心跳檢測(cè)網(wǎng)絡(luò)中斷,所有節(jié)點(diǎn)檢測(cè)到網(wǎng)絡(luò)不可達(dá),并更新集群狀態(tài)視圖。
#少數(shù)派節(jié)點(diǎn)(node3)
2023-05-27T13:16:01.716803+08:00 0 [Warning] [MY-011493] [Repl] Plugin group_replication reported: 'Member with address mysqlwjhtest01:3307 has become unreachable.'
2023-05-27T13:16:01.716934+08:00 0 [Warning] [MY-011493] [Repl] Plugin group_replication reported: 'Member with address mysqlwjhtest02:3307 has become unreachable.'
2023-05-27T13:16:01.716951+08:00 0 [ERROR] [MY-011496] [Repl] Plugin group_replication reported: 'This server is not able to reach a majority of members in the group. This server will now block all updates. The server will remain blocked for the next 85 seconds. Unless contact with the majority is restored, after this time the member will error out and leave the group. It is possible to use group_replication_force_members to force a new group membership.'
2023-05-27T13:17:26.724015+08:00 71231 [ERROR] [MY-011711] [Repl] Plugin group_replication reported: 'This member could not reach a majority of the members for more than 85 seconds. The member will now leave the group as instructed by the group_replication_unreachable_majority_timeout option.'
#多數(shù)派節(jié)點(diǎn)(node1、node2)
2023-05-27T13:16:01.719345+08:00 0 [Warning] [MY-011493] [Repl] Plugin group_replication reported: 'Member with address mysqlwjhtest03:3307 has become unreachable.'
<2> 35秒后,多數(shù)派節(jié)點(diǎn)(node1、node2)將node3逐出集群,并新主node2,更新狀態(tài)視圖。少數(shù)派節(jié)點(diǎn)(故障節(jié)點(diǎn))無日志輸出。
2023-05-27T13:16:32.706137+08:00 0 [Warning] [MY-011499] [Repl] Plugin group_replication reported: 'Members removed from the group: mysqlwjhtest03:3307'
2023-05-27T13:16:32.706150+08:00 0 [System] [MY-011500] [Repl] Plugin group_replication reported: 'Primary server with address mysqlwjhtest03:3307 left the group. Electing new Primary.'
2023-05-27T13:16:32.706259+08:00 0 [Note] [MY-013519] [Repl] Plugin group_replication reported: 'Elected primary member gtid_executed: debbaad4-1fd7-4652-80a4-5c87cfde0db6:1-19'
2023-05-27T13:16:32.706272+08:00 0 [Note] [MY-013519] [Repl] Plugin group_replication reported: 'Elected primary member applier channel received_transaction_set: debbaad4-1fd7-4652-80a4-5c87cfde0db6:1-19'
2023-05-27T13:16:32.706284+08:00 0 [System] [MY-011507] [Repl] Plugin group_replication reported: 'A new primary with address mysqlwjhtest02:3307 was elected. The new primary will execute all previous group transactions before allowing writes.'
<3> 85秒后,少數(shù)派節(jié)點(diǎn)(node3)更改自己狀態(tài),由online改為error。多數(shù)派節(jié)點(diǎn)無日志輸出。
2023-05-27T13:17:26.724015+08:00 71231 [ERROR] [MY-011711] [Repl] Plugin group_replication reported: 'This member could not reach a majority of the members for more than 85 seconds. The member will now leave the group as instructed by the group_replication_unreachable_majority_timeout option.'
2023-05-27T13:17:26.724483+08:00 0 [Note] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] xcom_client_remove_node: Try to push xcom_client_remove_node to XCom'
2023-05-27T13:17:26.724560+08:00 71231 [ERROR] [MY-011712] [Repl] Plugin group_replication reported: 'The server was automatically set into read only mode after an error was detected.'
2023-05-27T13:17:26.725179+08:00 71231 [System] [MY-011565] [Repl] Plugin group_replication reported: 'Setting super_read_only=ON.'
2023-05-27T13:17:26.725340+08:00 71231 [Note] [MY-011647] [Repl] Plugin group_replication reported: 'Going to wait for view modification'
<4> 115秒以后,少數(shù)派節(jié)點(diǎn)(node3)從自己的集群狀態(tài)視圖中踢出node1、node2節(jié)點(diǎn)信息,然后auto-rejoin嘗試加入集群(如果在85s-115s間網(wǎng)絡(luò)未恢復(fù),則加入失敗)。
2023-05-27T13:17:56.296998+08:00 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Timeout while waiting for the group communication engine to exit!'
2023-05-27T13:17:56.297075+08:00 0 [ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] The member has failed to gracefully leave the group.'
2023-05-27T13:17:56.396287+08:00 0 [System] [MY-011504] [Repl] Plugin group_replication reported: 'Group membership changed: This member has left the group.'
2023-05-27T13:17:56.396530+08:00 72720 [System] [MY-013373] [Repl] Plugin group_replication reported: 'Started auto-rejoin procedure attempt 1 of 3'
2023-05-27T13:17:56.397353+08:00 71913 [Note] [MY-010596] [Repl] Error reading relay log event for channel 'group_replication_applier': slave SQL thread was killed
2023-05-27T13:17:56.397914+08:00 71913 [Note] [MY-010587] [Repl] Slave SQL thread for channel 'group_replication_applier' exiting, replication stopped in log 'FIRST' at position 0
2023-05-27T13:17:56.398188+08:00 71911 [Note] [MY-011444] [Repl] Plugin group_replication reported: 'The group replication applier thread was killed.'
2023-05-27T13:17:56.398830+08:00 72720 [Note] [MY-011673] [Repl] Plugin group_replication reported: 'Group communication SSL configuration: group_replication_ssl_mode: "DISABLED"'
2023-05-27T13:17:56.400717+08:00 72720 [Note] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Debug messages will be sent to: asynchronous::/data/mysql/data/GCS_DEBUG_TRACE'
2023-05-27T13:17:56.400984+08:00 72720 [Warning] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Automatically adding IPv4 localhost address to the allowlist. It is mandatory that it is added.'
2023-05-27T13:17:56.401014+08:00 72720 [Warning] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Automatically adding IPv6 localhost address to the allowlist. It is mandatory that it is added.'
少數(shù)派節(jié)點(diǎn)(node3)集群視圖變化
#5秒后
root@localhost: 14:05: [(none)]> select MEMBER_HOST,MEMBER_STATE,MEMBER_ROLE,MEMBER_VERSION from performance_schema.replication_group_members;system date;
+----------------+--------------+-------------+----------------+
| MEMBER_HOST | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+----------------+--------------+-------------+----------------+
| mysqlwjhtest01 | UNREACHABLE | SECONDARY | 8.0.28 |
| mysqlwjhtest03 | ONLINE | PRIMARY | 8.0.28 |
| mysqlwjhtest02 | UNREACHABLE | SECONDARY | 8.0.28 |
+----------------+--------------+-------------+----------------+
3 rows in set (0.00 sec)
#85秒后
root@localhost: 14:07: [(none)]> select MEMBER_HOST,MEMBER_STATE,MEMBER_ROLE,MEMBER_VERSION from performance_schema.replication_group_members;system date;
+----------------+--------------+-------------+----------------+
| MEMBER_HOST | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+----------------+--------------+-------------+----------------+
| mysqlwjhtest01 | UNREACHABLE | SECONDARY | 8.0.28 |
| mysqlwjhtest03 | ERROR | | 8.0.28 |
| mysqlwjhtest02 | UNREACHABLE | SECONDARY | 8.0.28 |
+----------------+--------------+-------------+----------------+
3 rows in set (0.00 sec)
#115秒后
root@localhost: 14:08: [(none)]> select MEMBER_HOST,MEMBER_STATE,MEMBER_ROLE,MEMBER_VERSION from performance_schema.replication_group_members;system date;
+----------------+--------------+-------------+----------------+
| MEMBER_HOST | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION |
+----------------+--------------+-------------+----------------+
| mysqlwjhtest03 | ERROR | | 8.0.28 |
+----------------+--------------+-------------+----------------+
1 row in set (0.01 sec)
2.2 案例中的集群狀態(tài)變化分析
幾個(gè)重要的時(shí)間點(diǎn)
- <1> 網(wǎng)絡(luò)中斷5秒時(shí),心跳檢測(cè)超時(shí),少數(shù)派節(jié)點(diǎn)和多數(shù)派節(jié)點(diǎn)均將可疑節(jié)點(diǎn)設(shè)置為unreachable。
- <2> 網(wǎng)絡(luò)中斷35秒時(shí),多數(shù)派節(jié)點(diǎn)將可疑節(jié)點(diǎn)逐出集群,同時(shí)會(huì)選舉出新的主庫。
- <3> 網(wǎng)絡(luò)中斷85秒時(shí),少數(shù)派節(jié)點(diǎn)(故障節(jié)點(diǎn))將自己的狀態(tài)改為error。(如果在85秒前網(wǎng)絡(luò)恢復(fù),則集群自動(dòng)恢復(fù))
- <4> 網(wǎng)絡(luò)中斷115秒時(shí),少數(shù)派節(jié)點(diǎn)(故障節(jié)點(diǎn))將兩個(gè)失聯(lián)節(jié)點(diǎn)逐出集群。(如果在115秒前網(wǎng)絡(luò)恢復(fù),則在115秒時(shí)mgr先逐出可疑節(jié)點(diǎn),然后auto-rejoin嘗試將error節(jié)點(diǎn)重新加入集群,且可以成功加入。)
mgr參數(shù)值和以上時(shí)間點(diǎn)的關(guān)系
- 35秒:心跳檢測(cè)5s + group_replication_member_expel_timeout=30s
- 85秒:心跳檢測(cè)5s + group_replication_unreachable_majority_timeout=80s
- 115秒:心跳檢測(cè)5s + group_replication_unreachable_majority_timeout=80s + (試圖退出集群,硬編碼超時(shí)時(shí)間30秒 WAITING_TIME = 30s)
mgr相關(guān)參數(shù)的作用
1、group_replication_member_expel_timeout 表示多數(shù)派中驅(qū)逐unreable節(jié)點(diǎn)的時(shí)間,也就是容忍多少秒,看看網(wǎng)絡(luò)是否能夠恢復(fù)。同時(shí)也表示多數(shù)派選舉新主的時(shí)間,驅(qū)逐后會(huì)立馬選擇新主;
2、少數(shù)派節(jié)點(diǎn)首先讀取參數(shù)group_replication_unreachable_majority_timeout,到達(dá)超時(shí)時(shí)間后進(jìn)入error狀態(tài)。然后節(jié)點(diǎn)做退出操作,試圖通知其他節(jié)點(diǎn),但是由于無法通信造成超時(shí),超時(shí)時(shí)間同樣為30秒,這里大概流程如下:
unreable參數(shù)打開,partition線程
Group_partition_handling::partition_thread_handler
->leave_group_on_failure::leave
->Gcs_operations::leave
->Gcs_xcom_control::leave
->Gcs_xcom_notification *notification = new Control_notification(do_function_leave, this);
bool scheduled = m_gcs_engine->push(notification);
發(fā)送操作給xcom engine 。
xcom engine 操作,
Gcs_xcom_control::do_leave
-> m_xcom_proxy->xcom_remove_node(*m_local_node_info, m_gid_hash)
->Gcs_xcom_proxy_base::xcom_remove_nodes
->xcom_client_remove_node
->xcom_send_cfg_wait
通知其他節(jié)點(diǎn)進(jìn)行配置
-> int is_xcom_exit = m_xcom_proxy->xcom_wait_exit()
等待xcom 的新配置處理完成,這里30秒超時(shí)
/*
Time is defined in seconds.
*/
static const unsigned int WAITING_TIME = 30;
緊接著觸發(fā)auto-rejoin重試(group_replication_autorejoin_tries)。
3、group_replication_unreachable_majority_timeout參數(shù)的值必須大于group_replication_member_expel_timeout,否則故障節(jié)點(diǎn)會(huì)先于大多數(shù)節(jié)點(diǎn)的容忍時(shí)間而將自身狀態(tài)設(shè)置為ERROR。
2.3 故障檢測(cè)流程
結(jié)合上面的案例,我們來看看 Group Repliction 的故障檢測(cè)流程。
-
集群中每個(gè)節(jié)點(diǎn)都會(huì)定期(每秒 1 次)向其它節(jié)點(diǎn)發(fā)送心跳信息。如果在 5s 內(nèi)(固定值,無參數(shù)調(diào)整)沒有收到其它節(jié)點(diǎn)的心跳信息,則會(huì)將該節(jié)點(diǎn)標(biāo)記為可疑節(jié)點(diǎn),同時(shí)會(huì)將該節(jié)點(diǎn)的狀態(tài)設(shè)置為 UNREACHABLE 。如果集群中有等于或超過 1/2 的節(jié)點(diǎn)顯示為 UNREACHABLE ,則該集群不能對(duì)外提供寫服務(wù)。
-
如果在group_replication_member_expel_timeout(從 MySQL 8.0.21 開始,該參數(shù)的默認(rèn)值為 5,單位 s,最大可設(shè)置值為3600,即 1 小時(shí))時(shí)間內(nèi),多數(shù)派中可疑節(jié)點(diǎn)恢復(fù)正常,則會(huì)直接應(yīng)用 XCom Cache 中的消息。XCom Cache 的大小由group_replication_message_cache_size 決定,默認(rèn)是 1G。
-
如果在group_replication_member_expel_timeout時(shí)間內(nèi),多數(shù)派中可疑節(jié)點(diǎn)沒有恢復(fù)正常,則會(huì)被驅(qū)逐出集群。
-
在少數(shù)派中可疑節(jié)點(diǎn)不會(huì)自動(dòng)離開集群,
- 如果參數(shù)group_replication_unreachable_majority_timeout沒有設(shè)置(默認(rèn)值為0),一直處于UNREACHABLE,直到網(wǎng)絡(luò)恢復(fù)。
- 達(dá)到 group_replication_unreachable_majority_timeout 的限制,自動(dòng)設(shè)置為error。
-
如果group_replication_auto_rejoin_tries不為 0,對(duì)于 ERROR 狀態(tài)的節(jié)點(diǎn),會(huì)自動(dòng)重試,重新加入集群(auto-rejoin)。
-
如果group_replication_auto_rejoin_tries為 0 或重試失敗,則會(huì)執(zhí)行 group_replication_exit_state_action 指定的操作。可選的操作有:
-
READ_ONLY:只讀模式。在這種模式下,會(huì)將 super_read_only 設(shè)置為 ON。默認(rèn)值。
-
OFFLINE_MODE:離線模式。在這種模式下,會(huì)將 offline_mode 和 super_read_only 設(shè)置為 ON,此時(shí),只有CONNECTION_ADMIN(SUPER)權(quán)限的用戶才能登陸,普通用戶不能登錄。
-
ABORT_SERVER:關(guān)閉實(shí)例。
-
2.4 故障切換參數(shù)
#適用于8.0.21以上版本
loose-group_replication_member_expel_timeout=30 # 只對(duì)多數(shù)派中可疑節(jié)點(diǎn)有效,超過30秒后可疑節(jié)點(diǎn)將被驅(qū)逐集群,默認(rèn)5秒。
loose-group_replication_unreachable_majority_timeout=30 # 只對(duì)少數(shù)派有效,當(dāng)超過設(shè)置的網(wǎng)絡(luò)不可達(dá)超時(shí)時(shí)間時(shí),會(huì)進(jìn)入error狀態(tài)。默認(rèn)值為0,表示一直處于UNREACHABLE狀態(tài)。
loose-group_replication_message_cache_size=1G # XCom cache使用的消息緩存,默認(rèn)1G,最高控制在2G。
loose-group_replication_autorejoin_tries=3 # error狀態(tài)節(jié)點(diǎn)重新加入集群的次數(shù)
通過測(cè)試案例,當(dāng)參數(shù)group_replication_member_expel_timeout和group_replication_unreachable_majority_timeout的值相同時(shí),即少數(shù)派節(jié)點(diǎn)進(jìn)入error狀態(tài)時(shí),多數(shù)派節(jié)點(diǎn)恰好選舉了新主,可以避免出現(xiàn)“雙主”的現(xiàn)象。
三、MGR參數(shù)優(yōu)化總結(jié)
[mysqld]
###### 基本參數(shù)
binlog_format = row # binlog format格式必須設(shè)為row
binlog_row_image = full
gtid_mode = on # mgr必須開啟GTID
log_slave_updates = 1
enforce_gtid_consistency = 1
binlog_gtid_simple_recovery = 1
default_storage_engine = "InnoDB" # 默認(rèn)使用innodb引擎
disabled_storage_engines = "MyISAM" # 禁用MyISAM引擎
sql_require_primary_key = ON # 所有表必須有主鍵
lower_case_table_names = 1 # 所有節(jié)點(diǎn)統(tǒng)一大小寫規(guī)則
transaction_isolation = 'READ-COMMITTED' # 隔離級(jí)別為讀提交
slave_rows_search_algorithms=INDEX_SCAN,TABLE_SCAN # 禁用HASH_SCAN,減少復(fù)制錯(cuò)誤
###### mgr參數(shù)
# 單主模式
loose-group_replication_single_primary_mode=ON
# 節(jié)點(diǎn)重啟自動(dòng)加入集群
loose-group_replication_start_on_boot = off
# 并行復(fù)制度,性能最佳
binlog_transaction_dependency_tracking = WRITESET
# 多數(shù)派30秒驅(qū)逐可疑節(jié)點(diǎn),并選主
loose-group_replication_member_expel_timeout=30
# 少數(shù)派35秒后進(jìn)入error狀態(tài)
loose-group_replication_unreachable_majority_timeout=30
# XCom cache消息緩存,大事務(wù)頻繁執(zhí)行時(shí),可適當(dāng)調(diào)至2G,可避免緩存溢出。
loose-group_replication_message_cache_size=1G
# 少數(shù)派進(jìn)入error狀態(tài)30秒后嘗試加入集群的次數(shù)
loose-group_replication_autorejoin_tries=3
# 默認(rèn)值150MB,但建議調(diào)低在20MB以內(nèi),不要使用大事務(wù)
loose-group_replication_transaction_size_limit = 20M
# 禁止壓縮
loose-group_replication_compression_threshold=0
# 關(guān)閉流控
loose-group_replication_flow_control_mode = "DISABLED"




