feat: 项目初始化及当前全部内容提交
This commit is contained in:
+256
@@ -0,0 +1,256 @@
|
||||
# 情绪博物馆项目部署指南
|
||||
|
||||
## 概述
|
||||
|
||||
本文档提供了情绪博物馆项目的完整部署指南,包括一键部署脚本的使用方法和手动部署步骤。
|
||||
|
||||
## 系统要求
|
||||
|
||||
### 本地开发环境
|
||||
- Java 17+
|
||||
- Maven 3.6+
|
||||
- Node.js 18+
|
||||
- SSH客户端
|
||||
|
||||
### 服务器环境
|
||||
- CentOS 7/8 或 RHEL 7/8
|
||||
- 最小 4GB RAM,推荐 8GB+
|
||||
- 最小 50GB 磁盘空间
|
||||
- Docker 支持
|
||||
|
||||
## 快速部署
|
||||
|
||||
### 1. 一键部署(推荐)
|
||||
|
||||
```bash
|
||||
# 克隆项目
|
||||
git clone <repository-url>
|
||||
cd EmotionMuseum
|
||||
|
||||
# 执行一键部署
|
||||
./deploy-final.sh all
|
||||
```
|
||||
|
||||
### 2. 分步部署
|
||||
|
||||
```bash
|
||||
# 1. 构建项目
|
||||
./deploy-final.sh build
|
||||
|
||||
# 2. 配置服务器环境
|
||||
./deploy-final.sh env
|
||||
|
||||
# 3. 配置数据库
|
||||
./deploy-final.sh mysql
|
||||
|
||||
# 4. 配置Redis
|
||||
./deploy-final.sh redis
|
||||
|
||||
# 5. 配置Nacos
|
||||
./deploy-final.sh nacos
|
||||
|
||||
# 6. 上传构建产物
|
||||
./deploy-final.sh upload
|
||||
|
||||
# 7. 导入数据库
|
||||
./deploy-final.sh import-db
|
||||
|
||||
# 8. 部署应用服务
|
||||
./deploy-final.sh deploy
|
||||
|
||||
# 9. 配置Nginx
|
||||
./deploy-final.sh nginx
|
||||
|
||||
# 10. 创建密码记录
|
||||
./deploy-final.sh passwords
|
||||
|
||||
# 11. 健康检查
|
||||
./deploy-final.sh health
|
||||
```
|
||||
|
||||
## 服务管理
|
||||
|
||||
### 启动/停止服务
|
||||
|
||||
```bash
|
||||
# 查看服务状态
|
||||
./deploy-final.sh status
|
||||
|
||||
# 启动服务
|
||||
./deploy-final.sh start
|
||||
|
||||
# 停止服务
|
||||
./deploy-final.sh stop
|
||||
|
||||
# 重启服务
|
||||
./deploy-final.sh restart
|
||||
```
|
||||
|
||||
### 查看日志
|
||||
|
||||
```bash
|
||||
# 查看网关服务日志
|
||||
./deploy-final.sh logs gateway
|
||||
|
||||
# 查看AI服务日志
|
||||
./deploy-final.sh logs ai
|
||||
|
||||
# 查看用户服务日志
|
||||
./deploy-final.sh logs user
|
||||
```
|
||||
|
||||
## 配置说明
|
||||
|
||||
### 环境变量配置
|
||||
|
||||
主要配置文件:
|
||||
- `.env.prod` - 生产环境配置
|
||||
- `web/.env.production` - 前端生产环境配置
|
||||
|
||||
### 服务器配置
|
||||
|
||||
默认配置:
|
||||
- 服务器IP: 47.111.10.27
|
||||
- MySQL端口: 3306
|
||||
- Redis端口: 6379
|
||||
- Nacos端口: 8848
|
||||
- 网关端口: 9000
|
||||
- AI服务端口: 9002
|
||||
- 用户服务端口: 9001
|
||||
|
||||
### 目录结构
|
||||
|
||||
```
|
||||
/data/
|
||||
├── builds/ # 应用JAR文件
|
||||
├── www/ # 前端文件
|
||||
│ └── emotion-museum/
|
||||
│ └── web/
|
||||
├── logs/ # 日志文件
|
||||
│ └── emotion-museum/
|
||||
│ ├── gateway/
|
||||
│ ├── ai/
|
||||
│ └── user/
|
||||
└── programs/ # 其他程序文件
|
||||
```
|
||||
|
||||
## 访问地址
|
||||
|
||||
部署完成后的访问地址:
|
||||
|
||||
- **前端应用**: http://47.111.10.27/emotion-museum/
|
||||
- **API网关**: http://47.111.10.27:9000
|
||||
- **Nacos控制台**: http://47.111.10.27:8848/nacos
|
||||
|
||||
## 故障排除
|
||||
|
||||
### 常见问题
|
||||
|
||||
1. **服务无法启动**
|
||||
```bash
|
||||
# 检查服务状态
|
||||
./deploy-final.sh status
|
||||
|
||||
# 查看日志
|
||||
./deploy-final.sh logs <service>
|
||||
```
|
||||
|
||||
2. **数据库连接失败**
|
||||
```bash
|
||||
# 检查MySQL容器状态
|
||||
ssh root@47.111.10.27 "docker ps | grep mysql"
|
||||
|
||||
# 检查数据库连接
|
||||
ssh root@47.111.10.27 "docker exec emotion-mysql-prod mysql -uemotion -pEmotionDB2024! -e 'SELECT 1;'"
|
||||
```
|
||||
|
||||
3. **前端页面无法访问**
|
||||
```bash
|
||||
# 检查Nginx状态
|
||||
ssh root@47.111.10.27 "systemctl status nginx"
|
||||
|
||||
# 检查前端文件
|
||||
ssh root@47.111.10.27 "ls -la /data/www/emotion-museum/web/"
|
||||
```
|
||||
|
||||
### 日志位置
|
||||
|
||||
- 应用日志: `/data/logs/emotion-museum/*/app.log`
|
||||
- Nginx日志: `/var/log/nginx/`
|
||||
- Docker日志: `docker logs <container-name>`
|
||||
|
||||
## 安全建议
|
||||
|
||||
1. **修改默认密码**
|
||||
- MySQL root密码
|
||||
- 应用数据库密码
|
||||
- 服务器SSH密钥
|
||||
|
||||
2. **配置防火墙**
|
||||
```bash
|
||||
# 只开放必要端口
|
||||
firewall-cmd --permanent --add-port=80/tcp
|
||||
firewall-cmd --permanent --add-port=8848/tcp
|
||||
firewall-cmd --reload
|
||||
```
|
||||
|
||||
3. **定期备份**
|
||||
```bash
|
||||
# 数据库备份
|
||||
docker exec emotion-mysql-prod mysqldump -uemotion -pEmotionDB2024! emotion_museum > backup.sql
|
||||
```
|
||||
|
||||
## 更新部署
|
||||
|
||||
### 应用更新
|
||||
|
||||
```bash
|
||||
# 1. 构建新版本
|
||||
./deploy-final.sh build
|
||||
|
||||
# 2. 停止服务
|
||||
./deploy-final.sh stop
|
||||
|
||||
# 3. 上传新文件
|
||||
./deploy-final.sh upload
|
||||
|
||||
# 4. 启动服务
|
||||
./deploy-final.sh start
|
||||
```
|
||||
|
||||
### 配置更新
|
||||
|
||||
```bash
|
||||
# 重新配置Nginx
|
||||
./deploy-final.sh nginx
|
||||
|
||||
# 重启服务
|
||||
./deploy-final.sh restart
|
||||
```
|
||||
|
||||
## 监控和维护
|
||||
|
||||
### 健康检查
|
||||
|
||||
```bash
|
||||
# 执行完整健康检查
|
||||
./deploy-final.sh health
|
||||
```
|
||||
|
||||
### 性能监控
|
||||
|
||||
建议使用以下工具进行监控:
|
||||
- Prometheus + Grafana
|
||||
- ELK Stack (日志分析)
|
||||
- Docker监控
|
||||
|
||||
## 联系支持
|
||||
|
||||
如遇到部署问题,请提供以下信息:
|
||||
1. 错误日志
|
||||
2. 系统环境信息
|
||||
3. 部署步骤和配置
|
||||
|
||||
---
|
||||
|
||||
**注意**: 请确保在生产环境中修改默认密码和配置,并定期进行安全更新。
|
||||
Reference in New Issue
Block a user