主機 | IP | 所需包 |
bdc212node bdc213mysql bdc214sql |
192.168.13.212bootstrap 192.168.13.213bash 192.168.13.214服務器 |
Percona-XtraBackup-2.2.12-r8726828-el6-x86_64-bundle.tarsocket Percona-XtraDB-Cluster-5.6.29-25.15-rb60e98d-el7-x86_64-bundle.tar |
上傳兩個PXC安裝所需的壓縮包到/opt目錄ide
Percona-XtraBackup-2.2.12-r8726828-el6-x86_64-bundle.tar工具
Percona-XtraDB-Cluster-5.6.29-25.15-rb60e98d-el7-x86_64-bundle.tarui
安裝PXC備份軟件
tar xvf Percona-XtraDB-Cluster-server-56-5.6.29-25.15.1.el7.x86_64.rpm rpm -ivh percona-xtrabackup-debuginfo-2.2.12-1.el6.x86_64.rpm rpm -ivh percona-xtrabackup-2.2.12-1.el6.x86_64.rpm
安裝PXC工具包
tar -xvf Percona-XtraDB-Cluster-5.6.22-25.8-r978-el6-x86_64-bundle.tar rpm -ivh Percona-XtraDB-Cluster-devel-56-5.6.29-25.15.1.el7.x86_64.rpm rpm -ivh Percona-XtraDB-Cluster-56-debuginfo-5.6.29-25.15.1.el7.x86_64.rpm rpm -ivh Percona-XtraDB-Cluster-client-56-5.6.29-25.15.1.el7.x86_64.rpm rpm -ivh Percona-XtraDB-Cluster-shared-56-5.6.29-25.15.1.el7.x86_64.rpm rpm -ivh Percona-XtraDB-Cluster-galera-3-3.15-1.rhel7.x86_64.rpm
1.4 配置my.cnf
修改/etc/my.cnf控制文件(紅色標記着重注意修改)
[client] port = 3306 socket = /var/lib/mysql/mysql.sock [mysqld] port=3306 socket= /var/lib/mysql/mysql.sock log_error=/opt/percona/error.log wait_timeout=60 interactive_timeout = 3600 character-set-server = utf8 skip-name-resolve datadir=/opt/percona/data #edit user=mysql #edit # Path to Galera library wsrep_provider=/usr/lib64/libgalera_smm.so #edit # Cluster connection URL contains the IPs of node#1, node#2 and node#3 wsrep_cluster_address=gcomm://192.168.8.212,192.168.252.213,192.168.8.214 #edit # In order for Galera to work correctly binlog format should be ROW binlog_format=ROW # MyISAM storage engine has only experimental support default_storage_engine = InnoDB # This changes how InnoDB autoincrement locks are managed and is requirement for Galera innodb_autoinc_lock_mode=2 # Node #1 address wsrep_node_address=192.168.8.212 #edit #SST method #wsrep_sst_method=rsync wsrep_sst_method=xtrabackup-v2 # Cluster name wsrep_cluster_name=my_percona_cluster #Authentication for SST method wsrep_sst_auth="sst:sst" #edit wsrep_max_ws_size=4294901759 #wsrep_max_ws_rows=13107200 wsrep_max_ws_rows=1048576 net_retry_count=10 net_write_timeout=300 net_read_timeout=180
rpm -ivh Percona-XtraDB-Cluster-server-56-5.6.24-25.11.1.el6.x86_64.rpm
注:配置my.cnf以後再安裝服務組件是爲了讓mysql按照my.cnf的配置數據目錄進行安裝。
若是是最早啓動的服務器使用
/opt/percona/support-files/mysql.server bootstrap-pxc
其餘服務器使用
/opt/percona/support-files/mysql.server start
重要:每一次啓動集羣都要從上次最後關閉的節點開始。
./mysql –uroot -p
查看集羣情況
mysql>Show status like 'wsrep%'
2.3 添加遠程同步用戶
第一個節點啓動以後第二個節點啓動以前,須要配置備份用戶,不然第二節點沒法啓動。
由於第二節點經過xtrabackup進行拉數據,須要經過配置文件中的sst用戶
CREATE USER 'sst'@'localhost' IDENTIFIED BY 'sst'; GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sst'@'localhost'; FLUSH PRIVILEGES;
二三節點軟件安裝配置與第一個節點徹底一致
3.1 修改my.cnf(其他部分設置與一節點保持一致)
vi /etc/my.cnf
wsrep_node_address=本機Ip地址
3.2 啓動mysql服務
/opt/percona/support-files/mysql.server start
3.3 啓動mysql客戶端
./mysql
3.4 查看集羣狀況
mysql>show status like 'wsrep%';