Skip to content

Instantly share code, notes, and snippets.

@edward-hsu-1994
Last active June 29, 2019 05:38
Show Gist options
  • Save edward-hsu-1994/f125da60e8a97be1b8a09cd08dbc05dc to your computer and use it in GitHub Desktop.
Save edward-hsu-1994/f125da60e8a97be1b8a09cd08dbc05dc to your computer and use it in GitHub Desktop.
version: '3'
services:
# 主要PostgreSQL伺服器
pg1:
image: 'crunchydata/crunchy-postgres:centos7-11.4-2.4.1'
environment:
- PG_DATABASE=postgres
- PG_PRIMARY_PORT=5432
- PG_MODE=primary
- PG_USER=postgres
- PG_PASSWORD=postgres
- PG_PRIMARY_USER=postgres
- PG_PRIMARY_PASSWORD=postgres
- PG_ROOT_PASSWORD=postgres
volumes:
- pg1Vol:/pgdata
ports:
- '20001:5432'
# 次要PostgreSQL伺服器
pg2:
image: 'crunchydata/crunchy-postgres:centos7-11.4-2.4.1'
environment:
- PG_DATABASE=postgres
- PG_PRIMARY_PORT=5432
# 設定為replica模式
- PG_MODE=replica
- PG_USER=postgres
- PG_PASSWORD=postgres
- PG_PRIMARY_USER=postgres
- PG_PRIMARY_PASSWORD=postgres
- PG_ROOT_PASSWORD=postgres
# 設定主要伺服器Host
- PG_PRIMARY_HOST=pg1
volumes:
- pg2Vol:/pgdata
ports:
- '20002:5432'
pgpool:
image: 'crunchydata/crunchy-pgpool:centos7-11.4-2.4.1'
ports:
- '20000:5432'
links:
- 'pg1:pg1'
- 'pg2:pg2'
environment:
- PG_USERNAME=postgres
- PG_PASSWORD=postgres
# 設定主要與次要服務HOST
- PG_PRIMARY_SERVICE_NAME=pg1
- PG_REPLICA_SERVICE_NAME=pg2
volumes:
pg1Vol:
driver: local
driver_opts:
type: none
o: bind
device: /mnt/pg1Vol
pg2Vol:
driver: local
driver_opts:
type: none
o: bind
device: /mnt/pg2Vol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment