完善架构,修改很多地方

This commit is contained in:
编码猿
2025-10-04 00:08:33 +08:00
parent 3c66faf9a7
commit ff925d458a
32 changed files with 576 additions and 1602 deletions

View File

@@ -18,14 +18,15 @@ services:
volumes:
- mysql-data:/var/lib/mysql
- ./mysql-schema.sql:/docker-entrypoint-initdb.d/mysql-schema.sql
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
ports:
- "3306:3306"
- target: 3306
published: 3306
protocol: tcp
mode: host # 数据库通常使用 host 模式,避免路由网格开销
# 健康检查,确保数据库启动完成后再启动 Nacos
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
interval: 5s
timeout: 10s
retries: 10
@@ -50,11 +51,26 @@ services:
- nacos-logs:/home/nacos/logs
# 暴露 Nacos 所需的端口
ports:
- "8080:8080"
- "7848:7848"
- "8848:8848"
- "9848:9848"
- "9849:9849"
- target: 8080
published: 8080
protocol: tcp
mode: ingress # Web 控制台使用路由网格实现负载均衡
- target: 7848
published: 7848
protocol: tcp
mode: ingress # 集群通信端口
- target: 8848
published: 8848
protocol: tcp
mode: ingress # 主要服务端口,使用路由网格
- target: 9848
published: 9848
protocol: tcp
mode: ingress # gRPC 端口
- target: 9849
published: 9849
protocol: tcp
mode: ingress # gRPC 端口
# 使用环境变量文件
environment:
- MODE=cluster
@@ -88,7 +104,6 @@ services:
update_config:
parallelism: 1
delay: 30s
# 资源限制(可选,可根据你的服务器配置调整)
resources:
limits:
@@ -106,7 +121,10 @@ services:
volumes:
- ./prometheus/prometheus-cluster.yaml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
- target: 9090
published: 9090
protocol: tcp
mode: ingress # 监控服务使用路由网格
deploy:
replicas: 1
restart_policy:
@@ -116,12 +134,14 @@ services:
networks:
- nacos-net
# Grafana 服务
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
- target: 3000
published: 3000
protocol: tcp
mode: ingress # Grafana 使用路由网格
deploy:
# 通常 Grafana 单实例即可
replicas: 1
@@ -139,4 +159,4 @@ volumes:
networks:
nacos-net:
driver: overlay
driver: overlay

View File

@@ -1,2 +1,10 @@
## traefik 网关
部署在公网的 traefik 网关代码放到Linux服务器然后根据实际情况修改 `dynamic.yml` 文件,
然后在根目录执行命令即可:
```bash
docker-compose down && docker-compose up -d
docker compose down && docker compose up -d
# 或者这个命令
# docker compose down && docker compose up -d
```

View File

@@ -1,5 +1,7 @@
http:
routers:
# 共享模块的 路由 拦截 配置
app-shared-router:
rule: Host(`nacos.ddd.com`) && PathPrefix(`/app-shared`)
service: app-shared-service
@@ -9,8 +11,9 @@ http:
tracing: true
traceVerbosity: detailed
entryPoints:
- web
- web
# 商品模块的 路由 拦截 配置
app-product-router:
rule: Host(`nacos.ddd.com`) && PathPrefix(`/app-product`)
service: app-product-service
@@ -20,9 +23,9 @@ http:
tracing: true
traceVerbosity: detailed
entryPoints:
- web
- web
# 使用域名访问前端main-app
# 使用域名访问前端 main-app 主模块
main-ddd-router:
rule: Host(`main.ddd.com`)
service: main-ddd-service
@@ -34,7 +37,7 @@ http:
entryPoints:
- web
# Nacos 集群 管理后台的统一访问域名
# Nacos 集群 管理后台的统一 访问域名
nacosui-ddd-router:
rule: Host(`nacosui.ddd.com`)
service: nacosui-ddd-service
@@ -44,7 +47,7 @@ http:
tracing: true
traceVerbosity: detailed
entryPoints:
- web
- web
# trafik 网关 代理 内网 nacos 集群 的地址
nacos-ddd-router:
@@ -56,7 +59,7 @@ http:
tracing: true
traceVerbosity: detailed
entryPoints:
- web
- web
# trafik 网关的管理后台的域名
trafikui-ddd-router:
@@ -71,7 +74,7 @@ http:
- web
services:
services:
app-shared-service:
loadBalancer:
servers:
@@ -80,12 +83,14 @@ http:
app-product-service:
loadBalancer:
servers:
- url: http://192.168.31.101:1301
- url: http://192.168.139.19:1301
- url: http://192.168.139.120:1301
- url: http://192.168.139.242:1301
main-ddd-service:
loadBalancer:
servers:
- url: http://192.168.31.101:1300
- url: http://192.168.31.101:1300
nacosui-ddd-service:
loadBalancer:

View File

@@ -6,7 +6,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"axios": "^1.6.8",
"axios": "^1.12.2",
"js-yaml": "^4.1.0"
},
"keywords": [],