MySQL Replication Error 处理一例

故障现象

MySQL slave status详情

mysql> show slave status\G
*************************** 1. row ***************************
             Slave_IO_State: Waiting for master to send event
                Master_Host: 10.10.10.101
                Master_User: root
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File: mysql-bin.000010
        Read_Master_Log_Pos: 143861468
             Relay_Log_File: slave-relay-bin.000525
              Relay_Log_Pos: 128835579
      Relay_Master_Log_File: mysql-bin.000010
           Slave_IO_Running: Yes
          Slave_SQL_Running: No
            Replicate_Do_DB:
        Replicate_Ignore_DB:
         Replicate_Do_Table:
     Replicate_Ignore_Table:
    Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table: mysql.%,information_schema.%,test.%
                 Last_Errno: 0
                 Last_Error: Could not parse relay log event entry. The possck this by running ‘mysqlbinlog‘ on the binary log), the slave‘s relay log iay log), a network problem, or a bug in the master‘s or slave‘s MySQL code. you will be able to know their names by issuing ‘SHOW SLAVE STATUS‘ on this
               Skip_Counter: 0
        Exec_Master_Log_Pos: 128835442
            Relay_Log_Space: 143862393
            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
1 row in set (0.00 sec)

mysql> 

MySQL 错误日志中显示了问题的根源,磁盘空间满.

