ITPub博客

首页 > 数据库 > MySQL > 解决master and slave have equal MySQL server UUIDs导致Slave_IO_thread起不来问题

解决master and slave have equal MySQL server UUIDs导致Slave_IO_thread起不来问题

原创 MySQL 作者:西红柿炒番茄QAQ 时间:2016-12-07 14:28:06 0 删除 编辑
今天在部署mysql主从复制时遇到个小问题
在配置完所有步骤后,想在主库插入数据测试从库又没复制
结果发现从库没有反应。
这时查了一下从库的状态,如下:

root@localhost:mysql.sock  04:43:35 [lala]>show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: 192.168.161.128
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mybinlog.000004
          Read_Master_Log_Pos: 331
               Relay_Log_File: mysql-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mybinlog.000004
             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: 331
              Relay_Log_Space: 120
              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: 1593
                Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 203306
                  Master_UUID: 
             Master_Info_File: /data/mysql/mytest_3306/data/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: 161207 04:40:45
     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)

从我标粗体部分的信息可以清楚地看到Slave_IO_Running参数为no,这说明Slave_IO_thread没有起来
错误原因也给出了
 Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.
master和slave有同一个UUIDs导致线程停止,该线程需要将两个线程改成不一样才能工作。
这时查一下两个库的UUIDs
root@localhost:mysql.sock  06:13:40 [(none)]>show variables like '%UUID%'
    -> ;
+---------------+--------------------------------------+
| Variable_name | Value                                |
+---------------+--------------------------------------+
| server_uuid   | af3609-b426-11e6-9ff3-000c29d55626 |
+---------------+--------------------------------------+
1 row in set (0.00 sec)
发现都是 af3609-b426-11e6-9ff3-000c29d55626
这时修改删除slave库中的auto.cnf文件即可,该文件就在mysql的datadir下
因为UUID参数读的就是该文件下的内容,删除后,mysql会重新生成新的uuid。或者不删除直接改变该文件的几个数字。
删除完后重启mysql服务器,再开启主从复制,发现状态正常了
ps:两个auto.cnf一样的原因是因为我的从库是直接拷贝主库,所以auto.cnf自然相同了!!!


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31386161/viewspace-2129967/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2016-08-19

  • 博文量
    51
  • 访问量
    109029