链接:http://blog.csdn.net/yumushui/article/details/42742461

今天在搭建一个MySQL master-slave集群时,执行了change master命令,然后又 start slave 启动slave服务,结果查看salve状态就出现错误了:

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 192.168.62.108
                  Master_User: repl
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000544
          Read_Master_Log_Pos: 76175557
               Relay_Log_File: mysql-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000544
             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: 76175557
              Relay_Log_Space: 107
              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: 1236
                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 621083307
1 row in set (0.00 sec)
 
错误提示的内容,按照字面意思:
最后的IO错误为 1236; 当从binlog 中读取数据时,master返回一个1236的错误——在binlog索引文件中不能找到第一个日志文件。
 
之前我遇到这个错误,是因为搭建salve库时,使用的备份是master库7天前的备份,binlog设置默认保留天数为7天,过期的binlog日志文件都会被删除了。所以当时找不到最初binlog日志文件,所以提示这个错误。
 
于是我登录到 mysql master服务器上确认,mysql-bin.000544日志文件就是今天早上的,目前master正在写入的日志是mysql-bin.000550,肯定是存在,按说是可以读到的。
我查看是否还有其他原因,在网上一篇文章中看到,提示这样错误的原因可能是binlog日志文件不存在,或者binlog的名称没有写对,有空格。这个说法提醒了我,我的操作都是有记录的,赶快去确认开始执行的 change master 命令,结果发现是因为 一开始在进行 change master 命令时,binlog文件 的名称多一个空格,造成了binlog文件名称发生了变化,所以就找不到了。
 
处理方法:重新stop slave, 修改 change master确保binlog日志文件名称没有空格是正确的, 然后start slave 后状态正常。
 
通过这次故障,可以看出DBA在进行日常操作和故障处理时,还是需要更多的耐心和细心,这样才能避免更多的问题,尽快解决已经发生的问题。
 
************************************************
附:出现问题时查询到的网页内容为
 
 
MySQL Slave复制故障3例

1.Sandy飓风导致NYC机房停电,重启后看到的日志如下:

121101 16:35:25 [ERROR] Slave I/O: Got fatal error 1236 from master when
reading data from binary log: 'Client requested master to start
replication from impossible position', Error_code: 1236

121101 16:35:25 [Note] Slave I/O thread exiting, read
up to log 'mysql-bin.014497', position 38542146

121101 16:41:36 [Note] Error reading relay log event:
slave SQL thread was killed

然后看binlog如下:

# at 38539267

#121101 13:11:04 server id 1  end_log_pos 38539294  
   Xid = 934362432

COMMIT/*!*/;

DELIMITER ;

# End of log file

ROLLBACK /* added by mysqlbinlog */;

/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

master突然当机造成的master的pos要小于slave的错误日志记录的pos,mysql-bin.014497的最后一个位置是:
end_log_pos 38539294,但没有被commit,所以上一个是 38539267 那么直接设pos为master的最后有效的位置即可,

change
master to master_log_file='mysql-bin.014497',master_log_pos=38539267;

但也有可能情况相反,可能slave丢了部分数据或延迟,此时把pos往前移,反复试验即可。

2. Got fatal error
1236: 'Could not find first log file name in binary log index file' from master when reading data from binary log

logfile有空格,或是master上对应的Log被删了。

3. Show processlist 看到很多sleep,可能是应用代码做完query之后没用close()主动关闭链接。这样会一直到timeout才断掉,但这个timeout太小的话,会导致mysql
has gone away 这种错误。

 

