673 lines
14 KiB
Markdown
673 lines
14 KiB
Markdown
|
|
# 🚀 项目上线部署准备清单
|
|||
|
|
|
|||
|
|
本文档提供了项目上线前的完整准备清单和部署步骤。
|
|||
|
|
|
|||
|
|
## 📋 一、服务器环境准备
|
|||
|
|
|
|||
|
|
### 1.1 服务器要求
|
|||
|
|
|
|||
|
|
**最低配置:**
|
|||
|
|
- CPU: 4核
|
|||
|
|
- 内存: 8GB
|
|||
|
|
- 磁盘: 100GB SSD
|
|||
|
|
- 带宽: 10Mbps
|
|||
|
|
|
|||
|
|
**推荐配置(支持50人并发):**
|
|||
|
|
- CPU: 4核
|
|||
|
|
- 内存: 8GB
|
|||
|
|
- 磁盘: 100GB+ SSD
|
|||
|
|
- 带宽: 20Mbps
|
|||
|
|
|
|||
|
|
### 1.2 操作系统
|
|||
|
|
|
|||
|
|
- **Linux**: Ubuntu 20.04+ / CentOS 7+ / Debian 11+
|
|||
|
|
- **Windows Server**: Windows Server 2019+
|
|||
|
|
|
|||
|
|
### 1.3 必需软件安装
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# Java 21 (必需)
|
|||
|
|
sudo apt update
|
|||
|
|
sudo apt install openjdk-21-jdk
|
|||
|
|
|
|||
|
|
# 验证安装
|
|||
|
|
java -version
|
|||
|
|
|
|||
|
|
# MySQL 8.0+ (必需)
|
|||
|
|
sudo apt install mysql-server
|
|||
|
|
sudo systemctl start mysql
|
|||
|
|
sudo systemctl enable mysql
|
|||
|
|
|
|||
|
|
# FFmpeg (视频拼接功能需要)
|
|||
|
|
# Ubuntu/Debian
|
|||
|
|
sudo apt install ffmpeg
|
|||
|
|
|
|||
|
|
# CentOS/RHEL
|
|||
|
|
sudo yum install epel-release
|
|||
|
|
sudo yum install ffmpeg
|
|||
|
|
|
|||
|
|
# 验证安装
|
|||
|
|
ffmpeg -version
|
|||
|
|
|
|||
|
|
# Nginx (反向代理,推荐)
|
|||
|
|
sudo apt install nginx
|
|||
|
|
|
|||
|
|
# Maven (构建项目)
|
|||
|
|
sudo apt install maven
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 1.4 目录结构准备
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 创建应用目录
|
|||
|
|
sudo mkdir -p /app/aigc-platform
|
|||
|
|
sudo mkdir -p /app/aigc-platform/logs
|
|||
|
|
sudo mkdir -p /app/aigc-platform/uploads
|
|||
|
|
sudo mkdir -p /app/aigc-platform/temp
|
|||
|
|
sudo mkdir -p /app/aigc-platform/config
|
|||
|
|
|
|||
|
|
# 设置权限
|
|||
|
|
sudo chown -R $USER:$USER /app/aigc-platform
|
|||
|
|
chmod -R 755 /app/aigc-platform
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🗄️ 二、数据库准备
|
|||
|
|
|
|||
|
|
### 2.1 创建数据库
|
|||
|
|
|
|||
|
|
```sql
|
|||
|
|
-- 登录MySQL
|
|||
|
|
mysql -u root -p
|
|||
|
|
|
|||
|
|
-- 创建数据库
|
|||
|
|
CREATE DATABASE aigc_platform CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|||
|
|
|
|||
|
|
-- 创建用户(推荐)
|
|||
|
|
CREATE USER 'aigc_user'@'localhost' IDENTIFIED BY '强密码';
|
|||
|
|
GRANT ALL PRIVILEGES ON aigc_platform.* TO 'aigc_user'@'localhost';
|
|||
|
|
FLUSH PRIVILEGES;
|
|||
|
|
|
|||
|
|
-- 退出
|
|||
|
|
EXIT;
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 2.2 数据库配置优化
|
|||
|
|
|
|||
|
|
编辑 `/etc/mysql/mysql.conf.d/mysqld.cnf`:
|
|||
|
|
|
|||
|
|
```ini
|
|||
|
|
[mysqld]
|
|||
|
|
# 字符集
|
|||
|
|
character-set-server=utf8mb4
|
|||
|
|
collation-server=utf8mb4_unicode_ci
|
|||
|
|
|
|||
|
|
# 连接数
|
|||
|
|
max_connections=500
|
|||
|
|
max_user_connections=400
|
|||
|
|
|
|||
|
|
# 缓冲池(根据内存调整,建议为内存的50-70%)
|
|||
|
|
# 8GB内存服务器建议设置为2-4G
|
|||
|
|
innodb_buffer_pool_size=2G
|
|||
|
|
|
|||
|
|
# 日志
|
|||
|
|
slow_query_log=1
|
|||
|
|
slow_query_log_file=/var/log/mysql/slow-query.log
|
|||
|
|
long_query_time=2
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
重启MySQL:
|
|||
|
|
```bash
|
|||
|
|
sudo systemctl restart mysql
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## ⚙️ 三、环境变量配置
|
|||
|
|
|
|||
|
|
### 3.1 创建环境变量文件
|
|||
|
|
|
|||
|
|
创建 `/app/aigc-platform/config/.env`:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 数据库配置
|
|||
|
|
export DB_URL="jdbc:mysql://localhost:3306/aigc_platform?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true"
|
|||
|
|
export DB_USERNAME="aigc_user"
|
|||
|
|
export DB_PASSWORD="你的数据库密码"
|
|||
|
|
|
|||
|
|
# JWT配置
|
|||
|
|
export JWT_SECRET="生成一个至少128位的随机字符串"
|
|||
|
|
export JWT_EXPIRATION="604800000"
|
|||
|
|
|
|||
|
|
# AI API配置(可通过管理页面修改,但建议先配置)
|
|||
|
|
export AI_API_BASE_URL="https://ai.comfly.chat"
|
|||
|
|
export AI_API_KEY="你的Comfly API密钥"
|
|||
|
|
export AI_IMAGE_API_BASE_URL="https://ai.comfly.chat"
|
|||
|
|
export AI_IMAGE_API_KEY="你的Comfly API密钥(文生图)"
|
|||
|
|
|
|||
|
|
# 支付宝配置(如需支付功能)
|
|||
|
|
export ALIPAY_APP_ID="你的支付宝应用ID"
|
|||
|
|
export ALIPAY_PRIVATE_KEY="你的应用私钥(RSA2格式,完整内容)"
|
|||
|
|
export ALIPAY_PUBLIC_KEY="支付宝公钥(RSA2格式,完整内容)"
|
|||
|
|
export ALIPAY_NOTIFY_URL="https://yourdomain.com/api/payments/alipay/notify"
|
|||
|
|
export ALIPAY_RETURN_URL="https://yourdomain.com/api/payments/alipay/return"
|
|||
|
|
|
|||
|
|
# 腾讯云SES配置(如需邮件功能)
|
|||
|
|
export TENCENT_SES_SECRET_ID="你的SecretId"
|
|||
|
|
export TENCENT_SES_SECRET_KEY="你的SecretKey"
|
|||
|
|
export TENCENT_SES_FROM_EMAIL="你的发件邮箱"
|
|||
|
|
export TENCENT_SES_TEMPLATE_ID="你的邮件模板ID"
|
|||
|
|
|
|||
|
|
# 文件路径配置
|
|||
|
|
export FFMPEG_PATH="/usr/bin/ffmpeg"
|
|||
|
|
export TEMP_DIR="/app/aigc-platform/temp"
|
|||
|
|
export UPLOAD_PATH="/app/aigc-platform/uploads"
|
|||
|
|
export LOG_FILE_PATH="/app/aigc-platform/logs/application.log"
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 3.2 生成JWT密钥
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 方法1:使用OpenSSL
|
|||
|
|
openssl rand -base64 64
|
|||
|
|
|
|||
|
|
# 方法2:使用Python
|
|||
|
|
python3 -c "import secrets; print(secrets.token_urlsafe(64))"
|
|||
|
|
|
|||
|
|
# 方法3:在线生成
|
|||
|
|
# 访问 https://www.random.org/strings/
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 3.3 加载环境变量
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 编辑 ~/.bashrc 或 ~/.profile
|
|||
|
|
echo "source /app/aigc-platform/config/.env" >> ~/.bashrc
|
|||
|
|
source ~/.bashrc
|
|||
|
|
|
|||
|
|
# 或创建 systemd service 时直接加载
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📦 四、项目构建与部署
|
|||
|
|
|
|||
|
|
### 4.1 构建项目
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 进入项目目录
|
|||
|
|
cd /path/to/AIGC/demo
|
|||
|
|
|
|||
|
|
# 清理并打包(跳过测试)
|
|||
|
|
./mvnw clean package -DskipTests
|
|||
|
|
|
|||
|
|
# 或使用Maven
|
|||
|
|
mvn clean package -DskipTests
|
|||
|
|
|
|||
|
|
# 打包后的JAR文件位置
|
|||
|
|
# target/demo-0.0.1-SNAPSHOT.jar
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 4.2 上传文件到服务器
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 使用SCP上传
|
|||
|
|
scp target/demo-0.0.1-SNAPSHOT.jar user@server:/app/aigc-platform/
|
|||
|
|
|
|||
|
|
# 或使用FTP/SFTP工具
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 4.3 前端构建
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 进入前端目录
|
|||
|
|
cd frontend
|
|||
|
|
|
|||
|
|
# 安装依赖(如果还没有)
|
|||
|
|
npm install
|
|||
|
|
|
|||
|
|
# 构建生产版本
|
|||
|
|
npm run build
|
|||
|
|
|
|||
|
|
# 构建后的文件在 dist/ 目录
|
|||
|
|
# 需要配置Nginx指向 dist/ 目录
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🔧 五、应用配置
|
|||
|
|
|
|||
|
|
### 5.1 创建生产环境配置文件
|
|||
|
|
|
|||
|
|
在服务器上创建 `/app/aigc-platform/config/application-prod.properties`:
|
|||
|
|
|
|||
|
|
```properties
|
|||
|
|
# 激活生产环境配置
|
|||
|
|
spring.profiles.active=prod
|
|||
|
|
|
|||
|
|
# 数据库配置(使用环境变量)
|
|||
|
|
spring.datasource.url=${DB_URL}
|
|||
|
|
spring.datasource.username=${DB_USERNAME}
|
|||
|
|
spring.datasource.password=${DB_PASSWORD}
|
|||
|
|
|
|||
|
|
# JWT配置
|
|||
|
|
jwt.secret=${JWT_SECRET}
|
|||
|
|
jwt.expiration=${JWT_EXPIRATION:604800000}
|
|||
|
|
|
|||
|
|
# 支付宝配置
|
|||
|
|
alipay.app-id=${ALIPAY_APP_ID}
|
|||
|
|
alipay.private-key=${ALIPAY_PRIVATE_KEY}
|
|||
|
|
alipay.public-key=${ALIPAY_PUBLIC_KEY}
|
|||
|
|
alipay.gateway-url=https://openapi.alipay.com/gateway.do
|
|||
|
|
alipay.notify-url=${ALIPAY_NOTIFY_URL}
|
|||
|
|
alipay.return-url=${ALIPAY_RETURN_URL}
|
|||
|
|
|
|||
|
|
# 腾讯云SES配置
|
|||
|
|
tencent.ses.secret-id=${TENCENT_SES_SECRET_ID}
|
|||
|
|
tencent.ses.secret-key=${TENCENT_SES_SECRET_KEY}
|
|||
|
|
tencent.ses.from-email=${TENCENT_SES_FROM_EMAIL}
|
|||
|
|
tencent.ses.template-id=${TENCENT_SES_TEMPLATE_ID}
|
|||
|
|
|
|||
|
|
# 文件路径
|
|||
|
|
app.ffmpeg.path=${FFMPEG_PATH:ffmpeg}
|
|||
|
|
app.temp.dir=${TEMP_DIR:./temp}
|
|||
|
|
app.upload.path=${UPLOAD_PATH:./uploads}
|
|||
|
|
|
|||
|
|
# 日志
|
|||
|
|
logging.file.name=${LOG_FILE_PATH:./logs/application.log}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 5.2 创建Systemd服务(Linux)
|
|||
|
|
|
|||
|
|
创建 `/etc/systemd/system/aigc-platform.service`:
|
|||
|
|
|
|||
|
|
```ini
|
|||
|
|
[Unit]
|
|||
|
|
Description=AIGC Platform Application
|
|||
|
|
After=network.target mysql.service
|
|||
|
|
|
|||
|
|
[Service]
|
|||
|
|
Type=simple
|
|||
|
|
User=your-user
|
|||
|
|
WorkingDirectory=/app/aigc-platform
|
|||
|
|
EnvironmentFile=/app/aigc-platform/config/.env
|
|||
|
|
ExecStart=/usr/bin/java -jar \
|
|||
|
|
-Xms1g \
|
|||
|
|
-Xmx4g \
|
|||
|
|
-XX:+UseG1GC \
|
|||
|
|
-XX:MaxGCPauseMillis=200 \
|
|||
|
|
-Dspring.profiles.active=prod \
|
|||
|
|
-Dspring.config.location=file:/app/aigc-platform/config/application-prod.properties \
|
|||
|
|
/app/aigc-platform/demo-0.0.1-SNAPSHOT.jar
|
|||
|
|
Restart=always
|
|||
|
|
RestartSec=10
|
|||
|
|
StandardOutput=journal
|
|||
|
|
StandardError=journal
|
|||
|
|
SyslogIdentifier=aigc-platform
|
|||
|
|
|
|||
|
|
[Install]
|
|||
|
|
WantedBy=multi-user.target
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
启动服务:
|
|||
|
|
```bash
|
|||
|
|
sudo systemctl daemon-reload
|
|||
|
|
sudo systemctl enable aigc-platform
|
|||
|
|
sudo systemctl start aigc-platform
|
|||
|
|
sudo systemctl status aigc-platform
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
查看日志:
|
|||
|
|
```bash
|
|||
|
|
sudo journalctl -u aigc-platform -f
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🌐 六、Nginx反向代理配置
|
|||
|
|
|
|||
|
|
### 6.1 创建Nginx配置
|
|||
|
|
|
|||
|
|
创建 `/etc/nginx/sites-available/aigc-platform`:
|
|||
|
|
|
|||
|
|
```nginx
|
|||
|
|
upstream aigc_backend {
|
|||
|
|
server localhost:8080;
|
|||
|
|
keepalive 32;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
server {
|
|||
|
|
listen 80;
|
|||
|
|
server_name yourdomain.com www.yourdomain.com;
|
|||
|
|
|
|||
|
|
# 重定向到HTTPS
|
|||
|
|
return 301 https://$server_name$request_uri;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
server {
|
|||
|
|
listen 443 ssl http2;
|
|||
|
|
server_name yourdomain.com www.yourdomain.com;
|
|||
|
|
|
|||
|
|
# SSL证书配置
|
|||
|
|
ssl_certificate /path/to/your/cert.pem;
|
|||
|
|
ssl_certificate_key /path/to/your/key.pem;
|
|||
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|||
|
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
|||
|
|
ssl_prefer_server_ciphers on;
|
|||
|
|
|
|||
|
|
# 前端静态文件
|
|||
|
|
root /path/to/frontend/dist;
|
|||
|
|
index index.html;
|
|||
|
|
|
|||
|
|
# 前端路由
|
|||
|
|
location / {
|
|||
|
|
try_files $uri $uri/ /index.html;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 后端API代理
|
|||
|
|
location /api/ {
|
|||
|
|
proxy_pass http://aigc_backend;
|
|||
|
|
proxy_http_version 1.1;
|
|||
|
|
proxy_set_header Upgrade $http_upgrade;
|
|||
|
|
proxy_set_header Connection 'upgrade';
|
|||
|
|
proxy_set_header Host $host;
|
|||
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|||
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|||
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|||
|
|
proxy_cache_bypass $http_upgrade;
|
|||
|
|
|
|||
|
|
# 超时设置
|
|||
|
|
proxy_connect_timeout 300s;
|
|||
|
|
proxy_send_timeout 300s;
|
|||
|
|
proxy_read_timeout 300s;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 文件上传代理(支持大文件)
|
|||
|
|
location /uploads/ {
|
|||
|
|
proxy_pass http://aigc_backend;
|
|||
|
|
proxy_request_buffering off;
|
|||
|
|
client_max_body_size 500M;
|
|||
|
|
proxy_connect_timeout 300s;
|
|||
|
|
proxy_send_timeout 300s;
|
|||
|
|
proxy_read_timeout 300s;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 日志
|
|||
|
|
access_log /var/log/nginx/aigc-platform-access.log;
|
|||
|
|
error_log /var/log/nginx/aigc-platform-error.log;
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
启用配置:
|
|||
|
|
```bash
|
|||
|
|
sudo ln -s /etc/nginx/sites-available/aigc-platform /etc/nginx/sites-enabled/
|
|||
|
|
sudo nginx -t
|
|||
|
|
sudo systemctl reload nginx
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 6.2 SSL证书(Let's Encrypt)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 安装Certbot
|
|||
|
|
sudo apt install certbot python3-certbot-nginx
|
|||
|
|
|
|||
|
|
# 获取证书
|
|||
|
|
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
|
|||
|
|
|
|||
|
|
# 自动续期
|
|||
|
|
sudo certbot renew --dry-run
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🔒 七、安全配置
|
|||
|
|
|
|||
|
|
### 7.1 防火墙配置
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# UFW (Ubuntu)
|
|||
|
|
sudo ufw allow 22/tcp
|
|||
|
|
sudo ufw allow 80/tcp
|
|||
|
|
sudo ufw allow 443/tcp
|
|||
|
|
sudo ufw enable
|
|||
|
|
|
|||
|
|
# Firewalld (CentOS)
|
|||
|
|
sudo firewall-cmd --permanent --add-service=ssh
|
|||
|
|
sudo firewall-cmd --permanent --add-service=http
|
|||
|
|
sudo firewall-cmd --permanent --add-service=https
|
|||
|
|
sudo firewall-cmd --reload
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 7.2 数据库安全
|
|||
|
|
|
|||
|
|
```sql
|
|||
|
|
-- 删除匿名用户
|
|||
|
|
DELETE FROM mysql.user WHERE User='';
|
|||
|
|
|
|||
|
|
-- 禁止root远程登录(如果不需要)
|
|||
|
|
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
|
|||
|
|
|
|||
|
|
-- 刷新权限
|
|||
|
|
FLUSH PRIVILEGES;
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 7.3 文件权限
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 配置文件权限
|
|||
|
|
chmod 600 /app/aigc-platform/config/.env
|
|||
|
|
chmod 600 /app/aigc-platform/config/application-prod.properties
|
|||
|
|
|
|||
|
|
# 日志目录权限
|
|||
|
|
chmod 755 /app/aigc-platform/logs
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📊 八、监控与日志
|
|||
|
|
|
|||
|
|
### 8.1 日志管理
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 配置日志轮转
|
|||
|
|
sudo nano /etc/logrotate.d/aigc-platform
|
|||
|
|
|
|||
|
|
# 内容:
|
|||
|
|
/app/aigc-platform/logs/*.log {
|
|||
|
|
daily
|
|||
|
|
rotate 30
|
|||
|
|
compress
|
|||
|
|
delaycompress
|
|||
|
|
missingok
|
|||
|
|
notifempty
|
|||
|
|
create 0644 your-user your-user
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 8.2 监控脚本
|
|||
|
|
|
|||
|
|
创建 `/app/aigc-platform/scripts/health-check.sh`:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
#!/bin/bash
|
|||
|
|
HEALTH_URL="http://localhost:8080/api/health"
|
|||
|
|
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" $HEALTH_URL)
|
|||
|
|
|
|||
|
|
if [ $RESPONSE -ne 200 ]; then
|
|||
|
|
echo "Health check failed: $RESPONSE"
|
|||
|
|
systemctl restart aigc-platform
|
|||
|
|
fi
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
添加到crontab:
|
|||
|
|
```bash
|
|||
|
|
# 每5分钟检查一次
|
|||
|
|
*/5 * * * * /app/aigc-platform/scripts/health-check.sh
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## ✅ 九、上线前检查清单
|
|||
|
|
|
|||
|
|
### 9.1 配置检查
|
|||
|
|
|
|||
|
|
- [ ] 数据库连接配置正确
|
|||
|
|
- [ ] JWT密钥已生成并配置
|
|||
|
|
- [ ] AI API密钥已配置
|
|||
|
|
- [ ] 支付宝配置(如需要)
|
|||
|
|
- [ ] 腾讯云SES配置(如需要)
|
|||
|
|
- [ ] FFmpeg路径正确
|
|||
|
|
- [ ] 文件上传目录权限正确
|
|||
|
|
- [ ] 日志目录权限正确
|
|||
|
|
|
|||
|
|
### 9.2 功能测试
|
|||
|
|
|
|||
|
|
- [ ] 用户注册/登录
|
|||
|
|
- [ ] 文生视频功能
|
|||
|
|
- [ ] 图生视频功能
|
|||
|
|
- [ ] 分镜视频功能
|
|||
|
|
- [ ] 支付功能(如需要)
|
|||
|
|
- [ ] 邮件发送(如需要)
|
|||
|
|
- [ ] 文件上传/下载
|
|||
|
|
- [ ] 视频拼接功能
|
|||
|
|
|
|||
|
|
### 9.3 性能测试
|
|||
|
|
|
|||
|
|
- [ ] 并发测试(建议使用JMeter)
|
|||
|
|
- [ ] 数据库连接池测试
|
|||
|
|
- [ ] 内存使用监控
|
|||
|
|
- [ ] CPU使用监控
|
|||
|
|
- [ ] 磁盘空间监控
|
|||
|
|
|
|||
|
|
### 9.4 安全检查
|
|||
|
|
|
|||
|
|
- [ ] 防火墙已配置
|
|||
|
|
- [ ] SSL证书已安装
|
|||
|
|
- [ ] 敏感信息使用环境变量
|
|||
|
|
- [ ] 数据库用户权限最小化
|
|||
|
|
- [ ] 文件权限已设置
|
|||
|
|
|
|||
|
|
### 9.5 备份策略
|
|||
|
|
|
|||
|
|
- [ ] 数据库自动备份脚本
|
|||
|
|
- [ ] 文件上传目录备份
|
|||
|
|
- [ ] 配置文件备份
|
|||
|
|
- [ ] 备份恢复测试
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🔄 十、部署流程
|
|||
|
|
|
|||
|
|
### 10.1 首次部署
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 1. 准备服务器环境
|
|||
|
|
# 2. 安装必需软件
|
|||
|
|
# 3. 配置数据库
|
|||
|
|
# 4. 配置环境变量
|
|||
|
|
# 5. 构建项目
|
|||
|
|
# 6. 上传文件
|
|||
|
|
# 7. 配置Nginx
|
|||
|
|
# 8. 启动服务
|
|||
|
|
# 9. 测试功能
|
|||
|
|
# 10. 配置监控
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 10.2 更新部署
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 1. 备份当前版本
|
|||
|
|
cp demo-0.0.1-SNAPSHOT.jar demo-0.0.1-SNAPSHOT.jar.backup
|
|||
|
|
|
|||
|
|
# 2. 停止服务
|
|||
|
|
sudo systemctl stop aigc-platform
|
|||
|
|
|
|||
|
|
# 3. 上传新版本
|
|||
|
|
scp target/demo-0.0.1-SNAPSHOT.jar user@server:/app/aigc-platform/
|
|||
|
|
|
|||
|
|
# 4. 启动服务
|
|||
|
|
sudo systemctl start aigc-platform
|
|||
|
|
|
|||
|
|
# 5. 检查状态
|
|||
|
|
sudo systemctl status aigc-platform
|
|||
|
|
sudo journalctl -u aigc-platform -f
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🆘 十一、常见问题排查
|
|||
|
|
|
|||
|
|
### 11.1 应用无法启动
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 查看日志
|
|||
|
|
sudo journalctl -u aigc-platform -n 100
|
|||
|
|
|
|||
|
|
# 检查Java版本
|
|||
|
|
java -version
|
|||
|
|
|
|||
|
|
# 检查端口占用
|
|||
|
|
sudo netstat -tlnp | grep 8080
|
|||
|
|
|
|||
|
|
# 检查环境变量
|
|||
|
|
env | grep DB_
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 11.2 数据库连接失败
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 测试数据库连接
|
|||
|
|
mysql -h localhost -u aigc_user -p aigc_platform
|
|||
|
|
|
|||
|
|
# 检查MySQL服务
|
|||
|
|
sudo systemctl status mysql
|
|||
|
|
|
|||
|
|
# 检查防火墙
|
|||
|
|
sudo ufw status
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 11.3 文件上传失败
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 检查目录权限
|
|||
|
|
ls -la /app/aigc-platform/uploads
|
|||
|
|
|
|||
|
|
# 检查磁盘空间
|
|||
|
|
df -h
|
|||
|
|
|
|||
|
|
# 检查Nginx配置
|
|||
|
|
sudo nginx -t
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📞 十二、技术支持
|
|||
|
|
|
|||
|
|
如遇到问题,请检查:
|
|||
|
|
1. 应用日志:`/app/aigc-platform/logs/application.log`
|
|||
|
|
2. 系统日志:`sudo journalctl -u aigc-platform`
|
|||
|
|
3. Nginx日志:`/var/log/nginx/aigc-platform-error.log`
|
|||
|
|
4. MySQL日志:`/var/log/mysql/error.log`
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📝 十三、维护计划
|
|||
|
|
|
|||
|
|
### 日常维护
|
|||
|
|
|
|||
|
|
- **每日**: 检查日志、监控系统资源
|
|||
|
|
- **每周**: 检查备份、清理临时文件
|
|||
|
|
- **每月**: 更新依赖、安全补丁
|
|||
|
|
|
|||
|
|
### 定期任务
|
|||
|
|
|
|||
|
|
- **数据库备份**: 每天凌晨2点
|
|||
|
|
- **日志清理**: 每天凌晨4点
|
|||
|
|
- **任务清理**: 每天凌晨4点(已配置定时任务)
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
**祝部署顺利!** 🎉
|
|||
|
|
|