MySQL数据库中怎么实现主备切换,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
show processlist; Master has sent all binlog to slave; waiting for binlog to be updated show master status \G
show processlist; show slave status \G
stop slave IO_THREAD; show processlist; show slave status \G
stop slave; reset master; reset slave all; show master status \G
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user; GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'xxx; FLUSH PRIVILEGES;
reset master; reset slave all; CHANGE MASTER TO MASTER_HOST='1xxx', MASTER_USER='repl', MASTER_PASSWORD='xxx, MASTER_PORT=3306, MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=589;
SHOW PROCESSLIST; show master status \G
SHOW PROCESSLIST; start slave; show slave status \G
mysql> create table test123(id int(4)); Query OK, 0 rows affected (0.01 sec) mysql> insert into test123 values(1); Query OK, 1 row affected (0.00 sec) mysql> insert into test123 values(2); Query OK, 1 row affected (0.00 sec) mysql> insert into test123 values(3); Query OK, 1 row affected (0.00 sec) mysql> insert into test123 values(4); Query OK, 1 row affected (0.00 sec)
mysql> drop table test123;
关于MySQL数据库中怎么实现主备切换问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。