简体   繁体   English

MySQL错误1236使用GTID时

[英]MySQL error 1236 When using GTID

I want to create a replica to my Percona Server with GTID enabled, but got this error when i show slave status: 我想在启用GTID的情况下为Percona Server创建副本,但在显示slave状态时出现此错误:

Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.'

Normally, i would stop my slave, reset it, reset master (on the slave), and get new GTID_PURGED value from the master. 通常,我会停止我的奴隶,重置它,重置主机(在从机上),并从主机获得新的GTID_PURGED值。 But this time around, the master has a very unusual value(s) and i am not sure how to determine which one to use: 但这一次,主人有一个非常不寻常的价值,我不知道如何确定使用哪一个:

mysql> show master status\G
*************************** 1. row ***************************
             File: mysqld-bin.000283
         Position: 316137263
     Binlog_Do_DB: 
 Binlog_Ignore_DB: 
Executed_Gtid_Set: 1570dee1-165b-11e6-a4a2-00e081e93212:1-3537,
c73f3ee7-e8d4-ee19-6507-f898a9930ccd:1-18609,
cdb70eaa-f753-ee1b-5c95-ecb8024ae729:1-2357789559:2357789561-2357790104:2357790106-2514115701:2514115703-2514115705:2514115707-2546512667
1 row in set (0.00 sec)

From the slave with the new backup copy, i get this: 从具有新备份副本的slave,我得到:

root@ubuntu:/var/lib/mysql# cat xtrabackup_binlog_info
mysqld-bin.000283       294922064       1570dee1-165b-11e6-a4a2-00e081e93212:1-3537,
c73f3ee7-e8d4-ee19-6507-f898a9930ccd:1-18609,
cdb70eaa-f753-ee1b-5c95-ecb8024ae729:1-2357789559:2357789561-2357790104:2357790106-2514115701:2514115703-2514115705:2514115707-2546400960

One more thing, i just purged the binary logs on the master before i made a backup. 还有一件事,我在备份前清除了主服务器上的二进制日志。 automatic binlog purge is set to 7 days. 自动binlog清除设置为7天。 So i know its not because the bin log has been purged as the error is suggesting. 所以我知道这不是因为bin日志已被清除,因为错误是建议的。

I am running Ubuntu 14:04, and Percona server version 5.6.31-77. 我正在运行Ubuntu 14:04,以及Percona服务器版本5.6.31-77。

How can i resolve this issue? 我该如何解决这个问题? What is the correct value of the master's GTID_PURGED? 主人的GTID_PURGED的正确值是多少?

mysql 5.6 GTID replication errors and fixes What is GTID? mysql 5.6 GTID复制错误和修复什么是GTID?

4c2ad77f-697e-11e3-b2c3-c80aa9f17dc4
  • This is the server's 128 bit identification number (SERVER_UUID). 这是服务器的128位标识号(SERVER_UUID)。 It identifies where the transaction was originated. 它标识交易的起源地。 Every server has its own SERVER_UUID. 每个服务器都有自己的SERVER_UUID。 What problems GTID solves? GTID解决了什么问题?

  • It is possible to identify a transaction uniquely across the replication servers. 可以跨复制服务器唯一地标识事务。 Make the automation of failover process much easier. 使故障转移过程的自动化更加容易。 There is no need to do calculations, inspect the binary log and so on. 无需进行计算,检查二进制日志等。 Just MASTER_AUTO_POSITION=1. 只是MASTER_AUTO_POSITION = 1。

  • At application level, it is easier to do WRITE/READ split. 在应用程序级别,更容易进行WRITE / READ拆分。 After a write on the MASTER, you have a GTID so just check if that GTID has been executed on the SLAVE that you use for reads. 在MASTER上写入后,您有一个GTID,所以只需检查是否已在用于读取的SLAVE上执行了GTID。
  • Development of new automation tools isn't a pain now. 开发新的自动化工具现在并不痛苦。 How can I implement it? 我该如何实现它?

Three variables are needed in ALL servers of the replication chain 复制链的所有服务器都需要三个变量

  • gtid_mode: It can be ON or OFF (not 1 or 0). gtid_mode:可以是ON或OFF(不是1或0)。 It enables the GTID on the server. 它在服务器上启用GTID。
  • log_bin: Enable binary logs. log_bin:启用二进制日志。 Mandatory to create a replication environment. 必须创建复制环境。
  • log-slave-updates: Slave servers must log the changes that come from the master in its own binary log. log-slave-updates:从属服务器必须在其自己的二进制日志中记录来自主服务器的更改。
  • enforce-gtid-consistency: Statements that can't be logged in a transactionally safe manner are denied by the server. enforce-gtid-consistency:服务器拒绝无法以事务安全方式记录的语句。 ref: http://dev.mysql.com/doc/refman/5.6/en/replication-gtids-howto.html 参考: http//dev.mysql.com/doc/refman/5.6/en/replication-gtids-howto.html

Replication errors and fixes: 复制错误和修复:

"'Got fatal error 1236 from master when reading data from binary log: "The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires." slave_io thread stop running. “当从二进制日志读取数据时,来自主站的致命错误1236:”从站使用CHANGE MASTER连接到MASTER_AUTO_POSITION = 1,但主站已清除包含从站所需的GTID的二进制日志。“slave_io线程停止运行。

Resolution: Considering following are the master – slave UUID's 解决方案:考虑以下是主 - 从UUID

