大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说Percona-XtraDB,希望您对编程的造诣更进一步.
PXC(Percona-XtraDB-Cluster)5.7版本集群部署
Centos 7.3系统部署Mysql 集群
PXC三个节点分别执行和安装
(1)配置hosts
cat /etc/hosts
172.16.2.10 node1
172.16.2.11 node2
172.16.2.12 node3
(2)依赖
yum –y remove mariadb-*
yum -y install gcc gcc-c++ perl-IO-Socket-SSL.noarch perl-DBD-MySQL.x86_64 perl-Time-HiRes openssl* openssl-devel libcurl-devel wget
代码100分
(3)下载Percona XtraBackup 2.4
代码100分wget https://www.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.10/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.10-1.el7.x86_64.rpm yum -y localinstall percona-xtrabackup-24-2.4.10-1.el7.x86_64.rpm
(4)安装Percona Release和Socat
yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
(5)安装PXC 5.7二进制包
代码100分wget https://www.percona.com/downloads/Percona-XtraDB-Cluster-LATEST/Percona-XtraDB-Cluster-5.7.21-29.26/binary/tarball/Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl1:102.tar.gz
tar -xf Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl1_102.tar.gz -C /usr/local/
mv /usr/local/Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl1:102 /usr/local/mysql
useradd -s /sbin/nologin mysql
chown mysql.mysql -R /usr/local/mysql
mkdir -p /data/mysql/data
chown mysql.mysql -R /data/mysql/
echo “export PATH=/usr/local/mysql/bin:$PATH” > /etc/profile.d/mysql.sh
source /etc/profile.d/mysql.sh
先配置第一台机器,并成功启动,在配置其他两台
在第一台主机上创建配置文件:
vim /etc/my.cnf [client] port = 3306 socket= /data/mysql/mysql.sock default-character-set=utf8 [mysqld] basedir = /usr/local/mysql datadir = /data/mysql/data pid-file = /data/mysql/mysql.pid character-set-server=utf8 init_connect = "SET NAMES utf8" log-bin=/data/mysql/log_bin server-id = 101 innodb_buffer_pool_size = 100M innodb_data_file_path = ibdata1:10M:autoextend innodb_data_home_dir = /data/mysql innodb_file_per_table=1 skip-name-resolve port = 3306 socket = /data/mysql/mysql.sock user=mysql log_error=mysql_error.log #pxc binlog_format=ROW wsrep_cluster_address=gcomm://172.16.2.10,172.16.2.11,172.16.2.12 #三个节点都保持一样 wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so wsrep_node_address=172.16.2.10 #根据不同的node ip进行修改 wsrep_slave_threads=2 wsrep_cluster_name=pxc_mysql #同一个cluster此值需要一致 wsrep_sst_method=xtrabackup-v2 wsrep_node_name=node_1 #不同节点修改为不同的名字 innodb_autoinc_lock_mode=2 wsrep_sst_auth="sstuser:pxcmysql" log-slave-updates [mysql] no-auto-rehash default-character-set=utf8
把这个文件写好了,传到其他两台机器的 /etc 下面,
每个主机的server-id 和wsrep_node_address、wsrep_node_name保持不同即可
初始化mysql5.7:(初始化只在第一个节点执行)
mysqld --initialize --user=mysql --datadir=/data/mysql/data
初始化参数使用–initialize-insecure,这样不会设置初始化root密码,如果是 –initialize的话,会随机生成一个密码
grep “password” /data/mysql/data/error.log
启动pxc mysql5.7
node1上:
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --wsrep-new-cluster --user=mysql &
新建传送用户:
grant all privileges on *.* to "sstuser"@"localhost" identified by "pxcmysql";(一定要localhost) flush privileges;
查看集群状态
show status like "wsrep%";
其他节点安装,具体步骤查看前面步骤
scp percona-xtrabackup-24-2.4.10-1.el7.x86_64.rpm 172.16.2.11:/root
scp percona-xtrabackup-24-2.4.10-1.el7.x86_64.rpm 172.16.2.12:/root
scp Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl1_102.tar.gz 172.16.2.11:/root
scp Percona-XtraDB-Cluster-5.7.21-rel20-29.26.1.Linux.x86_64.ssl1_102.tar.gz 172.16.2.12:/root
scp /etc/my.cnf 172.16.2.11:/etc/
scp /etc/my.cnf 172.16.2.12:/etc/
node2和node3启动(无需初始化)
/usr/local/mysql/bin/mysqld_safe –-defaults-file=/etc/my.cnf &
在PXC部署集群多次踩坑:
(1)按照官网文档/etc/init.d/mysql bootstrap-pxc 启动一直失败
解决:一开始怀疑是PXC版本问题,换了二个5.7小版本还是一样报错,最后使用/usr/local/mysql/bin/mysqld_safe 模式启动成功
(2)启动jnode3节点报错:[ERROR] WSREP: Command did not run: wsrep_sst_xtrabackup-v2 –role “donor” –address “172.16.2.12:4444/xtrabackup_sst
解决:修改node3配置文件,用wsrep_sst_method = rsync启动,正常启动后同步数据完成,shutdown node2;然后修改node2的wsrep_sst_method = xtrabackup-v2,可以正常启动数据同步
以上解决方法希望对你有所帮助,解决方法来之不易,作者多次实验。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/10344.html