How to Provision and Deploy Highly Available Postgres with Terraform and Ansible Automation Scripts

March 13, 2020

 

The world loves Postgres. If you work with developers, data scientists or anyone wrangling data or you are one of them, you probably are already working on Postgres and know how to get started with the Postgres database. With the availability of the deployment scripts on EnterpriseDB GitHub, we have made the deployment of the Postgres platform easy.  

Improving the Postgres deployment experience by designing and developing automation that makes Postgres deployments in the cloud and on-premises, easy is the idea behind developing and making these scripts available for everyone.

 

High Available Postgres Cluster w/ Automatic Failover & Monitoring

Whether you are a new user trying out Postgres database or you are an enterprise with Postgres experience, you can equally leverage the simplified deployment of not only the Postgres database but the enterprise-class data management platform.

Using the deployment script you can setup - Highly Available Postgres Cluster with Automatic Failover and Monitoring enabled in minutes on AWS or VMware.

 

Terraform for Provisioning, Deployment & Ansible for Configuration

The Postgres deployments scripts use Terraform for provisioning of the compute, storage and network, and Ansible for configuration management. We use Terraform to stand up virtual machines or cloud instances depending on the provider, and then we hand over the reins to Ansible to finish up the configuration of the PostgreSQL database and tools like EDB Failover Manager (EFM) for high availability and Postgres Enterprise Manager(PEM) for monitoring the Postgres cluster.

The deployment scripts are currently available for 2 Terraform providers AWS and Vmware (Vsphere). Based on user inputs the next set of providers would be made available.

When you use the deployment scripts, you can setup not just the Postgres database of your choice( PG / EDB Postgres - Version 10 to 12) but in addition, the scripts will deploy and configure the tools as well that would take care of High availability and Automatic failover and also set up monitoring for the Postgres cluster.

 

Postgres Platform Architecture

The architecture is going to look like this:

PostgreSQL scripts, PostgreSQL deployment, Terraform, Ansible

High Availability & Resiliency

  1. Master & replica Spread Across
  2. Failover to most recent standby
  3. Reconfigure remaining standby to the new master. 
  4. allow switching the roles of Master-standby

Monitoring, Alerting & Tuning

  1. Monitor multiple database servers with an intuitive dashboard, email, SNMP alerts, and rich APIs. 
  2. Alerts on load, bloat, memory utilization, server/agent down
  3. stack slow queries, analyze and tune it

 

  • By default, the 3 node cluster would be provisioned – 1 Master and 2 Standby
  • They would have a replication setup between the master and standby nodes. Users have an option to choose the replication type, be it Synchronous / Asynchronous.
  • EFM agents are setup for each database node and will be responsible for failover management.
  • PEM Server is setup for monitoring the database, PEM agents are monitoring the database nodes and sending the data to the PEM server

 

Postgres Deployment, Provisioning & Configuration Steps

The Architecture that we discussed can be deployed as a single-use case or the user has an option to take a step-by-step approach as well. The deployment scripts have been kept modular and help you pick and choose based on your requirements. If you an advanced Postgres user and know that this is the exact enterprise use case I want to deploy, you can do it all in one go.

PostgreSQL scripts, PostgreSQL deployment, Terraform, Ansible
  1. Instance / VM are Provisioned – That would include not just Instance or server, but also provision Network, storage, etc
  2. Postgres Database - Postgres Database of your choice (PG/EPAS) is installed and configured.
  3. High Availability -  High Availability is put in place using the Failover manager. The scripts deploy and configure it for you.
  4. Monitoring - PEM server and PEM agents are configured to start monitoring and management of the newly setup cluster. 

 

EDB Postgres Deployment Scripts Available on the GitHub

From running Postgres on laptops to building out new applications with it to managing it across multi-cloud deployments or multiple sites, EnterpriseDB has made the deployment scripts available on the EnterpriseDB GitHub for you to try out. For detailed step by step instructions on the script usage, check out the Postgres Deployment Wiki Page.

 

Step by step instructions:  How to deploy PostgreSQL and EDB Postgres Platform on AWS using Terraform automation scripts

 

EDB wants to Make Postgres Easy for anyone to start using it easily and quickly.

The future of Postgres is about platform independence. Partnering with customers and encouraging their growth with Postgres is what we strive for. 

 

Share this