chore(config): Improve Nacos high availability deployment

This commit is contained in:
2026-03-17 17:26:49 +08:00
parent f7751cb633
commit 88bb0c0cd0
23 changed files with 609 additions and 1579 deletions
+129
View File
@@ -0,0 +1,129 @@
# Nacos 配置中心方案
## 一、配置架构
### 1.1 配置文件结构
```
application.yml (本地,极简)
├── Nacos: common.yaml (公共配置)
├── Nacos: common-redis-${profile}.yaml (按环境的Redis配置)
└── Nacos: ${spring.application.name}.yaml (服务专属配置)
```
### 1.2 Data ID 设计
| Data ID | 说明 |
|---------|------|
| common.yaml | 公共配置(MySQL连接池、MyBatis、Feign等) |
| common-redis-dev.yaml | 开发环境Redis单机配置 |
| common-redis-ha.yaml | 生产环境Redis Sentinel配置 |
| video-gateway.yaml | Gateway服务专属配置 |
| video-auth.yaml | Auth服务专属配置 |
| video-user.yaml | User服务专属配置 |
| video-content.yaml | Content服务专属配置 |
| video-comment.yaml | Comment服务专属配置 |
| video-recommend.yaml | Recommend服务专属配置 |
| video-admin.yaml | Admin服务专属配置 |
## 二、使用方式
### 2.1 初始化 Nacos 配置
**方式一:执行 SQL 脚本**
```bash
# 连接 Nacos 数据库
mysql -u root -p nacos_config < sql/nacos-config-init.sql
```
**方式二:通过 Nacos 控制台手动创建**
1. 登录 Nacos 控制台:http://localhost:8848/nacos(默认账号:nacos/nacos)
2. 进入「配置管理」->「配置列表」
3. 点击「+」创建配置,Data ID 和内容参考 `sql/nacos-config-init.sql`
### 2.2 环境切换
通过 `SPRING_PROFILES_ACTIVE` 环境变量切换环境:
**开发环境:**
```yaml
environment:
- SPRING_PROFILES_ACTIVE=dev
```
会加载 `common-redis-dev.yaml`,使用单机 Redis。
**生产/高可用环境:**
```yaml
environment:
- SPRING_PROFILES_ACTIVE=ha
- REDIS_SENTINEL_NODES=192.168.1.101:26379,192.168.1.102:26379,192.168.1.103:26379
```
会加载 `common-redis-ha.yaml`,使用 Sentinel 哨兵模式。
### 2.3 配置热更新
修改 Nacos 中的配置后,服务会自动感知并更新(`refreshEnabled=true`),无需重启!
## 三、配置优先级
```
环境变量 > Nacos 配置 > 本地 application.yml
```
## 四、本地开发
本地开发时,启动 Nacos 后:
1. 确保 Nacos 中已有配置
2. 启动服务,默认使用 `dev` profile
3. 自动连接开发环境的 Redis
## 五、生产部署
```bash
# 1. 执行 SQL 初始化配置
mysql -u root -p nacos_config < sql/nacos-config-init.sql
# 2. 构建镜像
mvn clean package -DskipTests
docker-compose -f docker-compose-node-01.yml build
# 3. 启动服务
docker-compose -f docker-compose-node-01.yml up -d
```
## 六、常见问题
### Q1: 配置没有生效?
检查以下几点:
1. Nacos 是否正常运行
2. 服务启动日志是否显示连接 Nacos 成功
3. 配置的 Data ID 是否正确
4. `spring.config.import` 是否正确配置
### Q2: 如何查看当前使用的配置?
```bash
# 查看服务日志
docker logs -f video-auth | grep -i nacos
```
### Q3: 如何动态修改配置?
1. 登录 Nacos 控制台
2. 找到对应配置
3. 编辑并发布
4. 服务自动感知更新
## 七、核心优势
| 优势 | 说明 |
|------|------|
| 配置集中管理 | 所有配置在 Nacos 统一管理 |
| 环境隔离 | 通过 profile 区分环境 |
| 热更新 | 修改配置无需重启 |
| 无需重构镜像 | 改配置只需在 Nacos 操作 |
| 代码精简 | 本地只留 Nacos 连接配置 |
+439
View File
@@ -0,0 +1,439 @@
-- Nacos 配置初始化脚本
-- 在 Nacos 数据库中执行此脚本,创建所有配置
-- 注意:tenant_id 为空字符串 '' 表示 public 命名空间
-- ============================================
-- 1. 公共基础配置 (common.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('common.yaml', 'DEFAULT_GROUP', '# 公共配置 - 所有微服务共享
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
minimum-idle: 5
maximum-pool-size: 20
idle-timeout: 300000
connection-timeout: 20000
connection-test-query: SELECT 1
keepalive-time: 60000
validation-timeout: 3000
max-lifetime: 58000
data:
redis:
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
feign:
circuitbreaker:
enabled: true
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
logging:
level:
com.nuaa.video: info
org.springframework.security: info', '', '', 'nacos');
-- ============================================
-- 2. 开发环境 Redis 配置 (common-redis-dev.yaml)
-- 单机模式
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('common-redis-dev.yaml', 'DEFAULT_GROUP', '# Redis 单机配置 - 开发环境
spring:
data:
redis:
host: ${REDIS_HOST:5.180.253.115}
port: ${REDIS_PORT:6379}
password: ${REDIS_PASSWORD:redis_EsJ8FX}', '', '', 'nacos');
-- ============================================
-- 3. 高可用环境 Redis 配置 (common-redis-ha.yaml)
-- Sentinel 哨兵模式
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('common-redis-ha.yaml', 'DEFAULT_GROUP', '# Redis Sentinel 高可用配置 - 生产环境
spring:
data:
redis:
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
sentinel:
master: mymaster
nodes: ${REDIS_SENTINEL_NODES:192.168.1.101:26379,192.168.1.102:26379,192.168.1.103:26379}
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}', '', '', 'nacos');
-- ============================================
-- 4. Gateway 服务配置 (video-gateway.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('video-gateway.yaml', 'DEFAULT_GROUP', '# Gateway 服务配置
spring:
cloud:
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
- id: video-auth
uri: lb://video-auth
predicates:
- Path=/auth/**
- id: video-user
uri: lb://video-user
predicates:
- Path=/user/**
- id: video-content
uri: lb://video-content
predicates:
- Path=/content/**
- id: video-comment
uri: lb://video-comment
predicates:
- Path=/comment/**
- id: video-recommend
uri: lb://video-recommend
predicates:
- Path=/recommend/**
- id: video-admin
uri: lb://video-admin
predicates:
- Path=/admin/**
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8720}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
scg:
fallback:
mode: response
response-body: "{\"code\":500,\"message\":\"服务不可用,请稍后再试\"}"
gateway:
ignore:
urls:
- /**/auth/login
- /**/auth/register
- /**/auth/captcha
- /content/video/public/**
- /content/category/tree
- /content/category/list
- /comment/reply/public/**
- /comment/public/**
- /admin/auth/captcha
- /admin/auth/login', '', '', 'nacos');
-- ============================================
-- 5. Auth 服务配置 (video-auth.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('video-auth.yaml', 'DEFAULT_GROUP', '# Auth 服务配置
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_auth?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
data:
redis:
database: 0
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8720}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
mybatis-plus:
type-aliases-package: com.nuaa.video.auth.entity
jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "', '', '', 'nacos');
-- ============================================
-- 6. User 服务配置 (video-user.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('video-user.yaml', 'DEFAULT_GROUP', '# User 服务配置
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
data:
redis:
database: 1
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8721}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
mybatis-plus:
type-aliases-package: com.nuaa.video.user.entity
auth:
ignore-urls:
- /user/profile/public/**
- /user/profile/init
- /actuator/**
minio:
endpoint: http://${MINIO_HOST:minio}:${MINIO_PORT:9000}
accessKey: minioadmin
secretKey: minioadmin123
bucketName: video-platform', '', '', 'nacos');
-- ============================================
-- 7. Content 服务配置 (video-content.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('video-content.yaml', 'DEFAULT_GROUP', '# Content 服务配置
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_content?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
data:
redis:
database: 2
servlet:
multipart:
max-file-size: 1024MB
max-request-size: 1024MB
enabled: true
rocketmq:
topic-prefix: video-platform-
name-server: ${NAMESRV_ADDR:192.168.1.101:9876;192.168.1.102:9876;192.168.1.103:9876}
producer:
group: video-content-producer
send-message-timeout: 3000
retry-times-when-send-failed: 3
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8722}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
mybatis-plus:
type-aliases-package: com.nuaa.video.content.entity
minio:
endpoint: http://${MINIO_HOST:minio}:${MINIO_PORT:9000}
accessKey: ${MINIO_ACCESS_KEY:minioadmin}
secretKey: ${MINIO_SECRET_KEY:minioadmin123}
bucketName: ${MINIO_BUCKET:video-platform}
ffmpeg:
binary:
path: ${FFMPEG_PATH:/usr/bin/ffmpeg}
probe:
path: ${FFPROBE_PATH:/usr/bin/ffprobe}
temp:
path: ${FFMPEG_TEMP_PATH:/tmp/ffmpeg}
auth:
ignore-urls:
- /content/video/public/**
- /content/category/list
- /content/tag/list
- /actuator/**
jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "', '', '', 'nacos');
-- ============================================
-- 8. Comment 服务配置 (video-comment.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('video-comment.yaml', 'DEFAULT_GROUP', '# Comment 服务配置
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_comment?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
data:
redis:
database: 3
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8723}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
mybatis-plus:
type-aliases-package: com.nuaa.video.comment.entity
global-config:
db-config:
logic-delete-field: status
logic-delete-value: 0
logic-not-delete-value: 1
comment:
sensitive-filter:
enabled: true
review:
enabled: false
jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
auth:
ignore-urls:
- /comment/public/**
- /actuator/**', '', '', 'nacos');
-- ============================================
-- 9. Recommend 服务配置 (video-recommend.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('video-recommend.yaml', 'DEFAULT_GROUP', '# Recommend 服务配置
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_recommend?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
data:
redis:
database: 4
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8724}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
mybatis-plus:
type-aliases-package: com.nuaa.video.recommend.entity
recommend:
hot:
default-size: 20
refresh-interval: 60
weights:
view: 1
like: 3
favorite: 5
coin: 5
comment: 2
share: 3
similarity:
tag-weight: 0.5
category-weight: 0.3
behavior-weight: 0.2
personalized:
default-size: 30
behavior-weights:
view: 1
like: 3
favorite: 5
coin: 5
comment: 2
share: 3
complete-watch: 4
jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
auth:
ignore-urls:
- /recommend/hot/**
- /recommend/tag/**
- /actuator/**', '', '', 'nacos');
-- ============================================
-- 10. Admin 服务配置 (video-admin.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
('video-admin.yaml', 'DEFAULT_GROUP', '# Admin 服务配置
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
data:
redis:
database: 5
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8725}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
mybatis-plus:
type-aliases-package: com.nuaa.video.admin.entity
global-config:
db-config:
logic-delete-field: status
logic-delete-value: 0
logic-not-delete-value: 1
jwt:
secret: video-platform-admin-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
login:
retry-count: 5
lock-time: 30
operation-log:
enabled: true
exclude-paths:
- /admin/auth/login
- /admin/auth/logout
- /admin/auth/captcha
- /actuator/**', '', '', 'nacos');
@@ -1,29 +0,0 @@
spring:
datasource:
dynamic:
primary: master
strict: false
datasource:
master:
url: jdbc:mysql://5.180.253.115:3306/video_admin?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: sty@G458221
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
database: 5
host: 5.180.253.115
port: 6379
password: redis_EsJ8FX
timeout: 10000
# 开发环境启用操作日志记录
operation-log:
enabled: true
# 开发环境日志配置
logging:
level:
com.nuaa.video: debug
org.springframework.security: debug
@@ -1,112 +0,0 @@
server:
port: 9006
spring:
application:
name: video-admin
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVERS:192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848}
namespace: ${NACOS_NAMESPACE:public}
group: ${NACOS_GROUP:DEFAULT_GROUP}
username: nacos
password: nacos
ip: ${ADMIN_IP:}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
group: ${spring.cloud.nacos.discovery.group}
file-extension: yaml
username: nacos
password: nacos
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8726
client-ip: ${ADMIN_IP:}
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
max-lifetime: 58000
idle-timeout: 300000
connection-timeout: 20000
connection-test-query: SELECT 1
keepalive-time: 60000
validation-timeout: 3000
minimum-idle: 5
maximum-pool-size: 20
data:
redis:
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
database: 5
timeout: 10000
sentinel:
master: mymaster
nodes: ${REDIS_SENTINEL_NODES:192.168.1.101:26379,192.168.1.102:26379,192.168.1.103:26379}
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.admin.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: status
logic-delete-value: 0
logic-not-delete-value: 1
jwt:
secret: video-platform-admin-secret-key-2024-nuaa-ha
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
login:
retry-count: 5
lock-time: 30
operation-log:
enabled: true
exclude-paths:
- /admin/auth/login
- /admin/auth/logout
- /admin/auth/captcha
- /actuator/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
circuitbreaker:
enabled: true
logging:
level:
com.nuaa.video: info
org.springframework.security: info
+6 -86
View File
@@ -5,15 +5,17 @@ spring:
application: application:
name: video-admin name: video-admin
profiles: profiles:
active: dev active: ${SPRING_PROFILES_ACTIVE:dev}
config: config:
import: import:
- optional:nacos:${spring.application.name}.yaml?username=${NACOS_USERNAME:nacos}&password=${NACOS_PASSWORD:nacos} - optional:nacos:common.yaml?refreshEnabled=true
- optional:nacos:common-redis-${spring.profiles.active}.yaml?refreshEnabled=true
- optional:nacos:${spring.application.name}.yaml?refreshEnabled=true
cloud: cloud:
nacos: nacos:
discovery: discovery:
server-addr: ${NACOS_HOST:5.180.253.115}:${NACOS_PORT:8848} server-addr: ${NACOS_SERVER_ADDR:${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}}
namespace: ${NACOS_NAMESPACE:public} namespace: ${NACOS_NAMESPACE:}
group: ${NACOS_GROUP:DEFAULT_GROUP} group: ${NACOS_GROUP:DEFAULT_GROUP}
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
@@ -25,74 +27,6 @@ spring:
file-extension: yaml file-extension: yaml
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:5.180.253.115}:${SENTINEL_DASHBOARD_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8725}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${MYSQL_HOST:5.180.253.115}:${MYSQL_PORT:3306}/video_admin?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:sty@G458221}
hikari:
minimum-idle: 5
maximum-pool-size: 20
idle-timeout: 30000
max-lifetime: 1200000
connection-timeout: 30000
connection-test-query: SELECT 1
data:
redis:
password: ${REDIS_PASSWORD:redis_EsJ8FX}
database: 5
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.admin.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: status
logic-delete-value: 0
logic-not-delete-value: 1
# JWT配置
jwt:
secret: video-platform-admin-secret-key-2024-nuaa
expiration: 86400 # 24小时
token-header: Authorization
token-prefix: "Bearer "
# 登录配置
login:
# 最大重试次数
retry-count: 5
# 锁定时间(分钟)
lock-time: 30
# 操作日志配置
operation-log:
enabled: true
exclude-paths:
- /admin/auth/login
- /admin/auth/logout
- /admin/auth/captcha
- /actuator/**
management: management:
endpoints: endpoints:
@@ -102,17 +36,3 @@ management:
endpoint: endpoint:
health: health:
show-details: always show-details: always
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
circuitbreaker:
enabled: true
logging:
level:
com.nuaa.video: info
org.springframework.security: info
@@ -1,26 +0,0 @@
spring:
datasource:
dynamic:
primary: master
strict: false
datasource:
master:
url: jdbc:mysql://5.180.253.115:3306/video_auth?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: sty@G458221
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
database: 0
host: 5.180.253.115
port: 6379
password: redis_EsJ8FX
timeout: 10000
logging:
level:
com.nuaa.video: debug
org.springframework.security: debug
org.springframework.beans: debug
org.springframework.context: debug
@@ -1,100 +0,0 @@
server:
port: 9001
spring:
application:
name: video-auth
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVERS:192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848}
namespace: ${NACOS_NAMESPACE:public}
group: ${NACOS_GROUP:DEFAULT_GROUP}
username: nacos
password: nacos
ip: ${AUTH_IP:}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
group: ${spring.cloud.nacos.discovery.group}
file-extension: yaml
username: nacos
password: nacos
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8721
client-ip: ${AUTH_IP:}
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_auth?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
max-lifetime: 58000
idle-timeout: 300000
connection-timeout: 20000
connection-test-query: SELECT 1
keepalive-time: 60000
validation-timeout: 3000
minimum-idle: 5
maximum-pool-size: 20
data:
redis:
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
database: 0
timeout: 10000
sentinel:
master: mymaster
nodes: ${REDIS_SENTINEL_NODES:192.168.1.101:26379,192.168.1.102:26379,192.168.1.103:26379}
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.auth.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
jwt:
secret: video-platform-secret-key-2024-nuaa-ha
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
logging:
level:
com.nuaa.video: info
org.springframework.security: info
feign:
circuitbreaker:
enabled: true
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
+6 -81
View File
@@ -5,15 +5,17 @@ spring:
application: application:
name: video-auth name: video-auth
profiles: profiles:
active: dev active: ${SPRING_PROFILES_ACTIVE:dev}
config: config:
import: import:
- optional:nacos:${spring.application.name}.yaml?username=${NACOS_USERNAME:nacos}&password=${NACOS_PASSWORD:nacos} - optional:nacos:common.yaml?refreshEnabled=true
- optional:nacos:common-redis-${spring.profiles.active}.yaml?refreshEnabled=true
- optional:nacos:${spring.application.name}.yaml?refreshEnabled=true
cloud: cloud:
nacos: nacos:
discovery: discovery:
server-addr: ${NACOS_HOST:5.180.253.115}:${NACOS_PORT:8848} server-addr: ${NACOS_SERVER_ADDR:${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}}
namespace: ${NACOS_NAMESPACE:public} namespace: ${NACOS_NAMESPACE:}
group: ${NACOS_GROUP:DEFAULT_GROUP} group: ${NACOS_GROUP:DEFAULT_GROUP}
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
@@ -25,67 +27,6 @@ spring:
file-extension: yaml file-extension: yaml
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:5.180.253.115}:${SENTINEL_DASHBOARD_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8720}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${MYSQL_HOST:5.180.253.115}:${MYSQL_PORT:3306}/video_auth?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:sty@G458221}
hikari:
# 减少最大生命周期,避免超过数据库的wait_timeout
max-lifetime: 58000 # 设置为MySQL wait_timeout的值减少一些,默认通常为8小时(28800000ms)
# 空闲连接超时时间
idle-timeout: 300000 # 5分钟,超过该时间的空闲连接将被移除
# 连接超时时间
connection-timeout: 20000 # 20秒
# 测试连接的有效性
connection-test-query: SELECT 1
# 保持连接活跃的时间间隔
keepalive-time: 60000 # 1分钟,定期发送ping保持连接
# 验证超时时间
validation-timeout: 3000 # 3秒
# 最小空闲连接数
minimum-idle: 5
# 最大连接池大小
maximum-pool-size: 20
data:
redis:
password: ${REDIS_PASSWORD:redis_EsJ8FX}
database: 0
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.auth.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
management: management:
endpoints: endpoints:
@@ -95,19 +36,3 @@ management:
endpoint: endpoint:
health: health:
show-details: always show-details: always
logging:
level:
com.nuaa.video: info
org.springframework.security: info
org.springframework.beans: debug
org.springframework.context: debug
feign:
circuitbreaker:
enabled: true # 启用断路器
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
@@ -1,25 +0,0 @@
spring:
datasource:
dynamic:
primary: master
strict: false
datasource:
master:
url: jdbc:mysql://5.180.253.115:3306/video_comment?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: sty@G458221
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
database: 3
host: 5.180.253.115
port: 6379
password: redis_EsJ8FX
timeout: 10000
# 开发环境日志级别
logging:
level:
com.nuaa.video: debug
org.springframework.security: debug
@@ -1,111 +0,0 @@
server:
port: 9004
spring:
application:
name: video-comment
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVERS:192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848}
namespace: ${NACOS_NAMESPACE:public}
group: ${NACOS_GROUP:DEFAULT_GROUP}
username: nacos
password: nacos
ip: ${COMMENT_IP:}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
group: ${spring.cloud.nacos.discovery.group}
file-extension: yaml
username: nacos
password: nacos
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8724
client-ip: ${COMMENT_IP:}
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_comment?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
max-lifetime: 58000
idle-timeout: 300000
connection-timeout: 20000
connection-test-query: SELECT 1
keepalive-time: 60000
validation-timeout: 3000
minimum-idle: 5
maximum-pool-size: 20
data:
redis:
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
database: 3
timeout: 10000
sentinel:
master: mymaster
nodes: ${REDIS_SENTINEL_NODES:192.168.1.101:26379,192.168.1.102:26379,192.168.1.103:26379}
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.comment.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: status
logic-delete-value: 0
logic-not-delete-value: 1
comment:
sensitive-filter:
enabled: true
review:
enabled: false
jwt:
secret: video-platform-secret-key-2024-nuaa-ha
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
auth:
ignore-urls:
- /comment/public/**
- /actuator/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
circuitbreaker:
enabled: true
logging:
level:
com.nuaa.video: info
org.springframework.security: info
@@ -5,15 +5,17 @@ spring:
application: application:
name: video-comment name: video-comment
profiles: profiles:
active: dev active: ${SPRING_PROFILES_ACTIVE:dev}
config: config:
import: import:
- optional:nacos:${spring.application.name}.yaml?username=${NACOS_USERNAME:nacos}&password=${NACOS_PASSWORD:nacos} - optional:nacos:common.yaml?refreshEnabled=true
- optional:nacos:common-redis-${spring.profiles.active}.yaml?refreshEnabled=true
- optional:nacos:${spring.application.name}.yaml?refreshEnabled=true
cloud: cloud:
nacos: nacos:
discovery: discovery:
server-addr: ${NACOS_HOST:5.180.253.115}:${NACOS_PORT:8848} server-addr: ${NACOS_SERVER_ADDR:${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}}
namespace: ${NACOS_NAMESPACE:public} namespace: ${NACOS_NAMESPACE:}
group: ${NACOS_GROUP:DEFAULT_GROUP} group: ${NACOS_GROUP:DEFAULT_GROUP}
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
@@ -25,72 +27,6 @@ spring:
file-extension: yaml file-extension: yaml
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:5.180.253.115}:${SENTINEL_DASHBOARD_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8723}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${MYSQL_HOST:5.180.253.115}:${MYSQL_PORT:3306}/video_comment?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:sty@G458221}
hikari:
minimum-idle: 5
maximum-pool-size: 20
idle-timeout: 30000
max-lifetime: 1200000
connection-timeout: 30000
connection-test-query: SELECT 1
data:
redis:
password: ${REDIS_PASSWORD:redis_EsJ8FX}
database: 3
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.comment.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: status
logic-delete-value: 0
logic-not-delete-value: 1
# 评论服务配置
comment:
# 敏感词过滤
sensitive-filter:
enabled: true
# 评论审核
review:
enabled: false # 默认不开启自动审核,由管理员手动审核
# JWT配置与auth模块保持一致
jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
auth:
ignore-urls:
- /comment/public/**
- /actuator/**
management: management:
endpoints: endpoints:
@@ -100,17 +36,3 @@ management:
endpoint: endpoint:
health: health:
show-details: always show-details: always
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
circuitbreaker:
enabled: true
logging:
level:
com.nuaa.video: info
org.springframework.security: info
@@ -1,42 +0,0 @@
spring:
datasource:
dynamic:
primary: master
strict: false
datasource:
master:
url: jdbc:mysql://5.180.253.115:3306/video_content?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: sty@G458221
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
database: 2
host: 5.180.253.115
port: 6379
password: redis_EsJ8FX
timeout: 10000
rocketmq:
name-server: 5.180.253.115:9876
minio:
endpoint: http://5.180.253.115:9002
accessKey: minioadmin
secretKey: minioadmin
bucketName: video-platform
# 开发环境使用相对路径或本地FFmpeg
ffmpeg:
binary:
path: D:/ffmpeg/bin/ffmpeg.exe # Windows路径示例,实际环境请修改
probe:
path: D:/ffmpeg/bin/ffprobe.exe # Windows路径示例,实际环境请修改
temp:
path: D:/temp/ffmpeg # 临时文件目录
logging:
level:
com.nuaa.video: debug
org.springframework.security: debug
@@ -1,134 +0,0 @@
server:
port: 9003
spring:
application:
name: video-content
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVERS:192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848}
namespace: ${NACOS_NAMESPACE:public}
group: ${NACOS_GROUP:DEFAULT_GROUP}
username: nacos
password: nacos
ip: ${CONTENT_IP:}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
group: ${spring.cloud.nacos.discovery.group}
file-extension: yaml
username: nacos
password: nacos
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8723
client-ip: ${CONTENT_IP:}
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_content?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
max-lifetime: 58000
idle-timeout: 300000
connection-timeout: 20000
connection-test-query: SELECT 1
keepalive-time: 60000
validation-timeout: 3000
minimum-idle: 5
maximum-pool-size: 20
data:
redis:
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
database: 2
timeout: 10000
sentinel:
master: mymaster
nodes: ${REDIS_SENTINEL_NODES:192.168.1.101:26379,192.168.1.102:26379,192.168.1.103:26379}
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
servlet:
multipart:
max-file-size: 1024MB
max-request-size: 1024MB
enabled: true
rocketmq:
topic-prefix: video-platform-
name-server: ${NAMESRV_ADDR:192.168.1.101:9876;192.168.1.102:9876;192.168.1.103:9876}
producer:
group: video-content-producer
send-message-timeout: 3000
retry-times-when-send-failed: 3
retry-times-when-send-async-failed: 3
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.content.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
minio:
endpoint: http://${MINIO_HOST:minio}:${MINIO_PORT:9000}
accessKey: ${MINIO_ACCESS_KEY:minioadmin}
secretKey: ${MINIO_SECRET_KEY:minioadmin123}
bucketName: ${MINIO_BUCKET:video-platform}
ffmpeg:
binary:
path: ${FFMPEG_PATH:/usr/bin/ffmpeg}
probe:
path: ${FFPROBE_PATH:/usr/bin/ffprobe}
temp:
path: ${FFMPEG_TEMP_PATH:/tmp/ffmpeg}
auth:
ignore-urls:
- /content/video/public/**
- /content/category/list
- /content/tag/list
- /actuator/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
circuitbreaker:
enabled: true
jwt:
secret: video-platform-secret-key-2024-nuaa-ha
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
logging:
level:
com.nuaa.video: info
org.springframework.security: info
@@ -5,15 +5,17 @@ spring:
application: application:
name: video-content name: video-content
profiles: profiles:
active: dev active: ${SPRING_PROFILES_ACTIVE:dev}
config: config:
import: import:
- optional:nacos:${spring.application.name}.yaml?username=${NACOS_USERNAME:nacos}&password=${NACOS_PASSWORD:nacos} - optional:nacos:common.yaml?refreshEnabled=true
- optional:nacos:common-redis-${spring.profiles.active}.yaml?refreshEnabled=true
- optional:nacos:${spring.application.name}.yaml?refreshEnabled=true
cloud: cloud:
nacos: nacos:
discovery: discovery:
server-addr: ${NACOS_HOST:5.180.253.115}:${NACOS_PORT:8848} server-addr: ${NACOS_SERVER_ADDR:${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}}
namespace: ${NACOS_NAMESPACE:public} namespace: ${NACOS_NAMESPACE:}
group: ${NACOS_GROUP:DEFAULT_GROUP} group: ${NACOS_GROUP:DEFAULT_GROUP}
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
@@ -25,91 +27,6 @@ spring:
file-extension: yaml file-extension: yaml
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:5.180.253.115}:${SENTINEL_DASHBOARD_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8722}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${MYSQL_HOST:5.180.253.115}:${MYSQL_PORT:3306}/video_content?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:sty@G458221}
hikari:
minimum-idle: 5
maximum-pool-size: 20
idle-timeout: 30000
max-lifetime: 1200000
connection-timeout: 30000
connection-test-query: SELECT 1
data:
redis:
password: ${REDIS_PASSWORD:redis_EsJ8FX}
database: 2
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
# 文件上传配置
servlet:
multipart:
max-file-size: 1024MB
max-request-size: 1024MB
enabled: true
# RocketMQ配置
rocketmq:
topic-prefix: video-platform-
name-server: ${ROCKETMQ_HOST:5.180.253.115}:${ROCKETMQ_PORT:9876}
producer:
group: video-content-producer
send-message-timeout: 3000
retry-times-when-send-failed: 3
retry-times-when-send-async-failed: 3
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.content.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
# MinIO配置
minio:
endpoint: http://${MINIO_HOST:5.180.253.115}:${MINIO_PORT:9002}
accessKey: ${MINIO_ACCESS_KEY:minioadmin}
secretKey: ${MINIO_SECRET_KEY:minioadmin}
bucketName: ${MINIO_BUCKET:video-platform}
# FFmpeg配置
ffmpeg:
binary:
path: ${FFMPEG_PATH:/usr/bin/ffmpeg}
probe:
path: ${FFPROBE_PATH:/usr/bin/ffprobe}
temp:
path: ${FFMPEG_TEMP_PATH:/tmp/ffmpeg}
auth:
ignore-urls:
- /content/video/public/**
- /content/category/list
- /content/tag/list
- /actuator/**
management: management:
endpoints: endpoints:
@@ -119,24 +36,3 @@ management:
endpoint: endpoint:
health: health:
show-details: always show-details: always
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
circuitbreaker:
enabled: true
# JWT配置与auth模块保持一致
jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
logging:
level:
com.nuaa.video: info
org.springframework.security: info
@@ -1,15 +0,0 @@
spring:
cloud:
sentinel:
log:
dir: ./logs/sentinel/
switch-pid: true
gateway:
httpclient:
connect-timeout: 60000
response-timeout: 60000
logging:
level:
org.springframework.cloud.gateway: debug
reactor.netty.http.client: debug
@@ -1,87 +0,0 @@
server:
port: 9000
spring:
application:
name: video-gateway
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVERS:192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848}
namespace: ${NACOS_NAMESPACE:public}
group: ${NACOS_GROUP:DEFAULT_GROUP}
username: nacos
password: nacos
ip: ${GATEWAY_IP:}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
group: ${spring.cloud.nacos.discovery.group}
file-extension: yaml
username: nacos
password: nacos
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
- id: video-auth
uri: lb://video-auth
predicates:
- Path=/auth/**
- id: video-user
uri: lb://video-user
predicates:
- Path=/user/**
- id: video-content
uri: lb://video-content
predicates:
- Path=/content/**
- id: video-comment
uri: lb://video-comment
predicates:
- Path=/comment/**
- id: video-recommend
uri: lb://video-recommend
predicates:
- Path=/recommend/**
- id: video-admin
uri: lb://video-admin
predicates:
- Path=/admin/**
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8720
client-ip: ${GATEWAY_IP:}
eager: true
scg:
fallback:
mode: response
response-body: '{"code":500,"message":"服务不可用,请稍后再试"}'
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
gateway:
enabled: true
gateway:
ignore:
urls:
- /**/auth/login
- /**/auth/register
- /**/auth/captcha
- /content/video/public/**
- /content/category/tree
- /content/category/list
- /comment/reply/public/**
- /comment/public/**
- /admin/auth/captcha
- /admin/auth/login
@@ -5,15 +5,16 @@ spring:
application: application:
name: video-gateway name: video-gateway
profiles: profiles:
active: dev active: ${SPRING_PROFILES_ACTIVE:dev}
config: config:
import: import:
- optional:nacos:${spring.application.name}.yaml?username=${NACOS_USERNAME:nacos}&password=${NACOS_PASSWORD:nacos} - optional:nacos:common.yaml?refreshEnabled=true
- optional:nacos:${spring.application.name}.yaml?refreshEnabled=true
cloud: cloud:
nacos: nacos:
discovery: discovery:
server-addr: ${NACOS_HOST:5.180.253.115}:${NACOS_PORT:8848} server-addr: ${NACOS_SERVER_ADDR:${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}}
namespace: ${NACOS_NAMESPACE:public} namespace: ${NACOS_NAMESPACE:}
group: ${NACOS_GROUP:DEFAULT_GROUP} group: ${NACOS_GROUP:DEFAULT_GROUP}
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
@@ -25,56 +26,6 @@ spring:
file-extension: yaml file-extension: yaml
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
extension-configs:
- data-id: video-gateway.yaml
group: ${NACOS_GROUP:DEFAULT_GROUP}
refresh: true
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
- id: video-auth
uri: lb://video-auth
predicates:
- Path=/auth/**
# 移除 StripPrefix 过滤器
- id: video-user
uri: lb://video-user
predicates:
- Path=/user/**
# 移除 StripPrefix 过滤器
- id: video-content
uri: lb://video-content
predicates:
- Path=/content/**
# 移除 StripPrefix 过滤器
- id: video-comment
uri: lb://video-comment
predicates:
- Path=/comment/**
# 移除 StripPrefix 过滤器
- id: video-recommend
uri: lb://video-recommend
predicates:
- Path=/recommend/**
# 移除 StripPrefix 过滤器
- id: video-admin
uri: lb://video-admin
predicates:
- Path=/admin/**
# 移除 StripPrefix 过滤器
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:5.180.253.115}:${SENTINEL_DASHBOARD_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8719}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
scg:
fallback:
mode: response
response-body: '{"code":500,"message":"服务不可用,请稍后再试"}'
management: management:
endpoints: endpoints:
@@ -86,18 +37,3 @@ management:
show-details: always show-details: always
gateway: gateway:
enabled: true enabled: true
# 不需要鉴权的URL列表
gateway:
ignore:
urls:
- /**/auth/login
- /**/auth/register
- /**/auth/captcha
- /content/video/public/**
- /content/category/tree
- /content/category/list
- /comment/reply/public/**
- /comment/public/**
- /admin/auth/captcha
- /admin/auth/login
@@ -1,32 +0,0 @@
# application-dev.yml
spring:
datasource:
dynamic:
primary: master
strict: false
datasource:
master:
url: jdbc:mysql://5.180.253.115:3306/video_recommend?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: sty@G458221
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
database: 4
host: 5.180.253.115
port: 6379
password: redis_EsJ8FX
timeout: 10000
# 推荐系统配置
recommend:
# 热门视频刷新间隔(分钟)- 开发环境设置更短以便测试
hot:
refresh-interval: 10
# 开发环境日志级别
logging:
level:
com.nuaa.video: debug
org.springframework.security: debug
@@ -1,132 +0,0 @@
server:
port: 9005
spring:
application:
name: video-recommend
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVERS:192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848}
namespace: ${NACOS_NAMESPACE:public}
group: ${NACOS_GROUP:DEFAULT_GROUP}
username: nacos
password: nacos
ip: ${RECOMMEND_IP:}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
group: ${spring.cloud.nacos.discovery.group}
file-extension: yaml
username: nacos
password: nacos
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8725
client-ip: ${RECOMMEND_IP:}
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_recommend?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
max-lifetime: 58000
idle-timeout: 300000
connection-timeout: 20000
connection-test-query: SELECT 1
keepalive-time: 60000
validation-timeout: 3000
minimum-idle: 5
maximum-pool-size: 20
data:
redis:
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
database: 4
timeout: 10000
sentinel:
master: mymaster
nodes: ${REDIS_SENTINEL_NODES:192.168.1.101:26379,192.168.1.102:26379,192.168.1.103:26379}
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.recommend.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
recommend:
hot:
default-size: 20
refresh-interval: 60
weights:
view: 1
like: 3
favorite: 5
coin: 5
comment: 2
share: 3
similarity:
tag-weight: 0.5
category-weight: 0.3
behavior-weight: 0.2
personalized:
default-size: 30
behavior-weights:
view: 1
like: 3
favorite: 5
coin: 5
comment: 2
share: 3
complete-watch: 4
jwt:
secret: video-platform-secret-key-2024-nuaa-ha
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
auth:
ignore-urls:
- /recommend/hot/**
- /recommend/tag/**
- /actuator/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
circuitbreaker:
enabled: true
logging:
level:
com.nuaa.video: info
org.springframework.security: info
@@ -5,15 +5,17 @@ spring:
application: application:
name: video-recommend name: video-recommend
profiles: profiles:
active: dev active: ${SPRING_PROFILES_ACTIVE:dev}
config: config:
import: import:
- optional:nacos:${spring.application.name}.yaml?username=${NACOS_USERNAME:nacos}&password=${NACOS_PASSWORD:nacos} - optional:nacos:common.yaml?refreshEnabled=true
- optional:nacos:common-redis-${spring.profiles.active}.yaml?refreshEnabled=true
- optional:nacos:${spring.application.name}.yaml?refreshEnabled=true
cloud: cloud:
nacos: nacos:
discovery: discovery:
server-addr: ${NACOS_HOST:5.180.253.115}:${NACOS_PORT:8848} server-addr: ${NACOS_SERVER_ADDR:${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}}
namespace: ${NACOS_NAMESPACE:public} namespace: ${NACOS_NAMESPACE:}
group: ${NACOS_GROUP:DEFAULT_GROUP} group: ${NACOS_GROUP:DEFAULT_GROUP}
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
@@ -25,104 +27,6 @@ spring:
file-extension: yaml file-extension: yaml
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:5.180.253.115}:${SENTINEL_DASHBOARD_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8724}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${MYSQL_HOST:5.180.253.115}:${MYSQL_PORT:3306}/video_recommend?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:sty@G458221}
hikari:
minimum-idle: 5
maximum-pool-size: 20
idle-timeout: 30000
max-lifetime: 1200000
connection-timeout: 30000
connection-test-query: SELECT 1
data:
redis:
password: ${REDIS_PASSWORD:redis_EsJ8FX}
database: 4
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.recommend.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
# 推荐系统配置
recommend:
# 热门视频推荐配置
hot:
# 默认获取数量
default-size: 20
# 刷新周期(分钟)
refresh-interval: 60
# 热度计算权重
weights:
view: 1
like: 3
favorite: 5
coin: 5
comment: 2
share: 3
# 相似度计算配置
similarity:
# 标签相似度权重
tag-weight: 0.5
# 分类相似度权重
category-weight: 0.3
# 用户行为相似度权重
behavior-weight: 0.2
# 个性化推荐配置
personalized:
# 默认获取数量
default-size: 30
# 行为权重
behavior-weights:
view: 1
like: 3
favorite: 5
coin: 5
comment: 2
share: 3
complete-watch: 4
# JWT配置与auth模块保持一致
jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "
auth:
ignore-urls:
- /recommend/hot/**
- /recommend/tag/**
- /actuator/**
management: management:
endpoints: endpoints:
@@ -132,17 +36,3 @@ management:
endpoint: endpoint:
health: health:
show-details: always show-details: always
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000
circuitbreaker:
enabled: true
logging:
level:
com.nuaa.video: info
org.springframework.security: info
@@ -1,24 +0,0 @@
spring:
datasource:
dynamic:
primary: master
strict: false
datasource:
master:
url: jdbc:mysql://5.180.253.115:3306/video_user?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: sty@G458221
driver-class-name: com.mysql.cj.jdbc.Driver
data:
redis:
database: 1
host: 5.180.253.115
port: 6379
password: redis_EsJ8FX
timeout: 10000
logging:
level:
com.nuaa.video: debug
org.springframework.security: debug
@@ -1,97 +0,0 @@
server:
port: 9002
spring:
application:
name: video-user
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVERS:192.168.1.101:8848,192.168.1.102:8848,192.168.1.103:8848}
namespace: ${NACOS_NAMESPACE:public}
group: ${NACOS_GROUP:DEFAULT_GROUP}
username: nacos
password: nacos
ip: ${USER_IP:}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
group: ${spring.cloud.nacos.discovery.group}
file-extension: yaml
username: nacos
password: nacos
sentinel:
transport:
dashboard: ${SENTINEL_HOST:sentinel}:${SENTINEL_PORT:8080}
port: 8722
client-ip: ${USER_IP:}
eager: true
datasource:
url: jdbc:mysql://${MYSQL_HOST:mysql}:${MYSQL_PORT:3306}/video_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root
password: ${MYSQL_ROOT_PASSWORD:root123456}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
max-lifetime: 58000
idle-timeout: 300000
connection-timeout: 20000
connection-test-query: SELECT 1
keepalive-time: 60000
validation-timeout: 3000
minimum-idle: 5
maximum-pool-size: 20
data:
redis:
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
database: 1
timeout: 10000
sentinel:
master: mymaster
nodes: ${REDIS_SENTINEL_NODES:192.168.1.101:26379,192.168.1.102:26379,192.168.1.103:26379}
password: ${REDIS_PASSWORD:redis_HA_Cluster_2024}
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.user.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
auth:
ignore-urls:
- /user/profile/public/**
- /user/profile/init
- /actuator/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
logging:
level:
com.nuaa.video: info
org.springframework.security: info
minio:
endpoint: http://${MINIO_HOST:minio}:${MINIO_PORT:9000}
accessKey: minioadmin
secretKey: minioadmin123
bucketName: video-platform
+6 -67
View File
@@ -5,15 +5,17 @@ spring:
application: application:
name: video-user name: video-user
profiles: profiles:
active: dev active: ${SPRING_PROFILES_ACTIVE:dev}
config: config:
import: import:
- optional:nacos:${spring.application.name}.yaml?username=${NACOS_USERNAME:nacos}&password=${NACOS_PASSWORD:nacos} - optional:nacos:common.yaml?refreshEnabled=true
- optional:nacos:common-redis-${spring.profiles.active}.yaml?refreshEnabled=true
- optional:nacos:${spring.application.name}.yaml?refreshEnabled=true
cloud: cloud:
nacos: nacos:
discovery: discovery:
server-addr: ${NACOS_HOST:5.180.253.115}:${NACOS_PORT:8848} server-addr: ${NACOS_SERVER_ADDR:${NACOS_HOST:127.0.0.1}:${NACOS_PORT:8848}}
namespace: ${NACOS_NAMESPACE:public} namespace: ${NACOS_NAMESPACE:}
group: ${NACOS_GROUP:DEFAULT_GROUP} group: ${NACOS_GROUP:DEFAULT_GROUP}
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
@@ -25,57 +27,6 @@ spring:
file-extension: yaml file-extension: yaml
username: ${NACOS_USERNAME:nacos} username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos} password: ${NACOS_PASSWORD:nacos}
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:5.180.253.115}:${SENTINEL_DASHBOARD_PORT:8080}
port: ${SPRING_CLOUD_SENTINEL_TRANSPORT_PORT:8721}
client-ip: ${SPRING_CLOUD_SENTINEL_TRANSPORT_CLIENT_IP:}
eager: true
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${MYSQL_HOST:5.180.253.115}:${MYSQL_PORT:3306}/video_user?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:sty@G458221}
hikari:
minimum-idle: 5
maximum-pool-size: 20
idle-timeout: 30000
max-lifetime: 1200000
connection-timeout: 30000
connection-test-query: SELECT 1
data:
redis:
password: ${REDIS_PASSWORD:redis_EsJ8FX}
database: 1
timeout: 10000
lettuce:
pool:
max-active: 200
max-wait: -1
max-idle: 10
min-idle: 0
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.nuaa.video.user.entity
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: auto
logic-delete-field: is_deleted
logic-delete-value: 1
logic-not-delete-value: 0
auth:
ignore-urls:
- /user/profile/public/**
- /user/profile/init
- /actuator/**
management: management:
endpoints: endpoints:
@@ -85,15 +36,3 @@ management:
endpoint: endpoint:
health: health:
show-details: always show-details: always
logging:
level:
com.nuaa.video: info
org.springframework.security: info
# MinIO配置
minio:
endpoint: http://5.180.253.115:9002
accessKey: minioadmin
secretKey: minioadmin
bucketName: video-platform