Lab 02: PostgreSQL Streaming Replication
Overview
Step 1: Launch PostgreSQL Primary
docker network create pg-replication
# Start primary with WAL streaming enabled
docker run -d \
--name pg-primary \
--network pg-replication \
-e POSTGRES_PASSWORD=rootpass \
-e POSTGRES_DB=testdb \
postgres:15 \
-c wal_level=replica \
-c max_wal_senders=5 \
-c max_replication_slots=5 \
-c hot_standby=on \
-c archive_mode=on \
-c archive_command='cp %p /tmp/pg_archive/%f'
sleep 10
docker exec pg-primary psql -U postgres -c "SELECT version();"Step 2: Configure Primary — Create Replication User and Slot
Step 3: Configure pg_hba.conf for Replication Connections
Step 4: Take Base Backup with pg_basebackup
Step 5: Launch the Standby with Replication Signal
Step 6: Monitor Streaming Replication
Step 7: Verify WAL File Generation
Step 8: Capstone — Promote Standby to Primary
Summary
Component
Setting
Purpose
Key Takeaways
Last updated
