安装环境:
集群名 |
pxc_lk |
节点1: |
192.168.1.20 |
节点2: |
192.168.1.21 |
节点3: |
192.168.1.22 |
所有节点安装
yum install perl-DBD-MySQL
yum install perl-IO-Socket-SSL.noarch
yum install socat
yum install nc
所有节点安装pxc数据库
cd /opt/mysql/
tar -zxvf /root/Percona-XtraDB-Cluster-5.5.37-rel35.0-25.10.756.Linux.x86_64.tar.gz
ln -s /opt/mysql/Percona-XtraDB-Cluster-5.5.37-rel35.0-25.10.756.Linux.x86_64/ /usr/local/pxc_3308
配置文件要放在默认的/etc/my.cnf
vi /etc/my.cnf -- 配置文件注意以下参数,并增加红色部分
basedir =/opt/mysql/Percona-XtraDB-Cluster-5.5.37-rel35.0-25.10.756.Linux.x86_64
datadir =/data/mysql/pxc_3308/data
tmpdir =/data/mysql/pxc_3308/tmp
server_id =203308
#percona xtradb cluster
binlog_format = ROW
--日志格式必须为ROW
default_storage_engine=InnoDB
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2
wsrep_cluster_name=pcx_lk
--cluster的名字
wsrep_cluster_address=gcomm://192.168.1.20,192.168.1.21,192.168.1.22 --集群中所有node-ip
wsrep_node_address=192.168.1.20 --每个节点配置为自己的ip
wsrep_provider=/usr/local/pxc_3308/lib/libgalera_smm.so
#wsrep_sst_method=rsync
wsrep_sst_method=xtrabackup
wsrep_sst_auth=sst:wubxwubx --运输的用户
mkdir -p /data/mysql/pxc_3308/{data,tmp,logs}
chown -R mysql:mysql /data/mysql
ln -sf /usr/lib64/libssl.so.10 /usr/lib64/libssl.so.6
ln -sf /usr/lib64/libcrypto.so.10 /usr/lib64/libcrypto.so.6
cd /opt/mysql/Percona-XtraDB-Cluster-5.5.37-rel35.0-25.10.756.Linux.x86_64/
./scripts/mysql_install_db --datadir=/data/mysql/pxc_3308/data
cp support-files/mysql.server /etc/init.d/mysql-pxc
vi /etc/init.d/mysql-pxc
basedir=/opt/mysql/Percona-XtraDB-Cluster-5.5.37-rel35.0-25.10.756.Linux.x86_64
datadir=/data/mysql/pxc_3308/data
第一个节点启动:
# /etc/init.d/mysql-pxc bootstrap-pxc --不能用mysqld启动
启动后,进入mysql创建用户
(testing)root@localhost [(none)]> grant all privileges on *.* to ‘sst‘@‘%‘ identified by ‘wubxwubx‘;
(testing)root@localhost [(none)]> grant reload,lock tables ,replication client on *.* to ‘sst‘@‘localhost‘ identified by ‘wubxwubx‘;
(testing)root@localhost [(none)]> flush privileges;
然后启动其他节点:
# /etc/init.d/mysql-pxc start