码迷,mamicode.com
首页 > 数据库 > 详细

MySQL 8.0 InnoDB Cluster 恢复故障成员

时间:2018-09-20 12:25:08      阅读:838      评论:0      收藏:0      [点我收藏+]

标签:water   default   format   use   节点   ica   恢复   instance   failure   

InnoDB Cluster 一节点丢失
技术分享图片
初始化故障节点

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"
}

MySQL 8.0 InnoDB Cluster 恢复故障成员

标签:water   default   format   use   节点   ica   恢复   instance   failure   

原文地址:http://blog.51cto.com/linux10000/2177488

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!