温馨提示×

CentOS GitLab如何重启

小樊
40
2026-07-20 03:58:57
栏目: 智能运维

CentOS 上重启 GitLab,取决于你的安装方式(Omnibus、Docker、源码),下面是最常见情况的做法。


一、Omnibus 安装方式(最常见 ✅)

如果你是通过官方 RPM 包 安装的 GitLab,使用 gitlab-ctl 管理。

1️⃣ 重启 GitLab(推荐)

sudo gitlab-ctl restart

这将重启所有 GitLab 组件(nginx、puma、sidekiq、postgresql 等)。


2️⃣ 只重启某个服务(可选)

sudo gitlab-ctl restart nginx
sudo gitlab-ctl restart puma
sudo gitlab-ctl restart sidekiq

3️⃣ 查看运行状态

sudo gitlab-ctl status

4️⃣ 停止 / 启动(而不是 restart)

sudo gitlab-ctl stop
sudo gitlab-ctl start

二、Docker 安装的 GitLab

1️⃣ 查看容器

docker ps

2️⃣ 重启容器

docker restart gitlab

假设容器名是 gitlab


三、通过 systemd 管理(部分环境)

sudo systemctl restart gitlab-runsvdir

查看状态:

sudo systemctl status gitlab-runsvdir

四、修改配置后重启(重要 ⚠️)

如果你修改了 /etc/gitlab/gitlab.rb

1️⃣ 重新生成配置

sudo gitlab-ctl reconfigure

2️⃣ 再重启

sudo gitlab-ctl restart

五、确认 GitLab 是否正常

curl -I http://localhost

或浏览器访问 GitLab 地址。


六、常见问题

❌ 重启后无法访问

检查:

sudo gitlab-ctl status
sudo ss -lntp

❌ 端口被占用

sudo netstat -tunlp | grep 80

如果你愿意,可以告诉我:

  • ✅ CentOS 版本(7 / 8 / Stream)
  • ✅ GitLab 安装方式(Omnibus / Docker / 源码)
  • ✅ 报错信息

我可以给你更精确的解决方案。

0