7.主从过滤复制和延迟复制

1.延时复制 

   配置延迟复制

# 从库上执行
mysql>stop slave;
mysql>CHANGE MASTER TO MASTER_DELAY = 300;   # 加上这一行
mysql>start slave;

   查看结果: show slave status

SQL_Delay: 300
SQL_Remaining_Delay: 266
slave_SQL_Running_State: Waiting until MASTER_DELAY seconds after master executed event
  • SQL_Delay: 从库要落后主库的秒数

  • SQL_Remaining_Delay: When Slave_SQL_Running_State is Waiting until MASTER_DELAY seconds after master executed event, this field contains an integer indicating the number of seconds left of the delay. At other times, this field is NULL.

  • Slave_SQL_Running_State: A string indicating the state of the SQL thread (analogous to Slave_IO_State). The value is identical to the State value of the SQL thread as displayed by SHOW PROCESSLIST.

   停止延迟复制

mysql> stop slave sql_thread;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> change master to master_delay=0;
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql> start slave sql_thread;
Query OK, 0 rows affected, 1 warning (0.01 sec)

参考:https://dev.mysql.com/doc/refman/5.7/en/replication-delayed.html

2.过滤复制

  过滤复制有数据库级别和表级别的过滤,其中数据库级别参数有(replicate-do-db|replicate-ignore-db) 表级别的有(--replicate-do-table|--replicate-ignore-table)

  也可以用库级别的参数+表级别的参数进行搭配用来进行过滤。然后这里要默认的binlog_format=ROW.

  从库中配置: 

 binlog_format = row
 replicate_ignore_db=test
 replicate_do_table=test1.s

    查看:show slave status\G;

Replicate_Ignore_DB: test
Replicate_Do_Table: test1.s

参考:https://dev.mysql.com/doc/refman/8.0/en/replication-rules-examples.html 

 

posted on   太白金星有点烦  阅读(39)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-03-18 2.oracle性能日常查看

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示