MySQL 5.7 複製的過濾引數

feelpurple發表於2016-04-30
1、庫級過濾引數

--binlog-do-db=db_name Master節點記錄二進位制日誌的庫

--binlog-ignore-db=db_name Master節點不記錄二進位制日誌的庫

--replicate-do-db=db_name Slave節點應用日誌的庫

--replicate-ignore-db=db_name Slave節點不應用日誌的庫

2、表級過濾引數

--replicate-do-table=db_name.tbl_name Slave節點執行指定表的修改事件

--replicate-wild-do-table=db_name.tbl_name Slave節點執行正則中含有指定表的修改事件

--replicate-ignore-table=db_name.tbl_name Slave節點不執行指定表的修改事件

--replicate-wild-ignore-table=db_name.tbl_name Slave節點不執行正則中含有指定表的修改事件

MySQL裡面有啟動引數、系統引數,啟動引數透過show variables無法查詢到,可以在mysqld的選項中查到
例如關於二進位制日誌有Startup Options Used with Binary Logging、System Variables Used with Binary Logging兩種引數
上面所說的複製過濾引數均為啟動引數

設定引數
[root@localhost log]# mysqld --verbose --help > 02.txt
[root@localhost log]# vim 02.txt
..
  --binlog-do-db=name Tells the master it should log updates for the specified
                      database, and exclude all others not explicitly
                      mentioned.
..
  --binlog-ignore-db=name
                      Tells the master that updates to the given database
                      should not be logged to the binary log.
..
  --replicate-do-table=name
                      Tells the slave thread to restrict replication to the
                      specified table. To specify more than one table, use the
                      directive multiple times, once for each table. This will
                      work for cross-database updates, in contrast to
                      replicate-do-db.
[root@localhost log]# vim /etc/my.cnf
..
# log
server-id = 10000
log-bin = /log/binlog/mysql-bin
binlog_format = MIXED
binlog-do-db = test

啟動資料庫後,檢視引數
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000009 |      120 | test         |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.03 sec)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2091370/,如需轉載,請註明出處,否則將追究法律責任。

相關文章