HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Can I cluster PostgreSQL by sharing a data directory over NFS?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlcandirectorynfsclusterdataoversharing

Problem

I created a PostgreSQL cluster in one host and shared it over NFS share to another host. Even though i can access the cluster using second host but can not use or log in to databases. Is it possible to use a single cluster by multiple hosts? so i can introduce it to clients as a single host and in case the first host that was used to create the cluster is down, the other host keeps the cluster running so clients would not face any connectivity or accessibility issue to that cluster.

Solution

No, you can not share a data directory over NFS.

This is a horrible idea if for no other reason than because fsync() assumes that there is only one buffer to the input device running on a single host which issues the fsync. It only ensures flushing buffers from the host you run it on. There is no way around this. You can not share a resource with two machines that use fsync.

Aside from all the buffering complexities, there are supported mechanisms to cluster PostgreSQL. I suggest reviewing the chapter on "High Availability, Load Balancing, and Replication" and also reviewing the wiki page "Replication, Clustering, and Connection Pooling".

Context

StackExchange Database Administrators Q#146700, answer score: 2

Revisions (0)

No revisions yet.