目 录CONTENT

文章目录

虚拟机安装gitlab16.0.1

Administrator
2025-07-29 / 0 评论 / 3 点赞 / 18 阅读 / 0 字
温馨提示:
部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

虚拟机安装gitlab16.0.1

Gitlab结构

Gitlab启动后会根据配置定义创建用户和目录,默认依赖的组件在/var/opt/gitlab目录下。
Gitlab主要组件有:
Nginxpostgresqlredisunicornsidekiq。这用gitlab-ctl status命令也可查看到。
gitlab架构图

  • Nginx:web访问入口
  • postgresql:数据库,或mysql
  • redis:缓存,分发任务
  • sidekiq:后台任务,主要负责电子邮件发送,任务来自redis
  • unicorn:gitlab主进程
  • gitlab-workhorse:反向代理服务器,可处理与主进程unicorn无关的请求
  • gitaly:后台服务,处理Gitlab发出的所有git调用

安装基础环境包

yum -y install curl policycoreutils openssh-server openssh-clients

启动sshd

systemctl enable sshd
systemctl start sshd

添加防火墙规则

firewall-cmd --permanent --add-service=http
systemctl reload firewalld
or
yum install firewalld
systemctl unmadk firewalld

下载并安装软件包

curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
yum install gitlab-ce

如遇到time out,请更换成国内源https://mirrors.tuna.tsinghua.edu.cn/help/gitlab-ce/

vim /etc/yum.repos.d/gitlab-ce.repo

[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

yum makecache
yum --showduplicates list gitlab-ce
yum install gitlab-ce-16.0.1-ce.0.el7.x86_64 -y

或者可以直接下载相应版本gitlab的rpm包,地址:https://packages.gitlab.com/gitlab/gitlab-ce/

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package gitlab-ce.x86_64 0:16.0.1-ce.0.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================
 Package                              Arch                              Version                                     Repository                            Size
===============================================================================================================================================================
Installing:
 gitlab-ce                            x86_64                            16.0.1-ce.0.el7                             gitlab-ce                            1.2 G

Transaction Summary
===============================================================================================================================================================
Install  1 Package

Total download size: 1.2 G
Installed size: 1.2 G
Downloading packages:
No Presto metadata available for gitlab-ce
gitlab-ce-16.0.1-ce.0.el7.x86_64.rpm                                                                                                    | 1.2 GB  00:03:20     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : gitlab-ce-16.0.1-ce.0.el7.x86_64                                                                                                            1/1 
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=16-0

  Verifying  : gitlab-ce-16.0.1-ce.0.el7.x86_64                                                                                                            1/1 

Installed:
  gitlab-ce.x86_64 0:16.0.1-ce.0.el7                                                                                                                           

Complete!

安装完毕后

  • 代码仓库保存位置:/var/opt/gitlab/git-data/repositories/
  • gitlab主要配置文件:/etc/gitlab/gitlab.rb
    • 编辑/etc/gitlab/gitlab.rb,修改gitlab运行外部URL默认的访问地址
      # 未修gitlab.rb配置文件中nginx配置时这个配置默认配置gitlab自带的nginx端口
      #external_url 'http://192.168.80.131:8082'
      #nginx['listen_port'] = 8082
      #时区
      #gitlab_rails['time_zone'] = 'Asia/Shanghai'
      external_url 'http://192.168.105.1/'
      gitlab_rails['manage_backup_path'] = true
      gitlab_rails['backup_path'] = "/data/gitlab/backups"
      git_data_dirs({
          "default" => {
          "path" => "/data/gitlab/git-data"
        }
      })
      
      
  • 修改完毕后,执行gitlab-ctl reconfigure
  • 查看初始密码
    [root@k8s-node2 yum.repos.d]# sudo cat /etc/gitlab/initial_root_password
      # WARNING: This value is valid only in the following conditions
      #          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
      #          2. Password hasn't been changed manually, either via UI or via command line.
      #
      #          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.
      
      Password: fHhHXY8ba6zc3KE9XW1skq0dTiH8b/C3NasH7+vLpOU=
      
      # NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
    
  • 访问gitlab首页,默认账号密码为root/上面显示的初始密码
    index

GitLab常用命令

  • gitlab-ctl status 查看gitlab组件状态
  • gitlab-ctl start 启动全部服务
  • gitlab-ctl restart 重启全部服务
  • gitlab-ctl stop 停止全部服务
  • gitlab-ctl reconfigure 使配置文件生效(一般修改完主配置文件/etc/gitlab/gitlab.rb,需要执行此命令)
  • gitlab-ctl show-config 验证配置文件
  • gitlab-ctl uninstall 删除gitlab(保留数据)
  • gitlab-ctl cleanse 删除所有数据,从新开始
  • gitlab-ctl tail 查看服务的日志
3
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区