109 lines
4.8 KiB
Markdown
109 lines
4.8 KiB
Markdown
# 生产 Salon Core 与 Gateway 环境变量准备说明
|
||
|
||
> 历史说明:本方案已于 2026-10-10 停用,不得再生成或注入本文所述环境文件。当前配置方式见 `后端配置统一由Nacos明文管理_20261010.md`。
|
||
|
||
更新时间:2026-08-27
|
||
|
||
## 适用节点
|
||
|
||
| 角色 | 节点 | 地址 | 服务端口 | 服务名 | 环境文件建议 |
|
||
| --- | --- | --- | ---: | --- | --- |
|
||
| Core | core01-01 | `192.168.10.24` | `81` | `jc-salon-core` | `/etc/jc-salon/jc-salon-core.env` |
|
||
| Core | core01-02 | `192.168.10.25` | `81` | `jc-salon-core` | `/etc/jc-salon/jc-salon-core.env` |
|
||
| Core | core01-03 | `192.168.20.16` | `81` | `jc-salon-core` | `/etc/jc-salon/jc-salon-core.env` |
|
||
| Gateway | gateway01-01 | `192.168.10.26` | `80` | `jc-salon-gateway` | `/etc/jc-salon/jc-salon-gateway.env` |
|
||
| Gateway | gateway01-02 | `192.168.10.27` | `80` | `jc-salon-gateway` | `/etc/jc-salon/jc-salon-gateway.env` |
|
||
| Gateway | gateway01-03 | `192.168.20.18` | `80` | `jc-salon-gateway` | `/etc/jc-salon/jc-salon-gateway.env` |
|
||
|
||
三台同角色节点使用相同环境变量。不要将节点本机 IP 写入应用连接变量;Nacos、数据库、Redis 和 RabbitMQ 使用生产统一入口。
|
||
|
||
## Gateway 环境文件
|
||
|
||
保存为 `/etc/jc-salon/jc-salon-gateway.env`,权限设为 `600 root:root`:
|
||
|
||
```dotenv
|
||
NACOS_SERVER_ADDR=192.168.10.11:8848,192.168.10.12:8848,192.168.10.13:8848
|
||
NACOS_NAMESPACE=jayucloud-salon
|
||
NACOS_GROUP=DEFAULT_GROUP
|
||
NACOS_USERNAME=jayucloud
|
||
NACOS_PASSWORD=122503wcy....
|
||
SERVER_PORT=80
|
||
```
|
||
|
||
Gateway 的业务路由从 Nacos `jayucloud-salon / DEFAULT_GROUP / gateway.yaml` 读取,注册名为 `jc-salon-gateway`。不要在 Gateway 环境文件中加入业务数据库、Redis 或对象存储密钥。
|
||
|
||
## Core 环境文件
|
||
|
||
保存为 `/etc/jc-salon/jc-salon-core.env`,权限设为 `600 root:root`:
|
||
|
||
```dotenv
|
||
NACOS_SERVER_ADDR=192.168.10.11:8848,192.168.10.12:8848,192.168.10.13:8848
|
||
NACOS_NAMESPACE=jayucloud-salon
|
||
NACOS_GROUP=DEFAULT_GROUP
|
||
NACOS_USERNAME=jayucloud
|
||
NACOS_PASSWORD=122503wcy....
|
||
SERVER_PORT=81
|
||
|
||
BUSINESS_JDBC_URL=jdbc:mysql://192.168.10.200:6033/jayucloud_salon?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||
BUSINESS_DB_USERNAME=root
|
||
BUSINESS_DB_PASSWORD=122503wcy....
|
||
|
||
REDIS_SENTINEL_MASTER=mymaster
|
||
REDIS_SENTINEL_NODES=192.168.10.17:26379,192.168.10.18:26379,192.168.10.19:26379,192.168.20.13:26379,10.66.0.4:26379
|
||
REDIS_USERNAME=xiaowang
|
||
REDIS_PASSWORD=122503wcy....
|
||
REDIS_DATABASE=0
|
||
|
||
RABBITMQ_ADDRESSES=mq-prod.internal:5672
|
||
RABBITMQ_VHOST=Jayucloud-Salon
|
||
RABBITMQ_USERNAME=xiaowang
|
||
RABBITMQ_PASSWORD=122503wcy....
|
||
|
||
OBJECT_STORAGE_PRIMARY_PROVIDER=MINIO
|
||
MINIO_ENABLED=true
|
||
MINIO_ENDPOINT=http://192.168.10.105:9000
|
||
MINIO_BUCKET_NAME=jayucloud
|
||
MINIO_ACCESS_KEY=root
|
||
MINIO_SECRET_KEY=122503wcy....
|
||
MINIO_PRIVATE_BUCKET=true
|
||
MINIO_SIGNED_URL_EXPIRE_MINUTES=60
|
||
|
||
QINIU_KODO_ACCESS_KEY=U_btHNrxj1X0UaHllVO8mq4p-8jB1Php-87vi2M7
|
||
QINIU_KODO_SECRET_KEY=WIO_jEcir_2upUqoIzn5Hu5EWSb4-yB4sWeLFiXD
|
||
QINIU_KODO_BUCKET_NAME=jayucloud
|
||
QINIU_KODO_DOMAIN=https://img.yunail.art
|
||
QINIU_KODO_ZONE=z2
|
||
QINIU_KODO_PRIVATE_BUCKET=true
|
||
QINIU_KODO_SIGNED_URL_EXPIRE_MINUTES=60
|
||
|
||
ALIYUN_OSS_ENABLED=true
|
||
ALIYUN_OSS_ENDPOINT=https://oss-cn-chengdu.aliyuncs.com
|
||
ALIYUN_OSS_REGION=cn-chengdu
|
||
ALIYUN_OSS_BUCKET_NAME=jayucloud
|
||
ALIYUN_OSS_ACCESS_KEY_ID=LTAI5t9divmxMWHiKhLSRdDd
|
||
ALIYUN_OSS_ACCESS_KEY_SECRET=U4BlsNpy7ISLbWYrQUsBMswaRH8G9Q
|
||
ALIYUN_OSS_SIGNED_URL_EXPIRE_MINUTES=60
|
||
```
|
||
|
||
Core 注册名为 `jc-salon-core`,通过环境变量 `SERVER_PORT=81` 监听 `81` 端口,与部署脚本健康检查一致。生产正常运行时 MinIO 使用中心1 `192.168.10.105:9000`;灾备接管时才切换到中心2 MinIO 地址,并同步确认桶和凭据。
|
||
|
||
## systemd 注入
|
||
|
||
对应服务单元的 `[Service]` 段加入:
|
||
|
||
```ini
|
||
EnvironmentFile=/etc/jc-salon/jc-salon-core.env
|
||
```
|
||
|
||
Gateway 使用 `jc-salon-gateway.env`。写入后执行 `systemctl daemon-reload`,首次启动前确认环境文件存在、权限正确且没有尖括号占位符。不要把环境文件打包进 JAR、前端产物或 Git。
|
||
|
||
## 发布前检查
|
||
|
||
1. 两个环境文件分别部署到 3 台同角色节点,并核对 SHA-256 一致。
|
||
2. 从每台节点确认可以访问三个 Nacos `8848` 和 `9848` 端口、Redis Sentinel `26379`、RabbitMQ `5672` 及业务数据库 `6033`。
|
||
3. 先启动 Core,确认 `jc-salon-core` 在 `jayucloud-salon` 注册且 `http://127.0.0.1:81/health/check` 成功。
|
||
4. 再启动 Gateway,确认 `jc-salon-gateway` 注册且 `http://127.0.0.1:80/health/check` 成功。
|
||
5. 通过入口节点验证 Salon Web/API;失败时保留旧 JAR 和旧环境文件,不直接覆盖回滚材料。
|
||
|
||
生产 Nacos、数据库和服务器部署仍需按审批后的 Gitea 发布工作流执行;本说明只准备变量,不执行连接或发布。`SERVER_PORT` 是本机 Spring Boot 端口,不依赖 Nacos 中是否声明 `server.port`。
|