File tree 5 files changed +15
-26
lines changed
5 files changed +15
-26
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Quick start
4
4
``` bash
5
- docker-compose up -d
5
+ docker-compose up -d --scale db.standby=2
6
6
```
7
7
8
8
## Testing
@@ -23,13 +23,14 @@ docker-compose exec -T db.master psql --host localhost --username devops --dbnam
23
23
SELECT * FROM account;
24
24
EOSQL
25
25
26
+ # NOTE: change the parameter --index (e.g. --index=2) to check other standby servers
26
27
# 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
28
29
SELECT * FROM account;
29
30
EOSQL
30
31
31
32
# 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
33
34
DELETE FROM account;
34
35
EOSQL
35
36
# ERROR: cannot execute DELETE in a read-only transaction
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -9,7 +9,12 @@ services:
9
9
- net_postgres
10
10
volumes :
11
11
- 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
13
18
restart : always
14
19
build :
15
20
context : ./db/
@@ -22,7 +27,11 @@ services:
22
27
- net_postgres
23
28
volumes :
24
29
- 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
26
35
restart : always
27
36
build :
28
37
context : ./db/
You can’t perform that action at this time.
0 commit comments