Percona-XtraDB-Cluster环境

单个物理server上部署的3个节点


一、相关软件安装


#安装前确认源安装mysql已经卸载

#rpm -qa |grep mysql*

#rpm -e --nodeps mysql-server-5.1.73-5.el6_6 mysql-libs-5.1.73-5.el6_6 mysql-5.1.73-5.el6_6 mysql-devel-5.1.73-5.el6_6


yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm

yum -y install wget

wget http://www.convirture.com/repos/deps/RHEL/6.x/x86_64/socat-1.7.1.3-1.el6.rf.x86_64.rpm

yum -y install tcp_wrappers

rpm -ivh socat-1.7.1.3-1.el6.rf.x86_64.rpm 

yum -y install Percona-XtraDB-Cluster-56


二、初始化及配置设定


附:[my.4000.cnf] 记得将其他两个配置文件做相应修改

#--------------------------------------------------------------------------------

#

[mysqld]

datadir=/var/lib/mysql4000

socket=/var/lib/mysql4000/mysql.sock

user=mysql

port=4000

character_set_server = utf8

#Path to Galera library 

wsrep_provider=/usr/lib64/libgalera_smm.so


#Cluster connection URL contains IPs of node#1,node#2,and node#3 

#wsrep_cluster_address=gcomm://192.168.1.224

wsrep_cluster_address='gcomm://192.168.1.224:5030,192.168.1.224:6030'

wsrep_sst_receive_address=192.168.1.224:4020

wsrep_node_incoming_address=192.168.1.224

wsrep_slave_threads=2

wsrep_provider_options = "gmcast.listen_addr=tcp://192.168.1.224:4030;"

#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 #2 address 

wsrep_node_address=192.168.1.224


#Cluster name 

wsrep_cluster_name=my_cluster


#SST method 

#wsrep_sst_method=xtrabackup-v2

wsrep_sst_method=rsync

wsrep_node_name=node4000

innodb_locks_unsafe_for_binlog=1


# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0


[mysqld_safe]

log-error=/var/log/mysqld4000.log

pid-file=/var/run/mysqld/mysqld4000.pid


#--------------------------------------------------------------------------------


mysql_install_db --user=mysql --datadir=/var/lib/mysql4000 --defaults-file=/etc/my.4000.cnf

mysql_install_db --user=mysql --datadir=/var/lib/mysql5000 --defaults-file=/etc/my.5000.cnf

mysql_install_db --user=mysql --datadir=/var/lib/mysql6000 --defaults-file=/etc/my.6000.cnf


三、PXC的启动


/usr/bin/mysqld_safe --defaults-file=/etc/my.4000.cnf --wsrep-new-cluster &

/usr/bin/mysqld_safe --defaults-file=/etc/my.5000.cnf &

/usr/bin/mysqld_safe --defaults-file=/etc/my.6000.cnf &


四、后续的相关测试