86 lines
2.2 KiB
Markdown
86 lines
2.2 KiB
Markdown
# postgres15
|
|
|
|
Implement automatic primary and standby
|
|
|
|
## Primary
|
|
|
|
Example `compose.yaml` for **primary** instance.
|
|
|
|
```yaqml
|
|
services:
|
|
db:
|
|
image: pendragon.zone/docker/postgres15replicate
|
|
restart: unless-stopped
|
|
shm_size: 128mb
|
|
environment:
|
|
POSTGRES_PASSWORD: ${DB_ROOT_PASSWORD}
|
|
REPLICATOR_PASSWORD: ${REPLICATOR_PASSWORD}
|
|
MAX_CONNECTIONS: "400"
|
|
|
|
network_mode: bridge
|
|
ports:
|
|
- 5432:5432
|
|
|
|
volumes:
|
|
- data:/var/lib/postgresql/data
|
|
- /docker/postgres_wal:/wal_archive
|
|
|
|
volumes:
|
|
data:
|
|
```
|
|
|
|
- Volume `/wal_archive` **must** be mapped to a location available by **all** replication participants.
|
|
|
|
- `DB_ROOT_PASSWORD` _required_, must be the same for all replication participants.
|
|
|
|
- `REPLICATOR_PASSWORD` _required_, must be the same for all replication participants.
|
|
|
|
- `UPSTREAM` **must not** be set for **primary** instance.
|
|
|
|
- `WAL_ARCHIVE` _default: `/wal_archive`_ use different location for write-ahead-logs.
|
|
|
|
- `TRIGGER_FILE` _default: `i_am_primary`_, name of the file that promotes a standby instance to primary instance, if it exists in directory `/var/lib/postgresql/data`.
|
|
|
|
- `WAL_KEEP_SIZE` _default: `1GB`_
|
|
|
|
- `REPLICATOR_NAME` _default: `replicator`_ name of user for replication.
|
|
|
|
- `MAX_CONNECTIONS` _optional_, change default value of `max_connections` configuration value.
|
|
|
|
|
|
## Standby
|
|
|
|
Example `compose.yaml` for **standby** instance.
|
|
|
|
```yaqml
|
|
services:
|
|
db:
|
|
image: pendragon.zone/docker/postgres15replicate
|
|
restart: unless-stopped
|
|
shm_size: 128mb
|
|
environment:
|
|
POSTGRES_PASSWORD: ${DB_ROOT_PASSWORD}
|
|
REPLICATOR_PASSWORD: ${REPLICATOR_PASSWORD}
|
|
UPSTREAM: ${UPSTREAM}
|
|
|
|
network_mode: bridge
|
|
ports:
|
|
- 5432:5432
|
|
|
|
volumes:
|
|
- data:/var/lib/postgresql/data
|
|
- /docker/postgres_wal:/wal_archive
|
|
|
|
volumes:
|
|
data:
|
|
```
|
|
|
|
- Volume `/wal_archive` **must** be mapped to a location available by **all** replication participants.
|
|
|
|
- `DB_ROOT_PASSWORD` _required_, must be the same for all replication participants.
|
|
|
|
- `REPLICATOR_PASSWORD` _required_, must be the same for all replication participants.
|
|
|
|
- `UPSTREAM` _required_, name of the node to replicate from. Can either be **primary** or a different **standby** instance.
|
|
|