MySQL数据库错误server_errno=2013的解决

  一组MySQL复制环境中的Master意外掉电,重启后Master运行正常,但该复制环境中的其它slave端,Error Log中却抛出的如下错误信息:

  1. Version: '5.6.17-log' socket: '' port: 3306 MySQL Community Server (GPL)
  2. 2014-09-26 18:30:19 5940 [Warning] Slave SQL: If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 0
  3. 2014-09-26 18:30:19 5940 [Note] Slave SQL thread initialized, starting replication in log 'FIRST' at position 0, relay log '.\Q12MB1DR67JGLJT-relay-bin.000001' position: 4
  4. 2014-09-26 18:30:19 5940 [Note] Slave I/O thread: connected to master 'c@115.29.36.149:3306',replication started in log 'FIRST' at position 4
  5. 2014-09-26 18:30:19 5940 [Warning] Slave I/O: Notifying master by SET @master_binlog_checksum= @@global.binlog_checksum failed with error: Unknown system variable 'binlog_checksum', Error_code: 1193
  6. 2014-09-26 18:30:19 5940 [Warning] Slave I/O: Unknown system variable 'SERVER_UUID' on master. A probable cause is that the variable is not supported on the master (version: 5.5.35-log), even though it is on the slave (version: 5.6.17-log), Error_code: 1193
  7. 2014-09-26 18:31:14 5940 [Note] Error reading relay log event: slave SQL thread was killed
  8. 2014-09-26 18:31:15 5940 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)
  9. 2014-09-26 18:31:15 5940 [Note] Slave I/O thread killed while reading event
  10. 2014-09-26 18:31:15 5940 [Note] Slave I/O thread exiting, read up to log 'binLog.000001', position 278
  11. 2014-09-26 18:31:20 5940 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='115.29.36.149', master_port= 3306, master_log_file='binLog.000001', master_log_pos= 278, master_bind=''. New state master_host='115.29.36.149', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''.
  12. 2014-09-26 18:35:27 5940 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='115.29.36.149', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''. New state master_host='115.29.36.149', master_port= 3306, master_log_file='', master_log_pos= 4, master_bind=''.

  1. 110110 15:21:25 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)
  2. 110110 15:21:25 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'forummysql01-bin.002937' position 243387731
  3. 110110 15:21:25 [Note] Slave: connected to master 'repl@192.168.1.31:3306',replication resumed in log 'forummysql01-bin.002937' at position 243387731
  4. 110110 15:21:25 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236)
  5. 110110 15:21:25 [ERROR] Got fatal error 1236: 'Client requested master to start replication from impossible position' from master when reading data from binary log
  6. 110110 15:21:25 [Note] Slave I/O thread exiting, read up to log 'forummysql01-bin.002937', position 243387731

通过mysql命令行连接到slave端,执行show slave status查看复制状态:

  1. mysql> show slave status\G
  2. *************************** 1. row ***************************
  3. Slave_IO_State:
  4. Master_Host: 115.29.36.149
  5. Master_User: c
  6. Master_Port: 3306
  7. Connect_Retry: 60
  8. Master_Log_File:
  9. Read_Master_Log_Pos: 4
  10. Relay_Log_File: Q12MB1DR67JGLJT-relay-bin.000001
  11. Relay_Log_Pos: 4
  12. Relay_Master_Log_File:
  13. Slave_IO_Running: No
  14. Slave_SQL_Running: No
  15. Replicate_Do_DB:
  16. Replicate_Ignore_DB:
  17. Replicate_Do_Table:
  18. Replicate_Ignore_Table:
  19. Replicate_Wild_Do_Table:
  20. Replicate_Wild_Ignore_Table:
  21. Last_Errno: 0
  22. Last_Error:
  23. Skip_Counter: 0
  24. Exec_Master_Log_Pos: 0
  25. Relay_Log_Space: 120
  26. Until_Condition: None
  27. Until_Log_File:
  28. Until_Log_Pos: 0
  29. Master_SSL_Allowed: No
  30. Master_SSL_CA_File:
  31. Master_SSL_CA_Path:
  32. Master_SSL_Cert:
  33. Master_SSL_Cipher:
  34. Master_SSL_Key:
  35. Seconds_Behind_Master: NULL
  36. Master_SSL_Verify_Server_Cert: No
  37. Last_IO_Errno: 1593
  38. Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have
  39. equal MySQL server ids; these ids must be different for replication to work (or the --replicate-sam
  40. e-server-id option must be used on slave but this does not always make sense; please check the manua
  41. l before using it).
  42. Last_SQL_Errno: 0
  43. Last_SQL_Error:
  44. Replicate_Ignore_Server_Ids:
  45. Master_Server_Id: 1
  46. Master_UUID:
  47. Master_Info_File: F:\db-data\mysql\master.info
  48. SQL_Delay: 0
  49. SQL_Remaining_Delay: NULL
  50. Slave_SQL_Running_State:
  51. Master_Retry_Count: 86400
  52. Master_Bind:
  53. Last_IO_Error_Timestamp: 140926 19:17:52
  54. Last_SQL_Error_Timestamp:
  55. Master_SSL_Crl:
  56. Master_SSL_Crlpath:
  57. Retrieved_Gtid_Set:
  58. Executed_Gtid_Set:
  59. Auto_Position: 0
  60. 1 row in set (0.00 sec)

