MySQL的复制过滤器

本文介绍了MySQL的复制过滤器,用于选择性地将主库的部分数据复制到从库。通常,过滤器配置在从库上以避免主库的日志信息过于局限。通过实验配置,展示了如何设置过滤器并验证其效果,确保从库只接收特定数据库的更新操作。
摘要由CSDN通过智能技术生成

1、过滤器概述
主数据库只复制给从数据库一部分数据给从节点,而不是复制全部内容;复制过滤器可以设置有哪些数据可以复制到从节点,类似于“白名单”,哪些数据是不可以进行复制,类似“黑名单”。
复制过滤器有两种实现机制:一种是在主库进行配置,一种是在从库上配置。然而第一种一般不会使用,因为如果在主库上配置过滤器,那么主库的二进制日志记录的便只有某一个数据库的信息,而不会记录其他库的信息,这样如果发生故障进行数据恢复时就没办法从二进制日志进行重放恢复。
所以一般会采用第二种方式,在从库上配置过滤器,但是也有缺点,就是增加IO读写的压力,因为主节点记录所有库的二进制日志信息依然会被从节点IO线程读取,并存储在从节点的中继日志中,由于设置了过滤,在从节点执行SQL线程时只会重放未被过滤掉的操作。

2、实验配置
1)先配置数据库主从
主库配置:

[root@www ~]# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
log_bin=master-bin
server_id=1
[root@www ~]# systemctl restart mariadb.service
[root@www ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> grant  replication slave,replication client  on  *.* to 'jyy'@'192.168.126.135' identified by  'jyy';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> 

从库配置:

[root@www ~]#vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
server_id=3
relay_log=relay-log
[root@www ~]# systemctl restart mariadb.service
[root@www ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值