本文介绍了如何使用Docker / Kubernetes建立PostgreSQL故障转移群集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还在围绕库伯纳斯包围我的头,这应该是如何工作的。目前,我正在努力地了解如何使用流式复制,扩展和自动故障转移/故障恢复( pgpool-II repmgr ,选择你的毒药)



我的主要问题是PostgreSQL实例的双重性质,它是主人或冷/暖/热待命。如果我增加了副本的数量,我希望他们全部成为备用,所以我想象一下,创建一个 postgresql-standby 复制控制器与 postgresql-master pod。不过我也希望其中一个Standbys成为主人,以防万一现在的主人关闭,所以它是一个常见的 postgresql 复制控制器。
$ b

到目前为止,我唯一的想法是将复制配置放在外部卷上,并管理容器外的状态和状态。



(在PostgreSQL的情况下,配置可能已经在其数据目录中的卷上,这本身显然是我想要的数量,但这是旁边的一点)



这是正确的选择,还是有其他更干净的方式?

解决方案

OpenShift有一个例子:原理在纯Kube中是一样的(它没有使用任何真正的OpenShift specifi c,您可以使用平原码头中的图像)


I'm still wrapping my head around Kubernetes and how that's supposed to work. Currently, I'm struggling to understand how to model something like a PostgreSQL cluster with streaming replication, scaling out and automatic failover/failback (pgpool-II, repmgr, pick your poison).

My main problem with the approach is the dual nature of a PostgreSQL instance, configuration-wise -- it's either a master or a cold/warm/hot standby. If I increase the number of replicas, I'd expect them all to come up as standbys, so I'd imagine creating a postgresql-standby replication controller separately from a postgresql-master pod. However I'd also expect one of those standbys to become a master in case current master is down, so it's a common postgresql replication controller after all.

The only idea I've had so far is to put the replication configuration on an external volume and manage the state and state changes outside the containers.

(in case of PostgreSQL the configuration would probably already be on a volume inside its data directory, which itself is obviously something I'd want on a volume, but that's beside the point)

Is that the correct approaach, or is there any other cleaner way?

解决方案

There's an example in OpenShift: https://github.com/openshift/postgresql/tree/master/examples/replica The principle is the same in pure Kube (it's not using anything truly OpenShift specific, and you can use the images in plain docker)

这篇关于如何使用Docker / Kubernetes建立PostgreSQL故障转移群集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 21:45