Salve的io线程没有运行,看起来是接收日志出现了问题,尝试启动该线程:start slave io_thread;

  1. mysql> start slave io_thread ;
  2. Query OK, 0 rows affected (0.00 sec)

再次执行show slave status查看复制状态:

  1. mysql> show slave status\G
  2. *************************** 1. row ***************************
  3. Slave_IO_State:
  4. Master_Host: 115.29.36.149
  5. Master_User: c
  6. Master_Port: 3306
  7. Connect_Retry: 60
  8. Master_Log_File:
  9. Read_Master_Log_Pos: 4
  10. Relay_Log_File: Q12MB1DR67JGLJT-relay-bin.000001
  11. Relay_Log_Pos: 4
  12. Relay_Master_Log_File:
  13. Slave_IO_Running: No
  14. Slave_SQL_Running: No
  15. Replicate_Do_DB:
  16. Replicate_Ignore_DB:
  17. Replicate_Do_Table:
  18. Replicate_Ignore_Table:
  19. Replicate_Wild_Do_Table:
  20. Replicate_Wild_Ignore_Table:
  21. Last_Errno: 0
  22. Last_Error:
  23. Skip_Counter: 0
  24. Exec_Master_Log_Pos: 0
  25. Relay_Log_Space: 120
  26. Until_Condition: None
  27. Until_Log_File:
  28. Until_Log_Pos: 0
  29. Master_SSL_Allowed: No
  30. Master_SSL_CA_File:
  31. Master_SSL_CA_Path:
  32. Master_SSL_Cert:
  33. Master_SSL_Cipher:
  34. Master_SSL_Key:
  35. Seconds_Behind_Master: NULL
  36. Master_SSL_Verify_Server_Cert: No
  37. Last_IO_Errno: 1593
  38. Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have
  39. equal MySQL server ids; these ids must be different for replication to work (or the --replicate-sam
  40. e-server-id option must be used on slave but this does not always make sense; please check the manua
  41. l before using it).
  42. Last_SQL_Errno: 0
  43. Last_SQL_Error:
  44. Replicate_Ignore_Server_Ids:
  45. Master_Server_Id: 1
  46. Master_UUID:
  47. Master_Info_File: F:\db-data\mysql\master.info
  48. SQL_Delay: 0
  49. SQL_Remaining_Delay: NULL
  50. Slave_SQL_Running_State:
  51. Master_Retry_Count: 86400
  52. Master_Bind:
  53. Last_IO_Error_Timestamp: 140926 19:25:12
  54. Last_SQL_Error_Timestamp:
  55. Master_SSL_Crl:
  56. Master_SSL_Crlpath:
  57. Retrieved_Gtid_Set:
  58. Executed_Gtid_Set:
  59. Auto_Position: 0
  60. 1 row in set (0.00 sec)

  看起来 没有反应,其中是有反映,执行启动io线程的命令后,Error Log文件中又抛出了日志文件位置异常的信息。看来还是得到master端,查看一下报错的日志文件指定位置到底执行的什么操作,以及该位置是否存在?

  通过mysqlbinlog命令可以查看二进制日志文件中的内容,在master端执行命令如下:

  1. [root@forummysql01 data]# mysqlbinlog --start-position= forummysql01-bin.
  2. /*!40019 SET @@session.max_insert_delayed_threads=0*/;
  3. /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
  4. DELIMITER /*!*/;
  5. DELIMITER ;
  6. # End of log file
  7. ROLLBACK /* added by mysqlbinlog */;
  8. /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

  还别说,这个位置看起来啥都没有做,稳妥起见,三思将整个forummysql01-bin.002937文件中的内容均提取出来查看一下,再次执行mysqlbinlog命令,这次不再指定position:

  1. [root@forummysql01 data]# mysqlbinlog ./forummysql01-bin. > /home/jss/bin-.log

