Skip to main content
Skip table of contents

Deployment of Postgres as a Streaming Standby with an External Repo

Introduction

PGO, the Postgres Operator from Crunchy Data, gives you a declarative Postgres solution that manages your PostgreSQL clusters. This document illustrates the procedure and steps to deploy Postgres as a streaming standby with an external repo. When deploying PostgreSQL as a streaming standby with an external repository, you set up a high-availability configuration where changes made on a primary PostgreSQL server are continuously streamed to a standby server. The standby server acts as a backup and can take over as the primary server in case of a failure. By utilizing an external repository, you can store the Write-Ahead Logs (WAL) required for replication in a separate location, ensuring data durability and resilience.

This configuration offers several benefits, including improved fault tolerance, failover, and the ability to offload read operations to the standby server, reducing the load on the primary server. It is commonly used in production environments to achieve high availability and data redundancy.

To implement this setup, you'll need to configure the primary and standby PostgreSQL servers, establish replication between them, and configure an external repository to store the WAL files. By following the steps outlined in the deployment process, you can achieve a reliable and resilient PostgreSQL streaming standby configuration.


you can take a look at the Architecture Diagram

Pre-requisites 

1) metalLB or Traefik for load balancer service provider.

Installation Steps

Step 1: Clone the Crunchy Data Repository

1. Start with cloning the repository from GitLab.

BASH
git clone https://gitlab.expertflow.com/general/crunchydata.git

2. Change to the directory.

BASH
cd crunchydata/postgres-operator/pgo-primary

Step 2: Create Namespace

1. Create the namespace using the command.

BASH
kubectl create namespace postgres-operator

Step 3: Deployment for Primary Node


1. Use the Helm command to deploy the Postgres operator on the primary node.

CODE
 s3:
 bucket: "<bucket-name>"
 endpoint: "https://<minio-vm-ip>:<minio-port>"
 region: "<bucket-regoin>"
 
 Access the minio frontend create minio key 
 
 key: "<minio-key>"
 keySecret: "<minio-secret-key>"


BASH
helm upgrade --install=true --wait=true  --timeout=10m0s --debug --namespace=postgres-operator ef-pgo  ./install/

2. Use the Helm command to deploy the Postgres on the primary node.

BASH
helm upgrade --install=true --wait=true  --timeout=10m0s --debug --namespace=postgres-operator hippo  ./postgres/

Deployment of Standby Node

Step 1: Clone the Crunchy Data Repository

1. Start with cloning the repository from GitLab on the standby node.

BASH
git clone https://gitlab.expertflow.com/general/crunchydata.git

Step 2: Create Namespace

1. Create the namespace using the command on the standby node.

BASH
kubectl create namespace postgres-operator

2. Change to the directory.

BASH
cd crunchydata/postgres-operator/pgo-standby

Step 3: Deployment for Standby Node

1. Use the Helm command to deploy the Postgres operator on the standby node.

CODE
standby:
  enabled: true
  repoName: repo1
  host: "10.192.168.155" <load-balancer-IP>
  port: 5432 <load-balancer-Service-Port>   


BASH
helm upgrade --install=true --wait=true  --timeout=10m0s --debug --namespace=postgres-operator ef-pgo  ./install/

2. Use the Helm command to deploy the Postgres on the standby node.

BASH
helm upgrade --install=true --wait=true  --timeout=10m0s --debug --namespace=postgres-operator hippo  ./postgres/


Failover Scenarios 

Step 1 :

make adjustments to the values file, and shut down the primary node.

CODE
    shutdown: true

 Use the Helm command to apply the above changes.

BASH
helm upgrade --install=true --wait=true  --timeout=10m0s --debug --namespace=postgres-operator hippo  ./postgres/

Step 2 :

make changes to the values file and make the standby node as primary.

CODE
standby:
  enabled: false

 Use the Helm command to apply the above changes.

BASH
helm upgrade --install=true --wait=true  --timeout=10m0s --debug --namespace=postgres-operator hippo  ./postgres/





JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.