Files
HAOVP/backend/sql/nacos-config-init.sql
T

472 lines
14 KiB
SQL

-- Nacos 配置初始化脚本
-- 在 Nacos 数据库中执行此脚本,创建所有配置
-- 注意:tenant_id 为空字符串 '' 表示 public 命名空间
-- Nacos 2.x 版本需要 encrypted_data_key 字段
USE nacos_config;
-- ============================================
-- 1. 公共基础配置 (common.yaml)
-- ============================================
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:
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
service:
auth:
token: ${SERVICE_AUTH_TOKEN}', '', '', 'nacos', '');
-- ============================================
-- 2. 开发环境 Redis 配置 (common-redis-dev.yaml)
-- 单机模式
-- ============================================
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}', '', '', 'nacos', '');
-- ============================================
-- 3. 高可用环境 Redis 配置 (common-redis-ha.yaml)
-- Sentinel 哨兵模式
-- ============================================
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:
redis:
password: ${REDIS_PASSWORD}
sentinel:
master: mymaster
nodes: ${REDIS_SENTINEL_NODES}
password: ${REDIS_PASSWORD}', '', '', 'nacos', '');
-- ============================================
-- 4. Gateway 服务配置 (video-gateway.yaml)
-- ============================================
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:
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_DASHBOARD_HOST:sentinel}:${SENTINEL_DASHBOARD_PORT:8880}
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
- /auth/username/**
- /content/video/public/**
- /content/category/tree
- /content/category/list
- /content/tag/list
- /content/tag/page
- /content/danmaku/all/**
- /content/danmaku/time
- /content/stat/**
- /user/profile/public/**
- /user/profile/search
- /user/follow/following/**
- /user/follow/followers/**
- /comment/reply/public/**
- /comment/public/**
- /admin/auth/captcha
- /admin/auth/login
jwt:
secret: ${USER_JWT_SECRET}
token-header: Authorization
token-prefix: "Bearer "', '', '', 'nacos', '');
-- ============================================
-- 5. Auth 服务配置 (video-auth.yaml)
-- ============================================
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:
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}
data:
redis:
database: 0
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:sentinel}:${SENTINEL_DASHBOARD_PORT:8880}
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: ${USER_JWT_SECRET}
expiration: ${JWT_EXPIRATION}
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, encrypted_data_key) 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}
data:
redis:
database: 1
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:sentinel}:${SENTINEL_DASHBOARD_PORT:8880}
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/**
jwt:
secret: ${USER_JWT_SECRET}
expiration: ${JWT_EXPIRATION}
token-header: Authorization
token-prefix: "Bearer "
minio:
endpoint: http://${MINIO_HOST:minio}:${MINIO_PORT:9000}
accessKey: ${MINIO_ACCESS_KEY}
secretKey: ${MINIO_SECRET_KEY}
bucketName: video-platform', '', '', 'nacos', '');
-- ============================================
-- 7. Content 服务配置 (video-content.yaml)
-- ============================================
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:
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}
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_DASHBOARD_HOST:sentinel}:${SENTINEL_DASHBOARD_PORT:8880}
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}
secretKey: ${MINIO_SECRET_KEY}
bucketName: ${MINIO_BUCKET}
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: ${USER_JWT_SECRET}
expiration: ${JWT_EXPIRATION}
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, encrypted_data_key) 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}
data:
redis:
database: 3
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:sentinel}:${SENTINEL_DASHBOARD_PORT:8880}
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: ${USER_JWT_SECRET}
expiration: ${JWT_EXPIRATION}
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, encrypted_data_key) 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}
data:
redis:
database: 4
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:sentinel}:${SENTINEL_DASHBOARD_PORT:8880}
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: ${USER_JWT_SECRET}
expiration: ${JWT_EXPIRATION}
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, encrypted_data_key) 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}
data:
redis:
database: 5
cloud:
sentinel:
transport:
dashboard: ${SENTINEL_DASHBOARD_HOST:sentinel}:${SENTINEL_DASHBOARD_PORT:8880}
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: ${ADMIN_JWT_SECRET}
expiration: ${JWT_EXPIRATION}
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/**
app:
init:
admin-password: ${ADMIN_INIT_PASSWORD}', '', '', 'nacos', '');