安裝配置PXC(Percona XtraDB Cluster)叢集
1、安裝percona-release包
下面操作在三臺伺服器上都執行:
建立使用者:
# groupadd mysql
# useradd -g mysql mysql
# passwd mysql
安裝資料來源:
# rpm -ivh percona-release-0.0-1.x86_64.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
裝軟體:
# yum install Percona-XtraDB-Cluster-56
2、pxc01配置:
# vi /etc/my.cnf
內容如下:
[mysqld]
# GENERAL
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
pid_file=/var/lib/mysql/mysql.pid
user=mysql
port=3306
default_storage_engine=InnoDB
character_set_server=utf8
# INNODB/XtraDB
innodb_buffer_pool_size=1610612736
innodb_log_file_size=104857600
#PXC
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.2.155,10.0.2.156,10.0.2.157
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_node_address=10.0.2.155
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_mysql_cluster
wsrep_sst_auth="sstuser:s3cret"
# LOGGING
log-error=/var/lib/mysql/mysql-error.log
slow_query_log=1
slow_query_log_file=/var/lib/mysql/mysql-slow.log
# OTHER
[client]
socket=/var/lib/mysql/mysql.sock
port=3306
# END
啟動PXC01伺服器
# su - mysql
$ /etc/init.d/mysql bootstrap-pxc
Bootstrapping PXC (Percona XtraDB Cluster)Starting MySQL (Percona XtraDB Cluster).. SUCCESS!
檢查狀態:
mysql> show status like 'wsrep%';
+------------------------------+--------------------------------------+
| Variable_name | Value |
+------------------------------+--------------------------------------+
| wsrep_local_state_uuid | 7123acbc-0ab4-11e5-b639-82c550f88127 |
| wsrep_protocol_version | 7 |
...
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
| wsrep_local_bf_aborts | 0 |
| wsrep_local_index | 0 |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy |
| wsrep_provider_version | 3.9(r93aca2d) |
| wsrep_ready | ON |
+------------------------------+--------------------------------------+
修改root密碼:
mysql> UPDATE mysql.user SET password=PASSWORD("Passw0rd") where user=’root’;
mysql> FLUSH PRIVILEGES;
建立SST使用者:
mysql> CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'sstuser';
mysql> GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
mysql> FLUSH PRIVILEGES;
2、pxc02配置:
# vi /etc/my.cnf
內容如下:
[mysqld]
# GENERAL
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
pid_file=/var/lib/mysql/mysql.pid
user=mysql
port=3306
default_storage_engine=InnoDB
character_set_server=utf8
# INNODB/XtraDB
innodb_buffer_pool_size=1610612736
innodb_log_file_size=104857600
#PXC
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.2.155,10.0.2.156,10.0.2.157
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_node_address=10.0.2.156
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_mysql_cluster
wsrep_sst_auth="sstuser:sstuser"
# LOGGING
log-error=/var/lib/mysql/mysql-error.log
slow_query_log=1
slow_query_log_file=/var/lib/mysql/mysql-slow.log
# OTHER
[client]
socket=/var/lib/mysql/mysql.sock
port=3306
啟動pxc02伺服器:
# su - mysql
$ /etc/init.d/mysql start
Stale sst_in_progress file in datadir
Starting MySQL (Percona XtraDB Cluster)State transfer in progress, setting sleep higher
... SUCCESS!
檢查狀態:
$ mysql -u root -p
mysql> show status like 'wsrep%';
+------------------------------+--------------------------------------+
| Variable_name | Value |
+------------------------------+--------------------------------------+
| wsrep_local_state_uuid | 7123acbc-0ab4-11e5-b639-82c550f88127 |
...
| wsrep_local_state_comment | Synced |
...
| wsrep_cluster_conf_id | 2 |
| wsrep_cluster_size | 2 |
| wsrep_cluster_state_uuid | 7123acbc-0ab4-11e5-b639-82c550f88127 |
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
| wsrep_local_bf_aborts | 0 |
| wsrep_local_index | 1 |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy |
| wsrep_provider_version | 3.11(ra0189ab) |
| wsrep_ready | ON |
+------------------------------+--------------------------------------+
3、PXC03伺服器配置:
# vi /etc/my.cnf
內容如下:
[mysqld]
# GENERAL
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
pid_file=/var/lib/mysql/mysql.pid
user=mysql
port=3306
default_storage_engine=InnoDB
character_set_server=utf8
# INNODB/XtraDB
innodb_buffer_pool_size=1610612736
innodb_log_file_size=104857600
#PXC
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.2.155,10.0.2.156,10.0.2.157
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_node_address=10.0.2.157
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_mysql_cluster
wsrep_sst_auth="sstuser:sstuser"
# LOGGING
log-error=/var/lib/mysql/mysql-error.log
slow_query_log=1
slow_query_log_file=/var/lib/mysql/mysql-slow.log
# OTHER
[client]
socket=/var/lib/mysql/mysql.sock
port=3306
啟動pxc03伺服器:
# su - mysql
$ /etc/init.d/mysql start
Stale sst_in_progress file in datadir
Starting MySQL (Percona XtraDB Cluster)State transfer in progress, setting sleep higher
... SUCCESS!
檢查狀態:
$ mysql -u root -p
mysql> show status like 'wsrep%';
+------------------------------+-------------------------------------------------+
| Variable_name | Value |
+------------------------------+-------------------------------------------------+
| wsrep_local_state_uuid | 7123acbc-0ab4-11e5-b639-82c550f88127 |
...
| wsrep_local_state_comment | Synced |
...
| wsrep_cluster_conf_id | 3 |
| wsrep_cluster_size | 3 |
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
| wsrep_local_bf_aborts | 0 |
| wsrep_local_index | 2 |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy |
| wsrep_provider_version | 3.11(ra0189ab) |
| wsrep_ready | ON |
+------------------------------+-------------------------------------------------+
4、測試配置結果:
在pxc02建立database
mysql> create database wjw;
在pxc03建立表
mysql> use wjw;
mysql> create table t (id int);
在pxc01插入資料:
mysql> use wjw;
mysql> insert into t values(1);
mysql> commit;
隨後在三個節點上都能查到剛建立的資料庫、表和資料。
下面操作在三臺伺服器上都執行:
建立使用者:
# groupadd mysql
# useradd -g mysql mysql
# passwd mysql
安裝資料來源:
# rpm -ivh percona-release-0.0-1.x86_64.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
裝軟體:
# yum install Percona-XtraDB-Cluster-56
2、pxc01配置:
# vi /etc/my.cnf
內容如下:
[mysqld]
# GENERAL
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
pid_file=/var/lib/mysql/mysql.pid
user=mysql
port=3306
default_storage_engine=InnoDB
character_set_server=utf8
# INNODB/XtraDB
innodb_buffer_pool_size=1610612736
innodb_log_file_size=104857600
#PXC
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.2.155,10.0.2.156,10.0.2.157
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_node_address=10.0.2.155
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_mysql_cluster
wsrep_sst_auth="sstuser:s3cret"
# LOGGING
log-error=/var/lib/mysql/mysql-error.log
slow_query_log=1
slow_query_log_file=/var/lib/mysql/mysql-slow.log
# OTHER
[client]
socket=/var/lib/mysql/mysql.sock
port=3306
# END
啟動PXC01伺服器
# su - mysql
$ /etc/init.d/mysql bootstrap-pxc
Bootstrapping PXC (Percona XtraDB Cluster)Starting MySQL (Percona XtraDB Cluster).. SUCCESS!
檢查狀態:
mysql> show status like 'wsrep%';
+------------------------------+--------------------------------------+
| Variable_name | Value |
+------------------------------+--------------------------------------+
| wsrep_local_state_uuid | 7123acbc-0ab4-11e5-b639-82c550f88127 |
| wsrep_protocol_version | 7 |
...
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
| wsrep_local_bf_aborts | 0 |
| wsrep_local_index | 0 |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy
| wsrep_provider_version | 3.9(r93aca2d) |
| wsrep_ready | ON |
+------------------------------+--------------------------------------+
修改root密碼:
mysql> UPDATE mysql.user SET password=PASSWORD("Passw0rd") where user=’root’;
mysql> FLUSH PRIVILEGES;
建立SST使用者:
mysql> CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'sstuser';
mysql> GRANT RELOAD,LOCK TABLES,REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
mysql> FLUSH PRIVILEGES;
2、pxc02配置:
# vi /etc/my.cnf
內容如下:
[mysqld]
# GENERAL
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
pid_file=/var/lib/mysql/mysql.pid
user=mysql
port=3306
default_storage_engine=InnoDB
character_set_server=utf8
# INNODB/XtraDB
innodb_buffer_pool_size=1610612736
innodb_log_file_size=104857600
#PXC
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.2.155,10.0.2.156,10.0.2.157
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_node_address=10.0.2.156
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_mysql_cluster
wsrep_sst_auth="sstuser:sstuser"
# LOGGING
log-error=/var/lib/mysql/mysql-error.log
slow_query_log=1
slow_query_log_file=/var/lib/mysql/mysql-slow.log
# OTHER
[client]
socket=/var/lib/mysql/mysql.sock
port=3306
啟動pxc02伺服器:
# su - mysql
$ /etc/init.d/mysql start
Stale sst_in_progress file in datadir
Starting MySQL (Percona XtraDB Cluster)State transfer in progress, setting sleep higher
... SUCCESS!
檢查狀態:
$ mysql -u root -p
mysql> show status like 'wsrep%';
+------------------------------+--------------------------------------+
| Variable_name | Value |
+------------------------------+--------------------------------------+
| wsrep_local_state_uuid | 7123acbc-0ab4-11e5-b639-82c550f88127 |
...
| wsrep_local_state_comment | Synced |
...
| wsrep_cluster_conf_id | 2 |
| wsrep_cluster_size | 2 |
| wsrep_cluster_state_uuid | 7123acbc-0ab4-11e5-b639-82c550f88127 |
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
| wsrep_local_bf_aborts | 0 |
| wsrep_local_index | 1 |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy
| wsrep_provider_version | 3.11(ra0189ab) |
| wsrep_ready | ON |
+------------------------------+--------------------------------------+
3、PXC03伺服器配置:
# vi /etc/my.cnf
內容如下:
[mysqld]
# GENERAL
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
pid_file=/var/lib/mysql/mysql.pid
user=mysql
port=3306
default_storage_engine=InnoDB
character_set_server=utf8
# INNODB/XtraDB
innodb_buffer_pool_size=1610612736
innodb_log_file_size=104857600
#PXC
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://10.0.2.155,10.0.2.156,10.0.2.157
binlog_format=ROW
innodb_autoinc_lock_mode=2
wsrep_node_address=10.0.2.157
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_mysql_cluster
wsrep_sst_auth="sstuser:sstuser"
# LOGGING
log-error=/var/lib/mysql/mysql-error.log
slow_query_log=1
slow_query_log_file=/var/lib/mysql/mysql-slow.log
# OTHER
[client]
socket=/var/lib/mysql/mysql.sock
port=3306
啟動pxc03伺服器:
# su - mysql
$ /etc/init.d/mysql start
Stale sst_in_progress file in datadir
Starting MySQL (Percona XtraDB Cluster)State transfer in progress, setting sleep higher
... SUCCESS!
檢查狀態:
$ mysql -u root -p
mysql> show status like 'wsrep%';
+------------------------------+-------------------------------------------------+
| Variable_name | Value |
+------------------------------+-------------------------------------------------+
| wsrep_local_state_uuid | 7123acbc-0ab4-11e5-b639-82c550f88127 |
...
| wsrep_local_state_comment | Synced |
...
| wsrep_cluster_conf_id | 3 |
| wsrep_cluster_size | 3 |
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
| wsrep_local_bf_aborts | 0 |
| wsrep_local_index | 2 |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy
| wsrep_provider_version | 3.11(ra0189ab) |
| wsrep_ready | ON |
+------------------------------+-------------------------------------------------+
4、測試配置結果:
在pxc02建立database
mysql> create database wjw;
在pxc03建立表
mysql> use wjw;
mysql> create table t (id int);
在pxc01插入資料:
mysql> use wjw;
mysql> insert into t values(1);
mysql> commit;
隨後在三個節點上都能查到剛建立的資料庫、表和資料。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26194851/viewspace-1719252/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PXC(Percona XtraDB Cluster)叢集的安裝
- PXC(Percona XtraDB Cluster)叢集安裝
- PXC(Percona-XtraDB-Cluster)5.7版本叢集安裝和使用初探
- MySQL Galera叢集搭建流程(Percona XtraDB Cluster 5.7)MySql
- mysql之 Percona XtraDB Cluster叢集執行緒模型MySql執行緒模型
- PXC(Percona XtraDB Cluster)特性和優缺點介紹
- 基於Docker搭建Percona XtraDB Cluster資料庫叢集Docker資料庫
- MySQL高可用方案-PXC(Percona XtraDB Cluster)環境部署詳解MySql
- PXC(Percona XtraDB Cluster)提供的特性,相容性和限制有哪些?
- Percona XtraDB Storage Engine安裝筆記筆記
- MySQL NDB Cluster,Galera Cluster和Percona XtraDB Cluster優缺點總結MySql
- redis偽叢集配置Cluster叢集模式Redis模式
- Percona XtraDB cluster的學習與實踐。
- docker-compose搭建percona-xtradb-cluster8.0Docker
- FastDFS 叢集 安裝 配置AST
- 丐版pxc叢集
- centos 6.9搭建pxc叢集CentOS
- MySQL叢集搭建方案(PXC)MySql
- Redis for linux原始碼&叢集(cluster)&主從(master-slave)&哨兵(sentinel)安裝配置RedisLinux原始碼AST
- PXC安裝
- Redis cluster 叢集Redis
- Redis Cluster(叢集)Redis
- CentOS上zookeeper叢集模式安裝配置CentOS模式
- 3 安裝配置oracle叢集和RACOracle
- Redis叢集 - cluster叢集、資料分片Redis
- 基於Centos7部署Percona Xtradb Cluster高可用架構CentOS架構
- Zookeeper-3.4.10 叢集的安裝配置
- 安裝配置 zookeeper (單機非叢集模式)模式
- Node js 叢集(cluster)JS
- MySQL CLUSTER(叢集)系列MySql
- 搭建redis cluster叢集Redis
- 安裝 REDIS 叢集Redis
- 安裝Kafka叢集Kafka
- azkaban叢集模式安裝與execute-as-user配置模式
- hadoop叢集內lzo的安裝與配置Hadoop
- FreeBSD下安裝配置Hadoop叢集(三)Hadoop
- Redis Cluster叢集模式部署Redis模式
- mysql cluster 7.38 叢集安裝 rpm安裝方式MySql