1、下载跟Linux版本相关的.rpm包

地址:https://packages.gitlab.com/gitlab/gitlab-ce

Gitlab-ce离线安装 - 图1

2、将下载的rpm包上传到机器

Gitlab-ce离线安装 - 图2

3、使用rpm安装

rpm -ivh ~~gitlab-ce-15.6.2-ce.0.el7.x86_64.rpm~~ 此处解压的包名需要换成下载的名称

Gitlab-ce离线安装 - 图3

  1. rpm -ivh gitlab-ce-16.3.5-ce.0.el7.x86_64.rpm
  2. warning: gitlab-ce-16.3.5-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
  3. Preparing... ################################# [100%]
  4. Updating / installing...
  5. 1:gitlab-ce-16.3.5-ce.0.el7 ################################# [100%]
  6. It looks like GitLab has not been configured yet; skipping the upgrade script.
  7. *. *.
  8. *** ***
  9. ***** *****
  10. .****** *******
  11. ******** ********
  12. ,,,,,,,,,***********,,,,,,,,,
  13. ,,,,,,,,,,,*********,,,,,,,,,,,
  14. .,,,,,,,,,,,*******,,,,,,,,,,,,
  15. ,,,,,,,,,*****,,,,,,,,,.
  16. ,,,,,,,****,,,,,,
  17. .,,,***,,,,
  18. ,*,.
  19. _______ __ __ __
  20. / ____(_) /_/ / ____ _/ /_
  21. / / __/ / __/ / / __ `/ __ \
  22. / /_/ / / /_/ /___/ /_/ / /_/ /
  23. \____/_/\__/_____/\__,_/_.___/
  24. Thank you for installing GitLab!
  25. GitLab was unable to detect a valid hostname for your instance.
  26. Please configure a URL for your GitLab instance by setting `external_url`
  27. configuration in /etc/gitlab/gitlab.rb file.
  28. Then, you can start your GitLab instance by running the following command:
  29. sudo gitlab-ctl reconfigure
  30. For a comprehensive list of configuration options please see the Omnibus GitLab readme
  31. https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
  32. Help us improve the installation experience, let us know how we did with a 1 minute survey:
  33. https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=16-3

根据启动成功后的提示语修改相应的配置。

4、安装完成后修改配置文件

(1)vim /etc/gitlab/gitlab.rb
(2)找到 external_url ‘http://gxitlab.example.com
(3)替换为你自己的IP和端口。 样例:

Gitlab-ce离线安装 - 图4

5、重置并启动

第一步刷新配置:gitlab-ctl reconfigure (需等待一会,3-5分钟)

第二步重新启动: gitlab-ctl restart (需等待一会,3-5分钟)

刷新配置:gitlab-ctl reconfigure时遇到报错

Gitlab-ce离线安装 - 图5

  1. [2023-10-08T10:21:32+08:00] INFO: file[/var/opt/gitlab/gitlab-kas/authentication_secret_file] sending restart action to runit_service[gitlab-kas] (delayed)
  2. Recipe: gitlab-kas::enable
  3. * runit_service[gitlab-kas] action restart
  4. ================================================================================
  5. Error executing action `restart` on resource 'runit_service[gitlab-kas]'
  6. ================================================================================
  7. Mixlib::ShellOut::ShellCommandFailed
  8. ------------------------------------
  9. Expected process to exit with [0], but received '1'
  10. ---- Begin output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----
  11. STDOUT: fail: /opt/gitlab/service/gitlab-kas: runsv not running
  12. STDERR:
  13. ---- End output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----
  14. Ran /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas returned 1
  15. Cookbook Trace: (most recent call first)
  16. ----------------------------------------
  17. /opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/helpers.rb:136:in `safe_sv_shellout!'
  18. /opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/helpers.rb:164:in `restart_service'
  19. /opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/provider_runit_service.rb:368:in `block in <class:RunitService>'
  20. Resource Declaration:
  21. ---------------------
  22. suppressed sensitive resource output
  23. Compiled Resource:
  24. ------------------
  25. suppressed sensitive resource output
  26. System Info:
  27. ------------
  28. chef_version=17.10.0
  29. platform=centos
  30. platform_version=7.6.1810
  31. ruby=ruby 3.0.6p216 (2023-03-30 revision 23a532679b) [x86_64-linux]
  32. program_name=/opt/gitlab/embedded/bin/cinc-client
  33. executable=/opt/gitlab/embedded/bin/cinc-client
  34. Running handlers:
  35. [2023-10-08T10:21:32+08:00] ERROR: Running exception handlers
  36. There was an error running gitlab-ctl reconfigure:
  37. runit_service[gitlab-kas] (gitlab-kas::enable line 148) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
  38. ---- Begin output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----
  39. STDOUT: fail: /opt/gitlab/service/gitlab-kas: runsv not running
  40. STDERR:
  41. ---- End output of /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas ----
  42. Ran /opt/gitlab/embedded/bin/sv restart /opt/gitlab/service/gitlab-kas returned 1
  43. Running handlers complete
  44. [2023-10-08T10:21:32+08:00] ERROR: Exception handlers complete
解决办法:
  1. chmod 0755 /var/opt/gitlab/postgresql
  2. systemctl restart gitlab-runsvdir
之后再重启Gitlab
  1. gitlab-ctl reconfigure
  2. gitlab-ctl restart

Gitlab-ce离线安装 - 图6

可以发现所有相关的服务都在正常运行。

6、访问

访问地址为第四步在配置文件中配置的IP和端口

需要关闭防火墙或者开放填写的端口。关闭防火墙命令:systemctl stop firewalld

:::warning

在启动Gitlab的时候访问是会提示502 Whoops, GitLab is taking too much time to respond.

Gitlab-ce离线安装 - 图7

开始以为是服务出了问题,实际这是一个正常的过程,此问题说明Gitlab正在启动,消耗内存中,还没有启动完成!这时不要去修改端口,启动等,等待一下即可。

:::

账号为:root

密码为:cat /etc/gitlab/initial_root_password 文件中的Password

:::color5 注意:初始化密码文件会在24小时后被清理,及时查看初始化密码。

:::

Gitlab-ce离线安装 - 图8

7、卸载步骤

  1. 停止Gitlab服务:
  1. sudo gitlab-ctl stop
  1. 卸载Gitlab:
  1. sudo rpm -e gitlab-ce
  1. 查看Gitlab进程:
  1. ps -ef | grep gitlab

Gitlab-ce离线安装 - 图9

杀掉第一个守护进程(就是带有好多………….的进程):
  1. kill -9 <进程ID>
  1. 再次查看Gitlab进程是否存在:
  1. ps -ef | grep gitlab
  1. 删除Gitlab文件:
  1. find / -name *gitlab* | xargs rm -rf