forked from paunin/PostDock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
139 lines (132 loc) · 4.59 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
version: '2'
networks:
cluster:
driver: bridge
services:
pgmaster:
# image: paunin/postgresql-cluster-pgsql
build:
context: .
dockerfile: Pgsql.Dockerfile
environment:
NODE_ID: 1 # Integer number of node
NODE_NAME: node1 # Node name
CLUSTER_NODE_NETWORK_NAME: pgmaster # (default: hostname of the node)
#database we want to use for application
POSTGRES_PASSWORD: monkey_pass
POSTGRES_USER: monkey_user
POSTGRES_DB: monkey_db
CONFIGS: "listen_addresses:'*'"
# in format variable1:value1[,variable2:value2[,...]]
# used for pgpool.conf file
#defaults:
CLUSTER_NAME: pg_cluster # default is pg_cluster
REPLICATION_DB: replication_db # default is replication_db
REPLICATION_USER: replication_user # default is replication_user
REPLICATION_PASSWORD: replication_pass # default is replication_pass
ports:
- 5432:5432
networks:
cluster:
aliases:
- pgmaster
#<<< Branch 1
pgslave1:
# image: paunin/postgresql-cluster-pgsql
build:
context: .
dockerfile: Pgsql.Dockerfile
environment:
REPLICATION_PRIMARY_HOST: pgmaster
NODE_ID: 2
NODE_NAME: node2
CLUSTER_NODE_NETWORK_NAME: pgslave1 # (default: hostname of the node)
ports:
- 5441:5432
networks:
cluster:
aliases:
- pgslave1
# Add more slaves if required
pgslave2:
# image: paunin/postgresql-cluster-pgsql
build:
context: .
dockerfile: Pgsql.Dockerfile
environment:
REPLICATION_PRIMARY_HOST: pgslave1 # I want to have cascade Streeming replication
NODE_ID: 3
NODE_NAME: node3
CLUSTER_NODE_NETWORK_NAME: pgslave2 # (default: hostname of the node)
ports:
- 5442:5432
networks:
cluster:
aliases:
- pgslave2
#>>> Branch 1
#<<< Branch 2
pgslave3:
# image: paunin/postgresql-cluster-pgsql
build:
context: .
dockerfile: Pgsql.Dockerfile
environment:
REPLICATION_PRIMARY_HOST: pgmaster
NODE_ID: 4
NODE_NAME: node4
CLUSTER_NODE_NETWORK_NAME: pgslave3 # (default: hostname of the node)
ports:
- 5443:5432
networks:
cluster:
aliases:
- pgslave3
pgslave4:
# image: paunin/postgresql-cluster-pgsql
build:
context: .
dockerfile: Pgsql.Dockerfile
environment:
REPLICATION_PRIMARY_HOST: pgslave3
NODE_ID: 5
NODE_NAME: node5
CLUSTER_NODE_NETWORK_NAME: pgslave4 # (default: hostname of the node)
ports:
- 5444:5432
networks:
cluster:
aliases:
- pgslave4
#>>> Branch 2
pgpool:
# image: paunin/postgresql-cluster-pgpool
build:
context: .
dockerfile: Pgpool.Dockerfile
environment:
PCP_USER: pcp_user
PCP_PASSWORD: pcp_pass
WAIT_BACKEND_TIMEOUT: 60
CHECK_USER: monkey_user
CHECK_PASSWORD: monkey_pass
CHECK_PGCONNECT_TIMEOUT: 3 #timout for checking if primary node is healthy
DB_USERS: monkey_user:monkey_pass # in format user:password[,user:password[...]]
BACKENDS: "0:pgmaster:5432:1:/var/lib/postgresql/data:ALLOW_TO_FAILOVER,1:pgslave1::::,2:pgslave2::::,3:pgslave3::::" #,4:pgslaveDOES_NOT_EXIST::::
# in format num:host:port:weight:data_directory:flag[,...]
# defaults:
# port: 5432
# weight: 1
# data_directory: /var/lib/postgresql/data
# flag: ALLOW_TO_FAILOVER
REQUIRE_MIN_BACKENDS: 3 # minimal number of backends to start pgpool (some might be unreachable)
CONFIGS: "num_init_children:250,max_pool:4"
# in format variable1:value1[,variable2:value2[,...]]
# used for pgpool.conf file
ports:
- 5430:5432
- 9898:9898 # PCP
networks:
cluster:
aliases:
- pgpool