mysql 8 33060_MySQL 8.0 InnoDB Cluster 恢复故障成员

当InnoDB Cluster中的一台节点发生故障时,通过停止并清除故障节点的数据,然后从正常节点导出数据库并导入到故障节点,设置用户权限,重启MySQL服务,最后使用MySQL Shell将故障节点重新加入集群,成功恢复集群正常运行状态。
摘要由CSDN通过智能技术生成

InnoDB Cluster 一节点丢失

d83b8441560cfe34194cc1c7e4d077b9.png

初始化故障节点

systemctl stop mysqld

rm -rf /var/lib/mysql/*

systemctl start mysqld

导出正常节点的数据库,并传到故障节点

mysqldump --all-databases --triggers --routines --events --quick --single-transaction --flush-logs --master-data=2 > dbs.dump

scp dbs.dump 192.168.1.224:~/

故障节点导入数据库

mysql> set sql_log_bin=0;

mysql> ALTER USER root@'localhost' IDENTIFIED BY 'MySQL8.0';

mysql> source dbs.dump

mysql> set sql_log_bin=1;

重启故障节点 MySQL

systemctl restart mysqld

将故障节点重新加入集群

MySQL 192.168.1.226:33060+ ssl JS > var cluster=dba.getCluster('appCluster')

MySQL 192.168.1.226:33060+ ssl JS > cluster.removeInstance('root@192.168.1.224:3306')

MySQL 192.168.1.226:33060+ ssl JS > cluster.addInstance('root@192.168.1.224:3306')

集群恢复正常

MySQL 192.168.1.226:33060+ ssl JS > cluster.status()

{

"clusterName": "appCluster",

"defaultReplicaSet": {

"name": "default",

"primary": "192.168.1.226:3306",

"ssl": "REQUIRED",

"status": "OK",

"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",

"topology": {

"192.168.1.224:3306": {

"address": "192.168.1.224:3306",

"mode": "R/O",

"readReplicas": {},

"role": "HA",

"status": "ONLINE"

},

"192.168.1.225:3306": {

"address": "192.168.1.225:3306",

"mode": "R/O",

"readReplicas": {},

"role": "HA",

"status": "ONLINE"

},

"192.168.1.226:3306": {

"address": "192.168.1.226:3306",

"mode": "R/W",

"readReplicas": {},

"role": "HA",

"status": "ONLINE"

}

}

},

"groupInformationSourceMember": "mysql://root@192.168.1.226:3306"

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值