我们只需要查看一下该文件最后几行的信息即可,例如:

  1. [root@forummysql01 data]# tail -50 /home/jss/bin-002937.log
  2. .............................
  3. # at 243297123
  4. #110110 15:02:19 server id 1 end_log_pos 243297459 Query thread_id=1773644066 exec_time=0 error_code=0
  5. SET TIMESTAMP=1294642939/*!*/;
  6. INSERT INTO cdb_sessions (sid, ip1, ip2, ip3, ip4, uid, username, groupid, styleid, invisible, action, lastactivity, lastolupdate, seccode, fid, tid)
  7. VALUES ('HQFzjy', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')
  8. /*!*/;
  9. ................
  10. ................
  11. ................
  12.  
  13. # at 243308840
  14. #110110 15:02:20 server id 1 end_log_pos 243315309 Query thread_id=1773638971 exec_time=0 error_code=0
  15. SET TIMESTAMP=1294642940/*!*/;
  16. update group_topic set TOPIC_TIT.............................
  17. /*!*/;
  18. DELIMITER ;
  19. # End of log file
  20. ROLLBACK /* added by mysqlbinlog */;
  21. /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

  可以看到该bin文件中最后的位置点是243315309,与错误日志中“'forummysql01-bin.002937', position 243387731”相差较大,提示的错误点在二进制日志文件中确实不存在,我将其理解为逻辑错误,应该是由于master意外掉电,重新启动时自动flush了binlog,而slave并未获取到这个信息导致,因此解决该问题也比较简单,直接重置同步的master位置应该就可以。这里三思选择将日志文件序号递增(也可以选择将position位置号提前),执行命令如下:

  1. mysql> stop slave;
  2. Query OK, 0 rows affected (0.00 sec)
  3. mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.101',
  4. -> MASTER_PORT=3306,
  5. -> MASTER_USER='repl',
  6. -> MASTER_PASSWORD='******',
  7. -> MASTER_LOG_FILE='forummysql01-bin.002938',
  8. -> MASTER_LOG_POS=0;
  9. Query OK, 0 rows affected (0.01 sec)

然后再重新启动slave,查看状态:

  1. mysql> start slave;
  2. Query OK, 0 rows affected (0.00 sec)
  3. mysql> show slave status\G
  4. *************************** 1. row ***************************
  5. Slave_IO_State: Waiting for master to send event
  6. Master_Host: 192.168.1.31
  7. Master_User: repl
  8. Master_Port: 3306
  9. Connect_Retry: 60
  10. Master_Log_File: forummysql01-bin.002938
  11. Read_Master_Log_Pos: 35910271
  12. Relay_Log_File: phpmysql02-relay-bin.000003
  13. Relay_Log_Pos: 21407790
  14. Relay_Master_Log_File: forummysql01-bin.002938
  15. Slave_IO_Running: Yes
  16. Slave_SQL_Running: Yes
  17. Replicate_Do_DB:
  18. Replicate_Ignore_DB: mysql
  19. Replicate_Do_Table:
  20. Replicate_Ignore_Table:
  21. Replicate_Wild_Do_Table:
  22. Replicate_Wild_Ignore_Table:
  23. Last_Errno: 0
  24. Last_Error:
  25. Skip_Counter: 0
  26. Exec_Master_Log_Pos: 21407646
  27. Relay_Log_Space: 35910415
  28. Until_Condition: None
  29. Until_Log_File:
  30. Until_Log_Pos: 0
  31. Master_SSL_Allowed: No
  32. Master_SSL_CA_File:
  33. Master_SSL_CA_Path:
  34. Master_SSL_Cert:
  35. Master_SSL_Cipher:
  36. Master_SSL_Key:
  37. Seconds_Behind_Master: 2215
  38. 1 row in set (0.00 sec)

  Slave相关进程已启动,Error Log文件中也没有再抛出错误信息。等待一段时间,让slave赶上master的进度,其它slave也参照此步骤操作,整个复制环境就恢复了。

来自  : http://blog.itpub.net/7607759/viewspace-683607/

  

MySQL数据库错误server_errno=2013的解决的更多相关文章

  1. sqlyog连接Linux上的mysql报错误号码2013,错误号码1130的解决办法

    sqlyog连接Linux上的mysql报错误号码2013,错误号码1130的解决办法 1.报错误号码2013,可能是端口号不是默认的3306,需要改成对应的,检查命令是: [root@host et ...

  2. Django 连接 MySQL 数据库及常见报错解决

    目录 Django 连接 MySQL数据库及常见报错解决 终端或者数据库管理工具连接 MySQL ,并新建项目所需数据库 安装访问 MySQL 的 Python 模块 Django 相关配置 可能会遇 ...

  3. 关于php读mysql数据库时出现乱码的解决方法

    关于php读mysql数据库时出现乱码的解决方法 php读mysql时,有以下几个地方涉及到了字符集. 1.建立数据库表时指定数据库表的字符集.例如 create table tablename ( ...

  4. MySQL数据库-错误1166 - Incorrect column name 'xxx' 的解决方法

    在用Navicat for MySQL给MySQL数据库修改表的字段时报如下的错误: 解决方法:检查字段里面是不是有空格,去掉就可以了.

  5. mysql 数据库缓存调优之解决The total number of locks exceeds the lock table size错误

    环境: mysql5.6.2  主从同步(备注:需操作主库和从库) 一.InnoDB表执行大批量数据的更新,插入,删除操作时会出现这个问题,需要调整InnoDB全局的innodb_buffer_poo ...

  6. Navicat连接阿里云(centos7.3)的MySQL数据库遇到的问题及解决方法

    注:本文涉及到的解决方案都是我遇到的问题的对应解决方案,不一定适用于每一个人,如果问题仍然存在,请继续百度查询其他解决方法 1.  首先是登录阿里云MySQL的一些必要信息(登录其他云主机的mysql ...

  7. centos/windows服务器,Mysql数据库表结构损坏-已解决

    [问题原因]服务器突然断电 [故障报告]数据库表结构损坏 [解决思路]进入强制恢复模式,备份库表及数据重建 故障发现 周末公司断电,周一启动数据库就直接报错了 查看日志 上面标记的log,明确表示是非 ...

  8. Linux下修改MySQL数据库字符编码为UTF-8解决中文乱码

    由于MySQL编码原因会导致数据库出现乱码. 解决办法: 修改MySQL数据库字符编码为UTF-8,UTF-8包含全世界所有国家需要用到的字符,是国际编码. 具体操作: 1.进入MySQL控制台 &g ...

  9. MySQL数据库无法远程连接的解决办法

    远程登陆数据库的时候出现了下面出错信息: ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.xxx.xxx.xxx', 经过今天下午的 ...

随机推荐

  1. 【Cocos2d入门教程四】Cocos2d-x菜单篇

    游戏世界多姿多彩,无论多靓丽的游戏,多耐玩的游戏,在与游戏用户交互上的往往是菜单. 上一章我们已经大概了解了导演.节点.层.精灵.这一章以菜单为主题. 菜单(Menu)包含以下内容: 1.精灵菜单项( ...

  2. window.open和window.showdialog区别

    open打开的窗口可以点击切换到其背后的父窗口,dialog的窗口无法点击切换到其背后的父窗口, 假如用window.opener或者parent等对象时,建议用open方法,不要用dialog,否则 ...

  3. rac安装oem

    [oracle@node1 ~]$ emca -config dbcontrol db -repos recreate -cluster STARTED EMCA at May 31, 2016 3: ...

  4. SQLSERVER中按年月分组

    SQLSERVER中按年月分组 一个表有三个字段id,dt,d  分别存放id,时间,数值  id    dt    d 1 2004-08-11 12:12:00.000 9  2 2005-09- ...

  5. JavaScript语言常量和变量

    我们在以往介绍使用JavaScript编写一个HelloJS的小程序,其中我们就用到变量.常量和变量是构成表达式的重要组成部分.常量在声明和初始化变量时,在标识符的前面加上关键字const,就可以把该 ...

  6. XMLHTTPRequest的属性和方法简介

    由于现在在公司负责制作标准的静态页面,为了增强客户体验,所以经常要做些AJAX效果,也学你也和我一样在,学习AJAX.而设计AJAX时使用的一个 重要的技术(工具)就是XMLHTTPRequest对象 ...

  7. (转)Linux vmstat命令实战详解

    vmstat命令是最常见的Linux/Unix监控工具,可以展现给定时间间隔的服务器的状态值,包括服务器的CPU使用率,内存使用,虚拟内存交换情况,IO读写情况.这个命令是我查看Linux/Unix最 ...

  8. SQL server基本操作(一)

      --1.create database CREATE DATABASE MyDB GO --2.use database USE MyDB GO --3.create table CREATE T ...

  9. 济南学习 Day1 T1 am

    题意:给你两个日期,问这两个日期差了多少毫秒 #include<cstdio> #include<cstring> #include<ctime> #include ...

  10. Fedora 19 vim c语言开发环境

    1. Fedora 19 居然没有自带 gcc 和 g++: sudo yum -y install gcc gcc-c++ 2. 安装 vim 和 cvim 插件: sudo yum -y vim ...