PXC5.7(Percona XtraDB Cluster)集群部署

PXC三节点安装:

node1:10.157.26.132

node2:10.157.26.133

node3:10.157.26.134

 

配置服务器ssh登录无密码验证

ssh-keygen实现三台主机之间相互免密钥登录,保证三台主机之间能ping通

1)在所有的主机上执行:

# ssh-keygen -t rsa

2)将所有机子上公钥(id_rsa.pub)导到一个主机的/root/.ssh/authorized_keys文件中,然后将authorized_keys分别拷贝到所有主机上

cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

ssh 10.157.26.133 cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

ssh 10.157.26.134 cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

scp /root/.ssh/authorized_keys 10.157.26.133:/root/.ssh/authorized_keys

scp /root/.ssh/authorized_keys 10.157.26.134:/root/.ssh/authorized_keys

测试:ssh 10.157.26.133/10.157.26.134

 

安装依赖包:

yum install -y git scons gcc gcc-c++ openssl check cmake bison boost-devel asio-devel libaio-devel ncurses-devel readline-devel pam-devel socat

若socat无法用yum安装,可下载源码包安装

wget 

tar zxvf socat-1.7.3.2.tar.gz

cd socat-1.7.3.2

./configure

make && make install

 

1、将二进制包解压,添加mysql账号,做软连接【三个节点都要操作】:

wget https://www.percona.com/downloads/Percona-XtraDB-Cluster-LATEST/Percona-XtraDB-Cluster-5.7.17-29.20/binary/tarball/Percona-XtraDB-Cluster-5.7.17-rel13-29.20.3.Linux.x86_64.ssl101.tar.gz

mkdir /opt/mysql

cd /opt/mysql

tar zxvf /data/src/Percona-XtraDB-Cluster-5.7.17-rel13-29.20.3.Linux.x86_64.ssl101.tar.gz

cd /usr/local

ln -s /opt/mysql/Percona-XtraDB-Cluster-5.7.17-rel13-29.20.3.Linux.x86_64.ssl101/ mysql

groupadd mysql

useradd -M -g mysql -s /sbin/nologin/ -d /usr/local/mysql mysql

 

2、新建文件夹请授权【三个节点都要操作】 :

mkdir -p /data/mysql/mysql_3306/{data,logs,tmp}

mkdir -p /data/mysql/mysql_3306/logs/binlog

chown -R mysql:mysql /data/mysql/

chown -R mysql:mysql /usr/local/mysql

 

3、配置文件my.cnf

132的配置文件:

     default_storage_engine=Innodb

     #pxc

     wsrep_provider = /usr/local/mysql/lib/libgalera_smm.so    #库文件位置

     wsrep_cluster_address = gcomm://10.157.26.132,10.157.26.133,10.157.26.134    #集群中所有节点的ip

     wsrep_node_name = node132     #本节点的名字

     wsrep_node_address = 10.157.26.132    #本节点的ip 

     wsrep_cluster_name = pxc_sampson    #集群名字

     wsrep_sst_auth = sst:sampson     #sst模式需要的用户名和密码

     wsrep_sst_method = xtrabackup-v2     #采用什么方式复制数据。还支持mysqldump,rsync

     wsrep_slave_threads = 2     # 开启的复制线程数,建议cpu核数*2 ,解决apply_cb跟不上问题

     pxc_strict_mode = ENFORCING     #pxc严厉模式,还有DISABLED、PERMISSIVE、MASTER可选

     innodb_autoinc_lock_mode = 2     #自增锁的优化

     wsrep_provider_options = "debug=1;gcache.size=1G"     #打开调试模式

133的配置文件:

     default_storage_engine=Innodb

     #pxc

     wsrep_provider = /usr/local/mysql/lib/libgalera_smm.so

     wsrep_cluster_address = gcomm://10.157.26.132,10.157.26.133,10.157.26.134

     wsrep_node_name = node133

     wsrep_node_address = 10.157.26.133

     wsrep_cluster_name = pxc_sampson

     wsrep_sst_auth = sst:sampson

     wsrep_sst_method = rsync

     wsrep_slave_threads = 2

     pxc_strict_mode = ENFORCING

     innodb_autoinc_lock_mode = 2

     wsrep_provider_options = "debug=1;gcache.size=1G"

134的配置文件:

     default_storage_engine=Innodb

     #pxc

     wsrep_provider = /usr/local/mysql/lib/libgalera_smm.so

     wsrep_cluster_address = gcomm://10.157.26.132,10.157.26.133,10.157.26.134

     wsrep_node_name = node134

     wsrep_node_address = 10.157.26.134    

     wsrep_cluster_name = pxc_sampson

     wsrep_sst_auth = sst:sampson

     wsrep_sst_method = rsync

     wsrep_slave_threads = 2  

     pxc_strict_mode = ENFORCING

     innodb_autoinc_lock_mode = 2

     wsrep_provider_options = "debug=1;gcache.size=1G"

 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/a85134239bca6b44909bdcf601655fc7.html