Error 1236 A slave with the same server_uuid/server_id as this slave has connected to the master

mysql-replication

I got this error when configuring single master multiple slave servers.

Last_IO_Error :Got fatal error 1236 from master when reading data from binary log : ' A slave with the same server_uuid/server_id as this slave has connected to the master; the first event 'mysql-bin.xxxx' at event read from /var/lib/mysql/mysql-bin.xxx' at xx, the last byte read from '/var/lib/mysql/mysql-bin.xxx' at xxx.'
Screenshot from one of the slave

Best Answer

APPLIES TO: MySQL Server - Version 5.6 and later Information in this document applies to any platform.

When attempting to start replication, the following error occurs:

mysql> SHOW SLAVE STATUS\G
*************************** 1. row *************************** ... Slave_IO_Running: No Slave_SQL_Running: Yes ... 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: ... Master_UUID: 7cb3e340-39d6-11e3-bc02-080027fa0f20 ... 1 row in set (0.00 sec)

The error can also be seen in the error log:

2013-11-12 09:54:21 10149 [ERROR] Slave I/O: 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. Error_code: 1593 2013-11-12 09:54:21 10149 [Note] Slave I/O thread exiting, read up to log 'binlog.000005', position 231

CHANGES This issue will typically happen just after cloning a slave from the master, particularly when file system snapshots are used or the data directory has been copied using file system commands.

CAUSE The server UUIDs are the same for the master and slave. The UUIDs are used to identify the servers, so they must be identical. This is for example needed for replication using GTIDs.

The server UUID is stored in the file auto.cnf which is located in the data directory. You can see the value of the server's UUID with:

mysql> SHOW GLOBAL VARIABLES LIKE 'server_uuid'; +---------------+--------------------------------------+ | Variable_name | Value | +---------------+--------------------------------------+ | server_uuid | 7cb3e340-39d6-11e3-bc02-080027fa0f20 | +---------------+--------------------------------------+ 1 row in set (0.00 sec) To see the master's UUID, you can use the output of SHOW SLAVE STATUS:

mysql> SHOW SLAVE STATUS\G
*************************** 1. row *************************** ... Master_UUID: 7cb3e340-39d6-11e3-bc02-080027fa0f20 ... 1 row in set (0.00 sec)

SOLUTION If auto.cnf does not exists, MySQL will automatically create a new file with a new UUID. So to resolve the issue:

  1. Stop MySQL process on the slave.
  2. Remove the auto.cnf file from the data directory.
  3. Start MySQL again on the slave.

You should also revise your procedure for creating the slave to ensure the auto.cnf file is not copied across from the master.