在 CentOS 上调试 GitLab,通常涵盖 服务状态、日志、配置文件、网络、权限、资源 等多个方面。下面给你一套比较系统的调试思路和常用命令(适用于 Omnibus 版 GitLab,最常见)。
sudo gitlab-ctl status
正常应看到:
run: nginx: ...
run: postgresql: ...
run: redis: ...
run: sidekiq: ...
run: unicorn / puma: ...
如果有 down,说明对应服务异常。
sudo gitlab-ctl start
单独重启某个服务:
sudo gitlab-ctl restart nginx
sudo gitlab-ctl restart sidekiq
sudo gitlab-ctl restart puma
/var/log/gitlab/
sudo tail -f /var/log/gitlab/gitlab-rails/production.log
sudo tail -f /var/log/gitlab/nginx/error.log
sudo tail -f /var/log/gitlab/nginx/access.log
sudo tail -f /var/log/gitlab/sidekiq/current
sudo tail -f /var/log/gitlab/redis/current
sudo tail -f /var/log/gitlab/postgresql/current
sudo gitlab-ctl reconfigure
sudo vi /etc/gitlab/gitlab.rb
sudo gitlab-ctl reconfigure
⚠️ 不执行 reconfigure,配置不会生效
ss -lntp
常见端口:
sudo firewall-cmd --list-all
开放端口示例:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo gitlab-rake gitlab:check
常用于:
ssh -T git@your-gitlab-domain
sudo tail -f /var/log/secure
top
htop
free -h
GitLab 资源建议:
df -h
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
sudo gitlab-rails console
user = User.find_by(username: 'root')
user.password = 'NewPassword123'
user.password_confirmation = 'NewPassword123'
user.save!
| 问题 | 排查点 |
|---|---|
| 502 Bad Gateway | nginx / puma / unicorn 未启动 |
| 无法访问页面 | 防火墙 / 端口 / SELinux |
| Git push 失败 | SSH / 权限 / 磁盘 |
| 页面很慢 | 内存不足 / sidekiq |
| 邮件发不出去 | SMTP 配置 |
你可以直接贴出:
gitlab-ctl statusgitlab-rake gitlab:env:info)我可以 精准定位问题,一步一步带你修 ✅