Percona XtraDB Cluster叢集的安裝與配置
Percona XtraDB Cluster是針對MySQL使用者的高可用性和擴充性解決方案,基於Percona Server 。其包括了Write Set REPlication補丁,使用Galera 2.0庫,這是一個針對事務性應用程式的同步多主機複製外掛程式。
Percona XtraDB Cluster特點:
(1)同步複製,事務在所有叢集節點要麼同時提交,要麼不提交。
(2)多主複製,可以在任意一個節點寫入。
(3)從伺服器上的並行應用事件,真正的“並行複製”。
(4)自動設定節點。
(5)資料一致性,沒有不同步的從伺服器。
實驗系統:CentOS 6.6_x86_64
實驗前提:防火牆和selinux都關閉,伺服器上沒有安裝任何版本的MYSQL
實驗說明:本實驗共有3台主機,IP分配如拓撲
實驗拓撲:
一、安裝percona環境
1.配置yum源:
yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum -y epel*
2.安裝Percona軟體:
yum -y install Percona-XtraDB-Cluster-server Percona-XtraDB-Cluster-client Percona-Server-shared-compat percona-xtrabackup
3.添加賬戶:
/etc/init.d/mysql bootstrap-pxc //啟動PXC
mysql
---------------------------------------->
GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT ON *.* TO com@localhost IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
\q
<----------------------------------------
/etc/init.d/mysql stop
二、編輯PXC的節點配置:
1.在19.66上:
vim /etc/my.cnf
------------------------------------->
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.19.66,192.168.19.74,192.168.19.76"
wsrep_sst_auth=com:123456
wsrep_cluster_name=Percona
wsrep_sst_method=xtrabackup-v2
wsrep_node_address=192.168.19.66
wsrep_slave_threads=2
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2
<-------------------------------------
/etc/init.d/mysql bootstrap-pxc
2.在19.74上:
vim /etc/my.cnf
-------------------------------------->
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.19.66,192.168.19.74,192.168.19.76"
wsrep_sst_auth=com:123456
wsrep_cluster_name=Percona
wsrep_sst_method=xtrabackup-v2
wsrep_node_address=192.168.19.74
wsrep_slave_threads=2
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2
<--------------------------------------
/etc/init.d/mysql start
3.在19.76上:
vim /etc/my.cnf
-------------------------------->
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.19.66,192.168.19.74,192.168.19.76"
wsrep_sst_auth=com:123456
wsrep_node_address=192.168.19.76
wsrep_cluster_name=Percona
wsrep_sst_method=xtrabackup-v2
wsrep_slave_threads=2
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2
<--------------------------------
/etc/init.d/mysql start
4.各節點上查看狀態,保證如下幾項沒有問題:
mysql
---------------------------------------------->
SHOW STATUS LIKE '%wsrep%';
+------------------------------+----------------------------------------------------------+
| Variable_name | Value |
+------------------------------+----------------------------------------------------------+
| wsrep_local_state_uuid | a82bc530-3748-11e5-a4fc-c26f7c90839c |
...
| wsrep_local_state | 4 |
| wsrep_local_state_comment | Synced |
...
| wsrep_cluster_size | 3 |
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
...
| wsrep_ready | ON |
+------------------------------+----------------------------------------------------------+
5.測試:
在19.66上:
CREATE DATABASE jason;
USE jason;
CREATE TABLE jjj (id int ,name char(10)) engine=innodb;
COMMIT;
在19.74上:
USE jason;
INSERT INTO jjj values (1,'22');
COMMIT;
在19.76上:
USE jason;
SELECT * FROM jjj;
在任意伺服器均可讀寫,其他動作大家可以自行嘗試。至此實驗成功,謝謝!如有問題,請聯絡我,QQ:82800452
Percona XtraDB Cluster 的詳細介紹:請點這裡
Percona XtraDB Cluster 的:請點這裡
本文永久更新連結地址: