Percona XtraDB Cluster Installation Guide

來源:互聯網
上載者:User

標籤:複製   第一個   名稱   即時同步   ati   storage   sha   cal   http   

Percona XtraDB Cluster(簡稱PXC)叢集是基於Galera,事務型應用下的通用的多主同步複製外掛程式,主要用於解決強一致性問題,使得各個節點之間的資料保持即時同步以及實現多節點同時讀寫。提高了資料庫的可靠性,也可以實現讀寫分離,是MySQL關係型資料庫中大家公認的叢集優選方案之一。

1、安裝PXC軟體包

這裡使用的是官方最新的軟體包Percona XtraDB Cluster 5.7.22-29.26,對應的作業系統是Oracle Linux 7.5。主機列表如下表所示:

在各個節點分別使用yum進行安裝,如下:

[[email protected] ~]# yum -y install Percona-XtraDB-Cluster-57[[email protected] ~]# yum -y install Percona-XtraDB-Cluster-57[[email protected] ~]# yum -y install Percona-XtraDB-Cluster-57

安裝完成後,分別啟動各個節點的MySQL服務,更改[email protected]的密碼,更改完成後再關閉MySQL服務。以mydb03作為樣本,如下:

[[email protected] ~]# grep ‘temporary password‘ /var/log/mysqld.log[[email protected] ~]# mysql -uroot -pmysql> alter user [email protected] identified by “[email protected]”;mysql> flush privileges;
2、編輯PXC設定檔

編輯/etc/percona-xtradb-cluster.conf.d/mysqld.cnf檔案,修改或者加入如下內容:

#mydb03對應1,mydb04對應2,mydb05對應3server-id=1     expire_logs_days=1log_timestamps=systemcollation-server=utf8_general_cicharacter-set-server = utf8

編輯/etc/percona-xtradb-cluster.conf.d/wsrep.cnf檔案,修改以下內容:

[mysqld]wsrep_provider=/usr/lib64/galera3/libgalera_smm.so#加入各個節點的IPwsrep_cluster_address=gcomm://192.168.120.129,192.168.120.130,192.168.120.131binlog_format=ROWdefault_storage_engine=InnoDBwsrep_slave_threads= 8wsrep_log_conflictsinnodb_autoinc_lock_mode=2#節點主機名稱,其他節點需要更改wsrep_node_name=mydb03#節點IP,其他節點需要更改wsrep_node_address=192.168.120.129#叢集名稱wsrep_cluster_name=pxc-clusterpxc_strict_mode=ENFORCINGwsrep_sst_method=xtrabackup-v2#sstuser使用者的密碼任意設定wsrep_sst_auth="sstuser:passw0rd"
3、啟動PXC叢集服務

首先在mydb03上啟動PXC叢集服務,其它節點後續再加進來即可。

[[email protected] ~]# systemctl start [email protected][[email protected] ~]# mysql -uroot -pmysql> show status like ‘wsrep%‘;


建立設定檔裡定義的sstuser使用者(只在第一個啟動的節點執行,其他節點啟動後會自行同步)。

mysql> CREATE USER ‘sstuser‘@‘localhost‘ IDENTIFIED BY ‘passw0rd‘;mysql> GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO ‘sstuser‘@‘localhost‘;mysql> FLUSH PRIVILEGES;

將其它節點加入叢集,只要啟動MySQL服務即可。

[[email protected] ~]# systemctl start mysqld[[email protected] ~]# systemctl start mysqld

叢集狀態驗證:

mysql> show status like ‘%wsrep_clust%‘;

4、PXC同步測試

任意一節點建立表或者資料庫,在其他節點查詢驗證:

[[email protected] ~]# mysql -uroot -pmysql> create database xdb;[[email protected] ~]# mysql -uroot -pmysql> show databases;

Percona XtraDB Cluster Installation Guide

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.