MASTER UUID: 4c2ad77f-697e-11e3-b2c3-c80aa9f17dc4
SLAVE UUID: 5b37def1-6189-11e3-bee0-e89a8f22a444

Steps: 脚步:

slave>stop slave;

slave> FLUSH TABLES WITH READ LOCK;

slave>show master status;

'4c2ad77f-697e-11e3-b2c3-c80aa9f17dc4:1-83345127,5b37def1-6189-11e3-bee0-e89a8f22a444:1-13030:13032-13317:13322-13325:13328-653183:653185-654126:654128-1400817:1400820-3423394:3423401-5779965′

(HERE 83345127  Last GTID executed on master and 5779965 Last slave GTID executed on Master )

slave> reset master;

slave>set global GTID_PURGED='4c2ad77f-697e-11e3-b2c3-c80aa9f17dc4:1-83345127,5b37def1-6189-11e3-bee0-e89a8f22a444:1-5779965′;

slave>start slave;

slave>unlock  tables;

  slave>show slave status;

NOTE: After this Re-start slave other chain-slaves if they stop replicating; 注意:如果它们停止复制,则在重新启动从属其他链式从属之后;

ERROR: 'Error "Table … 'doesn"t exist" on query. Default database: …Query: "INSERT INTO OR Last_SQL_Error: ….Error 'Duplicate entry' SKIP Transaction on slave (slave_sql Thread stop running) NOTE: 错误:'错误'表...'查询不存在'。默认数据库:...查询:“INSERT INTO OR Last_SQL_Error:...。Error'重复项'从站的SKIP事务(slave_sql线程停止运行)注意:

  • SQL_SLAVE_SKIP_COUNTER doesn't work anymore with GTID. SQL_SLAVE_SKIP_COUNTER不再适用于GTID。
  • We need to find what transaction is causing the replication to fail. 我们需要找到导致复制失败的事务。
    • – From binary log - 从二进制日志
    • – From SHOW SLAVE STATUS (retrieved vs executed) Type of errors: (check last sql error in show slave status) - 从SHOW SLAVE STATUS(检索到已执行)错误类型:(检查show slave status中的最后一个sql错误)

Resolution: Considering following are the master – slave UUID's 解决方案:考虑以下是主 - 从UUID

MASTER UUID: 4c2ad77f-697e-11e3-b2c3-c80aa9f17dc4
SLAVE UUID: 5b37def1-6189-11e3-bee0-e89a8f22a444

slave>show slave status; 奴隶>显示奴隶状态;

copy the 'Executed_Gtid_Set' value. 复制'Executed_Gtid_Set'值。 '4c2ad77f-697e-11e3-b2c3-c80aa9f17dc4:1-659731804,5b37def1-6189-11e3-bee0-e89a8f22a444:1-70734947-80436012:80436021-80437839' '4c2ad77f-697e-11e3-b2c3-c80aa9f17dc4:1-659731804,5b37def1-6189-11e3-bee0-e89a8f22a444:1-70734947-80436012:80436021-80437839'

-Seems that slave (with uuid 5b37def1-6189-11e3-bee0-e89a8f22a444) transaction '80437840' is causing the problem here. -seems奴隶(与uuid 5b37def1-6189-11e3-bee0-e89a8f22a444)交易'80437840'在这里造成了问题。

slave> STOP SLAVE;

slave> SET GTID_NEXT="5b37def1-6189-11e3-bee0-e89a8f22a444:80437840";  (last_executed_slave_gtid_on_master + 1)

slave> BEGIN; COMMIT;

slave> SET GTID_NEXT="AUTOMATIC";

slave> START SLAVE;

slave>  show slave status;

and it's ALL SET !!! 这一切都是!!!

#If using xtrabackup is the backup in the main instance. #如果使用xtrabackup是主实例中的备份。

cat xtrabackup_info | grep binlog_pos

#Use the information you gave as an example: #使用您提供的信息作为示例:

binlog_pos = filename 'mysqld-bin.000283', position '294922064', GTID of the last change '1570dee1-165b-11e6-a4a2-00e081e93212:1-3537,c73f3ee7-e8d4-ee19-6507-f898a9930ccd:1-18609,cdb70eaa-f753-ee1b-5c95-ecb8024ae729:1-2357789559:2357789561-2357790104:2357790106-2514115701:2514115703-2514115705:2514115707-2546400960' binlog_pos = filename'mysqld-bin.000283',位置'294922064',最后一次更改的GTID'1570dee1-165b-11e6-a4a2-00e081e93212:1-3537,c73f3ee7-e8d4-ee19-6507-f898a9930ccd:1-18609, cdb70eaa-f753-ee1b-5c95-ecb8024ae729:1-2357789559:2357789561-2357790104:2357790106-2514115701:2514115703-2514115705:2514115707-2546400960'

#copy GTID of the last change to gtid_purged #copy GTID对gtid_purged的最后一次更改

slave>STOP SLAVE;
slave>RESET MASTER;
slave>SET GLOBAL gtid_purged='1570dee1-165b-11e6-a4a2-00e081e93212:1-3537,c73f3ee7-e8d4-ee19-6507-f898a9930ccd:1-18609,cdb70eaa-f753-ee1b-5c95-ecb8024ae729:1-2357789559:2357789561-2357790104:2357790106-2514115701:2514115703-2514115705:2514115707-2546400960';
slave>change master to master_host='master ip',master_port=master port,MASTER_USER = 'Your replicate username', MASTER_PASSWORD = 'Your replicate password',master_auto_position=1; 
slave>START SLAVE;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM