Home > Database > Mysql Tutorial > mysql主从切换步骤_MySQL

mysql主从切换步骤_MySQL

WBOY
Release: 2016-06-01 13:04:06
Original
1207 people have browsed it

1> 正常切换

1)从服务器检查SHOW PROCESSLIST语句的输出,直到你看到Has read all relaylogwaiting for the slave I/O thread to update it

2)确保从服务器已经处理了日志中的所有语句。 mysql> STOP SLAVE IO_THREAD

当从服务器都执行完这些,它们可以被重新配置为一个新的设置。

3)在被提升为主服务器的从服务器上,发出 STOP SLAVE和RESET MASTER和RESET SLAVE操作。

4)然后重启mysql服务。

5)在备用服务器(新的主服务器)创建用户grant replication slave on *.* torepdcs@'IP of A' identified by 'replpwd'

grant allprivileges on *.* to 'repdcs'@'IP' identified by replpwd;

6) 在主服务器上RESET MASTER。然后CHANGE MASTER TOMASTER_HOST='原从服务器IP',MASTER_USER='用户名',MASTER_PASSWORD='密码' ,master_log_file='master-bin.000015' ;

7)查看状态 show slave status \G;

Show master status \G;

如果还不行再次重启主库,并在备库上执行CHANGE MASTER TOMASTER_HOST='192.168.0.110',MASTER_USER='repdcs',MASTER_PASSWORD='111111',master_log_file='mysqlbin.000002';

8)修改应用的连接地址到新的主库

切换完成。

2> 主机直接宕机

1> 在备机上执行STOP SLAVE 和RESET MASTER

2> 查看show slave status \G;

3> 然后修改应用的连接地址。

一般大部分切换为直接宕机主机已经没法提供服务

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template