MySQL56 GTID模式同步复制报错不能跳过解决方法

上传人:d****2 文档编号:169601258 上传时间:2022-11-16 格式:DOCX 页数:7 大小:17.11KB
返回 下载 相关 举报
MySQL56 GTID模式同步复制报错不能跳过解决方法_第1页
第1页 / 共7页
MySQL56 GTID模式同步复制报错不能跳过解决方法_第2页
第2页 / 共7页
MySQL56 GTID模式同步复制报错不能跳过解决方法_第3页
第3页 / 共7页
点击查看更多>>
资源描述
MySQL5.6 GTID模式,同步复制报错不能跳过解决方法。 数据库版本:mysql select version();+| version() | +| 5.6.10-log | +1 row in set (0.02 sec) 同步复制信息: mysql show slave statusG;V * 1. row *Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.8.25Master_User: replMaster_Port: 3306 Connect_Retry: 60Master_Log_File: mysql-bin.000007 Read_Master_Log_Pos: 5036Relay_Log_File: M2-relay-bin.000008 Relay_Log_Pos: 408Relay_Master_Log_File: mysql-bin.000007 Slave_IO_Running: YesSlave_SQL_Running: NoReplicate_Do_DB:Replicate_Ignore_DB: mysqlReplicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 1062Last_Error: Could not execute Write_rows event on table test.t; Duplicate entry 12 for key PRIMARY, Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the events master log mysql-bin.000007, end_log_pos 2267Skip_Counter: 0 Exec_Master_Log_Pos: 2045Relay_Log_Space: 3810 Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: NULLMaster_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 1062Last_SQL_Error: Could not execute Write_rows event on table test.t; Duplicate entry 12 for key PRIMARY, Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the events master log mysql-bin.000007, end_log_pos 2267Replicate_Ignore_Server_Ids:Master_Server_Id: 25Master_UUID: cf716fda-74e2-11e2-b7b7-000c290a6b8fMaster_Info_File: /usr/local/mysql/data2/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State:Master_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp: 130313 07:24:43Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:141-151Executed_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-140Auto_Position: 11 row in set (0.02 sec)ERROR:No query specified 提示主键冲突,由于是测试机,于是我直接跳过, mysql set global sql_slave_skip_counter=1;ERROR 1858 (HY000): sql_slave_skip_counter can not be set when the server is running with GTID_MODE = ON.Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction提示:由于运行在GTID模式,所以不支持sql_slave_skip_counter语法,如果你想跳过,就 必须把事务ID设置为空值。看来只能用这个方法了。mysql show global variables like %GTID%;| Variable_name| Value+| enforce_gtid_consistency | ON| gtid_executed| cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-140 | gtid_mode| ON| gtid_owned| gtid_purged| cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-140 |+5 rows in set (0.04 sec) mysql set global gtid_executed=;ERROR 1238 (HY000): Variable gtid_executed is a read only variable mysqlmysql set global gtid_purged=;ERROR 1840 (HY000): GTID_PURGED can only be set when GTID_EXECUTED is empty. 郁闷,直接设置还不行。查看了手册,需要执行reset master才可以(注:在从上执行啊,千万别在主上)。mysql reset master;Query OK, 0 rows affected (0.16 sec) mysql reset slave;ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE firstmysql stop slave;Query OK, 0 rows affected (0.08 sec) mysql reset slave;Query OK, 0 rows affected (0.16 sec)执行 reset slave 的目的是清空 master.info 和 relay-log.info,以便后面重新 change master to 主 从复制。还记得刚才的 gtid_purged 那个点吗,只需重新设置下一个点即可。下面是步骤:mysql show global variables like %GTID%;+| Variable_name| Value |+| enforce_gtid_consistency | ON | gtid_executed| gtid_mode| ON| gtid_owned| gtid_purged|5 rows in set (0.06 sec)TOmysql set global gtid_purged=cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-141; Query OK, 0 rows affected (0.16 sec)mysql CHANGE MASTERMASTER_HOST=192.168.8.25,MASTER_USER=repl,MASTER_PASSWORD=repl ,MASTER_AUTO_POSITION = 1;Query OK, 0 rows affected, 2 warnings (0.32 sec)mysql start slave;Query OK, 0 rows affected (0.13 sec)mysql show slave statusG;V* 1. row *Slave_IO_State: Waiting for master to send event Master_Host: 192.168.8.25 Master_User: replMaster_Port: 3306Connect_Retry: 60Master_Log_File: mysql-bin.000007Read_Master_Log_Pos: 5036Relay_Log_File: M2-relay-bin.000008Relay_Log_Pos: 408Relay_Master_Log_File: mysql-bin.000007Slave_IO_Running: YesSlave_SQL_Running: NoReplicate_Do_DB:Replicate_Ignore_DB: mysqlReplicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 1050Last_Error: Error Table t0 already exists on query.Default database: test. Query: create table t0 like tSkip_Counter: 0Exec_Master_Log_Pos: 2298 Relay_Log_Space: 3557 Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: NULLMaster_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 1050Last_SQL_Error: Error Table t0 already exists on query.Default database: test. Query: create table t0 like tReplicate_Ignore_Server_Ids:Master_Server_Id: 25Master_UUID: cf716fda-74e2-11e2-b7b7-000c290a6b8fMaster_Info_File: /usr/local/mysql/data2/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State:Master_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp: 130313 07:50:42Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:142-151Executed_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-141Auto_Position: 11 row in set (0.02 sec)ERROR:No query specified# 看,这里的报错信息已经不一样了,按照这种方法,重复执行,直到同步复制正常mysql stop slave;Query OK, 0 rows affected (0.07 sec) mysql reset master;Query OK, 0 rows affected (0.17 sec) mysql reset slave;Query OK, 0 rows affected (0.16 sec)mysql set global gtid_purged=cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-151;Query OK, 0 rows affected (0.13 sec)TOmysql CHANGE MASTER MASTER_HOST=192.168.8.25,MASTER_USER=repl,MASTER_PASSWORD=repl ,MASTER_AUTO_POSITION = 1;Query OK, 0 rows affected, 2 warnings (0.33 sec)mysql start slave;Query OK, 0 rows affected (0.11 sec)mysql show slave statusG;V* 1. row *Slave_IO_State: Waiting for master to send event Master_Host: 192.168.8.25 Master_User: replMaster_Port: 3306 Connect_Retry: 60Master_Log_File: mysql-bin.000007 Read_Master_Log_Pos: 5036Relay_Log_File: M2-relay-bin.000008 Relay_Log_Pos: 408Relay_Master_Log_File: mysql-bin.000007Slave_IO_Running: YesSlave_SQL_Running: Yes Replicate_Do_DB:Replicate_Ignore_DB: mysqlReplicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0 Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 5036 Relay_Log_Space: 819 Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File: Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: 0Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 25Master_UUID: cf716fda-74e2-11e2-b7b7-000c290a6b8fMaster_Info_File: /usr/local/mysql/data2/master.infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread toupdate itMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set:Executed_Gtid_Set: cf716fda-74e2-11e2-b7b7-000c290a6b8f:1-151Auto_Position: 11 row in set (0.01 sec)ERROR:No query specified呵呵,总算是解决好了,真麻烦啊。如果大家有更好、更方便的解决方法,也给我回帖哦 谢谢。
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!