2

I need to setup a Highly available Postgresql Cluster. So I found Pacemaker and DRBD with pgpool load balancer are the best options.

So the architecture will look like this.

enter image description here

As of my knowledge, DRBD is for Block level replication (works on storage) and Pacemaker is Service Cluster (works on service level). So which is the best one to use and best HA solution?

And another question is Im using AWS EC2, So how can I manage VIP (I mean if the primary goes down how the PGpool will switch the VIP to Standby also its and in AWS)?

TheDataGuy
  • 1,986
  • 5
  • 36
  • 67

2 Answers2

4

Usually, you use them both. DRBD to replicate the data synchronously, and Pacemaker to manage where the services become active. Pacemaker will control promoting/demoting DRBD, and starting your database and virtual IP address.

Pacemaker uses resource-agents to manage cluster services. One of those, is a resource-agent for moving a secondary IP between AWS nodes: https://github.com/ClusterLabs/resource-agents/blob/master/heartbeat/awsvip

Hope that leads you down the right path.

2

Shared storage is a seriously bad idea with postgres unless you have total trust in your fencing.

It looks like DRBD is single-master, so it's probably OK.

It's absolutely vital that you ensure that the non-master's postgres is completely down, and there's zero overlap in which two postgres instances could be sharing the same data directory. Otherwise massive data corruption will occur. PostgreSQL is not a shared-storage database.

Get your STONITH and fencing right.

Personally, I'd recommend using PostgreSQL's replication, rather than block device replication, but I'm a PostgreSQL developer so that's hardly surprising.

Craig Ringer
  • 57,821
  • 6
  • 162
  • 193