thatsit-mysql:/var/lib/mysql # grep -i disk mysqld.log-20160114
/usr/sbin/mysqld: Disk is full writing ‘./mysql-bin.000319‘ (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
/usr/sbin/mysqld: Disk is full writing ‘./mysql-bin.000320‘ (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
thatsit-mysql:/var/lib/mysql # 

MySQL 错误日志中同样还记录了binlog执行截至的位置点.

thatsit-mysql:/var/lib/mysql # grep ERROR mysqld.log-20160114|grep stopped|tail -1
160114 13:16:16 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log ‘mysql-bin.000010‘ position 128835442
thatsit-mysql:/var/lib/mysql # 

修复

① 清理MySQL datadir所在的磁盘

② 恢复MySQL SLAVE (STOP SLAVE → CHANGE MASTER → START SLAVE)

※: 位置点为上面从SLAVE STATUS的"Exec_Master_Log_Pos"或者错误日志中获取的.

mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> CHANGE MASTER TO
    -> MASTER_HOST=‘10.10.10.101‘,
    -> MASTER_PORT=3306,
    -> MASTER_USER=‘REP_USER‘,
    -> MASTER_PASSWORD=‘REP_PASSWORD‘,
    -> MASTER_LOG_FILE=‘mysql-bin.000010‘,
    -> MASTER_LOG_POS=128835442;
Query OK, 0 rows affected (0.41 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql>

操作后状态确认

mysql> show slave status\G
*************************** 1. row ***************************
             Slave_IO_State: Waiting for master to send event
                Master_Host: 10.10.10.101
                Master_User: root
                Master_Port: 3306
              Connect_Retry: 60
            Master_Log_File: mysql-bin.000010
        Read_Master_Log_Pos: 144444705
             Relay_Log_File: slave-relay-bin.000002
              Relay_Log_Pos: 38259
      Relay_Master_Log_File: mysql-bin.000010
           Slave_IO_Running: Yes
          Slave_SQL_Running: Yes
            Replicate_Do_DB:
        Replicate_Ignore_DB:
         Replicate_Do_Table:
     Replicate_Ignore_Table:
    Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table: mysql.%,information_schema.%,test.%
                 Last_Errno: 0
                 Last_Error:
               Skip_Counter: 0
        Exec_Master_Log_Pos: 128873466
            Relay_Log_Space: 15609498
            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: 99299
1 row in set (0.00 sec)

mysql>

此故障至此修复完毕.

时间: 2024-10-15 15:35:54

MySQL Replication Error 处理一例的相关文章

Linux运维 第四阶段(八)MySQL REPLICATION(SSL)

Linux运维 第四阶段(八)MySQLREPLICATION(SSL) 一.准备: mysql replication(ssl加密方式传输) mysql-5.5.45-linux2.6-i686.tar.gz(通用二进制格式包) 两node,一主一从 master(node1:192.168.41.131,既是CA又是master) slave(node2:192.168.41.132) 环境: [[email protected] ~]# uname -a Linux node1.maged

mysql 主从复制 error 1677

2016-06-03 今天在主库建了一张表,在向该表插入数据时,发现没有同步到从库,并且在从库发现有以下报错: 根据网上的说法,一开始以为是binlog_format的问题,在主库把binlog_format由row改为statement,又改成mixed,都试了一遍,发现还是有报错. 后来找到了答案,是slave_type_conversions的问题,在从库执行以下操作: stop slave;set global slave_type_conversions=ALL_NON_LOSSY;s

mysql replication principle--转

原文地址:http://www.codeweblog.com/mysql-replication-principle/ 1, the replication process Mysql replication (replication) is an asynchronous replication, from a Mysql instace (called Master) to another Mysql instance (call it Slave). Implement the copy

MySQL Replication Report

很多人都会MySQL主从框架的搭建,但很多人没有真正理解同步基本用途.同步的基本原理,还有当Master和Slave同步断开后的处理以及导致Master和slave不同步的原因等等,当你对这些都了如指掌的时候,对于MySQL主从出现的一些常见问题,也能很轻松的解决它,而且对数据库架构的优化及改造都会有很大的帮助.下面我们一起来学习下MySQL Replication吧,^0^ Replication的用途: 1.数据分发,scale out,sacle up,垂直划分,水平划分 2.负载均衡 l

MySQL replication illegal mix of collations

MySQL replication case 一则 转载:http://www.vmcd.org/2013/09/mysql-replication-case-%E4%B8%80%E5%88%99/ Posted by admin on September 10th, 2013 最近同事处理了一则mysql复制错误.发出来参考下 MYSQL同步出错,报错信息如下: ? Last_Errno: 1267 Last_Error: Error 'Illegal mix of collations (u

MySQL Replication 主从复制全方位解决方案

原文:MySQL Replication 主从复制全方位解决方案 1.1 主从复制基础概念 在了解主从复制之前必须要了解的就是数据库的二进制日志(binlog),主从复制架构大多基于二进制日志进行,二进制日志相关信息参考:http://www.cnblogs.com/clsn/p/8087678.html#_label6 1.1.1 二进制日志管理说明 二进制日志在哪?如何设置位置和命名? 在my.cnf文件中使用 log-bin = 指定:命名规则为 mysql-bin.000000 (后为6

MySQL Replication 即主从复制

MySQL Replication主要用于MySQL的时时备份或者读写分离.在配置之前先做一下准备工作,配置两台mysql服务器,或者在一台服务器上配置两个端口也可以.流程示意图: A-->change data-->bin_log-->transfer-->B-->repl_log-->change data 一.搭建好了一个mysql,跑的是3306端口. 1.下载mysql到/usr/local/src/ wget http://mirrors.sohu.com/

MySQL Replication的主从同步的常用2种配置方式

因为实际的业务需求最近就需要部署一些mysql服务器,而在部署mysql服务器中在做主从同步时用的都是MySQL Replication的主从同步的方法,当然实现mysql主从同步的方法还有很多,这里就只说使用MySQL Replication的主从同步的功能,在实现mysql的主从同步的常用的2种配置方式,当然可以根据实际的生产环境选择不同的方式,在这里就简单的把2种配置方法配置my.cnf说一下,因为以前有写过mysql的主从同步方法,这里就不再赘述了,需要可以参看:http://jim12

Mac Mysql mysql_secure_installation Error: Access denied for user 'root'@'localhost' (using password: YES)

mysql由brew安装, 期间好像自动更新了一次 然后再次执行mysql_secure_installation, 输入root密码后报错, 重装mysql还是不行 Error: Access denied for user 'root'@'localhost' (using password: YES) 原因是之前安装的mysql配置文件没有彻底清除 参照 http://stackoverflow.com/questions/4359131/brew-install-mysql-on-mac