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
: WhenSlave_SQL_Running_State
isWaiting 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 isNULL
. -
Slave_SQL_Running_State
: A string indicating the state of the SQL thread (analogous toSlave_IO_State
). The value is identical to theState
value of the SQL thread as displayed bySHOW 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
2022-03-18 2.oracle性能日常查看