新节点在线加入PXC

Posted zy1234567

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了新节点在线加入PXC相关的知识,希望对你有一定的参考价值。

环境

192.168.139.151 新增节点

192.168.139.148-150 集群节点

 

192.168.139.151 已经安装好PXC软件

计划:

选用192.168.139.150 节点先与192.168.139.151组成主从节点

再转成集群节点

构建主从环境

150 节点创建主从同步账号:

mysql>create user ‘bak‘@‘192.168.139.%‘ identified by ‘123456‘;

mysql>grant replication slave on *.* to ‘bak‘@‘192.168.139.%‘;

mysql>flush privileges;

150数据拷贝至151上

#mysqldump --single-transaction -uroot -p123456 -A --master-data=2 > all.sql

#scp all.sql [email protected]:/opt/

151上恢复数据

mysql>SET GLOBAL pxc_strict_mode=PERMISSIVE;

#mysql -u root -p123456   < all.sql

151配置主从同步

#####master_log 信息可在150 使用flsuh logs ; show master status查看

 change master to master_host=‘192.168.139.150‘,master_user=‘bak‘,master_password=‘123456‘,master_log_file=‘pxc-bin.000001‘,master_log_pos=928;

151开启同步

start slave;

show slave statusG;

151配置集群

systemctl stop mysql

 

 vim /etc/my.cnf   ===>注意文件下面的include ,配置文件可能在指定路径中,my.cnf只是类似于软链

server-id=4  #与集群中其他的节点不一样

[mysqld]
# Path to Galera library
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
# Cluster connection URL contains IPs of nodes
#If no IP is found, this implies that a new cluster needs to be created,
#in order to do that you need to bootstrap this node
wsrep_cluster_address=gcomm://192.168.139.148,192.168.139.149,192.168.139.150,192.168.139.151
# 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
# Slave thread to use
wsrep_slave_threads= 8
wsrep_log_conflicts
# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera
innodb_autoinc_lock_mode=2
# Node IP address
wsrep_node_address=192.168.139.151
# Cluster name
wsrep_cluster_name=pxc-cluster
#If wsrep_node_name is not specified,  then system hostname will be used
wsrep_node_name=pxc-cluster-node-4
#pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER
pxc_strict_mode=ENFORCING
# SST method
wsrep_sst_method=xtrabackup-v2
#Authentication for SST method
srep_sst_auth="sstuser:passw0rd"
 

150检查PXC需要同步位置

mysqlbinlog -v -v mysql-bin.000001 | grep Xid   ===》找到position 对应的,没有 就在MySQL中的表随便插入什么东西,执行commit ,在查询

scp /var/lib/mysql/grastate.dat [email protected]:/var/lib/mysql/

 

151编辑文件

vim /var/lib/mysql/grastate.dat
seqno  ===> 修改成Xid对应的值
 
chown mysql:mysql /var/lib/mysql/grastate.dat
 
systemctl start mysql
 

151查看测试结果:

mysql> show status like ‘wsrep%‘;
可在其他节点插入数据,查看151节点的数据是否同步

 

















以上是关于新节点在线加入PXC的主要内容,如果未能解决你的问题,请参考以下文章

PXC加入新节点避免SST时grastate.dat文件内容的修改问题

PXC 避免加入集群时发生SST

PXC集群修改业务访问端口

MySQL PXC构建一个新节点只需IST传输的方法

PXC DDL 操作阻塞写

PXC添加新节点