

You need to configure security groups of your servers to restrict the Incoming and the Outgoing traffic to the EC2 Instances. We will refer to these servers as node-4 and node-5 respectively. Reserve two servers for installing etcd and HAProxy.Ensure Pip3 package manager is installed on all your servers to install and manage packages on your servers by following the guide How to Install Pip3 on Ubuntu 20.04 and Use It?.Ensure Python 3 is available on your three servers where PostgreSQL is installed by following the guide Install python.These three servers are referred as node-1, node-2, node-3 in this tutorial. Just follow Step 1 of PostgreSQL installation tutorial. Install PostgreSQL on three of your servers by following the Install PostgreSQL on Ubuntu 20.04.In all five nodes, Upgrade the packages to the latest versions using sudo apt upgrade.In all five nodes, Update the packages list which are upgrade-able using sudo apt update.Create 5 EC2 instances in AWS by following the guide How to launch EC2 instance in EC2.Prerequisitesīefore you begin this guide, you’ll need the following: When you’re finished, you will have a robust and highly available PostgreSQL cluster ready for production use. It keeps track of changes in the Master/Slave nodes and connects to the appropriate master node when the clients request connection. It becomes difficult to maintain the database end points in this situation. With this high availability solution which has more than one database instances in a single cluster, the master node of the cluster keeps changing in case of any failure. With this information, ETCD elects the master node and keeps the cluster UP and running. Whenever there is a change in the state of any PostgreSQL node in the cluster, Patroni updates the state change in the ETCD key-value store. It gracefully handles leader elections during network partitions and can tolerate machine failure, even in the leader node. It is also capable of handling Database replication, backup and restoration configurations.ĮTCD is a fault-tolerant, distributed key-value store that is used to store the state of the PostgreSQL cluster.

Patroni is a template for you to create your own customized, high-availability solution developed using Python. In this tutorial, you’ll set up the PostgreSQL with high availability using Patroni, ETCD and HAProxy. There are other open source frameworks available which can be used to manage high availability of the PostgreSQL Database. It is highly robust and versatile, but doesn’t have features for the high availability. PostgreSQL is an opensource relational database that can run on major operating systems.
