Skip to content

Commit 76397c2

Browse files
committed
tidy up and update document
1 parent c2b722d commit 76397c2

File tree

5 files changed

+15
-26
lines changed

5 files changed

+15
-26
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Quick start
44
```bash
5-
docker-compose up -d
5+
docker-compose up -d --scale db.standby=2
66
```
77

88
## Testing
@@ -23,13 +23,14 @@ docker-compose exec -T db.master psql --host localhost --username devops --dbnam
2323
SELECT * FROM account;
2424
EOSQL
2525

26+
# NOTE: change the parameter --index (e.g. --index=2) to check other standby servers
2627
# the data has been replicated to db.standby
27-
docker-compose exec -T db.standby psql --host localhost --username devops --dbname postgres <<-EOSQL
28+
docker-compose exec -T --index=1 db.standby psql --host localhost --username devops --dbname postgres <<-EOSQL
2829
SELECT * FROM account;
2930
EOSQL
3031

3132
# cannot write/delete data on db.standby
32-
docker-compose exec -T db.standby psql --host localhost --username devops --dbname postgres <<-EOSQL
33+
docker-compose exec -T --index=1 db.standby psql --host localhost --username devops --dbname postgres <<-EOSQL
3334
DELETE FROM account;
3435
EOSQL
3536
# ERROR: cannot execute DELETE in a read-only transaction

db/.dockerignore

-10
This file was deleted.

db/pg.master.env

-6
This file was deleted.

db/pg.standby.env

-5
This file was deleted.

docker-compose.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ services:
99
- net_postgres
1010
volumes:
1111
- vol_postgres:/var/lib/postgresql/data
12-
env_file: ./db/pg.master.env
12+
environment:
13+
- POSTGRES_USER=devops
14+
- POSTGRES_PASSWORD=devops
15+
- POSTGRES_DB=postgres
16+
- PG_MASTER_REP_USER=devops_rep
17+
- PG_MASTER_REP_PASS=devops_rep
1318
restart: always
1419
build:
1520
context: ./db/
@@ -22,7 +27,11 @@ services:
2227
- net_postgres
2328
volumes:
2429
- vol_postgres:/var/lib/postgresql/data
25-
env_file: ./db/pg.standby.env
30+
environment:
31+
- PG_MASTER_HOST=db.master
32+
- PG_MASTER_PORT=5432
33+
- PG_MASTER_REP_USER=devops_rep
34+
- PG_MASTER_REP_PASS=devops_rep
2635
restart: always
2736
build:
2837
context: ./db/

0 commit comments

Comments
 (0)