chore(config): Extend Nacos high availability improvements

This commit is contained in:
2026-03-17 17:53:14 +08:00
parent 88bb0c0cd0
commit 1016814cf2
2 changed files with 121 additions and 38 deletions
+21 -20
View File
@@ -1,11 +1,12 @@
-- Nacos 配置初始化脚本
-- 在 Nacos 数据库中执行此脚本,创建所有配置
-- 注意:tenant_id 为空字符串 '' 表示 public 命名空间
-- Nacos 2.x 版本需要 encrypted_data_key 字段
-- ============================================
-- 1. 公共基础配置 (common.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) VALUES
('common.yaml', 'DEFAULT_GROUP', '# 公共配置 - 所有微服务共享
spring:
datasource:
@@ -62,26 +63,26 @@ feign:
logging:
level:
com.nuaa.video: info
org.springframework.security: info', '', '', 'nacos');
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
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) 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');
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
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) VALUES
('common-redis-ha.yaml', 'DEFAULT_GROUP', '# Redis Sentinel 高可用配置 - 生产环境
spring:
data:
@@ -90,12 +91,12 @@ spring:
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');
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
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) VALUES
('video-gateway.yaml', 'DEFAULT_GROUP', '# Gateway 服务配置
spring:
cloud:
@@ -152,12 +153,12 @@ gateway:
- /comment/reply/public/**
- /comment/public/**
- /admin/auth/captcha
- /admin/auth/login', '', '', 'nacos');
- /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
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) VALUES
('video-auth.yaml', 'DEFAULT_GROUP', '# Auth 服务配置
spring:
datasource:
@@ -182,12 +183,12 @@ jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "', '', '', 'nacos');
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
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) VALUES
('video-user.yaml', 'DEFAULT_GROUP', '# User 服务配置
spring:
datasource:
@@ -218,12 +219,12 @@ minio:
endpoint: http://${MINIO_HOST:minio}:${MINIO_PORT:9000}
accessKey: minioadmin
secretKey: minioadmin123
bucketName: video-platform', '', '', 'nacos');
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
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) VALUES
('video-content.yaml', 'DEFAULT_GROUP', '# Content 服务配置
spring:
datasource:
@@ -281,12 +282,12 @@ jwt:
secret: video-platform-secret-key-2024-nuaa
expiration: 86400
token-header: Authorization
token-prefix: "Bearer "', '', '', 'nacos');
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
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) VALUES
('video-comment.yaml', 'DEFAULT_GROUP', '# Comment 服务配置
spring:
datasource:
@@ -327,12 +328,12 @@ jwt:
auth:
ignore-urls:
- /comment/public/**
- /actuator/**', '', '', 'nacos');
- /actuator/**', '', '', 'nacos', '');
-- ============================================
-- 9. Recommend 服务配置 (video-recommend.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) VALUES
('video-recommend.yaml', 'DEFAULT_GROUP', '# Recommend 服务配置
spring:
datasource:
@@ -389,12 +390,12 @@ auth:
ignore-urls:
- /recommend/hot/**
- /recommend/tag/**
- /actuator/**', '', '', 'nacos');
- /actuator/**', '', '', 'nacos', '');
-- ============================================
-- 10. Admin 服务配置 (video-admin.yaml)
-- ============================================
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user) VALUES
INSERT INTO config_info (data_id, group_id, content, tenant_id, app_name, src_user, encrypted_data_key) VALUES
('video-admin.yaml', 'DEFAULT_GROUP', '# Admin 服务配置
spring:
datasource:
@@ -436,4 +437,4 @@ operation-log:
- /admin/auth/login
- /admin/auth/logout
- /admin/auth/captcha
- /actuator/**', '', '', 'nacos');
- /actuator/**', '', '', 'nacos', '');