Docker部署MySQL-PXC5.6叢集
阿新 • • 發佈:2021-11-09
節點 | IP |
---|---|
node1 | 10.3.192.29 |
node2 | 10.3.192.30 |
node3 | 10.3.192.31 |
官方文件
https://www.percona.com/doc/percona-xtradb-cluster/5.6/index.html
Benefits:
- When you execute a query, it is executed locally on the node. All data is available locally, no need for remote access.
- No central management. You can loose any node at any point of time, and the cluster will continue to function.
- Good solution for scaling a read workload. You can put read queries to any of the nodes.
本叢集採用多主同步結構(multi-master),部署3個master節點,任意一個節點上都可以進行讀寫操作。
叢集特性
- 實現mysql資料庫叢集架構的高可用性和資料的強一致性。
- 完成了真正的多節點讀寫的叢集方案。
- 改善了傳統意義上的主從複製延遲問題,真正達到了實時同步。
- 新加入的節點可以自動部署,無須提供手動備份,維護起來很方便。
- 由於是多節點寫入,所以資料庫故障切換很容易。
叢集架構
部署步驟
node1
./docker-compose -f MySQL-PXC-MASTER.yaml up -d version: "3.7" services: MySQLPXC_node: image: 1573927589/mysql:percona-xtradb-cluster-5.6.50 network_mode: "host" restart: always environment: MYSQL_ROOT_PASSWORD: "Single&2020" CLUSTER_NAME: "PXC" XTRABACKUP_PASSWORD: 123456 MYSQL_USER: "single" MYSQL_PASSWORD: "Single&2020" MYSQL_DATABASE: "scplatform_node" command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci' ] volumes: - mysqldata:/var/lib/mysql
node2
export MASTER_IP=10.3.192.29 docker-compose -f MySQL-PXC-node.yaml up -d version: "3.7" services: MySQLPXC_node: image: dockerhub.test.wacai.info/fmpc/percona-xtradb-cluster:5.6.50 network_mode: "host" restart: always environment: MYSQL_ROOT_PASSWORD: "Single&2020" CLUSTER_NAME: "PXC" XTRABACKUP_PASSWORD: 123456 CLUSTER_JOIN: $MASTER_IP MYSQL_USER: "single" MYSQL_PASSWORD: "Single&2020" command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci' ] volumes: - mysqldata:/var/lib/mysql
node3
和node2一樣
叢集擴容
增加一個部署節點即可
export MASTER_IP=10.3.192.29
docker-compose -f MySQL-PXC-node.yaml up -d