Book Image

PostgreSQL 13 Cookbook

By : Vallarapu Naga Avinash Kumar
Book Image

PostgreSQL 13 Cookbook

By: Vallarapu Naga Avinash Kumar

Overview of this book

PostgreSQL has become the most advanced open source database on the market. This book follows a step-by-step approach, guiding you effectively in deploying PostgreSQL in production environments. The book starts with an introduction to PostgreSQL and its architecture. You’ll cover common and not-so-common challenges faced while designing and managing the database. Next, the book focuses on backup and recovery strategies to ensure your database is steady and achieves optimal performance. Throughout the book, you’ll address key challenges such as maintaining reliability, data integrity, a fault-tolerant environment, a robust feature set, extensibility, consistency, and authentication. Moving ahead, you’ll learn how to manage a PostgreSQL cluster and explore replication features for high availability. Later chapters will assist you in building a secure PostgreSQL server, along with covering recipes for encrypting data in motion and data at rest. Finally, you’ll not only discover how to tune your database for optimal performance but also understand ways to monitor and manage maintenance activities, before learning how to perform PostgreSQL upgrades during downtime. By the end of this book, you’ll be well-versed with the essential PostgreSQL 13 features to build enterprise relational databases.
Table of Contents (14 chapters)
12
About Packt

Using xinetd to detect a primary or a standby

HAProxy can be used to load balance the connections or even route the connections to a specific host that passes a check. This check can be performed using Xinetd (Extended Internet Service Daemon). The Xinetd daemon can listen to requests on any custom port. It executes custom logic to serve the request. We could then send unique status codes based on the server to which it has connected. For example, if the server is the primary, the status code should be 200. If the server is a standby, the status code can be 300.

In this recipe, we shall see how HAProxy can rely on xinetd for transparent application failover.

Getting ready...

Performing checks using xinetd may be time-consuming if a connection could not be established to a database server while performing the checks. This needs to be well tested before implementing it in production.

How to do it...

The following are the steps to enable consistency checks using xinetd:

  1. Create a script...