标签:主从 replica myisam hang contain galera replicat man mode
环境
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 root@192.168.139.151:/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 status\G;
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 root@192.168.139.151:/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
标签:主从 replica myisam hang contain galera replicat man mode
原文地址:https://www.cnblogs.com/zy1234567/p/10201752.html