slave have equal MySQL server UUIDs

    最近在部署MySQL主从复制架构的时候,碰到了"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." 这个错误提示。即主从架构中使用了相同的UUID。检查server_id系统变量,已经是不同的设置,那原因是?接下来为具体描述。 

1、错误消息
mysql> show slave staus;
 
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.
 
2、查看主从的server_id变量
master_mysql> show variables like 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 33    |
+---------------+-------+

slave_mysql> show variables like 'server_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 11    |
+---------------+-------+
-- 从上面的情形可知,主从mysql已经使用了不同的server_id

3、解决故障
###查看auto.cnf文件
[root@dbsrv1 ~] cat /data/mysqldata/auto.cnf  ### 主上的uuid
[auto]
server-uuid=62ee10aa-b1f7-11e4-90ae-080027615026

[root@dbsrv2 ~]# more /data/mysqldata/auto.cnf ###从上的uuid,果然出现了重复,原因是克隆了虚拟机,只改server_id不行
[auto]
server-uuid=62ee10aa-b1f7-11e4-90ae-080027615026

[root@dbsrv2 ~]# mv /data/mysqldata/auto.cnf  /data/mysqldata/auto.cnf.bk  ###重命名该文件
[root@dbsrv2 ~]# service mysql restart          ###重启mysql
Shutting down MySQL.[  OK  ]
Starting MySQL.[  OK  ]
[root@dbsrv2 ~]# more /data/mysqldata/auto.cnf  ###重启后自动生成新的auto.cnf文件,即新的UUID
[auto]
server-uuid=6ac0fdae-b5d7-11e4-a9f3-0800278ce5c9


###再次查看slave的状态已经正常
[root@dbsrv1 ~]# mysql -uroot -pxxx -e "show slave status\G"|grep Running
Warning: Using a password on the command line interface can be insecure.
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it

###主库端查看自身的uuid
master_mysql> show variables like 'server_uuid';
+---------------+--------------------------------------+
| Variable_name | Value                                |
+---------------+--------------------------------------+
| server_uuid   | 62ee10aa-b1f7-11e4-90ae-080027615026 |
+---------------+--------------------------------------+
1 row in set (0.00 sec)

###主库端查看从库的uuid
master_mysql> show slave hosts;
+-----------+------+------+-----------+--------------------------------------+
| Server_id | Host | Port | Master_id | Slave_UUID                           |
+-----------+------+------+-----------+--------------------------------------+
|        33 |      | 3306 |        11 | 62ee10aa-b1f7-11e4-90ae-080027615030 |
|        22 |      | 3306 |        11 | 6ac0fdae-b5d7-11e4-a9f3-0800278ce5c9 |
+-----------+------+------+-----------+--------------------------------------+
### Author : Leshami
### Blog   : http://blog.csdn.net/leshami

4、延生参考 a、有关server_id的描述 The server ID, used in replication to give each master and slave a unique identity. This variable is set by the --server-id option. For each server participating in replication, you should pick a positive integer in the range from 1 to 232– 1(2的32次方减1) to act as that server's ID.

b、有关 server_uuid的描述 Beginning with MySQL 5.6, the server generates a true UUID in addition to the --server-id supplied by the user. This is available as the global, read-only variable server_uuid(全局只读变量)

When starting, the MySQL server automatically obtains a UUID as follows: a).  Attempt to read and use the UUID written in the file data_dir/auto.cnf (where data_dir is the server's data directory); exit on success. b). Otherwise, generate a new UUID and save it to this file, creating the file if necessary. The auto.cnf file has a format similar to that used for my.cnf or my.ini files. In MySQL 5.6, auto.cnf has only a single [auto] section containing a single server_uuid [1992] setting and value;

Important The auto.cnf file is automatically generated; you should not attempt to write or modify this file

Also beginning with MySQL 5.6, when using MySQL replication, masters and slaves know one another's UUIDs. The value of a slave's UUID can be seen in the output of SHOW SLAVE HOSTS. Once START SLAVE has been executed (but not before), the value of the master's UUID is available on the slave in the output of SHOW SLAVE STATUS.

In MySQL 5.6.5 and later, a server's server_uuid is also used in GTIDs for transactions originating on that server. For more information, see Section 16.1.3, “Replication with Global Transaction

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏乐沙弥的世界

MySQL 复制简要描述及示例

    主从复制技术在MySQL中被广泛使用,主要用于同步一台服务器上的数据至多台从服务器,可以用于实现负载均衡,高可用和故障切换,以及提供备份等等。MySQL...

11210
来自专栏杨建荣的学习笔记

Oracle 12c DG新特性Far Sync(r10笔记第67天)

Oracle的Data Guard技术再11g中有了Active Data Guard,就产生了很多的技术解决方案,比如读写分离,多活的技术支撑等。 12c 中...

53370
来自专栏王磊的博客

Spring Boot 最佳实践(五)Spring Data JPA 操作 MySQL 8

JPA(Java Persistence API)Java持久化API,是 Java 持久化的标准规范,Hibernate是持久化规范的技术实现,而Spring...

31320
来自专栏耕耘实录

RHEL7.X系列及周边Linux发行版中,关于MBR与GPT的选择一些思考与建议

存储的选型、规划与管理等工作一直以来都是日常系统运维工作中的重点。MBR与GPT两种类型的分区表的选择与使用则是在磁盘管理中需要根据应用场景来注或考虑的要点。结...

13920
来自专栏腾讯Bugly的专栏

《Android外部存储》

| 导语 外部存储作为开发中经常接触的一个重要系统组成,在Android历代版本中,有过许许多多重要的变更。我也曾疑惑过,为什么一个简简单单外部存储,会存在存在...

64350
来自专栏运维技术迷

解决Sublime在LinuxMint下无法输入中文的问题

环境说明: 操作系统: Linux Mint 18 MATE 输入法管理:fcitx 一、创建sublime_imfix.c文件 进入sublime安装目录...

46770
来自专栏快乐八哥

Angular企业级开发(4)-ngResource和REST介绍

一、RESTful介绍 ? RESTful维基百科 REST(表征性状态传输,Representational State Transfer)是Roy Fie...

20370
来自专栏实战docker

pinpoint插件开发之一:牛刀小试,调整gson插件

从本章开始我们一起来实战pinpoint插件开发,做一些实用的pinpoint插件,本着先易后难的原则,我们从修改现有插件开始吧; 准备工作 本次实战的操作环境...

37050
来自专栏乐沙弥的世界

基于Innobackupex的完全恢复

    对于MySQL的完全恢复,我们可以借助于Innobackupex的多重备份加上binlog来将数据库恢复到故障点。这里的完全恢复是相对于时点恢复(也叫...

16920
来自专栏杨建荣的学习笔记

关于Oracle和MySQL中的无密码登录 (r5笔记第39天)

无密码登录在一定程度上能够简化流程,对于密码敏感,但是又需要提供访问权限的情况下是一个不错的选择。尤其是在乙方在做一些操作的时候,要密码和给密码是一个纠结的问题...

40430

扫码关注云+社区

领取腾讯云代金券