MySQL--从库启动复制报错1236的更多相关文章

  1. MySql:CentOS7安装mysql后无法启动服务报错,(需要更新yum源)

    首先:需要更新你的yum源,保证yum源最新. 1.安装: yum install -y mariadb-server 2.启动maria DB服务: systemctl start mariadb. ...

  2. Eclipse启动Tomcat报错,系统缺少本地apr库

    Eclipse启动Tomcat报错,系统缺少本地apr库. Tomcat中service.xml中的设置情况. 默认情况是HTTP协议的值:protocol="HTTP/1.1" ...

  3. mysql5.7同步复制报错1060故障处理

    mysql5.7同步复制报错故障处理 # 报错 1060,具体如下Last_Errno: 1060Last_Error: Coordinator stopped because there were ...

  4. C# 解决SharpSvn启动窗口报错 Unable to connect to a repository at URL 'svn://....'

    在远程机打开sharpsvn客户端测试,结果报错 Svn启动窗口报错 Unable to connect to a repository at URL 'svn://...' 咋整,我在win10我的 ...

  5. mysql-connector-java升级到6.0以后启动tomcat报错

    mysql-connector-java升级到6.0以后启动tomcat报错 java.sql.SQLException: The server time zone value '�й���׼ʱ��' ...

  6. Springboot项目 配置数据库连接属性后,启动项目报错

    Springboot项目 配置数据库连接属性后,启动项目报错,错误如下: 错误原因分析: 1.连接信息配置错误 当使用properties为配置文件时,如图所示,上面的 spring.datasour ...

  7. maven 项目启动tomcat报错 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

    maven项目启动tomcat报错: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderLi ...

  8. 【转】Eclipse下启动tomcat报错:/bin/bootstrap.jar which is referenced by the classpath, does not exist.

    转载地址:http://blog.csdn.net/jnqqls/article/details/8946964 1.错误: 在Eclipse下启动tomcat的时候,报错为:Eclipse下启动to ...

  9. 学习中的错误——ubuntu 14.04 LTS 启动eclipse报错

    在ubuntu中启动eclipse报错:(Eclipse:15978): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assert ...

随机推荐

  1. PHP截取指定字符前的字符串

    $str = 'A|B||C|D'; echo substr($str,0,strpos($str, '||')); 输出:A|B

  2. php中date('Y/m/d',time())显示不对

    一. 时间不对是因为没设置时区 在xampp/php/php.ini中ctrl + f 查找date.timezone 该行默认注释,去掉 ; 修改为 date.timezone = PRC 二 上述 ...

  3. vue-i18n多语言文件归类的两种方法

    1.按语言类型归类 流行的做法是按照语言对文件进行归类,目录结构类似于: --lang ----en ------test.json --------"abc": "ab ...

  4. writeObiect与序列化反序列化

    在写仿QQ聊天工具中,客户端与服务端之间的通信一开始是采用的是InputStream和OutputStream,这导致在数据传输过程中,登录信息,注册信息等难以区分,这时我给传输的数据加了标识来分辨信 ...

  5. 史上最全的mysql聚合函数总结(与分组一起使用)

    1.首先我们需要了解下什么是聚合函数 聚合函数aggregation function又称为组函数. 认情况下 聚合函数会对当前所在表当做一个组进行统计. 2.聚合函数的特点 1.每个组函数接收一个参 ...

  6. 洛谷P1002——过河卒

    又是洛谷题,要不是有小姐姐不会,我才不想动脑子.先贴一下题目地址https://www.luogu.org/problem/P1002 再贴一下题目: 我们读一下题目,这可不比学校的**算法题,读完一 ...

  7. 项目中常用的JS操作技巧

    1.<a>标签-超链接中confirm方法使用介绍 <a href="a.html" onclick="if(confirm('确定删除?')==fal ...

  8. MongoDB 常用查询语法

    一.查询 find方法 db.collection_name.find(); 查询所有的结果: select * from users; db.users.find(); 指定返回那些列(键): se ...

  9. Python基础笔记:函数式编程:高阶函数、返回函数、匿名函数

    高阶函数 高阶函数:一个函数可以接收另一个函数作为参数 或 一个函数可以返回一个函数作为返回值,这种函数称之为高阶函数. #函数 add 接收 f 函数作为参数 >>> def ad ...

  10. 015-PHP读取TXT记事本内容

    <?php print("<H3>通过http协议打开文件</H3>\n"); // 通过 http 协议打开文件 if (!($myFile = f ...