從屬伺服器具有相同的 MySQL 伺服器 UUID

黄舟
發布: 2017-02-15 10:50:02
原創
1376 人瀏覽過

    最近在部署MySQL主從複製架構的時候,碰到了"Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal My 錯誤提示。即主從架構中使用了相同的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://www.php.cn/
登入後複製


4、延生參考
a、有關server_id的描述
The server ID, used in replication to give each master and slave a unique identity. This 集. 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.

、有關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, server-on vhariableuu只讀變數)

When starting, the MySQL server automatically obtains a UUID as follows:a).  Attempt to read and use the UUID written in the data_dir/hersserverf (dir/Ffilethe)f (dir/profilef. ); 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.that used for my.finior used for my. files. In MySQL 5.6,

auto.cnf has only a single [auto] section containing a single server_uuid [1992] setting and

value;



automatically generated; you should not attempt to write
or modify this file

 

Also beginning with MySQL 5.6, when snows SQL SQL ​​dowues 完成. s UUID can be seen in the output of SHOW SLAVE HOSTS. OnceSTART 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.A5,7. 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

的上述內容,以上是更多內容。相關內容請關注PHP中文網(www.php.cn)!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!