centos7安装gitlab

2022-02-21  本文已影响0人  只是甲

一. centos7安装gitlab

1.1 下载rpm包

下载的rpm包有900M+,需要等待一下

命令:

mkdir -p /usr/local/tools
cd /usr/local/tools
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ol/7/gitlab-ce-14.6.1-ce.0.el7.x86_64.rpm/download.rpm

测试记录:

[root@hp5 tools]# wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ol/7/gitlab-ce-14.6.1-ce.0.el7.x86_64.rpm/download.rpm
--2022-01-07 16:53:04--  https://packages.gitlab.com/gitlab/gitlab-ce/packages/ol/7/gitlab-ce-14.6.1-ce.0.el7.x86_64.rpm/download.rpm
正在解析主机 packages.gitlab.com (packages.gitlab.com)... 104.18.27.123, 104.18.26.123, 2606:4700::6812:1a7b, ...
正在连接 packages.gitlab.com (packages.gitlab.com)|104.18.27.123|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://d20rj4el6vkp4c.cloudfront.net/7/8/ol/7/package_files/78154.rpm?t=1641545885_21ce301ac6d1dd17f37171664c1e94083ad5339e [跟随至新的 URL]
--2022-01-07 16:53:05--  https://d20rj4el6vkp4c.cloudfront.net/7/8/ol/7/package_files/78154.rpm?t=1641545885_21ce301ac6d1dd17f37171664c1e94083ad5339e
正在解析主机 d20rj4el6vkp4c.cloudfront.net (d20rj4el6vkp4c.cloudfront.net)... 99.84.194.84, 99.84.194.196, 99.84.194.192, ...
正在连接 d20rj4el6vkp4c.cloudfront.net (d20rj4el6vkp4c.cloudfront.net)|99.84.194.84|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:973318826 (928M) [application/x-rpm]
正在保存至: “gitlab-ce-14.6.1-ce.0.el7.x86_64.rpm”

100%[=============================================================================================================================================================>] 973,318,826 7.44MB/s 用时 1m 45s 

2022-01-07 16:54:51 (8.86 MB/s) - 已保存 “gitlab-ce-14.6.1-ce.0.el7.x86_64.rpm” [973318826/973318826])

[root@hp5 tools]# 

1.2 安装

命令:

cd /usr/local/tools
rpm -ivh gitlab-ce-14.6.1-ce.0.el7.x86_64.rpm
yum install -y curl policycoreutils-python openssh-server cronie
yum -y install lokkit
lokkit -s http -s ssh
yum install postfix -y
service postfix start
chkconfig postfix on
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash

测试记录;

[root@hp5 tools]# rpm -ivh gitlab-ce-14.6.1-ce.0.el7.x86_64.rpm
警告:gitlab-ce-14.6.1-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:gitlab-ce-14.6.1-ce.0.el7        ################################# [100%]
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=14-6

[root@hp5 tools]# 
[root@hp5 tools]# lokkit -s http -s ssh
[root@hp5 tools]# service postfix start
Redirecting to /bin/systemctl start postfix.service
[root@hp5 tools]# chkconfig postfix on
注意:正在将请求转发到“systemctl enable postfix.service”。
[root@hp5 tools]# 
[root@hp5 tools]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6928  100  6928    0     0   7727      0 --:--:-- --:--:-- --:--:--  7732
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
已加载插件:fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile
gitlab_gitlab-ce-source/signature                                                                                                                                               |  862 B  00:00:00     
从 https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey 检索密钥
导入 GPG key 0x51312F3F:
 用户ID     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 指纹       : f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
 来自       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
从 https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg 检索密钥
gitlab_gitlab-ce-source/signature                                                                                                                                               |  951 B  00:00:01 !!! 
gitlab_gitlab-ce-source/primary                                                                                                                                                 |  175 B  00:00:01     
软件包 pygpgme-0.3-9.el7.x86_64 已安装并且是最新版本
无须任何处理
Installing yum-utils...
已加载插件:fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
无须任何处理
Generating yum cache for gitlab_gitlab-ce...
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
导入 GPG key 0x51312F3F:
 用户ID     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 指纹       : f640 3f65 44a3 8863 daa0 b6e0 3f01 618a 5131 2f3f
 来自       : https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
Generating yum cache for gitlab_gitlab-ce-source...
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration

The repository is setup! You can now install packages.
[root@hp5 tools]# EXTERNAL_URL="http://gitlab.example.com" yum -y install gitlab-ce
已加载插件:fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile
软件包 gitlab-ce-14.6.1-ce.0.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@hp5 tools]# 

二. gitlab服务操作

2.1 初始化配置gitlab

命令:

gitlab-ctl reconfigure

这个过程耗时较久,然后输出日志较多


image.png

2.2 启动和停止gitlab

命令:

gitlab-ctl start
gitlab-ctl stop

测试记录:

[root@hp5 tools]# gitlab-ctl start
ok: run: alertmanager: (pid 13556) 117s
ok: run: gitaly: (pid 13600) 116s
ok: run: gitlab-exporter: (pid 13528) 119s
ok: run: gitlab-workhorse: (pid 13501) 121s
ok: run: grafana: (pid 13587) 116s
ok: run: logrotate: (pid 12012) 333s
ok: run: nginx: (pid 12690) 236s
ok: run: node-exporter: (pid 13516) 120s
ok: run: postgres-exporter: (pid 13574) 117s
ok: run: postgresql: (pid 12278) 315s
ok: run: prometheus: (pid 13536) 119s
ok: run: puma: (pid 12532) 254s
ok: run: redis: (pid 12058) 327s
ok: run: redis-exporter: (pid 13530) 119s
ok: run: sidekiq: (pid 12564) 248s
[root@hp5 tools]# 

三. 浏览器访问

访问Linux 服务器IP 地址即可,如果想访问EXTERNAL_URL 指定的域名还需要配置
域名服务器或本地hosts 文件。

http://10.31.1.119/

初次登录时需要为gitlab 的root 用户设置密码。
命令:

cd /opt/gitlab/bin
gitlab-rails console -e production
user = User.where(username:"root").first
user.password = 12345678
user.password_confirmation = 12345678
user.save!
quit

测试记录:


image.png

最终登陆成功的页面:


image.png

参考:

  1. https://about.gitlab.com/install/#centos-7
上一篇下一篇

猜你喜欢

热点阅读