mysql主从环境,切换IP操作

环境:

redhat7.5 

mysql5.7

老IP :192.168.1.1, 192.168.1.2

新IP :192.168.3.3, 192.168.3.4

--备库停机

mysql> stop slave;

systemctl stop mysqld

--主库停机

systemctl stop mysqld

--修改主库备库服务器IP

--起主库

systemctl start mysqld

--主库增加新同步用户授权到新IP
grant replication slave on *.* to 'repl'@'192.168.3.4' identified by 'xxx';

--删除老的同步用户

delete from mysql.user where user='repl' and host='192.168.1.2';

flush privileges;

show grants for 'repl'@'192.168.3.4';

--查看主库当前的偏移量(如果使用gtid可以不用记录)
show master status \G
        
        
        
--起从库

systemctl start mysqld

stop slave;

change master to master_host='192.168.3.3', master_user='repl',master_password='xxx',master_port=3306,master_auto_position=1;

start slave;

grant replication slave on *.* to 'repl'@'192.168.3.3' identified by 'xxx';

flush privileges;

--删除老的同步用户

delete from mysql.user where user='repl' and host='192.168.1.1';

--确认同步状态

show slave status\G

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

Python3:sqlalchemy对mysql数据库操作,非sql语句

Python3:sqlalchemy对mysql数据库操作,非sql语句python3authorlizmdatetime2018020110:00:00coding:utf8'''

Oracle 12c DG备库Alert报错ORA

环境是12.2.0.1version,OracleDataGuard备库近段时间一直报错,但是备库主库同步一致,数据一致。20190306T23:42:22.18404808:00Errorsinfile/u01/app/oracle/diag/rdbms/ccdb/ccdb/trace/ccdb_m000_12