Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication


Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication

Overview

Galera Cluster

  • 由 Codership 開發 官網
  • 包含在MariaDB,在Percona、MySQL 都可以使用

Galera Cluster 是一個基於 InnoDB 多主的同步復制,可以讀寫任何節點,即使失去任何一個節點也不影響業務中斷,而且無需復雜的 failover 操作。

Percona XtraDB Cluster

  • 由 Percona 開發,在 Galera 基礎打 Patch [官網](https://www.percona.com/software/mysql- database/percona-xtradb-cluster)
  • 自 2012 年 4 月可用
  • 附加的特性
    • PFS 擴展支持
    • SST/XtraBackup 方式的改變
    • PXC Strict mode *
    • ProxySQL 集成 *
    • 提升性能 *

MySQL Group Replication

  • 由 Oracle 官方開發
  • 2016 年 12 月 MySQL 5.7.17 發布 GA
  • MySQL InnoDB Cluster 整體解決方案

MySQL Group Replication 是一個 MySQL Server Plugin,提供分布式狀態機復制與 Server 強大協調,當在一個 Group Replication 時,Server 將自動協調,每個節點都可以自動處理更新,自動檢測,有一個 membership service 維護一個 view,記錄組內 記錄可見成員在某個時間點一致性和高可用性的,當任何一個成加入或離開,view 就會相應的更新

MySQL InnoDB Cluster

 
-w610

Similarities

  • MySQL/MariaDB
  • 復制方法
  • 所有節點都有全部的數據 - 讀僅發生在當前本地節點
  • 都需要 InnoDB/XtraDB 引擎
  • 都支持 多主的拓撲 (Active-active multi-master Topology)
    • 寫多主節點
    • 不需要復雜的 Failover 操作
  • 節點管理,加入和離開都是完全自動處理的
  • 執行和寫都是按全局的順序進行的
  • 數據一致性
  • 樂觀鎖 / 最早提交的先贏
  • Quorum - 防止腦裂

Similar - Use Cases

  • 嚴格的持久化環境
  • 同時定入多個節點,保證數據一致性
  • 減少故障轉移時間 (Reduce failover time)

Similar Limitation

  • 大事務或長事務
    • 很大的可能失敗
    • 大事務導致在有效事務
  • 熱點,多個節點更新同一行數據
  • 只有一個節點寫,是最好的解決方案

Differences GR & Galera

  • Group Communication System 組通信系統
  • Binlogs & Gcache
  • Node Provisioning 節點配置
  • GTID vs Seqno
  • Partition Handling 分區控制
  • Full Solution or Plugin
  • Flow Control 流控制
  • WAN Support
  • OS Support
  • Schema Changes DDL

Group Communication System 組通信系統

  • Galera

    • 標志的單環順序 Totem Single-ring Ordering
    • 所有節點都必須有 ACK 消息
  • MySQL Group Replication

    • 基於 Paxos
    • Paxos 只要求大多數 ACK 消息

Binlogs & Gcache

  • Galera Cluster/PXC

    • uses binlog row events
    • but does not require binary logging
    • writes events to Gcache (con gurable size)
  • MySQL Group Replication

    • requires binary logging

Node Provisioning 節點配置

  • Galera Cluster/PXC

    • has State Snapshot Transfer (SST) 全量同步
      • Percona XtraBackup (Recommended)
      • rsync
      • mysqldump
    • incremental State Transfer (IST) using GCache 增量同步
  • MySQL Group Replication

    • 沒有自動全量同步,除非保留所有 Binlog
    • 用於同步的異步復制通道

GTID vs. Seqno

  • Galera Cluster/PXC

    • has a seqno which is a incrementing number
  • MySQL Group Replication

    • 依賴 MySQL GTID
    • writes to a cluster create GTID events on the GR Cluster UUID

Partition Handling

  • Galera Cluster/PXC

    • A partitioned node will refuse reads/writes (con gurable)
    • A partitioned node will automatically recover and rejoin
  • MySQL Group Replication

    • A partitioned node will accept reads
    • A partitioned node will accept write requests, but will hang forever
    • A partitioned node needs to be manually rejoined to the cluster

Full Solution or Plugin

  • Plugin

    • Group Replication is a 'Replication Plugin'
    • several split brain bugs in current code ( fixes pending!)
  • Solution

    • Galera Cluster 不處理應用連接
    • 與 GR 相比有更強的防止腦裂
    • MySQL InnoDB Cluster (w. MySQLRouter)
  • Full Solution

    • Percona XtraDB Cluster (w. ProxySQL)
    • 集成 ProxySQL
    • 嚴格的 mode,防止使用限制

Flow Control 流控制

防止太慢的節點,被落下太遠

  • Galera Cluster/PXC

    • 當一個節點慢到一個限制,阻止所有節點寫
    • Flow Control 的消息已經發送
    • low defaults; Galera: 16(*), PXC: 100
    • Tell others to stop writes
  • MySQL Group Replication

    • 每個節點都有每個成員的統計信息
    • 每個獨立的節點決定寫的閾值
    • high default: 25000
    • 如果有節點太慢,其他節點放慢寫速度

WAN Support

  • Galera Cluster/PXC

    • 投票權重
    • 調節網絡通信設置
    • 減少分段網絡流量
    • 仲裁人
  • MySQL Group Replication

    • 不建議在 WAN 上使用

OS Support

  • Galera

    • FreeBSD & Linux
  • Galera Cluster/PXC

    • Linux
  • MySQL Group Replication

    • Linux, Windows, Solaris, OSX, FreeBSD

Schema Changes - DDL

  • Galera Cluster/PXC

    • Total Order Isolation
    • All writes will be blocked during Writes on other nodes will be terminated
    • Workarounds 變通辦法
      • pt-online-schema-change
      • wsrep_osu_method=RSU
        • 更多的操作工作
        • 並不是所有 DDL 可行
  • MySQL Group Replication

    • DDL 並不會阻塞寫,像平常使用一樣
    • 僅建議在單主模式下使用 (因為 DDL 並沒有沖突檢測)

Differences PXC & Galera

  • 擴展 PFS 支持
  • SST/XtraBackup 方式的改變
  • Bug-Fixes
  • PXC Strict Mode - PXC 嚴格的 Mode
  • ProxySQL 集成
  • 性能提升

PXC Strict Mode

預防實驗性或不支持的特性

  • 僅支持 InnoDB 的操作
  • 預防修改 binlog_format!=ROW
  • 需要 Table 有主鍵
  • 禁用不支持的特性
    • GET_LOCK,LOCK TABLES,CTAS
    • FLUSH TABLES <tables> WITH READ LOCK
    • tx_isolation=SERIALIZABLE

ProxySQL 集成

ProxySQL 在 PXC 當負載均衡的角色

  • proxysql-admin 配置工具

  • ProxySQL schedulers

    • 健康檢查
    • 重新配置節點
  • PXC 維護模式

    • tell load balancer to rebalance load

性能提升

  • 可伸縮性 fixs PXC 5.7.17

  • 新的默認值

    • gcs.fc_limit=100
    • evs.send_window=10
    • evs.user_send_window=4

[圖片上傳失敗...(image-b39cb1-1513951864372)]

Limitations

  • Galera Cluster/PXC

    • InnoDB/XtraDB Only
    • tx_isolation=SERIALIZABLE
    • GET_LOCK()
    • LOCK TABLES
    • SELECT ... FOR UPDATE
    • Careful with ALTER TABLE ... IMPORT/EXPORT
    • Capped maximum transaction size 最大事務
    • XA transactions
  • Group Replication

    • InnoDB/XtraDB Only
    • tx_isolation=SERIALIZABLE
    • GET_LOCK()
    • LOCK TABLES
    • SELECT ... FOR UPDATE
    • CarefulwithALTER TABLE ... IMPORT/EXPORT.
    • Careful with large transactions
    • no support for tables with multi-level foreign key dependencies, can create inconsistencies

Known Issues

Galera Cluster/PXC Issues

  • Crashes due to background thread handling trx
    processing

    • mysql-wsrep#306: stored procedure aborts
    • mysql-wsrep#305: event scheduler
    • mysql-wsrep#304: local scope functions such as CURRENT_USER()
  • Various crashes related to DDL

    • mysql-wsrep#301:runningSHOW CREATE TABLE in multiple nodes with DDL can cause crash.
    • mysql-wsrep#275: Aborting trx leaves behind open tables in cache can cause crash
  • Concurrent DDLs using wsrep_OSU_method=RSU crash/inconsistency issues

    • mysql-wsrep#283 & mysql-wsrep#282
  • Shutdown issues

    • mysql-wsrep#303: cleanup during shutdown fails to clear the EXPLICT MDL locks (FTWRL)
    • mysql-wsrep#273: Not getting clean shutting down message if we start the server with unknown variable
    • mysql-wsrep#279: Trying to access stale binlog handler leads to crash

Group Replication Issues

分區容忍問題,不能防止腦裂

* #84727: partitioned nodes still accept writes: queries hang (~Fixed in 5.7.20) * #84728: GR failure at start still starts MySQL (~Fixed in 8.0.2) * #84729: block reads on partitioned nodes * #84733: not possible to start with super_read_only=1 (Fixed in 8.0.2) * #84784: Nodes Do Not Reconnect * #84795: STOP GROUP_REPLICATION sets super_read_only=off 

減少沖突

* #84731: mysql client connections get stuck during GR start 

穩定性

* #84785: Prevent Large Transactions in Group Replication (~Fixed in 5.7.19) * #84792: Member using 100% CPU in idle cluster (*) * #84796: GR Member status is wrong 

可用性

* #84674: unresolved hostnames block GR from starting (~Fixed in 5.7.18) * #84794: cannot kill query that is stuck inside GR * #84798: Group Replication can use some verbosity in the error log 

Q & A

這個看原 PDF 吧。

Performance Tests


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM