Home United States USA — software How to Set Up PostgreSQL High Availability With Patroni

How to Set Up PostgreSQL High Availability With Patroni

283
0
SHARE

This guide demonstrates how you can create a PostgreSQL High Availability cluster with Patroni, etcd, and HAProxy on Ubuntu 20.04.
Join the DZone community and get the full member experience. PostgreSQL is an open-source, versatile, and most popular database system around the world. However, it does not have any features for high availability. Enter Patroni. Patroni is a cluster manager tool used for customizing and automating deployment and maintenance of high availability PostgreSQL clusters. It is written in Python and uses etcd, Consul, and ZooKeeper as a distributed configuration store for maximum accessibility. In addition, Patroni is capable of handling database replication, backup, and restoration configurations. In this guide, we will show you how to set up a four-node PostgreSQL cluster with Patroni on Ubuntu 20.04. Use the following setup to identify the IP address and application of each node. The first step you will need to do is to install the PostgreSQL server on node1 and node2. Run the following command to install PostgreSQL on both nodes. apt install postgresql postgresql-contrib -y After the installation, you will need to stop the PostgreSQL service on both nodes: systemctl stop postgresql Next, you will need to symlink /usr/lib/postgresql/12/bin/ to /usr/sbin because it contains tools used in Patroni. ln -s /usr/lib/postgresql/12/bin/* /usr/sbin/ First, install all the required dependencies on node1 and node2 using the command below: apt install python3-pip python3-dev libpq-dev -y Next, run the following command to upgrade PIP to the latest version: pip3 install –upgrade pip Finally, use the PIP command to install the Patroni and other dependencies on both node1 and node2: At this point, Patroni has been installed on node1 and node2.

Continue reading...