PostgreSQL 9.4 Allow time delayed standbys and recovery

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
简介:
PostgreSQL 9.4 支持standby apply xlog有一个时间延迟的配置, 即使XLOG源源不断的从master节点接收过来, standby可以判断一下当前系统时间和xlog rec上的时间戳, 只有xlog rec是比系统时间早过配置的时间的XLOG才允许apply, 否则就暂停apply,
该配置名为min_recovery_apply_delay. 在standby节点的recovery.conf中配置.
例如配置了1个小时, 那么standby节点会接收xlog, 但是apply会在系统时间的前1个小时.
这样可以允许standby弥补一些问题, 例如主库发生了一次误操作, 这次误操作如果在1小时内发现的话, standby其实就是误操作以前的数据库状态.

min_recovery_apply_delay (integer)

By default, a standby server keeps restoring WAL records from the primary as soon as possible. It may be useful to have a time-delayed copy of the data, offering various options to correct data loss errors. This parameter allows you to delay recovery by a fixed period of time, specified in milliseconds if no unit is specified. For example, if you set this parameter to5min, the standby will replay each transaction commit only when the system time on the standby is at least five minutes past the commit time reported by the master.

It is possible that the replication delay between servers exceeds the value of this parameter, in which case no delay is added. Note that the delay is calculated between the WAL timestamp as written on master and the time on the current standby. Delays in transfer because of networks or cascading replication configurations may reduce the actual wait time significantly. If the system clocks on master and standby are not synchronised, this may lead to recovery applying records earlier than expected but is not a major issue because the useful settings of the parameter are much larger than typical time deviation between the servers. Be careful to allow for different timezone settings on master and standby.

The delay occurs only on WAL records for COMMIT and Restore Points. Other records may be replayed earlier than the specified delay, which is not an issue for MVCC though may potentially increase the number of recovery conflicts generated.

The delay occurs until the standby is promoted or triggered. After that the standby will end recovery without further waiting.

This parameter is intended for use with streaming replication deployments, however, if the parameter is specified it will be honoured in all cases. Synchronous replication is not affected by this setting because there is not yet any setting to request synchronous apply of transaction commits. hot_standby_feedback will be delayed by use of this feature which could lead to bloat on the master; use both together with care.

使用注意事项, 
1. 主库和standby节点的时间做好同步, 尽量使用同样的时间服务器.
2. 不要和hot_standby_feedback同时使用. 因为如果配置了feedback的话, 主节点的vacuum会根据feedback来判断是否要回收某些垃圾. 降低conflict

[参考]
相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
相关文章
|
弹性计算 容灾 关系型数据库
PostgreSQL PITR 任意时间点恢复过程中如何手工得到recovery需要的下一个WAL文件名 - 默认情况下restore_command自动获取
标签 PostgreSQL , recovery , recovery.conf , restore_command , timeline , 时间线 , next wal , PITR , 时间点恢复 背景 PostgreSQL数据库支持PITR时间点恢复。默认情况下,只需要配置目标是时间点,resotre_command即可,PG会自动调用resotre_command去找需要的WA
1366 0
|
3天前
|
关系型数据库 MySQL BI
关系型数据库选择合适的数据库管理系统
关系型数据库选择合适的数据库管理系统
15 4
|
2天前
|
负载均衡 关系型数据库 MySQL
关系型数据库的安装和配置数据库节点
关系型数据库的安装和配置数据库节点
12 3
|
2天前
|
SQL 关系型数据库 数据库
关系型数据库选择合适的数据库管理系统
关系型数据库选择合适的数据库管理系统
9 2
|
3天前
|
SQL 存储 关系型数据库
性能诊断工具DBdoctor如何快速纳管数据库PolarDB-X
DBdoctor是一款基于eBPF技术的数据库性能诊断工具,已通过阿里云PolarDB分布式版(V2.3)认证。PolarDB-X是阿里云的高性能云原生分布式数据库,采用Shared-nothing和存储计算分离架构,支持高可用、水平扩展和低成本存储。PolarDB-X V2.3.0在读写混合场景下对比开源MySQL有30-40%的性能提升。DBdoctor能按MySQL方式纳管PolarDB-X的DN节点,提供性能洞察和诊断。用户可通过指定步骤安装PolarDB-X和DBdoctor,实现数据库的管理和性能监控。