Skip to content

Commit 6487075

Browse files
committed
feat(infra): 重构基础设施配置,修改相关配置
- 新增redis.conf和otel-config.yaml配置文件 - 更新metadata-config.yaml中的数据库和redis配置 - 重构docker-compose.yml使用国内镜像并调整端口 - 优化prometheus.yml配置使用固定IP地址 - 更新postgres初始化脚本中的权限设置 - 新增supervisor配置文件用于管理基础设施 - 删除旧的构建脚本并新增部署脚本
1 parent 4d21d9a commit 6487075

File tree

11 files changed

+311
-165
lines changed

11 files changed

+311
-165
lines changed
Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
11
{
22
"datacenter": "mock-s3-dc",
3-
"node_name": "consul-server",
3+
"data_dir": "/consul/data",
4+
"log_level": "INFO",
45
"server": true,
56
"bootstrap_expect": 1,
6-
"bind_addr": "172.20.0.10",
7-
"client_addr": "0.0.0.0",
8-
"retry_join": [
9-
"consul"
10-
],
117
"ui_config": {
128
"enabled": true
13-
},
14-
"connect": {
15-
"enabled": true
16-
},
17-
"ports": {
18-
"grpc": 8502,
19-
"grpc_tls": 8503
20-
},
21-
"acl": {
22-
"enabled": false,
23-
"default_policy": "allow"
24-
},
25-
"log_level": "INFO",
26-
"enable_syslog": false,
27-
"data_dir": "/consul/data",
28-
"encrypt_verify_incoming": false,
29-
"encrypt_verify_outgoing": false,
30-
"verify_incoming": false,
31-
"verify_outgoing": false,
32-
"ca_file": "",
33-
"cert_file": "",
34-
"key_file": "",
35-
"verify_server_hostname": false
9+
}
3610
}

mock/s3/deployments/docker-compose.infra.yml renamed to mock/s3/deployments/docker-compose.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ volumes:
2121
services:
2222
# Consul - 服务发现
2323
consul:
24-
image: hashicorp/consul:1.16
24+
image: docker.m.daocloud.io/hashicorp/consul:1.16
2525
container_name: mock-s3-consul
2626
hostname: consul
2727
networks:
@@ -33,19 +33,19 @@ services:
3333
volumes:
3434
- consul-data:/consul/data
3535
- ./consul/consul-config.json:/consul/config/consul-config.json:ro
36-
command: consul agent -server -bootstrap -ui -node=consul-server -bind=172.21.0.10 -client=0.0.0.0
36+
command: consul agent -server -bootstrap -ui -node=consul-server -bind=172.21.0.10 -client=0.0.0.0 -data-dir=/consul/data
3737
restart: unless-stopped
3838

3939
# PostgreSQL - 数据存储
4040
postgres:
41-
image: postgres:15-alpine
41+
image: docker.m.daocloud.io/postgres:15-alpine
4242
container_name: mock-s3-postgres
4343
hostname: postgres
4444
networks:
4545
infra-network:
4646
ipv4_address: 172.21.0.11
4747
ports:
48-
- "5432:5432"
48+
- "5532:5432" # 改为5532避免与系统PostgreSQL冲突
4949
environment:
5050
POSTGRES_USER: postgres
5151
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres123}
@@ -57,14 +57,14 @@ services:
5757

5858
# Redis - 缓存和队列
5959
redis:
60-
image: redis:7-alpine
60+
image: docker.m.daocloud.io/redis:7-alpine
6161
container_name: mock-s3-redis
6262
hostname: redis
6363
networks:
6464
infra-network:
6565
ipv4_address: 172.21.0.12
6666
ports:
67-
- "6379:6379"
67+
- "16379:6379" # 改为16379避免与系统Redis冲突
6868
volumes:
6969
- redis-data:/data
7070
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
@@ -73,7 +73,7 @@ services:
7373

