ITPub博客

首页 > 数据库 > MySQL > MySQL 5.7 复制的过滤参数

MySQL 5.7 复制的过滤参数

原创 MySQL 作者:feelpurple 时间:2016-04-30 23:46:30 0 删除 编辑
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博客 ” ,链接:https://blog.itpub.net/26506993/viewspace-2091370/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-08-01

  • 博文量
    404
  • 访问量
    1673977