简单来说,GitLab 是一个基于 Git 的、一体化的 DevOps 平台。
它最初是一个类似于 GitHub 的代码托管和协作平台,但现在已经发展成一个功能极其丰富的完整工具链,覆盖了从项目规划、源代码管理到 CI/CD、监控的整个软件开发生命周期。
核心定位: 在一个统一的平台上完成所有 DevOps 流程,无需集成大量零散的工具。
总结
GitLab 是一个极其强大的、一体化的 DevOps 生命周期管理平台。它的核心优势在于将所有必要工具(从代码管理到 CI/CD、监控)整合在一个应用中,提供了无缝的协作体验,降低了维护多套系统的复杂性,并特别适合对代码安全性和私有化部署有要求的企业。
国内镜像:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/
1.下载安装包 [root@200-gitlab ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-16.9.11-ce.0.el7.x86_64.rpm 2.安装 [root@200-gitlab ~]# rpm -ivh gitlab-ce-16.9.8-ce.0.el7.x86_64.rpm 警告:gitlab-ce-16.9.8-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY 错误:依赖检测失败: policycoreutils-python 被 gitlab-ce-16.9.8-ce.0.el7.x86_64 需要 ##提示需要依赖,安装依赖 [root@200-gitlab ~]# yum -y install policycoreutils-python ##继续安装 [root@200-gitlab ~]# rpm -ivh gitlab-ce-16.9.8-ce.0.el7.x86_64.rpm 警告:gitlab-ce-16.9.11-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:gitlab-ce-16.9.11-ce.0.el7 ################################# [100%] It looks like GitLab has not been configured yet; skipping the upgrade script. 3.启动前配置访问域名 [root@200-gitlab ~]# vim /etc/gitlab/gitlab.rb ##只改这一行 external_url 'http://10.0.0.200' ##配置完后执行命令 [root@200-gitlab ~]# gitlab-ctl reconfigure ... Notes: Default admin account has been configured with following details: Username: root Password: You didn't opt-in to print initial root password to STDOUT. Password stored to /etc/gitlab/initial_root_password. This file will be cleaned up in first reconfigure run after 24 hours. ##完成以后会提示用户名和密码存放目录
| 组件 | 核心职责 | 关键技术 |
|---|---|---|
Nginx |
网关、路由、静态文件服务 |
HTTP 服务器、反向代理 |
GitLab Workhorse |
处理大流量 I/O 操作 |
Go |
Puma |
运行业务逻辑(Rails 应用) |
Ruby on Rails |
PostgreSQL |
存储结构化数据(用户、项目等) |
关系型数据库 |
Redis |
缓存、会话、消息队列 |
内存数据库 |
Sidekiq |
执行后台任务(邮件、CI) |
Ruby(后台进程) |
Gitaly |
统一管理所有 Git 仓库操作 |
RPC、Git |
GitLab Shell |
处理 SSH 协议的 Git 操作 |
Shell、SSH |
| 命令 | 说明 | 使用场景 |
|---|---|---|
sudo gitlab-ctl status |
查看所有组件的运行状态。这是你首先应该运行的命令。 |
快速检查 GitLab 是否健康。 |
sudo gitlab-ctl start |
启动所有 GitLab 组件。 |
开机后或需要启动整个 GitLab。 |
sudo gitlab-ctl stop |
停止所有 GitLab 组件。 |
计划维护或关机前。 |
sudo gitlab-ctl restart |
重启所有 GitLab 组件。最常用的重启命令。 |
在修改了大部分配置后,使更改生效。 |
sudo gitlab-ctl restart <service-name> |
重启单个组件,而不影响其他服务。 |
只修改了某个组件(如 Nginx、Puma)的配置时。 |
示例:
# 检查状态 sudo gitlab-ctl status # 只重启 Puma 应用服务器(比如更新了某个程序逻辑) sudo gitlab-ctl restart puma # 只重启 Nginx(比如修改了 SSL 证书) sudo gitlab-ctl restart nginx
| 命令 | 说明 | 使用场景 |
|---|---|---|
sudo gitlab-ctl reconfigure |
最重要的命令之一。根据配置文件重新配置整个 GitLab 系统。 |
每次修改了主配置文件 /etc/gitlab/gitlab.rb 后必须运行。 |
sudo gitlab-ctl show-config |
显示当前生效的配置。 |
验证配置是否按预期生效。 |
示例:
# 1. 编辑配置文件 sudo vi /etc/gitlab/gitlab.rb # 2. 修改配置,例如修改外部URL external_url 'https://gitlab.example.com' # 3. 重新配置使更改生效 sudo gitlab-ctl reconfigure
| 命令 | 说明 | 使用场景 |
|---|---|---|
sudo gitlab-ctl tail |
实时跟踪所有组件的日志。 |
快速查看整体运行情况。 |
sudo gitlab-ctl tail <service-name> |
实时跟踪特定组件的日志。按 Ctrl+C 退出。 |
调试特定组件的问题。 |
示例:
# 跟踪所有日志 sudo gitlab-ctl tail # 只跟踪 Puma 和 Sidekiq 的日志(用于调试Web操作和后台任务) sudo gitlab-ctl tail puma sidekiq # 将日志输出到文件(用于详细分析) sudo gitlab-ctl tail > /tmp/gitlab-logs.txt
| 命令 | 说明 | 使用场景 |
|---|---|---|
sudo gitlab-backup create |
创建 GitLab 的完整备份。 |
定期备份,防止数据丢失。 |
sudo gitlab-backup restore BACKUP=备份文件名 |
从备份文件中恢复 GitLab。 |
灾难恢复。 |
示例:
# 创建备份(备份文件默认在 /var/opt/gitlab/backups/) sudo gitlab-backup create # 创建备份,并指定路径 sudo gitlab-backup create BACKUP=/path/to/backup # 从备份恢复(需要先停止相关服务) sudo gitlab-ctl stop puma sudo gitlab-ctl stop sidekiq sudo gitlab-backup restore BACKUP=1590683529_2020_05_28_13.0.0 sudo gitlab-ctl reconfigure sudo gitlab-ctl restart
| 备注 | 修改日期 | 修改人 |
| 修改标题 | 2025-11-23 00:24:37[当前版本] | 文艺范儿 |
| 内容更新 | 2025-11-17 21:30:37 | 文艺范儿 |
| 创建版本 | 2025-11-17 21:26:49 | 文艺范儿 |
| 附件类型 |
|
|
|
|
||