7474
# Prometheus - 指标收集
7575
prometheus:
76-
image: prom/prometheus:latest
76+
image: docker.m.daocloud.io/prom/prometheus:latest
7777
container_name: mock-s3-prometheus
7878
hostname: prometheus
7979
networks:
@@ -92,7 +92,7 @@ services:
9292

9393
# Grafana - 可视化
9494
grafana:
95-
image: grafana/grafana:latest
95+
image: docker.m.daocloud.io/grafana/grafana:latest
9696
container_name: mock-s3-grafana
9797
hostname: grafana
9898
networks:
@@ -111,7 +111,7 @@ services:
111111

112112
# Elasticsearch - 日志存储
113113
elasticsearch:
114-
image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
114+
image: docker.m.daocloud.io/elastic/elasticsearch:8.10.2
115115
container_name: mock-s3-elasticsearch
116116
hostname: elasticsearch
117117
networks:
@@ -130,7 +130,7 @@ services:
130130

131131
# Kibana - 日志查询
132132
kibana:
133-
image: docker.elastic.co/kibana/kibana:8.10.2
133+
image: docker.m.daocloud.io/elastic/kibana:8.10.2
134134
container_name: mock-s3-kibana
135135
hostname: kibana
136136
networks:
@@ -146,7 +146,7 @@ services:
146146

147147
# OpenTelemetry Collector
148148
otel-collector:
149-
image: otel/opentelemetry-collector-contrib:latest
149+
image: docker.m.daocloud.io/otel/opentelemetry-collector-contrib:latest
150150
container_name: mock-s3-otel
151151
hostname: otel-collector
152152
networks:
@@ -155,7 +155,7 @@ services:
155155
ports:
156156
- "4317:4317" # OTLP gRPC
157157
- "4318:4318" # OTLP HTTP
158-
- "8888:8888" # Prometheus metrics
158+
- "18888:8889" # Prometheus metrics - 使用8889内部端口避免冲突
159159
volumes:
160160
- ./otel/otel-config.yaml:/etc/otel-collector-config.yaml:ro
161161
command: ["--config=/etc/otel-collector-config.yaml"]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# OpenTelemetry Collector配置
2+
receivers:
3+
otlp:
4+
protocols:
5+
grpc:
6+
endpoint: 0.0.0.0:4317
7+
http:
8+
endpoint: 0.0.0.0:4318
9+
10+
processors:
11+
batch:
12+
13+
exporters:
14+
prometheus:
15+
endpoint: "0.0.0.0:8889" # 改用8889端口避免冲突
16+
17+
service:
18+
pipelines:
19+
metrics:
20+
receivers: [otlp]
21+
processors: [batch]
22+
exporters: [prometheus]

mock/s3/deployments/observability/prometheus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ scrape_configs:
1414
# OpenTelemetry Collector指标
1515
- job_name: 'otel-collector'
1616
static_configs:
17-
- targets: ['otel-collector:8888']
17+
- targets: ['172.21.0.24:8889'] # 使用otel-collector的固定IP和新端口
1818
scrape_interval: 10s
1919
metrics_path: /metrics
2020

2121
# Mock S3服务通过Consul服务发现
2222
- job_name: 'mock-s3-services'
2323
consul_sd_configs:
24-
- server: 'consul:8500'
24+
- server: '172.21.0.10:8500' # 使用Consul的固定IP地址
2525
services:
2626
- metadata-service
2727
- storage-service

mock/s3/deployments/postgres/init.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ CREATE INDEX IF NOT EXISTS idx_metadata_status ON metadata(status);
1919
CREATE INDEX IF NOT EXISTS idx_metadata_created_at ON metadata(created_at);
2020

2121
-- 权限设置
22-
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO admin;
23-
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO admin;
24-
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO admin;
22+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO postgres;
23+
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO postgres;
24+
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO postgres;
2525

2626
COMMIT;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Redis配置文件
2+
bind 0.0.0.0
3+
protected-mode no
4+
port 6379

mock/s3/deployments/supervisor/build.sh

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)