91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

主從復制中忽略庫的參數

發布時間:2020-05-01 12:03:28 來源:網絡 閱讀:1416 作者:qhd2004 欄目:MySQL數據庫

replicate-ignore-db

在slave服務器上設置 replicate-ignore-db = test(my.conf中設置)


在master上如下執行

use test

delete from moedb.moe_userinfo where id=3;  slave上此語句不執行


replicate_do_db

如在slave服務器上設置 replicate_do_db = test(my.conf中設置)


在master上如下執行

use moedb

insert into test.moe(id,name) values (1,'moe');  slave上此語句不執行


原因是設置replicate_ignore_db或replicate_do_db后,MySQL執行sql前檢查的是當前默認數據庫,所以跨庫更新語句在Slave上會被忽略。

可以在Slave上使用 replicate_wild_do_table 和 replicate_wild_ignore_table 來解決跨庫更新的問題,如:

replicate_wild_ignore_table=test.%

replicate_wild_do_table=test.%


如果是針對多個庫,那每行一個庫名,例如,需要忽略test、mysql,如下:

replicate_wild_ignore_table=test.%

replicate_wild_ignore_table=mysql.%


參考如下:

原文: http://www.mysqlperformanceblog.com/2009/05/14/why-mysqls-binlog-do-db-option-is-dangerous/

作者: Baron Schwartz

Why MySQL’s binlog-do-db option is dangerous

為什么 MySQL的 binlog-do-db 選項是危險的.

 

I see a lot of people filtering replication with binlog-do-db, binlog-ignore-db, replicate-do-db, and replicate-ignore-db. Although there are uses for these, they are dangerous and in my opinion, they are overused. For many cases, there's a safer alternative.

 

我發現很多人通過 binlog-do-db, binlog-ignore-db, replicate-do-db 和 replicate-ignore-db 來過濾復制(某些數據庫), 盡管有些使用, 但是,在我看來,他們是危險的,并且他們被濫用了. 對于很多的實例,有更安全的替換方案.

 

The danger is simple: they don't work the way you think they do. Consider the following scenario: you set binlog-ignore-db to "garbage" so data in the garbage database (which doesn't exist on the slave) isn't replicated. (I'll come back to this in a second, so if you already see the problem, don't rush to the comment form.)

 

為什么危險很簡單: 他們并不像你想的那樣工作. 想象如下的場景: 你設置了 binlog-ignore-db = garbage, 所以 garbage數據庫(在slave上不存在這個數據庫) 中的數據不會被復制,(待會兒我再講這個,如果你已經發現問題了,不要急于到評論表單)

 

Now you do the following:

現在做下面的事情:

$ mysql
mysql> delete from garbage.junk; 
mysql> use garbage;
mysql> update production.users set disabled = 1 where user = "root";

You just broke replication, twice. Once, because your slave is going to execute the first query and there's no such table "garbage.junk" on the slave. The second time, silently, because the update to production.users isn't replicated, so now the root user isn't disabled on the slave.

 

復制會broke2次, 第一次,因為 slave嘗試著去之西你給第一條語句,但是slave上并沒有這樣的表"garbage.junk" , 第二次, 隱含的, 因為 對 production.users不會被 復制,因為 root帳號并沒有在slave上被禁用掉.

 

Why? Because binlog-ignore-db doesn't do what you think. The phrase I used earlier, "data in the garbage database isn't replicated," is a fallacy. That's not what it does. In fact, it filters out binary logging for statements issued from connections whose default database is "garbage." In other words, filtering is not based on the contents of the query -- it is based on what database you USE.

 

為什么? 因為 binlog-ignore-db 并不像你想的那樣執行, 我之前說的, "在garbage數據庫中的數據不會被復制" 是錯的, 實際上(數據庫)并沒有這么做.事實上, 他是通過默認的數據庫為“garbage" 的連接, 過濾二進制的(SQL)語句日志的. 換句話說, 過濾不是基于 查詢的字符串的, 而實際于你used的數據庫.

 

 

The other configuration options I mentioned work similarly. The binlog-do-db and binlog-ignore-db statements are particularly dangerous because they keep statements from ever being written to the binary log, which means you can't use the binary log for point-in-time recovery of your data from a backup.

 

其他我提到的配置選項也都類似. binlog-do-db 和 binlog-ignore-db 語句是特別危險的,因為他們將語句寫入了二進制日志. 意味著你不能使用二進制日志從備份恢復指定時間的數據.

 

In a carefully controlled environment, these options can have benefits, but I won't talk about that here. (We covered that in our book.)

 

在嚴格控制的環境中, 這些選項是很有用的,但是我不會談論這些(這些包含在我們的書中),

 

The safer alternative is to configure filters on the slave, with options that actually operate on the tables mentioned in the query itself. These are replicate-wild-* options. For example, the safer way to avoid replicating data in the garbage database is to configure replicate-wild-ignore-table=garbage.%. There are still edge cases where that won't work, but it works in more cases and has fewer gotchas.

 

安全的替換方案是 在 slave上配置過濾, 使用基于查詢中真正涉及到的表的選項, 這些是: replicate-wild-* 選項, 例如, 避免復制 garbage數據庫中的數據的安全的方案是 配置: replicate-wild-ignore-table=garbage.%. 這樣做仍然有一些特殊的情況, 不能正常工作,但可以在更多的情況下正常工作,并且會遇到更少的意外 (gotchas).

 

If you are confused, you should read the replication rules section of the manual until you know it by heart

如果你有些疑惑了,你應該去讀一讀手冊上的復制規則一節,直到你真正明白為止.

 

Refer from http://www.mysqlperformanceblog.com/2009/05/14/why-mysqls-binlog-do-db-option-is-dangerous


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

丽江市| 保定市| 葵青区| 富锦市| 永宁县| 贵德县| 贵州省| 巴南区| 新民市| 渝中区| 德保县| 麻阳| 邵阳市| 绥化市| 稷山县| 宜城市| 昌宁县| 柏乡县| 武宣县| 思南县| 凯里市| 本溪| 巴马| 皋兰县| 石屏县| 阳江市| 蓬溪县| 小金县| 永城市| 石楼县| 吴忠市| 三明市| 曲水县| 新建县| 宁陕县| 商丘市| 宁夏| 志丹县| 沂水县| 平塘县| 突泉县|