跨库复制

网友投稿 257 2022-12-01

跨库复制

一.从库执行:show slave status\G;

admin@a8-dba-cloud-db00.wh ((none)) > show slave status\G;*************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.10.10.10 Master_User: mysqlsync Master_Port: 3307 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 3543191 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 3543396 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 3543191 Relay_Log_Space: 3543589 Until_Condition: None Until_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: 0Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 176689962 Master_UUID: 978aaabd-82b2-11ea-b0b5-e4434bac7bda Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 978aaabd-82b2-11ea-b0b5-e4434bac7bda:1-3692 Executed_Gtid_Set: 978aaabd-82b2-11ea-b0b5-e4434bac7bda:1-3692 Auto_Position: 1 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 1 row in set (0.00 sec)ERROR: No query specifiedSat May 2 00:58:24 2020

二.现象

使用replicate_do_db和replicate_ignore_db时有一个隐患,跨库更新时会出错。

如设置 replicate_do_db=testuse mysql;update test.table1 set ......第二句将不会被执行

如设置 replicate_ignore_db=mysqluse mysql;update test.table1 set ......第二句会被忽略执行

原因是设置replicate_do_db或replicate_ignore_db后,MySQL执行sql前检查的是当前默认数据库,所以跨库更新语句被忽略。

可以使用 replicate_wild_do_table 和 replicate_wild_ignore_table 来解决跨库更新的问题,如:replicate_wild_do_table=test.%或replicate_wild_ignore_table=mysql.%

这样就可以避免出现上述问题了

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Springboot错误页面和错误信息定制操作
下一篇:Linux中SSH免密登陆配置
相关文章

 发表评论

暂时没有评论,来抢沙发吧~