Files
xiaoxia-saas/infra/scripts/SERVER-CLEANUP.md
T

54 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
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.
# 服务器清理说明
## 当前问题
服务器存储性能达到上限,导致:
- Docker 构建中断
- SSH 命令超时
- 部署失败
## 清理方案
### 安全清理(推荐)
执行 `server-cleanup.sh`,会清理:
- Docker 未使用的镜像/容器/卷
- 旧的 systemd 日志(保留 7 天)
- APT 缓存
**不会删除**
- `/var/lib/xiaoxia-saas-staging`
- `/var/lib/xiaoxia-saas-production`
- `/var/lib/xiaoxia-ci`
- 当前运行的容器
### 执行步骤
```bash
# 1. SSH 登录服务器
ssh root@47.98.113.167
# 2. 下载并执行清理脚本
cd /tmp
wget https://你的服务器/server-cleanup.sh # 或手动上传
chmod +x server-cleanup.sh
./server-cleanup.sh
```
### 手动清理(如果脚本不够)
```bash
# 查看最大的目录
du -sh /* | sort -hr | head -20
# 清理特定旧版本目录(确认后再删)
# 例如:
# rm -rf /path/to/old-project
# 清理大日志
find /var/log -type f -size +100M -exec truncate -s 0 {} \;
```
## 清理后
存储空间释放后,再执行部署:
```bash
cd /var/lib/xiaoxia-saas-staging/repo/infra/docker
./deploy-staging.sh
```