-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompose.yaml
117 lines (111 loc) · 2.7 KB
/
compose.yaml
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
version: '3'
services:
#сервер конфигурации
configSrv:
image: mongo:latest # docker образ
container_name: configSrv
restart: always
ports:
- "27017:27017"
networks:
app-network:
ipv4_address: 173.17.0.10
volumes:
- config-data:/data/db
command:
[
"--configsvr", #запуск в режиме конфигурации
"--replSet",
"config_server",
"--bind_ip_all",
"--port",
"27017"
]
healthcheck:
test: [ "CMD", "mongo", "--eval", "db.adminCommand('ping')" ]
interval: 5s
start_period: 10s
#1-й шард
shard1:
image: mongo:latest
container_name: shard1
restart: always
ports:
- "27018:27018"
networks:
app-network:
ipv4_address: 173.17.0.9
volumes:
- shard1-data:/data/db
command:
[
"--shardsvr", #запуск в режиме шардинга
"--replSet",
"shard1", #название реплики
"--bind_ip_all",
"--port",
"27018"
]
healthcheck:
test: [ "CMD", "mongo", "--eval", "db.adminCommand('ping')" ]
interval: 5s
start_period: 10s
#2-й шард
shard2:
image: mongo:latest
container_name: shard2
restart: always
ports:
- "27019:27019"
networks:
app-network:
ipv4_address: 173.17.0.8
volumes:
- shard2-data:/data/db
command:
[
"--shardsvr", #запуск в режиме шардинга
"--replSet",
"shard2", #название реплик
"--bind_ip_all", # обратите внимание - она отличается от реплики 1-го шарда
"--port",
"27019"
]
healthcheck:
test: [ "CMD", "mongo", "--eval", "db.adminCommand('ping')" ]
interval: 5s
start_period: 10s
#роутер
mongos_router:
image: mongo:latest
container_name: mongos_router
restart: always
ports:
- "27020:27020"
networks:
app-network:
ipv4_address: 173.17.0.7
command:
[
"mongos", #обычная mongo в режиме роутера
"--configdb",
"config_server/configSrv:27017", #передача данных сервера конфигурации
"--bind_ip_all",
"--port",
"27020"
]
healthcheck:
test: [ "CMD", "mongo", "--eval", "db.adminCommand('ping')" ]
interval: 5s
start_period: 10s
networks:
app-network:
driver: bridge
ipam:
driver: default
config:
- subnet: 173.17.0.0/16
volumes:
config-data:
shard1-data:
shard2-data: