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文件
[[email protected] ~] cat /data/mysqldata/auto.cnf  ### 主上的uuid
[auto]
server-uuid=62ee10aa-b1f7-11e4-90ae-080027615026

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

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

###再次查看slave的状态已经正常
[[email protected] ~]# 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://www.linuxidc.com

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

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-02/113564.htm

时间: 2024-10-11 12:45:25

slave have equal MySQL Server UUIDs原因及解决的相关文章

[转载][MySQL]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系统变量,已经是不同的设置,那原因是

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系统变量,已经是不同的设置,那原因是

mysql添加从库报错slave have equal MySQL server UUIDs

添加从库 问题出现情况1:复制的另一个从库的目录以及数据到新的从库,启动后报错: slave have equal MySQL server UUIDs 问题出现情况2:从主库复制目录以及数据到新的从库, 启动后报错: error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to w

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

配置MySQL主从复制,遇到报错 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 是因为主从服务器里auto.cnf中的server-uuid是相同的(服务器是复制过去的). 把从服务器中的auto.cnf重命名或者删除,然后重新启动MySQL,

故障案例:主从同步报错Fatal error: The slave I/O thread stops because master and slave have equal MySQL server

场景一:因为数据量非常,大概有1.4T,需要在原先master1-slave1的情况下再创建一个库slave2,并且挂在slave1下,即master1-slave1-slave2的结构.为了方便,当时停掉从库salve1,show master status记录状态,开启log_slave_updates,并且关闭salve1,然后将这个从库的data文件夹直接copy到新的从库,结果在创建slave2和slave1的主从关系时报错 Fatal error: The slave I/O thr

mysql5.5.44 主从复制master and slave have equal MySQL server ids

mysql5.5.44  主从复制配置 注:mysql从5.1.7以后开始就不支持my.cnf中"master-host"类似的参数; 必须在slave 的mysql中执行以下命令(最后的pos没有引号): mysql> change master to master_host='192.168.137.100', master_user='tongbu', master_password='123456', master_log_file='mysql-bin.000014',

配置MySQL主从复制报错Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work

配置MySQL主从复制报错 Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this do

关于MySQL的异常处理 Can't connect to MySQL server on localhost (10061)解决方法

首先检查MySQL 服务没有启动>如果没有启动,则要启动这个服务. 昨天,重起服务器后出现MySQL 'localhost' (10061)错误,开始以为是因为数据库链接打开过多,数据库资源耗尽的缘故,但是重启服务器以后,仍旧出现问题,于是在网上查找解决方法.大体如下: 解决办法: 第一步 删除c:\windows\下面的my.ini 第二步 打开c:\mysql\bin\winmysqladmin.exe 输入用户名 和密码 第三步 在dos下 输入 mysqld-nt -remove 删除服

Can't connect to MySQL server on localhost (10061)解决方法

出现这种错误的原因是由于MySQL的服务被关闭的原因,重新启动一下服务就可以了,启动服务的操作如下: 右键[计算机]-[管理] 选择MySQL右键点击[启动]就可以了 Can't connect to MySQL server on localhost (10061)解决方法