当前位置: 首页 > news >正文

Master Slave 主从同步错误 Slave_IO_Running:NO/Slave_SQL_Running: No

Master Slave 主从同步错误

Slave_IO_Running:NO
Slave_SQL_Running:Yes

#在Slave库上查看状态
mysql> show slave status\G
Slave_IO_Running: No
Slave_SQL_Running: Yes

#重启master库:service mysqld restart
mysql> show master status;
±-----------------±---------±-------------±-----------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
±-----------------------±-------------±-------------±-----------------+
| mysql-bin.000534 | 14670663 | | |
±-----------------------±-------------±-------------±-----------------+
mysql> stop slave;
mysql> change master to Master_Log_File=‘mysql-bin.000001’,Master_Log_Pos=98;
mysql> start slave;
mysql> show slave status\G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

Slave_IO_Running:NO

检查发现他们的auto.cnf中的server-uuid是否相同

[root@localhost ~]# vim /var/lib/mysql/auto.cnf[auto]
server-uuid=4f37a731-9b79-11e8-8013-000c29f0700f

停止从库的mysqld服务,删除他的auto.cnf文件,再启动数据库服务即可

[root@localhost mysql]# systemctl stop mysqld.service[root@localhost mysql]# mv /var/lib/mysql/auto.cnf /var/lib/mysql/auto.cnf.bak[root@localhost mysql]# systemctl start mysqld.service

此时再去查看从库auto.cnf,已自动生成新的server-uuid:

[root@localhost mysql]# vim /var/lib/mysql/auto.cnf[auto]
server-uuid=2682888d-994a-11e8-aaf0-000c298cdafc

解决Slave_SQL_Running: No

下面介绍两种解决方法:

方法一:忽略错误后,继续同步

该方法适用于主从库数据相差不大,或者要求数据可以不完全统一的情况,数据要求不严格的情况
解决:
stop slave;
#表示跳过一步错误,后面的数字可变
set global sql_slave_skip_counter =1;
start slave;
之后再用mysql> show slave status\G 查看:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
ok,现在主从同步状态正常了。。。

方法二重新配置从库

主库:

mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000029 |      157 |              |                  |                   |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

从库:

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.01 sec)mysql> change master to master_host='192.168.25.111',-> master_user='repl',-> master_port=3306,-> master_password='Cv.125166',-> master_log_file='binlog.000029',-> master_log_pos=157;
Query OK, 0 rows affected, 9 warnings (0.01 sec)
mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

之后查看从库状态:

mysql> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting for source to send eventMaster_Host: 192.168.25.111Master_User: replMaster_Port: 3306Connect_Retry: 60Master_Log_File: binlog.000029Read_Master_Log_Pos: 157Relay_Log_File: slavee-relay-bin.000002Relay_Log_Pos: 323Relay_Master_Log_File: binlog.000029Slave_IO_Running: YesSlave_SQL_Running: Yes
http://www.lryc.cn/news/27747.html

相关文章:

  • JavaScript函数之prototype原型和原型链
  • 从上海分时电价机制调整看转供电用户电能计费
  • TypeScript类型体操:获取数组中元素对象属性的值作为新类型
  • npm,yarn和pnpm
  • 【算法】【数组与矩阵模块】在排好序的矩阵中找数,时间复杂度O(M+N)
  • 【Java|基础篇】计算机中数据的存储规则
  • RestTemplate使用HttpClient连接池
  • Python 操作Redis
  • CEC2020:鱼鹰优化算法(Osprey optimization algorithm,OOA)求解CEC2020(提供MATLAB代码
  • 词对齐 - MGIZA++
  • GUI 之 Tkinter编程
  • 【软件测试】性能测试面试题都问什么?面试官想要什么?回答惊险避坑......
  • 后端开发基础能力以及就Java的主流开发框架介绍
  • H2数据库连接时用户密码错误:Wrong user name or password [28000-214] 28000/28000 (Help)
  • 青岛诺凯达机械盛装亮相2023济南生物发酵展,3月与您相约
  • 【JAVA程序设计】【C00111】基于SSM的网上图书商城管理系统——有文档
  • 基于卷积神经网络CNN的三相故障识别
  • Java工厂设计模式详解,大厂的Java抽象工厂模式分享!
  • Git 企业级分支提交流程
  • C/C++每日一练(20230303)
  • Python3-条件控制
  • KDZD地埋电缆故障测试仪
  • 爆款升级!新系列南卡Neo最强旗舰杀到,业内首款无线充骨传导耳机!
  • 基于Spring Boot+Thymeleaf的在线投票系统
  • 【每日一题Day135】LC1487保证文件名唯一 | 哈希表
  • 计算机系统的基本组成 第一节
  • Scrapy爬虫框架入门
  • 最新使用nvm控制node版本步骤
  • Linux内核4.14版本——drm框架分析(1)——drm简介
  • Google的一道经典面试题 - 767. 重构字符串