操作系统CentOS 6.5 minimal
node1:192.168.2.54
node2:192.168.2.55
node3:192.168.2.56
一、添加repo源和epel源
在三台节点上运行:
#yum -y install />
#rpm -ivh />
二、安装
在三台节点上运行
安装依赖包
#yum -y install socat.x86_64
安装Percona-XtraDB-Cluster
#yum install Percona-XtraDB-Cluster-56
配置第一台节点
percona1:
在my.cnf配置文件添加以下配置参数
#vim my.cnf
# Path to Galera library
wsrep_provider=/usr/lib64/libgalera_smm.so
#
# # Cluster connection URL contains the IPs of node#1, node#2 and node#3
wsrep_cluster_address=gcomm://192.168.2.54,192.168.2.55,192.168.2.56
#
# # 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 a requirement for Galera
innodb_autoinc_lock_mode=2
#
# # Node #1 address
wsrep_node_address=192.168.2.54
#
# # SST method
wsrep_sst_method=xtrabackup-v2
#
# # Cluster name
wsrep_cluster_name=my_centos_cluster
#
# # Authentication for SST method
wsrep_sst_auth="sstuser:s3cret"
启动第一台节点
# /etc/init.d/mysql bootstrap-pxc
Bootstrapping PXC (Percona XtraDB Cluster)Starting MySQL (Percona XtraDB Cluster). SUCCESS!
# /etc/init.d/mysql start 启动mysql服务
为root用户设置密码
mysql@percona1> UPDATE mysql.user SET password=PASSWORD("Passw0rd") where user=’root’;
mysql@percona1> FLUSH PRIVILEGES;
添加sst用户
mysql@percona1> CREATE USER ’sstuser’@’localhost’ IDENTIFIED BY ’s3cret’;
mysql@percona1> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO ’sstuser’@’localhost’;
mysql@percona1> FLUSH PRIVILEGES;
percona2:
在my.cnf配置文件添加以下配置参数
#vim my.cnf
# Path to Galera library
wsrep_provider=/usr/lib64/libgalera_smm.so
#
# # Cluster connection URL contains the IPs of node#1, node#2 and node#3
wsrep_cluster_address=gcomm://192.168.2.54,192.168.2.55,192.168.2.56
#
# # 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 a requirement for Galera
innodb_autoinc_lock_mode=2
#
# # Node #1 address
wsrep_node_address=192.168.2.55
#
# # SST method
wsrep_sst_method=xtrabackup-v2
#
# # Cluster name
wsrep_cluster_name=my_centos_cluster
#
# # Authentication for SST method
wsrep_sst_auth="sstuser:s3cret"
启动数据库
# /etc/init.d/mysql start
percona3:
在my.cnf配置文件添加以下配置参数
#vim my.cnf
# Path to Galera library
wsrep_provider=/usr/lib64/libgalera_smm.so
#
# # Cluster connection URL contains the IPs of node#1, node#2 and node#3
wsrep_cluster_address=gcomm://192.168.2.54,192.168.2.55,192.168.2.56
#
# # 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 a requirement for Galera
innodb_autoinc_lock_mode=2
#
# # Node #1 address
wsrep_node_address=192.168.2.56
#
# # SST method
wsrep_sst_method=xtrabackup-v2
#
# # Cluster name
wsrep_cluster_name=my_centos_cluster
#
# # Authentication for SST method
wsrep_sst_auth="sstuser:s3cret"
#
启动数据库
/etc/init.d/mysql start
三、测试数据同步情况
percona2:
mysql> create database percona;
percona1:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| percona |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
可以看到,数据同步过来了