Files
rust-user-api/docs/deployment-checklist.md
enoch bb9d7a869d
Some checks failed
Deploy to Production / Run Tests (push) Failing after 16m35s
Deploy to Production / Security Scan (push) Has been skipped
Deploy to Production / Build Docker Image (push) Has been skipped
Deploy to Production / Deploy to Staging (push) Has been skipped
Deploy to Production / Deploy to Production (push) Has been skipped
Deploy to Production / Notify Results (push) Successful in 31s
feat: 完成Rust User API完整开发
 新功能:
- SQLite数据库集成和持久化存储
- 数据库迁移系统和版本管理
- API分页功能和高效查询
- 用户搜索和过滤机制
- 完整的RBAC角色权限系统
- 结构化日志记录和系统监控
- API限流和多层安全防护
- Docker容器化和生产部署配置

🔒 安全特性:
- JWT认证和授权
- 限流和防暴力破解
- 安全头和CORS配置
- 输入验证和XSS防护
- 审计日志和安全监控

📊 监控和运维:
- Prometheus指标收集
- 健康检查和系统监控
- 自动化备份和恢复
- 完整的运维文档和脚本
- CI/CD流水线配置

🚀 部署支持:
- 多环境Docker配置
- 生产环境部署指南
- 性能优化和安全加固
- 故障排除和应急响应
- 自动化运维脚本

📚 文档完善:
- API使用文档
- 部署检查清单
- 运维操作手册
- 性能和安全指南
- 故障排除指南
2025-08-07 16:03:32 +08:00

