Replication With ZFS and PostgreSQL - Six Feet Up
Replication With ZFS and PostgreSQL - Six Feet Up
Sections
Six Feet Up
Blog
Thanks for filling out the form! A Six Feet Up representative will be in contact with you soon.
First Name
Last Name
Message
Submit
<< All Blog Posts
Postgresql
Relstorage
ZFS
replication
FreeBSD
When clients have high availability requirements for their Plone site, we recommend using the RelStorage implementation for the ZODB, combined with the
PostgreSQL database platform. When we deploy this solution, we use ZFS on FreeBSD. Until recenty, this solution relied on rsync to synchronize the PostgreSQL
data directory from the primary server to the secondary server. The problem with this approach is that rsync has to scan the entire data directory to find changed files.
We decided to take advantage of the ZFS snapshot replication features to make this step more efficient.
Since ZFS snapshots have the deltas we need regarding changes to the PostgreSQL data directory, we wrote a script that will:
Prerequesites
There are moving parts to this solution, so you'll need to do some leg work before being able to use the script.
PostgreSQL User
The calls to pg_start_backup and pg_stop_backup require elevated privileges in PostgreSQL. Here's how to set up a PostgreSQL database user with the
replication role:
Then, in pg_hba.conf:
You can use md5 for the METHOD, but you must then setup the .pgpass file for your operating system user.
In order to take advantage of efficient incremental replication, the secondary database server must first transfer an initial snapshot of the ZFS filesystem holding the
current PostgreSQL data directory (this builds on the first requisite above, to be run on the secondary server):
Coup de grâce
The reset_secondary.sh script (and ancillary config file info) is on Github: https://gist.github.com/davidblewett/8282108 . It's usage is pretty simple (on secondary):
After the script has run, the secondary server will be running off of an up-to-date ZFS snapshot. If you use the config file info in the gist, it will then continue to use
PostgreSQL's built-in streaming replication to keep itself up to date.
It is possible to build on this setup and add automatic failover and promotion of the secondary to primary by using FreeBSD's CARP and ifstated mechanisms.
Filed under:
Postgresql
Relstorage
ZFS
replication
FreeBSD
Free Guide
Use this free guide when interviewing technology partners to determine if they are a good fit for your next project.
Name Email Download
Newsletter Sign Up
Get our latest posts and tips delivered to your inbox.
Email Sign Up
Categories
Open Source
Python
Django
Plone
AWS
Cloud
Performance
Best Practices
Cool Factor
Follow Us
!
Facebook
"
Twitter
#
LinkedIn
$
YouTube
+
Google+
Contact Us
Main Office Location
Six Feet Up Headquarters
9084 Technology Drive - Suite 100
Fishers, IN 46038 - USA
Phone: +1 (317) 861-5948
Fax: +1 (775) 295-6925
Email: [email protected] [email protected]
Mailing Address
Six Feet Up, Inc.
5604 W Hackberry Trail
New Palestine, IN 46163
!
#
$
"
+
Tweets by @sixfeetup
Six Feet Up, Inc.
@sixfeetup
Hands on with Multisite Management using Lineage by @calvinhp buff.ly/2HmYkdY
Subscribe
Company | Expertise | Services | Technologies | Projects | Blog | Contact Us
© 2018 Six Feet Up, Inc. All rights reserved. Powered by Plone Section 508 WCAG Accessibility Privacy Sitemap