Sign inSign up

sourcemation/postgres-repmgr

By sourcemation

•Updated 4 days ago

Image
0

6.6K

sourcemation/postgres-repmgr repository overview

⁠PostgreSQL with Repmgr Container

This image provides a complete PostgreSQL and repmgr environment for building high-availability database clusters. It's designed to simplify the setup of primary and standby nodes with automated failover capabilities, which is critical for production database environments.

Maintained by Sourcemation, this distribution is regularly updated to ensure it's current and secure. It is a focused container designed for easy integration into your existing infrastructure, providing a robust foundation for a resilient PostgreSQL setup.


⁠Core Features

  • High Availability: Implements a full primary/standby replication cluster.
  • Automated Failover: repmgr continuously monitors the cluster and can automatically promote a standby node to primary in case of a failure.
  • Simplified Cluster Management: Easily add new standby nodes that clone data from the primary, scaling your read capacity and improving redundancy.
  • Configuration via Environment: The entire cluster setup is managed through environment variables, making it perfect for containerized and orchestrated environments like Kubernetes.

⁠Operational Use

This image is intended for production environments where database uptime is critical. The setup requires starting at least two containers: one primary and one or more standbys.

⁠Step 1: Create network
docker network create my-network
⁠Step 2: Start the Primary Node

The first node in the cluster must be started with the REPMGR_ROLE set to primary.

PRIMARY_NAME=primary
docker run -d --network  my-network --name $PRIMARY_NAME \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=mysecretpassword \
  -e REPMGR_ROLE=primary \
  -e REPMGR_USER=repmgr \
  -e REPMGR_PASSWORD=repmgrpass \
  -e REPMGR_DB=repmgr \
  -e NODE_ID=1 \
  -e NODE_NAME=$PRIMARY_NAME \
  sourcemation/postgres-repmgr
⁠Step 3: Start a Standby Node

A standby node clones its data from an upstream node (usually the primary). You must provide the node name of the primary in the REPMGR_UPSTREAM_NAME variable.

Start the standby container, pointing it to the primary:

STANDBY_NAME=standby
docker run -d --network  my-network --name $STANDBY_NAME \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=mysecretpassword \
  -e REPMGR_ROLE=standby \
  -e REPMGR_USER=repmgr \
  -e REPMGR_PASSWORD=repmgrpass \
  -e REPMGR_DB=repmgr \
  -e REPMGR_UPSTREAM_NAME=$PRIMARY_NAME \
  -e NODE_ID=2 \
  -e NODE_NAME=$STANDBY_NAME \
  sourcemation/postgres-repmgr
⁠Step 4: Verify the Cluster Status

You can check the health and status of your replication cluster by running the repmgr cluster show command inside any of the containers.

docker exec -it primary repmgr cluster show -f "/etc/repmgr/repmgr.conf"

⁠Key Environment Variables

This container uses the following environment variables for configuration:

VariableDescriptionExample
POSTGRES_PASSWORDRequired. Sets the password for the main postgres superuser.mysecretpassword
REPMGR_ROLERequired. Defines the node's role. Must be primary or standby.primary
REPMGR_USERRequired. The username repmgr will use to connect for replication.repmgr
REPMGR_PASSWORDRequired. The password for the repmgr user.repmgrpass
REPMGR_DBRequired. The database repmgr will use for its metadata.repmgr
REPMGR_UPSTREAM_NAMERequired for standbys. The node name of the primary node to clone from.primary1
NODE_IDRequired. A unique integer ID for each node in the cluster.1
NODE_NAMERequired. A unique name for each node, often matching the container name.primary-db

⁠Port Exposure

The standard PostgreSQL port, 5432, is exposed by default for database connections.


⁠Contributing and Reporting Issues

Your contributions are valued! Feel free to suggest enhancements or request new images by opening an issue, or submit your own contributions via pull requests to the Sourcemation GitHub repository.


⁠Extra notes

Disclaimer: The sourcemation/postgres-repmgr image is not affiliated with the PostgreSQL Global Development Group or EnterpriseDB. The respective entities own the trademarks mentioned in the offering. The sourcemation/postgres-repmgr image is a separate project and is maintained by Sourcemation⁠.

⁠Image and its components Risk Analysis report

A detailed risk analysis report of the image and its components can be found on the Sourcemation platform⁠.

⁠Licenses

The base licenses for the solution are the PostgreSQL License⁠ and the GNU General Public License v3.0⁠ for repmgr.

Tag summary

Content type

Image

Digest

sha256:167205d7a…

Size

103.6 MB

Last updated

4 days ago

docker pull sourcemation/postgres-repmgr