温馨提示×

CentOS如何重启GitLab

小樊
38
2026-07-08 09:37:08
栏目: 智能运维

CentOS 上重启 GitLab,最常用、最推荐的方式是使用 GitLab 自带的 gitlab-ctl 管理命令。


一、重启 GitLab(最常用 ✅)

sudo gitlab-ctl restart

该命令会依次重启 GitLab 的所有组件(如 nginx、puma、sidekiq、postgresql 等)。


二、仅重启某个组件(可选)

如果你只想重启某一个服务:

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

查看所有组件状态:

sudo gitlab-ctl status

三、停止 / 启动 GitLab

sudo gitlab-ctl stop
sudo gitlab-ctl start

restart = stop + start


四、重新加载配置(修改 gitlab.rb 后必做)

如果你修改了 /etc/gitlab/gitlab.rb,需要先执行:

sudo gitlab-ctl reconfigure

然后再重启:

sudo gitlab-ctl restart

五、查看 GitLab 日志(排错常用)

sudo gitlab-ctl tail

或查看指定服务日志:

sudo gitlab-ctl tail nginx
sudo gitlab-ctl tail puma

六、使用 systemctl(不推荐但可用)

如果 GitLab 是以系统服务方式安装的:

sudo systemctl restart gitlab-runsvdir

⚠️ 注意
官方推荐使用 gitlab-ctl,而不是 systemctl 直接操作各组件。


七、验证是否重启成功

sudo gitlab-ctl status

浏览器访问 GitLab 页面确认是否正常。


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

  • CentOS 版本(7 / 8 / Stream)
  • GitLab 安装方式(Omnibus / Docker / 源码)

我可以给你更精确的操作方案。

0