msyql 主从切换
从库是192.168.1.70 ,主库是192.168.1.64,主从切换一次
即:主库是192.168.1.70,从库是192.168.1.64
1、从库上执行,修改为主
修改从库为非只读库
修改配置 /etc/my.cnf
read_only = 1
重启mysql
service mysqld_3306 restart
mysql> stop slave io_thread;
Query OK, 0 rows affected (0.07 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.1.64
Master_User: zabbix64
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000147
Read_Master_Log_Pos: 49072513
Relay_Log_File: relay-bin-3306.000179
Relay_Log_Pos: 17594196
Relay_Master_Log_File: mysql-bin.000147
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 49072513
Relay_Log_Space: 17594368
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 101
Master_UUID: 9a5386d8-cd13-11e8-96cb-c68297e2a5d7
Master_Info_File: /home/mysql_data/3306/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> stop slave;
Query OK, 0 rows affected (0.05 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.1.64
Master_User: zabbix64
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000147
Read_Master_Log_Pos: 49072513
Relay_Log_File: relay-bin-3306.000179
Relay_Log_Pos: 17594196
Relay_Master_Log_File: mysql-bin.000147
Slave_IO_Running: No
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 49072513
Relay_Log_Space: 17594368
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 101
Master_UUID: 9a5386d8-cd13-11e8-96cb-c68297e2a5d7
Master_Info_File: /home/mysql_data/3306/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> reset master;
Query OK, 0 rows affected (0.28 sec)
mysql> grant replication slave on *.* to 'repl'@'192.168.1.64' identified by '123456';
Query OK, 0 rows affected (0.05 sec)
2、主上执行(修改为从)
mysql> change master to master_host='192.168.1.70',master_user='repl',master_password='123456';
Query OK, 0 rows affected, 2 warnings (0.31 sec)
mysql> start slave;
Query OK, 0 rows affected (0.05 sec)
参考来源 :https://www.cnblogs.com/gomysql/p/3663146.html
msyql 主从切换的更多相关文章
- Redis集群(九):Redis Sharding集群Redis节点主从切换后客户端自动重新连接
上文介绍了Redis Sharding集群的使用,点击阅读 本文介绍当某个Redis节点的Master节点发生问题,发生主从切换时,Jedis怎样自动重连新的Master节点 一.步骤如下: 1.配 ...
- redis主从配置及主从切换
环境描述: 主redis:192.168.10.1 6379从redis:192.168.10.2 6380 一.主从配置 1.将主从redis配置文件redis.conf中的aemonize no ...
- mysql主从切换
mysql 主从切换 主停,从做主步骤如下: 1 确认从服务器已经完成所有同步操作:stop slave io_thread show processlist 直到看到状态都为:xxx has rea ...
- Sentinel-Redis高可用方案(二):主从切换
Redis 2.8版开始正式提供名为Sentinel的主从切换方案,Sentinel用于管理多个Redis服务器实例,主要负责三个方面的任务: 1. 监控(Monitoring): Senti ...
- redis的主从复制,读写分离,主从切换
当数据量变得庞大的时候,读写分离还是很有必要的.同时避免一个redis服务宕机,导致应用宕机的情况,我们启用sentinel(哨兵)服务,实现主从切换的功能. redis提供了一个master,多个s ...
- redis主从配置及主从切换 转
redis主从配置及主从切换 转自 http://blog.sina.com.cn/s/blog_67196ddc0101h8v0.html (2014-04-28 17:48:47) 转载▼ 分 ...
- mysql主从备份、主从切换的例子
指定binlog(因为时通过binlog实现数据同步的) 配置完后重启数据库服务,用show master status可以看到Master信息. StepB: 在SerB的my.cnf中指定 [ht ...
- redis - 主从复制与主从切换
redis2.8之前本身是不支持分布式管理的,一般建议使用redis3.0及以后版本 redis主从切换的方法 keepalive 或者 使用sentinel线程管理 说明如何使用sentinel实 ...
- master_pos_wait函数与MySQL主从切换
背景 主从切换是高可用MySQL架构的必要步骤(即使用不发生,也要有备无患).一般设置为双M(M1.M2),假设当前状态为写M1,而M2只读,切换的大致流程如下: 1. 停止应用写M1,将M1设置为 ...
随机推荐
- MultipartFile 类
本文链接:https://blog.csdn.net/Peter_S/article/details/84951978今天说下 MultipartFile 这个类吧,这两天正在用,也在网上查了查资料, ...
- 初次Java web项目的建立以及与数据库的连接
题目要求: 1登录账号:要求由6到12位字母.数字.下划线组成,只有字母可以开头:(1分) 2登录密码:要求显示“• ”或“*”表示输入位数,密码要求八位以上字母.数字组成.(1分) 3性别:要求用单 ...
- 字符串匹配(KMP&BF)
字符串匹配 题目描述 设计一个程序,从一个主字符串中查找一个子字符串在主串中第一次出现的位置.主串和子串的长度不超过100.如果找不到,则输出-1. 程序输入说明 第一行输入一个整数N,说明需要进 ...
- mybatis中foreach参数过多效率很慢的优化
foreach 后面in 传入的参数有1万条,#和$是有效率区别的,$的效率远高于#,上篇文章做了比较. 但没达到我的理想结果. 1. 更改方式,把foreach 去掉,改成拼装方式, 参数直接拼装成 ...
- nltk data 离线安装
运行程序时发现如下错误: 在命令行下载速度太慢,因此需要离线安装: 按照:http://www.nltk.org/data.html 中manual installation的方法, 将包下载好后解压 ...
- ? 这是个很好的问题。Go 当前的 GC 显然做了一些额外的工作,但它也跟其他的工作并行执行,所以在具有备用 CPU 的系统上,Go 正在作出合理的选择。请看 https://golang.org/issue/17969 结束语(Closing notes) 通过研究 Go 垃圾收集器,我能够理解 Go GC 当前结构的背景以及它如何克服它的弱点。Go发展得非常快。如果你对 Go感兴趣,最好继
? 这是个很好的问题.Go 当前的 GC 显然做了一些额外的工作,但它也跟其他的工作并行执行,所以在具有备用 CPU 的系统上,Go 正在作出合理的选择.请看 https://golang.org/i ...
- python 简单了解一下 描述器
1.描述器是什么? 在Python中描述器也被称为描述符, 1)描述器实际上是任何新式类(新式类是继承自 type 或者 object 的类),这种类至少实现了3个特殊的方法__get__, __se ...
- centos7 搭建FTP
通过yum安装vsftpd yum install -y vsftpd 修改vsftpd的配置文件 vim /etc/vsftpd/vsftpd.conf 修改配置文件如下: 1.不允许匿名访问 an ...
- 通过id获取指定元素内容(标签里面的 标签内容获取)
html页面如下 <tr style="background-color:#fff;"> <td colspan="2" align=left ...
- PAT 甲级 1020 Tree Traversals (25 分)(二叉树已知后序和中序建树求层序)
1020 Tree Traversals (25 分) Suppose that all the keys in a binary tree are distinct positive integ ...