15、高可用 PXC(percona xtradb cluster) 搭建

安装环境:
集群名 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        -- 配置文件注意以下参数,并增加红色部分
  1. basedir                         =/opt/mysql/Percona-XtraDB-Cluster-5.5.37-rel35.0-25.10.756.Linux.x86_64
  2. datadir                         =/data/mysql/pxc_3308/data
  3. tmpdir                          =/data/mysql/pxc_3308/tmp
  4. server_id                      =203308
  5. #percona xtradb cluster
  6. binlog_format                  =  ROW    --日志格式必须为ROW
  7. default_storage_engine=InnoDB
  8. innodb_locks_unsafe_for_binlog=1
  9. innodb_autoinc_lock_mode=2
  10. wsrep_cluster_name=pcx_lk    --cluster的名字
  11. wsrep_cluster_address=gcomm://192.168.1.20,192.168.1.21,192.168.1.22    --集群中所有node-ip
  12. wsrep_node_address=192.168.1.20        --每个节点配置为自己的ip
  13. wsrep_provider=/usr/local/pxc_3308/lib/libgalera_smm.so
  14. #wsrep_sst_method=rsync
  15. wsrep_sst_method=xtrabackup
  16. 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
  1. basedir=/opt/mysql/Percona-XtraDB-Cluster-5.5.37-rel35.0-25.10.756.Linux.x86_64
  2. 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
 
 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。