PostgreSQL Switchover vs. Failover

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
简介:

Wednesday, April 19, 2017 


With streaming replication, Postgres allows sophisticated setups of primary and standby servers. There are two ways to promote a standby to be the new primary. A switchover is

when the change happens in a planned way: 

1.All clients are disconnected from the master to prevent writes 

2.A sufficient delay allows the final write-ahead log (wal) records to be transferred to all standbys 

3.The primary is shut down 

4.The standby is promoted to be the primary 

A failover happens when the steps above can't be performed, usually because the primary has failed in some catastrophic way. The major difficulty with failover is the possibility

that some of the final database changes contained in the wal are not transferred to standbys, unless synchronous_standby_names was used. When a standby is promoted to 

primary after a failover, the final missing wal records can cause problems: 

1.Some transactions on the old primary that were acknowledged to clients might be lost 

2.If the old master needs to be reconnected as a standby without reimaging, it might be necessary to use pg_rewind 

Make sure you practice both methods of promoting a standby so, when you have to do the promotion in production, you are ready. 


2017年4月19日,星期三 

通过流复制方式,Postgres允许用复杂的方式配置所有 master 和 standby 服务器。standby 升级为新的 master 有两种方式。

角色切换,一般是一种有计划的变更:

1.所有连接 master 的客户端断开连接,阻止继续的写入。

2.足够的时间延迟允许最终所有 WAL 日志传输到所有 standbys 。

3.关闭 master 。

4.standby 升级为 primary。


通常如果 master 服务器发生灾难并变得已经无效,以上步骤无法执行时就必须要进行故障转移。故障转移发生时主要难题是可能一些包含在 WAL 中的代表数据库最终变化的 WAL 记录不会被传输到 standby ,除非使用了synchronous_standby_names。当一个 standby 经过故障转移后被提升为 master 最后的 WAL 记录也会导致一些问题:

1.旧 master 中的一些客户端确认提交的事务或许会丢失。

2. 如果旧 master 想作为一台 standby 被重新连接,没有重新生成的话,也许有必要使用pg_rewind。

确保你已经实践过以上提到的两种升级 standby 的方法,这样在生产环境做升级就会有所准备。


reference:


http://momjian.us/main/blogs/pgblog/2017.html#April_19_2017



本文转自 pgmia 51CTO博客,原文链接:http://blog.51cto.com/heyiyi/1917655
相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
相关文章
|
2月前
|
关系型数据库 分布式数据库 数据库
成都晨云信息技术完成阿里云PolarDB数据库产品生态集成认证
近日,成都晨云信息技术有限责任公司(以下简称晨云信息)与阿里云PolarDB PostgreSQL版数据库产品展开产品集成认证。测试结果表明,晨云信息旗下晨云-站群管理系统(V1.0)与阿里云以下产品:开源云原生数据库PolarDB PostgreSQL版(V11),完全满足产品兼容认证要求,兼容性良好,系统运行稳定。
|
2月前
|
关系型数据库 分布式数据库 数据库
PolarDB常见问题之数据库不能自己减少节点如何解决
PolarDB是阿里云推出的下一代关系型数据库,具有高性能、高可用性和弹性伸缩能力,适用于大规模数据处理场景。本汇总囊括了PolarDB使用中用户可能遭遇的一系列常见问题及解答,旨在为数据库管理员和开发者提供全面的问题指导,确保数据库平稳运行和优化使用体验。
|
2月前
|
缓存 关系型数据库 分布式数据库
PolarDB常见问题之数据库cpu突然飙高如何解决
PolarDB是阿里云推出的下一代关系型数据库,具有高性能、高可用性和弹性伸缩能力,适用于大规模数据处理场景。本汇总囊括了PolarDB使用中用户可能遭遇的一系列常见问题及解答,旨在为数据库管理员和开发者提供全面的问题指导,确保数据库平稳运行和优化使用体验。
|
20小时前
|
SQL JSON 关系型数据库
[UE虚幻引擎插件DTPostgreSQL] PostgreSQL Connector 使用蓝图连接操作 PostgreSQL 数据库说明
本插件主要是支持在UE蓝图中连接和操作PostgreSQL 数据库。
|
7天前
|
分布式计算 DataWorks 关系型数据库
DataWorks产品使用合集之在使用 DataWorks 数据集成同步 PostgreSQL 数据库中的 Geometry 类型数据如何解决
DataWorks作为一站式的数据开发与治理平台,提供了从数据采集、清洗、开发、调度、服务化、质量监控到安全管理的全套解决方案,帮助企业构建高效、规范、安全的大数据处理体系。以下是对DataWorks产品使用合集的概述,涵盖数据处理的各个环节。
17 0