修复 Linux 上的 GitLab 需要根据具体故障现象来处理。下面我按「常见故障 → 排查 → 修复方法」给你一个实用速查手册,你可以对照使用;如果你愿意,也可以把报错信息或日志贴出来,我可以更精准地帮你定位。
sudo gitlab-ctl status
常见状态:
run:正常down:服务未启动或异常start/stop 卡住:可能端口/权限/配置问题sudo gitlab-ctl status
free -h
df -h
sudo gitlab-ctl restart
如果内存 < 4G:
# 临时释放内存
sync && echo 3 > /proc/sys/vm/drop_caches
⚠️ 官方建议:
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
如果有报错:
sudo gitlab-ctl tail
sudo gitlab-ctl pg-upgrade
sudo gitlab-ctl status postgresql
sudo gitlab-ctl restart postgresql
sudo gitlab-ctl downgrade
sudo gitlab-ctl reconfigure
sudo gitlab-rails console
user = User.where(id: 1).first
user.password = 'NewPassword123'
user.password_confirmation = 'NewPassword123'
user.save!
exit
df -h
清理:
sudo gitlab-ctl cleanup
或手动清理:
/var/opt/gitlab/backups
/var/log/gitlab
⚠️ 谨慎操作
sudo gitlab-ctl uninstall
sudo gitlab-ctl cleanse
sudo apt reinstall gitlab-ee
sudo gitlab-ctl reconfigure
# 所有日志
sudo gitlab-ctl tail
# Nginx
sudo gitlab-ctl tail nginx
# Puma
sudo gitlab-ctl tail puma
# PostgreSQL
sudo gitlab-ctl tail postgresql
| 检查项 | 命令 |
|---|---|
| 服务状态 | gitlab-ctl status |
| 内存 | free -h |
| 磁盘 | df -h |
| 配置 | gitlab-ctl reconfigure |
| 日志 | gitlab-ctl tail |
你可以直接告诉我:
gitlab-rake gitlab:env:info
cat /etc/os-release
我可以一步一步带你修好 ✅