Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
143 lines (137 loc) · 3.77 KB
/
Copy pathdocker-compose.yml
File metadata and controls
143 lines (137 loc) · 3.77 KB
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
140
141
142
143
services:
mysql:
image: mysql:8.0.33
container_name: mes-mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-123455}
MYSQL_DATABASE: mes_db
ports:
- "3306:3306"
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-p${MYSQL_ROOT_PASSWORD:-123455}"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
deploy:
resources:
limits:
memory: 512M
networks:
- mes-network
redis:
image: redis:7-alpine
container_name: mes-redis
restart: always
ports:
- "6379:6379"
command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru --appendonly yes
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 10
start_period: 10s
deploy:
resources:
limits:
memory: 256M
networks:
- mes-network
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
container_name: mes-zookeeper
restart: always
# Confluent entrypoint 不 exec 且健康检查脚本频繁 fork,僵尸子进程无人回收
# (服务器实测 137 个);init: true 注入 tini 作为 PID 1 统一回收
init: true
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
healthcheck:
test: ["CMD-SHELL", "echo ruok | nc -w 2 localhost 2181 | grep imok"]
interval: 10s
timeout: 5s
retries: 10
start_period: 20s
deploy:
resources:
limits:
memory: 128M
networks:
- mes-network
kafka:
image: confluentinc/cp-kafka:7.5.0
container_name: mes-kafka
restart: always
# 同上:僵尸进程累积 (服务器实测 1072 个),tini 作为 PID 1 回收
init: true
depends_on:
zookeeper:
condition: service_healthy
ports:
- "9092:9092"
environment:
KAFKA_NODE_ID: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_internal:PLAINTEXT
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_internal://0.0.0.0:9093
# advertised 用容器服务名 kafka,容器内客户端才能正确连接
# (之前用 localhost 导致 dashboard 连不上 broker)
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_internal://kafka:9093
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_LOG_DIRS: /var/lib/kafka/data
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- kafka-data:/var/lib/kafka/data
healthcheck:
test: ["CMD-SHELL", "kafka-topics --bootstrap-server localhost:9092 --list >/dev/null 2>&1"]
interval: 15s
timeout: 10s
retries: 10
start_period: 40s
deploy:
resources:
limits:
memory: 512M
networks:
- mes-network
emqx:
image: emqx/emqx:5.8.3
container_name: mes-emqx
restart: always
ports:
- "1883:1883" # MQTT
- "18083:18083" # Dashboard 控制台
environment:
EMQX_NODE_NAME: mes-emqx@127.0.0.1
EMQX_DASHBOARD__DEFAULT_PASSWORD: ${EMQX_DEFAULT_PASSWORD:-public}
healthcheck:
test: ["CMD-SHELL", "emqx ctl status | grep -q 'is running'"]
interval: 10s
timeout: 5s
retries: 10
start_period: 20s
deploy:
resources:
limits:
memory: 256M
networks:
- mes-network
volumes:
mysql-data:
redis-data:
kafka-data:
networks:
mes-network:
driver: bridge