feat: 完成项目整理优化和生产环境配置

🧹 项目结构优化:
- 删除重复和过时的文件
- 整理文档到docs目录结构
- 优化配置文件到configs目录
- 创建清晰的PROJECT_STRUCTURE.md

🔧 中间件配置:
- 重启MySQL/Redis/Nacos中间件
- 使用现有数据目录,确保数据完整性
- 统一密码配置: MySQL(EmotionMuseum2025*#), Nacos(Peanut2817*#)

🌐 Nginx配置:
- 配置前端路径: /emotion-museum
- 配置API代理: /api/ -> 19000
- 配置WebSocket代理: /ws/ -> 19007
- 添加健康检查端点: /health

📋 部署脚本优化:
- restart-middleware.sh - 中间件重启脚本
- setup-nginx.sh - Nginx配置脚本
- cleanup-project.sh - 项目清理脚本
- one-click-deploy.sh - 一键部署脚本

📖 文档完善:
- DEPLOYMENT_FINAL.md - 最终部署指南
- PROJECT_STRUCTURE.md - 项目结构说明
- 完整的运维和故障排查指南

 生产环境就绪:
- 中间件: MySQL/Redis/Nacos 运行正常
- Nginx: 反向代理配置完成
- 访问地址: http://47.111.10.27/emotion-museum
- 健康检查: http://47.111.10.27/health

🎯 项目现状:
- 10个微服务模块完整
- 前后端分离架构
- 容器化部署
- 统一配置管理
- 完整的部署和运维体系
This commit is contained in:
2025-07-21 13:55:36 +08:00
parent 50c63f1b1a
commit 26f0cdd760
306 changed files with 1088 additions and 56000 deletions
+253
View File
@@ -0,0 +1,253 @@
# 情感博物馆 - 最终部署指南
## 🎯 项目概述
情感博物馆是一个基于Spring Cloud Alibaba微服务架构的情感AI应用,包含10个微服务模块和Vue前端。
## 🏗️ 系统架构
### 后端微服务 (Spring Cloud Alibaba)
- **emotion-gateway** (19000) - API网关,统一入口
- **emotion-user** (19001) - 用户管理服务
- **emotion-ai** (19002) - AI聊天服务,集成Coze平台
- **emotion-record** (19003) - 记录管理服务
- **emotion-growth** (19004) - 成长跟踪服务
- **emotion-explore** (19005) - 探索服务
- **emotion-reward** (19006) - 奖励服务
- **emotion-websocket** (19007) - WebSocket实时通信
- **emotion-auth** (19008) - 认证授权服务
- **emotion-stats** (19009) - 统计分析服务
### 前端 (Vue + Ant Design)
- 基于Vue 3 + TypeScript + Ant Design
- 响应式设计,支持移动端
- WebSocket实时通信
- 集成AI聊天功能
### 中间件
- **MySQL 8.0** (3306) - 主数据库
- **Redis 7** (6379) - 缓存和会话存储
- **Nacos 2.2.0** (8848) - 服务注册发现和配置中心
## 🚀 快速部署
### 1. 一键部署(推荐)
```bash
# 完整部署前后端
./one-click-deploy.sh
# 仅部署后端
./one-click-deploy.sh backend
# 仅部署前端
./one-click-deploy.sh frontend
# 健康检查
./one-click-deploy.sh check
```
### 2. 中间件管理
```bash
# 重启中间件(MySQL, Redis, Nacos
./restart-middleware.sh
```
### 3. Nginx配置
```bash
# 配置Nginx反向代理
./setup-nginx.sh
```
## 📋 分步部署
### 步骤1: 准备环境
确保本地环境已安装:
- Java 17+
- Maven 3.6+
- Node.js 16+
- Docker (远程服务器)
### 步骤2: 启动中间件
```bash
./restart-middleware.sh
```
### 步骤3: 构建后端
```bash
cd backend
./build-all.sh
```
### 步骤4: 部署后端
```bash
cd backend
./deploy-remote.sh
```
### 步骤5: 部署前端
```bash
cd web-flowith
./deploy.sh
```
### 步骤6: 配置Nginx
```bash
./setup-nginx.sh
```
## 🌐 访问地址
### 生产环境
- **前端应用**: http://47.111.10.27/emotion-museum
- **API网关**: http://47.111.10.27/api/
- **WebSocket**: ws://47.111.10.27/ws/
- **健康检查**: http://47.111.10.27/health
### 管理后台
- **Nacos控制台**: http://47.111.10.27:8848/nacos
- 用户名: nacos
- 密码: Peanut2817*#
### 数据库连接
- **MySQL**: 47.111.10.27:3306
- 用户名: root
- 密码: EmotionMuseum2025*#
- 数据库: emotion_museum
- **Redis**: 47.111.10.27:6379
## 🔧 运维管理
### 查看服务状态
```bash
# 查看所有容器
ssh root@47.111.10.27 "docker ps"
# 查看特定服务日志
ssh root@47.111.10.27 "docker logs emotion-gateway --tail 50"
# 查看服务健康状态
curl http://47.111.10.27:19000/actuator/health
```
### 重启服务
```bash
# 重启单个服务
ssh root@47.111.10.27 "docker restart emotion-gateway"
# 重启所有微服务
ssh root@47.111.10.27 "docker restart \$(docker ps -q --filter name=emotion-)"
```
### 更新部署
```bash
# 更新后端服务
cd backend && ./deploy-remote.sh
# 更新前端
cd web-flowith && ./deploy.sh
# 完整更新
./one-click-deploy.sh
```
## 📊 监控和日志
### 应用日志
- 容器日志: `docker logs <service_name>`
- 应用日志: `/data/logs/emotion-museum/`
### Nginx日志
- 访问日志: `/var/log/nginx/emotion-museum.access.log`
- 错误日志: `/var/log/nginx/emotion-museum.error.log`
### 健康检查端点
- 网关: http://47.111.10.27:19000/actuator/health
- 用户服务: http://47.111.10.27:19001/actuator/health
- AI服务: http://47.111.10.27:19002/actuator/health
## 🛠️ 故障排查
### 常见问题
#### 1. 服务启动失败
```bash
# 查看容器日志
docker logs <service_name> --tail 50
# 检查端口占用
netstat -tlnp | grep <port>
# 重启服务
docker restart <service_name>
```
#### 2. 数据库连接失败
```bash
# 检查MySQL状态
docker exec emotion-mysql mysqladmin ping
# 检查数据库连接
mysql -h 47.111.10.27 -u root -p
```
#### 3. Nacos连接失败
```bash
# 检查Nacos状态
curl http://47.111.10.27:8848/nacos/v1/console/health
# 重启Nacos
docker restart emotion-nacos
```
#### 4. 前端访问404
```bash
# 检查Nginx配置
nginx -t
# 检查前端文件
ls -la /data/www/emotion-museum/
# 重载Nginx
systemctl reload nginx
```
## 📁 项目结构
```
emotion-museum/
├── 📁 backend/ # 后端微服务
├── 📁 web-flowith/ # 前端Vue项目
├── 📁 docs/ # 项目文档
├── 📁 configs/ # 配置文件
├── 🔧 one-click-deploy.sh # 一键部署脚本
├── 🔧 restart-middleware.sh # 中间件重启脚本
├── 🔧 setup-nginx.sh # Nginx配置脚本
└── 📄 DEPLOYMENT_FINAL.md # 部署指南
```
## 🔐 安全配置
### 密码管理
- MySQL root密码: EmotionMuseum2025*#
- Nacos密码: Peanut2817*#
- 所有密码已在配置文件中统一
### 网络安全
- 所有服务运行在Docker网络中
- Nginx反向代理保护内部服务
- 仅必要端口对外开放
## 📞 技术支持
如遇到问题,请:
1. 查看相关日志文件
2. 检查服务健康状态
3. 参考故障排查章节
4. 联系开发团队并提供完整日志
---
**版本**: v2.0
**更新时间**: 2025-07-21
**维护团队**: 情感博物馆开发团队