feat: 所有页面添加ICP备案号 浙ICP备2026052792号
Some checks failed
Deploy Backend / deploy (push) Has been cancelled

This commit is contained in:
2026-07-03 21:59:38 +08:00
parent 178008496e
commit 38ee5ccbc6
8 changed files with 292 additions and 5 deletions

View File

@@ -0,0 +1,99 @@
# 服务器迁移计划
## 新旧对比
| 项目 | 旧服务器 (1panel-server) | 新服务器 (47.109.203.92) |
|------|------------------------|-------------------------|
| 系统 | - | Debian 13.5 |
| CPU | - | 2 核 |
| 内存 | - | 1.6 GiB |
| 磁盘 | - | 40G (可用 36G) |
| 区域 | - | 成都 |
| 角色 | 当前生产+开发 | 目标生产+开发 |
## 阶段 1 — 基础设施安装
### 1.1 安装 Docker
```bash
apt update && apt install -y docker.io docker-compose-v2
```
### 1.2 启动 PostgreSQL
```bash
docker run -d --name postgres \
--network host \
-e POSTGRES_PASSWORD=password \
-v /var/lib/postgresql/data:/var/lib/postgresql/data \
postgres:17.6-alpine
```
创建数据库milkydata、milkydata_dev
### 1.3 从旧服务器迁移数据库
```bash
# 旧服务器导出
pg_dump -Fc milkydata > /tmp/milkydata.dump
# 新服务器导入
pg_restore -d milkydata /tmp/milkydata.dump
```
### 1.4 启动 OpenResty
```bash
docker run -d --name openresty \
--network host \
-v /www/sites:/www/sites \
1panel/openresty:1.21.4.3-3-3-focal
```
### 1.5 复制 SSL 证书 + nginx 配置
```bash
rsync -av root@1panel-server:/www/sites/ /www/sites/
```
## 阶段 2 — 后端部署
### 2.1 创建 systemd 服务blue/green/dev
```bash
# 创建目录
mkdir -p /root/rust/rust_backend_blue
mkdir -p /root/rust/rust_backend_green
mkdir -p /root/rust/rust_backend_dev
# 注册 systemd service从 deploy/ 目录上传)
```
### 2.2 部署 Rust 后端
```bash
# 先部署到 dev 验证
cd ASD-backend/rust-backend
deploy.sh development --remote-host 47.109.203.92
# 再部署 blue/green
deploy.sh production --remote-host 47.109.203.92
```
### 2.3 更新 deploy.sh
将默认 REMOTE_HOST 改为新服务器 IP
## 阶段 3 — 切换
### 3.1 内部验证
```bash
curl http://127.0.0.1:8080/health # dev
curl -k https://127.0.0.1:4433/health # blue
curl -k https://127.0.0.1:4434/health # green
```
### 3.2 更新 DNS
将域名指向新服务器 IP
### 3.3 验证公网访问
```bash
curl https://dev.xmclassmate.top/health
curl https://xmclassmate.top/health
```
## 阶段 4 — 清理(可选)
- 迁移 GlitchTip (Sentry)
- 旧服务器保留 1 周作为回退
- 确认无问题后关闭旧服务器