363 lines
8.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 生产环境部署检查清单
## 📋 部署前检查清单
### 🔧 系统环境检查
- [ ] **服务器规格确认**
- [ ] CPU: 至少2核心
- [ ] 内存: 至少2GB RAM
- [ ] 存储: 至少20GB可用空间
- [ ] 网络: 稳定的互联网连接
- [ ] **操作系统配置**
- [ ] Ubuntu 20.04+ 或 CentOS 8+ 或 Debian 11+
- [ ] 系统已更新到最新版本
- [ ] 时区设置正确
- [ ] NTP时间同步已启用
- [ ] **Docker环境**
- [ ] Docker Engine 20.10+ 已安装
- [ ] Docker Compose 2.0+ 已安装
- [ ] Docker服务正常运行
- [ ] 当前用户已加入docker组
### 🔒 安全配置检查
- [ ] **防火墙配置**
- [ ] UFW或iptables已配置
- [ ] 仅开放必要端口 (22, 80, 443)
- [ ] SSH端口已修改可选但推荐
- [ ] 禁用root用户SSH登录
- [ ] **SSL/TLS证书**
- [ ] SSL证书已准备Let's Encrypt或商业证书
- [ ] 证书文件权限正确设置
- [ ] 证书有效期检查
- [ ] 自动续期配置Let's Encrypt
- [ ] **用户权限**
- [ ] 创建专用的非特权用户
- [ ] 应用目录权限正确设置
- [ ] 敏感文件权限限制
### 📁 文件和配置检查
- [ ] **项目文件**
- [ ] 源代码已上传到服务器
- [ ] 文件权限正确设置
- [ ] .env.production文件已创建并配置
- [ ] 敏感信息已从代码中移除
- [ ] **配置文件**
- [ ] docker-compose.prod.yml已配置
- [ ] Nginx配置文件已准备
- [ ] 监控配置文件已准备
- [ ] 日志配置正确
### 🗄️ 数据库准备
- [ ] **数据库配置**
- [ ] 数据库连接字符串正确
- [ ] 数据库文件目录已创建
- [ ] 数据库权限正确设置
- [ ] 备份策略已制定
- [ ] **迁移脚本**
- [ ] 数据库迁移脚本已准备
- [ ] 迁移脚本已测试
- [ ] 回滚方案已准备
## 🚀 部署执行检查清单
### 1⃣ 环境准备
- [ ] **创建目录结构**
```bash
sudo mkdir -p /opt/rust-api/{data,logs,backups,ssl,config}
sudo mkdir -p /opt/rust-api/nginx/{conf.d,ssl}
sudo mkdir -p /opt/rust-api/monitoring/{prometheus,grafana}
```
- [ ] **设置权限**
```bash
sudo useradd -r -s /bin/false -m -d /opt/rust-api apiuser
sudo chown -R apiuser:apiuser /opt/rust-api
sudo chmod 750 /opt/rust-api
```
- [ ] **复制项目文件**
```bash
sudo cp -r /path/to/project/* /opt/rust-api/
sudo chown -R apiuser:apiuser /opt/rust-api
```
### 2⃣ 配置文件设置
- [ ] **环境变量配置**
```bash
sudo cp config/production.env.template /opt/rust-api/.env.production
sudo nano /opt/rust-api/.env.production # 编辑配置
sudo chmod 600 /opt/rust-api/.env.production
```
- [ ] **SSL证书配置**
```bash
sudo cp /path/to/cert.pem /opt/rust-api/ssl/
sudo cp /path/to/key.pem /opt/rust-api/ssl/
sudo chmod 600 /opt/rust-api/ssl/*.pem
```
- [ ] **Nginx配置**
```bash
sudo cp nginx/nginx.conf /opt/rust-api/nginx/
sudo chown apiuser:apiuser /opt/rust-api/nginx/nginx.conf
```
### 3⃣ 服务启动
- [ ] **构建镜像**
```bash
cd /opt/rust-api
sudo docker-compose -f docker-compose.prod.yml build
```
- [ ] **启动服务**
```bash
sudo docker-compose -f docker-compose.prod.yml up -d
```
- [ ] **检查服务状态**
```bash
sudo docker-compose -f docker-compose.prod.yml ps
sudo docker-compose -f docker-compose.prod.yml logs
```
### 4⃣ 功能验证
- [ ] **健康检查**
```bash
curl -f http://localhost/health
curl -f https://yourdomain.com/health
```
- [ ] **API端点测试**
```bash
# 测试用户注册
curl -X POST https://yourdomain.com/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"testuser","email":"test@example.com","password":"TestPass123!"}'
# 测试用户登录
curl -X POST https://yourdomain.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"TestPass123!"}'
# 测试用户列表
curl -H "Authorization: Bearer YOUR_TOKEN" https://yourdomain.com/api/users
```
- [ ] **监控端点测试**
```bash
curl https://yourdomain.com/monitoring/health
curl https://yourdomain.com/monitoring/metrics/prometheus
```
## 📊 部署后验证检查清单
### 🔍 系统监控验证
- [ ] **服务状态检查**
- [ ] 所有容器正常运行
- [ ] 内存使用率正常 (<80%)
- [ ] CPU使用率正常 (<70%)
- [ ] 磁盘空间充足 (>20%可用)
- [ ] **网络连接检查**
- [ ] HTTP重定向到HTTPS正常
- [ ] SSL证书验证通过
- [ ] 域名解析正确
- [ ] 负载均衡器配置正确(如有)
- [ ] **日志检查**
- [ ] 应用日志正常输出
- [ ] 错误日志无异常
- [ ] 访问日志记录正常
- [ ] 审计日志功能正常
### 🛡️ 安全验证
- [ ] **安全扫描**
- [ ] SSL Labs测试通过 (A级以上)
- [ ] 安全头检查通过
- [ ] 端口扫描无异常开放端口
- [ ] 漏洞扫描无高危漏洞
- [ ] **访问控制验证**
- [ ] 未授权访问被正确拒绝
- [ ] JWT令牌验证正常
- [ ] 角色权限控制正常
- [ ] 限流机制正常工作
- [ ] **数据保护验证**
- [ ] 敏感数据加密存储
- [ ] 数据库访问权限正确
- [ ] 备份功能正常
- [ ] 数据恢复测试通过
### 📈 性能验证
- [ ] **响应时间测试**
- [ ] API响应时间 <200ms (95%请求)
- [ ] 数据库查询时间 <100ms
- [ ] 静态资源加载时间 <1s
- [ ] **并发测试**
- [ ] 100并发用户测试通过
- [ ] 1000并发用户测试通过可选
- [ ] 内存泄漏检查通过
- [ ] 连接池正常工作
- [ ] **压力测试**
```bash
# 使用Apache Bench进行压力测试
ab -n 1000 -c 10 https://yourdomain.com/api/users
# 使用wrk进行压力测试
wrk -t12 -c400 -d30s https://yourdomain.com/api/users
```
## 🔧 故障排除检查清单
### 🚨 常见问题诊断
- [ ] **服务无法启动**
- [ ] 检查Docker服务状态
- [ ] 检查端口占用情况
- [ ] 检查配置文件语法
- [ ] 检查文件权限
- [ ] **数据库连接失败**
- [ ] 检查数据库文件权限
- [ ] 检查连接字符串配置
- [ ] 检查数据库文件是否存在
- [ ] 检查磁盘空间
- [ ] **SSL证书问题**
- [ ] 检查证书文件路径
- [ ] 检查证书有效期
- [ ] 检查证书权限
- [ ] 检查域名匹配
- [ ] **性能问题**
- [ ] 检查系统资源使用
- [ ] 检查数据库查询性能
- [ ] 检查网络延迟
- [ ] 检查缓存配置
### 🔧 调试工具
- [ ] **日志查看命令**
```bash
# 查看应用日志
sudo docker-compose -f docker-compose.prod.yml logs -f rust-user-api
# 查看Nginx日志
sudo docker-compose -f docker-compose.prod.yml logs -f nginx
# 查看系统日志
sudo journalctl -u docker -f
```
- [ ] **性能监控命令**
```bash
# 查看容器资源使用
sudo docker stats
# 查看系统资源
htop
iotop
nethogs
# 查看网络连接
netstat -tulpn
ss -tulpn
```
- [ ] **数据库调试**
```bash
# 进入数据库容器
sudo docker-compose -f docker-compose.prod.yml exec rust-user-api sqlite3 /app/data/production.db
# 检查数据库完整性
PRAGMA integrity_check;
# 查看数据库统计
PRAGMA table_info(users);
```
## 📝 部署记录
### 部署信息记录
- **部署日期**: _______________
- **部署版本**: _______________
- **部署人员**: _______________
- **服务器信息**: _______________
- **域名**: _______________
### 配置参数记录
- **数据库类型**: _______________
- **SSL证书类型**: _______________
- **监控配置**: _______________
- **备份策略**: _______________
### 测试结果记录
- **功能测试**: ✅ / ❌
- **性能测试**: ✅ / ❌
- **安全测试**: ✅ / ❌
- **监控测试**: ✅ / ❌
### 问题和解决方案
| 问题描述 | 解决方案 | 状态 |
|---------|---------|------|
| | | |
| | | |
| | | |
## 📞 应急联系信息
### 技术支持
- **主要联系人**: _______________
- **电话**: _______________
- **邮箱**: _______________
- **备用联系人**: _______________
### 服务商信息
- **云服务商**: _______________
- **域名注册商**: _______________
- **SSL证书提供商**: _______________
- **监控服务商**: _______________
## 📚 相关文档
- [ ] [生产环境部署指南](production-deployment.md)
- [ ] [性能优化和安全加固指南](performance-security-guide.md)
- [ ] [Docker部署文档](../README-Docker.md)
- [ ] [API文档](../README.md)
- [ ] [故障排除指南](troubleshooting.md)
---
**注意**:
1. 请按照检查清单逐项验证,确保每个步骤都已完成
2. 遇到问题时,请参考故障排除部分或联系技术支持
3. 部署完成后,请保存此检查清单作为部署记录
4. 定期审查和更新此检查清单以适应新的需求
**部署完成签名**: _______________ **日期**: _______________