GitLab安装和使用指南

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
简介: GitLab安装和使用指南

登录账户,输入密码

Last login: Thu Dec  6 08:59:16 on console
w1:~ jiaguoshang$ ssh root@192.168.1.156
root@192.168.1.156's password:
Last login: Wed Dec  5 18:02:02 2018 from gateway
ABRT 已检测到 '1' 个问题。预了解详细信息请执行:abrt-cli list --since 1544004122
[root@localhost ~]#

1、配置yum源

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

复制以下内容:

[gitlab-ce]

name=Gitlab CE Repository

baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

gpgcheck=0

enabled=1

需要点击i键进入文本编辑状态,点击 esc键退出编辑状态,输入:wq回车退出编辑并保存,输入:w!回车强制退出编辑并放弃保存。

2、更新本地yum缓存

sudo yum makecache

[root@localhost[root@localhost jgs]# vim /etc/yum.repos.d/gitlab-ce.repo
[root@localhost jgs]# sudo yum makecache
CentOS-8 - AppStream                                                                           7.3 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                                                                6.0 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                                                                              904  B/s | 1.5 kB     00:01
Gitlab CE Repository                                                                           1.0 MB/s |  13 MB     00:12
元数据缓存已建立。

注意:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/这个地址是变化的,这个地址被废弃。最好打开https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/,查看最新的地址。

我需要安装的是https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm。

特别注意:目录el7代表是centOS7,目录el8代表的是centOS8,千万别下错版本了。不然报下面的错误:

[root@localhost ~]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:07:44 前,执行于 2020年05月11日 星期一 01时07分33秒。
错误:
 问题: conflicting requests
  - nothing provides policycoreutils-python needed by gitlab-ce-12.3.5-ce.0.el7.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)

当然你也可以通过命令直接下载到当前目录并安装:

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
rpm -i gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm

[root@localhost ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
--2020-05-11 01:31:44--  https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:696213194 (664M) [application/x-redhat-package-manager]
正在保存至: “gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm”

gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm     66%[===================================================>                           ] 441.78M   184KB/s  用时 4m 3s

[gitlab-ce]
2020-05-11 01:35:52 (1.82 MB/s) - 在 463240865/696213194 字节处发生读取错误 (Error decoding the received TLS packet.)。重试中。

--2020-05-11 01:35:53--  (尝试次数: 2)  https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 206 Partial Content
长度:696213194 (664M),剩余 232972329 (222M) [application/x-redhat-package-manager]
正在保存至: “gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm”

gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm    100%[++++++++++++++++++++++++++++++++++++++++++++++++++++==========================>] 663.96M  2.95MB/s  用时 89s

2020-05-11 01:37:23 (2.49 MB/s) - 已保存 “gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm” [696213194/696213194])

下载的包和操作系统不匹配,用命令本地安装的错误:

[root@localhost ~]# rpm -i gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm
警告:gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
错误:依赖检测失败:
  policycoreutils-python 被 gitlab-ce-12.3.5-ce.0.el7.x86_64 需要

就是你执行yum install policycoreutils-python*成功,再执行安装仍旧报那个错误。

[root@localhost gitlab]# yum install -y curl policycoreutils-python openssh-server postfix
上次元数据过期检查:0:30:37 前,执行于 2020年05月10日 星期日 23时07分36秒。
软件包 curl-7.61.1-11.el8.x86_64 已安装。
未找到匹配的参数: policycoreutils-python
软件包 openssh-server-8.0p1-3.el8.x86_64 已安装。
错误:没有任何匹配: policycoreutils-python
[root@localhost gitlab]# sudo yum makecache
CentOS-8 - AppStream                                                                           7.7 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                                                                7.5 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                                                                              3.1 kB/s | 1.5 kB     00:00
Gitlab CE Repository                                                                           4.1 kB/s | 2.9 kB     00:00
Gitlab CE Repository                                                                           5.4 MB/s |  13 MB     00:02
元数据缓存已建立。
[root@localhost gitlab]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:00:24 前,执行于 2020年05月10日 星期日 23时41分32秒。
未找到匹配的参数: gitlab-ce-12.3.5
错误:没有任何匹配: gitlab-ce-12.3.5
[root@localhost gitlab]# vim /etc/yum.repos.d/gitlab-ce.repo
[root@localhost gitlab]# sudo yum makecache
[gitlab-ce]
CentOS-8 - AppStream                                                                           9.0 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                                                                6.4 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                                                                              3.4 kB/s | 1.5 kB     00:00
Gitlab CE Repository                                                                           776 kB/s |  39 MB     00:51
为 repo 'gitlab-ce' 下载元数据失败
错误:为 repo 'gitlab-ce' 下载元数据失败
[root@localhost gitlab]# sudo yum makecache
CentOS-8 - AppStream                                                                           9.3 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                                                                704  B/s | 3.9 kB     00:05
CentOS-8 - Extras                                                                              2.8 kB/s | 1.5 kB     00:00
Gitlab CE Repository                                                                           5.5 MB/s | 376 MB     01:08
元数据缓存已建立。
[root@localhost gitlab]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:02:15 前,执行于 2020年05月10日 星期日 23时46分39秒。
错误:
[gitlab-ce]
 问题: conflicting requests
  - nothing provides policycoreutils-python needed by gitlab-ce-12.3.5-ce.0.el7.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)
[root@localhost gitlab]# sudo yum install gitlab-ce-12.3.5 --skip-broken
上次元数据过期检查:0:03:51 前,执行于 2020年05月10日 星期日 23时46分39秒。
依赖关系解决。
无需任何处理。
完毕!
[root@localhost gitlab]# vim /etc/yum.repos.d/gitlab-ce.repo
[root@localhost gitlab]# sudo yum makecache
CentOS-8 - AppStream                                                                           7.9 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                                                                7.1 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                                                                              3.2 kB/s | 1.5 kB     00:00
Gitlab CE Repository                                                                           6.5 kB/s | 2.9 kB     00:00
元数据缓存已建立。
[root@localhost gitlab]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:00:11 前,执行于 2020年05月10日 星期日 23时52分15秒。
未找到匹配的参数: gitlab-ce-12.3.5
错误:没有任何匹配: gitlab-ce-12.3.5
[root@localhost gitlab]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:01:10 前,执行于 2020年05月10日 星期日 23时52分15秒。
未找到匹配的参数: gitlab-ce-12.3.5
错误:没有任何匹配: gitlab-ce-12.3.5
[root@localhost gitlab]# vim /etc/yum.repos.d/gitlab-ce.repo
[root@localhost gitlab]# sudo yum makecache
CentOS-8 - AppStream                                                                           3.5 kB/s | 4.3 kB     00:01
CentOS-8 - Base                                                                                6.0 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                                                                              1.5 kB/s | 1.5 kB     00:01
Gitlab CE Repository                                                                           870  B/s | 2.9 kB     00:03
元数据缓存已建立。
[root@localhost gitlab]# vim VERSION
[root@localhost gitlab]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:01:44 前,执行于 2020年05月10日 星期日 23时55分10秒。
错误:
 问题: conflicting requests
  - nothing provides policycoreutils-python needed by gitlab-ce-12.3.5-ce.0.el7.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)
[root@localhost gitlab]# sudo yum install gitlab-ce-12.3.5-ce.0.el7.x86_64
上次元数据过期检查:0:02:11 前,执行于 2020年05月10日 星期日 23时55分10秒。
错误:
 问题: conflicting requests
  - nothing provides policycoreutils-python needed by gitlab-ce-12.3.5-ce.0.el7.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)
[root@localhost gitlab]# yum install policycoreutils-python
上次元数据过期检查:0:03:50 前,执行于 2020年05月10日 星期日 23时55分10秒。
未找到匹配的参数: policycoreutils-python
错误:没有任何匹配: policycoreutils-python
[root@localhost gitlab]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64
--2020-05-10 23:59:53--  https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.3.5-ce.0.el7.x86_64
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 404 Not Found
2020-05-10 23:59:53 错误 404:Not Found。

[root@localhost gitlab]# ping https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
ping: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7: 未知的名称或服务
[root@localhost gitlab]# vim /etc/yum.repos.d/gitlab-ce.repo
[root@localhost gitlab]# sudo yum makecache
CentOS-8 - AppStream                                                                           7.6 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                                                                7.0 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                                                                              2.9 kB/s | 1.5 kB     00:00
Gitlab CE Repository                                                                           6.3 kB/s | 2.9 kB     00:00
元数据缓存已建立。
[root@localhost gitlab]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:00:15 前,执行于 2020年05月11日 星期一 01时07分33秒。
错误:
 问题: conflicting requests
  - nothing provides policycoreutils-python needed by gitlab-ce-12.3.5-ce.0.el7.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)
[root@localhost gitlab]# yum install
usage: yum install [-c [config file]] [-q] [-v] [--version]
                   [--installroot [path]] [--nodocs] [--noplugins]
                   [--enableplugin [plugin]] [--disableplugin [plugin]]
                   [--releasever RELEASEVER] [--setopt SETOPTS]
                   [--skip-broken] [-h] [--allowerasing] [-b | --nobest] [-C]
                   [-R [minutes]] [-d [debug level]] [--debugsolver]
                   [--showduplicates] [-e ERRORLEVEL] [--obsoletes]
                   [--rpmverbosity [debug level name]] [-y] [--assumeno]
                   [--enablerepo [repo]] [--disablerepo [repo] | --repo
                   [repo]] [--enable | --disable] [-x [package]]
                   [--disableexcludes [repo]] [--repofrompath [repo,path]]
                   [--noautoremove] [--nogpgcheck] [--color COLOR] [--refresh]
                   [-4] [-6] [--destdir DESTDIR] [--downloadonly]
                   [--comment COMMENT] [--bugfix] [--enhancement]
                   [--newpackage] [--security] [--advisory ADVISORY]
                   [--bz BUGZILLA] [--cve CVES]
                   [--sec-severity {Critical,Important,Moderate,Low}]
                   [--forcearch ARCH]
                   软件包 [软件包 ...]
yum install: error: the following arguments are required: 软件包
[root@localhost gitlab]# yun -v
bash: yun: 未找到命令...
[root@localhost gitlab]# yum install -v
加载插件:builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
DNF version: 4.2.7
cachedir: /var/cache/dnf
usage: yum install [-c [config file]] [-q] [-v] [--version]
                   [--installroot [path]] [--nodocs] [--noplugins]
                   [--enableplugin [plugin]] [--disableplugin [plugin]]
                   [--releasever RELEASEVER] [--setopt SETOPTS]
                   [--skip-broken] [-h] [--allowerasing] [-b | --nobest] [-C]
                   [-R [minutes]] [-d [debug level]] [--debugsolver]
                   [--showduplicates] [-e ERRORLEVEL] [--obsoletes]
                   [--rpmverbosity [debug level name]] [-y] [--assumeno]
                   [--enablerepo [repo]] [--disablerepo [repo] | --repo
                   [repo]] [--enable | --disable] [-x [package]]
                   [--disableexcludes [repo]] [--repofrompath [repo,path]]
                   [--noautoremove] [--nogpgcheck] [--color COLOR] [--refresh]
                   [-4] [-6] [--destdir DESTDIR] [--downloadonly]
                   [--comment COMMENT] [--bugfix] [--enhancement]
                   [--newpackage] [--security] [--advisory ADVISORY]
                   [--bz BUGZILLA] [--cve CVES]
                   [--sec-severity {Critical,Important,Moderate,Low}]
                   [--forcearch ARCH]
                   软件包 [软件包 ...]
yum install: error: the following arguments are required: 软件包
[root@localhost gitlab]# sudo yum install
usage: yum install [-c [config file]] [-q] [-v] [--version]
                   [--installroot [path]] [--nodocs] [--noplugins]
                   [--enableplugin [plugin]] [--disableplugin [plugin]]
                   [--releasever RELEASEVER] [--setopt SETOPTS]
                   [--skip-broken] [-h] [--allowerasing] [-b | --nobest] [-C]
                   [-R [minutes]] [-d [debug level]] [--debugsolver]
                   [--showduplicates] [-e ERRORLEVEL] [--obsoletes]
                   [--rpmverbosity [debug level name]] [-y] [--assumeno]
                   [--enablerepo [repo]] [--disablerepo [repo] | --repo
                   [repo]] [--enable | --disable] [-x [package]]
                   [--disableexcludes [repo]] [--repofrompath [repo,path]]
                   [--noautoremove] [--nogpgcheck] [--color COLOR] [--refresh]
                   [-4] [-6] [--destdir DESTDIR] [--downloadonly]
                   [--comment COMMENT] [--bugfix] [--enhancement]
                   [--newpackage] [--security] [--advisory ADVISORY]
                   [--bz BUGZILLA] [--cve CVES]
                   [--sec-severity {Critical,Important,Moderate,Low}]
                   [--forcearch ARCH]
                   软件包 [软件包 ...]
yum install: error: the following arguments are required: 软件包
[root@localhost gitlab]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:06:13 前,执行于 2020年05月11日 星期一 01时07分33秒。
错误:
 问题: conflicting requests
  - nothing provides policycoreutils-python needed by gitlab-ce-12.3.5-ce.0.el7.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)
[root@localhost gitlab]# yum install policycoreutils-python -y
上次元数据过期检查:0:07:04 前,执行于 2020年05月11日 星期一 01时07分33秒。
未找到匹配的参数: policycoreutils-python
错误:没有任何匹配: policycoreutils-python
[root@localhost gitlab]# cd
[root@localhost ~]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:07:44 前,执行于 2020年05月11日 星期一 01时07分33秒。
错误:
 问题: conflicting requests
  - nothing provides policycoreutils-python needed by gitlab-ce-12.3.5-ce.0.el7.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)
[root@localhost ~]# sudo yum install gitlab-ce-12.3.5  --nobest
上次元数据过期检查:0:08:09 前,执行于 2020年05月11日 星期一 01时07分33秒。
错误:
 问题: conflicting requests
  - nothing provides policycoreutils-python needed by gitlab-ce-12.3.5-ce.0.el7.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包)
[root@localhost ~]# yum -y install policycoreutils openssh-server openssh-clients postfix
上次元数据过期检查:0:09:02 前,执行于 2020年05月11日 星期一 01时07分33秒。
软件包 policycoreutils-2.9-3.el8.x86_64 已安装。
软件包 openssh-server-8.0p1-3.el8.x86_64 已安装。
软件包 openssh-clients-8.0p1-3.el8.x86_64 已安装。
依赖关系解决。
===============================================================================================================================
 软件包                                      架构                  版本                            仓库                   大小
===============================================================================================================================
安装:
 postfix                                     x86_64                2:3.3.1-9.el8                   BaseOS                1.5 M
升级:
 openssh                                     x86_64                8.0p1-4.el8_1                   BaseOS                496 k
 openssh-clients                             x86_64                8.0p1-4.el8_1                   BaseOS                704 k
 openssh-server                              x86_64                8.0p1-4.el8_1                   BaseOS                485 k
 policycoreutils                             x86_64                2.9-3.el8_1.1                   BaseOS                377 k
 policycoreutils-python-utils                noarch                2.9-3.el8_1.1                   BaseOS                250 k
 python3-policycoreutils                     noarch                2.9-3.el8_1.1                   BaseOS                2.2 M

事务概要
===============================================================================================================================
安装  1 软件包
升级  6 软件包

总下载:6.0 M
下载软件包:
(1/7): openssh-8.0p1-4.el8_1.x86_64.rpm                                                        759 kB/s | 496 kB     00:00
(2/7): openssh-clients-8.0p1-4.el8_1.x86_64.rpm                                                821 kB/s | 704 kB     00:00
(3/7): openssh-server-8.0p1-4.el8_1.x86_64.rpm                                                 1.1 MB/s | 485 kB     00:00
(4/7): policycoreutils-2.9-3.el8_1.1.x86_64.rpm                                                990 kB/s | 377 kB     00:00
(5/7): policycoreutils-python-utils-2.9-3.el8_1.1.noarch.rpm                                   923 kB/s | 250 kB     00:00
(6/7): postfix-3.3.1-9.el8.x86_64.rpm                                                          993 kB/s | 1.5 MB     00:01
(7/7): python3-policycoreutils-2.9-3.el8_1.1.noarch.rpm                                        1.1 MB/s | 2.2 MB     00:01
-------------------------------------------------------------------------------------------------------------------------------
总计                                                                                           1.6 MB/s | 6.0 MB     00:03
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                1/1
  运行脚本: openssh-8.0p1-4.el8_1.x86_64                                                                                   1/1
  运行脚本: openssh-8.0p1-4.el8_1.x86_64                                                                                  1/13
  升级    : openssh-8.0p1-4.el8_1.x86_64                                                                                  1/13
  升级    : policycoreutils-2.9-3.el8_1.1.x86_64                                                                          2/13
  运行脚本: policycoreutils-2.9-3.el8_1.1.x86_64                                                                          2/13
  升级    : python3-policycoreutils-2.9-3.el8_1.1.noarch                                                                  3/13
  升级    : policycoreutils-python-utils-2.9-3.el8_1.1.noarch                                                             4/13
  升级    : openssh-clients-8.0p1-4.el8_1.x86_64                                                                          5/13
  运行脚本: openssh-server-8.0p1-4.el8_1.x86_64                                                                           6/13
  升级    : openssh-server-8.0p1-4.el8_1.x86_64                                                                           6/13
  运行脚本: openssh-server-8.0p1-4.el8_1.x86_64                                                                           6/13
  运行脚本: postfix-2:3.3.1-9.el8.x86_64                                                                                  7/13
  安装    : postfix-2:3.3.1-9.el8.x86_64                                                                                  7/13
  运行脚本: postfix-2:3.3.1-9.el8.x86_64                                                                                  7/13
  清理    : policycoreutils-python-utils-2.9-3.el8.noarch                                                                 8/13
  清理    : python3-policycoreutils-2.9-3.el8.noarch                                                                      9/13
  运行脚本: openssh-server-8.0p1-3.el8.x86_64                                                                            10/13
  清理    : openssh-server-8.0p1-3.el8.x86_64                                                                            10/13
  运行脚本: openssh-server-8.0p1-3.el8.x86_64                                                                            10/13
  清理    : openssh-clients-8.0p1-3.el8.x86_64                                                                           11/13
  清理    : openssh-8.0p1-3.el8.x86_64                                                                                   12/13
  运行脚本: policycoreutils-2.9-3.el8.x86_64                                                                             13/13
  清理    : policycoreutils-2.9-3.el8.x86_64                                                                             13/13
  运行脚本: policycoreutils-2.9-3.el8.x86_64                                                                             13/13
  验证    : postfix-2:3.3.1-9.el8.x86_64                                                                                  1/13
  验证    : openssh-8.0p1-4.el8_1.x86_64                                                                                  2/13
  验证    : openssh-8.0p1-3.el8.x86_64                                                                                    3/13
  验证    : openssh-clients-8.0p1-4.el8_1.x86_64                                                                          4/13
  验证    : openssh-clients-8.0p1-3.el8.x86_64                                                                            5/13
  验证    : openssh-server-8.0p1-4.el8_1.x86_64                                                                           6/13
  验证    : openssh-server-8.0p1-3.el8.x86_64                                                                             7/13
  验证    : policycoreutils-2.9-3.el8_1.1.x86_64                                                                          8/13
  验证    : policycoreutils-2.9-3.el8.x86_64                                                                              9/13
  验证    : policycoreutils-python-utils-2.9-3.el8_1.1.noarch                                                            10/13
  验证    : policycoreutils-python-utils-2.9-3.el8.noarch                                                                11/13
  验证    : python3-policycoreutils-2.9-3.el8_1.1.noarch                                                                 12/13
  验证    : python3-policycoreutils-2.9-3.el8.noarch                                                                     13/13

已升级:
  openssh-8.0p1-4.el8_1.x86_64                                     openssh-clients-8.0p1-4.el8_1.x86_64
  openssh-server-8.0p1-4.el8_1.x86_64                              policycoreutils-2.9-3.el8_1.1.x86_64
  policycoreutils-python-utils-2.9-3.el8_1.1.noarch                python3-policycoreutils-2.9-3.el8_1.1.noarch

[gitlab-ce]
已安装:
  postfix-2:3.3.1-9.el8.x86_64

完毕!
[root@localhost ~]# sudo yum install gitlab-ce-12.3.5
上次元数据过期检查:0:09:53 前,执行于 2020年05月11日 星期一 01时07分33秒。
错误:
 问题: conflicting requests
  - nothing provides policycoreutils-python needed by gitlab-ce-12.3.5-ce.0.el7.x86_64
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)

3、下载最新的汉化包

由于汉化版本都低于英文版本,为了不产生不必要的麻烦就要先下载汉化包,查看汉化包的版本号,根据汉化包的版本号来安装指定版本的GitLab。若你安装的版本是最新的比汉化包高太多,那么你汉化时需要忽略数百到上千次的文件。并且还要执行sudo touch /etc/gitlab/skip-auto-migrations然后才能刷新配置。我想你不会选择这种傻方法吧?当然截止到2020年5月11日,汉化包不支持centOS8。

git clone https://gitlab.com/xhang/gitlab.git

下载完毕,切换到你下载的汉化包目录(gitlab),查看汉化包的版本号(vim VERSION)。

4、安装指定版本GitLab社区版

(sudo yum install gitlab-ce #自动安装最新版)

sudo yum install gitlab-ce-x.x.x #安装指定版本

[root@localhost gitlab]# sudo yum install gitlab-ce-11.4.8
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 gitlab-ce.x86_64.0.11.4.7-ce.0.el7 将被 升级
---> 软件包 gitlab-ce.x86_64.0.11.4.8-ce.0.el7 将被 更新
--> 解决依赖关系完成

依赖关系解决

=================================================================================================================================================
 Package                          架构                          版本                                      源                                大小
=================================================================================================================================================
正在更新:
 gitlab-ce                        x86_64                        11.4.8-ce.0.el7                           gitlab-ce                        435 M

事务概要
=================================================================================================================================================
升级  1 软件包

总下载量:435 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for gitlab-ce
gitlab-ce-11.4.8-ce.0.el7.x86_64.rpm                      60% [=============================                   ] 9.7 MB/s | 265 MB  00:00:17 ETA

安装成功会有这些标志:

 Recipe: gitlab::gitlab-workhorse
  * service[gitlab-workhorse] action restart
    - restart service service[gitlab-workhorse]
Recipe: gitaly::enable
  * service[gitaly] action restart
    - restart service service[gitaly]

Running handlers:
Running handlers complete
Chef Client finished, 14/561 resources updated in 01 minutes 35 seconds
gitlab Reconfigured!
Checking for an omnibus managed postgresql: OK
Checking for a newer version of PostgreSQL to install
No new version of PostgreSQL installed, nothing to upgrade to
Ensuring PostgreSQL is updated: OK
Restarting previously running GitLab services

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


Upgrade complete! If your GitLab server is misbehaving try running
  sudo gitlab-ctl restart
before anything else.
If you need to roll back to the previous version you can use the database
backup made during the upgrade (scroll up for the filename).

  验证中      : gitlab-ce-11.4.8-ce.0.el7.x86_64                                                                                             1/1

已安装:
  gitlab-ce.x86_64 0:11.4.8-ce.0.el7

完毕!
您在 /var/spool/mail/root 中有新邮件
GitLab常用命令
sudo gitlab-ctl start    # 启动所有 gitlab 组件;
sudo gitlab-ctl stop        # 停止所有 gitlab 组件;
sudo gitlab-ctl restart        # 重启所有 gitlab 组件;
sudo gitlab-ctl status        # 查看服务状态;
sudo gitlab-ctl reconfigure        # 启动服务;
sudo vim /etc/gitlab/gitlab.rb        # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab;
sudo gitlab-ctl tail        # 查看日志;

5、修改服务地址

sudo vim /etc/gitlab/gitlab.rb

注意:要修改这个红框的地址。若你的服务器是装再局域网上,那么要配置这个局域网服务器的本机地址加上端口号。若你是装在公网云上,那么你可以配置域名了。不配置正确地址这个地址你不能上传和下载项目的。这个配置最关键,要多检查。

6、刷新配置,启动服务看GitLab主页是否能够使用。

注意:服务器启动成功,需要等待2分钟才能打开主页。

sudo gitlab-ctl reconfigure
sudo gitlab-ctl start

看到这个网页说明你的GitLab基本安装成功。

看到这个说明很可能服务器再重启中,等两分钟后再刷新页面。当然也可能是你的服务器配置错误或配置文件有冲突。若是后者需要你修改配置或执行忽略配置冲突命令(sudo touch /etc/gitlab/skip-auto-migrations)后重新刷新配置。

若出现Unable to round-trip http request to upstream: dial tcp 192.163.1.156:8888: i/o timeout或包网络超时链接超时错误。那么很可能是你服务器服务配置错误,服务器端口被占用或端口被禁用。

ping IP地址(ping 192.168.1.156),ctrl+c键可以停止。

w1:~ jiaguoshang$ ping 192.168.1.156

PING 192.168.1.156 (192.168.1.156): 56 data bytes

64 bytes from 192.168.1.156: icmp_seq=0 ttl=62 time=3.490 ms

64 bytes from 192.168.1.156: icmp_seq=1 ttl=62 time=2.554 ms

64 bytes from 192.168.1.156: icmp_seq=7 ttl=62 time=8.155 ms

^C

— 192.168.1.156 ping statistics —

8 packets transmitted, 8 packets received, 0.0% packet loss

round-trip min/avg/max/stddev = 2.253/39.847/284.912/92.659 ms

使用ssh判断

ssh是linux的标准配置并且最常用,可以用来判断端口吗?

用法: ssh -v -p port username@ip

-v 调试模式(会打印日志).

-p 指定端口username可以随意

端口和ip可用的情况:


w1:~ jiaguoshang$ ssh -v -p 8888 ddd@192.168.1.156
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to 192.168.1.156 port 8888.
debug1: Connection established.
debug1: identity file /Users/jiaguoshang/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jiaguoshang/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request


debug1: ssh_exchange_identification: Server: nginx


debug1: ssh_exchange_identification: Date: Thu, 06 Dec 2018 03:24:33 GMT


debug1: ssh_exchange_identification: Content-Type: text/html


debug1: ssh_exchange_identification: Content-Length: 166


debug1: ssh_exchange_identification: Connection: close


debug1: ssh_exchange_identification: 


debug1: ssh_exchange_identification: <html>


debug1: ssh_exchange_identification: <head><title>400 Bad Request</title></head>


debug1: ssh_exchange_identification: <body bgcolor="white">


debug1: ssh_exchange_identification: <center><h1>400 Bad Request</h1></center>


debug1: ssh_exchange_identification: <hr><center>nginx</center>


debug1: ssh_exchange_identification: </body>


debug1: ssh_exchange_identification: </html>


ssh_exchange_identification: Connection closed by remote host
w1:~ jiaguoshang$ 

端口不可用的情况:


w1:~ jiaguoshang$ ssh -v -p 888 ddd@192.168.1.156
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to 192.168.1.156 port 888.
ssh: connect to host 192.168.1.156 port 888: Connection refused

因为我就遇到过端口没有开通的情况,我折腾了大半天。

若出现端口被禁用可以使用firewall-cmd --zone=public --list-ports查看开发端口列表。使用firewall-cmd --zone=public --add-port=8888/tcp --permanent开放防火墙的端口,重启防火墙firewall-cmd --reload。通过命令查看是否生效firewall-cmd --zone=public --query-port=8888/tcp,如下命令可查看当前系统打开的所有端口firewall-cmd --zone=public --list-ports。

查看当前系统打开的所有端口firewall-cmd --zone=public --list-ports

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since 二 2018-12-04 14:03:05 CST; 1 day 21h ago
     Docs: man:firewalld(1)
 Main PID: 46502 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─46502 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
12月 04 14:03:06 localhost.localdomain firewalld[46502]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w2 -w --table filter --del...ailed:
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# uname -a
[root@localhost ~]# firewall-cmd --zone=public --list-ports
8888/tcp

7、修改root的密码。

[root@localhost ~]# gitlab-rails console production
-------------------------------------------------------------------------------------
 GitLab:       11.4.8 (bdfeff3)
 GitLab Shell: 8.3.3
 postgresql:   9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password=12345678
=> 12345678
irb(main):003:0> user.password_confirmation=12345678
=> 12345678
irb(main):004:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: d9b1f1f7-1256-48ff-b18a-c07d9c98e504) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1
=> true
irb(main):005:0> quit

注意: User.where(id: 1).中的1代码用户列表的序号,1永远都是超级管理员root用户。若大于1就是非超级管理员账户,但是至少这个用户存在才能设置成功。

新创建的用户邮件收到的信息:

你好 郏国上!

管理员创建了你的账号。现在你已是 GitLab 应用的成员。

账号.......................................... jiaguoshang2005@163.com

点击这里设置你的密码

此链接在 2 天 内有效。 过期后请 申请一个新的.


点击这里设置你的密码(http://192.168.1.156:8888/users/password/new?user_email=),需要输入手机号后重置密码。点击申请一个新的(http://192.168.1.156:8888/users/password/new?user_email=jiaguoshang2005%40163.com)直接帮你填写号手机号点击重置密码就给你的邮箱发送一个重置密码链接,打开链接重置密码就可以。

你会发现要求的成员或命令批量加入的成员,可以打开从邮箱里点击重置密码链接:http://192.168.1.156:8888/users/password/edit?reset_password_token=DehvJjhYuyuKcFD7VG9t 。也可以使用的上面命令重置普通成员账户的初始密码,全数字类型。然后让成员账户登录里面修改密码的。刷新配置(sudo gitlab-ctl reconfigure)后若没有启动GitLab,启动GitLab(sudo gitlab-ctl start)就可以,当然重启GitLab(sudo gitlab-ctl restart)也可以;已经启动了GitLab,那么直接启动GitLab没有效果,需要重启GitLab(sudo gitlab-ctl restart),当然也可以先停止GitLab(sudo gitlab-ctl stop)后启动GitLab(sudo gitlab-ctl start)。超级管理员命令行设置普通用户初始密码具体操作如下:

修改密码

注意这个姓名要填写你的真名。Usename是项目中你使用的名字,这个名字会用到自己创建的私有库中的,所以这个名字要使用拼音为好。
![在这里插入图片描述](https://ucc.alicdn.com/images/user-upload-01/20181206172754833.jpeg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ppYTEyMjE2,size_16,color_FFFFFF,t_70)
[root@localhost gitlab]# gitlab-rails console production
-------------------------------------------------------------------------------------
 GitLab:       11.4.8 (bdfeff3)
 GitLab Shell: 8.3.3
 postgresql:   9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> user = User.where
=> #<ActiveRecord::QueryMethods::WhereChain:0x00007f80a62b4660 @scope=#<ActiveRecord::Relation [#<User id:1 @root>, #<User id:5 @jiaguoshang2>, #<User id:4 @ghost>, #<User id:3 @jiaguoshang>]>>
irb(main):002:0> quit

这个是查询用户列表命令。

[root@localhost ~]# gitlab-rails console production
-------------------------------------------------------------------------------------
 GitLab:       11.4.8 (bdfeff3)
 GitLab Shell: 8.3.3
 postgresql:   9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> user = User.where(id: 5).first
=> #<User id:5 @jiaguoshang2>
irb(main):002:0> user.password="12345678"
=> "12345678"
irb(main):003:0> user.password_confirmation="12345678"
=> "12345678"
irb(main):004:0> user.save!
Enqueued ActionMailer::DeliveryJob (Job ID: a79417d9-10eb-4948-83f9-483eee0b807e) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/5
=> true
irb(main):005:0> quit

这个是修改id为5的用户初始密码并确认密码的操作。

8、禁用注册功能。

把邮箱注册的默认选择勾选去掉。设置后看到的登录页面没有注册了。

9、制作ssh登录用证书。

由于内容太多,关于汉化和删除后重装GitLab的内容在GitLab汉化彻底卸载GitLab并重装叙述了。

10.用超级管理员登录账户可以增加用户并初始化密码。

注意:Username最好用拼音或英文,因为这个名称会在你自己的私有库时自动添加上去,电子邮件必须有,密码和确认密码要填写。

11.当启动双重认证后,登录时会显示输入两部验证代码。若你是超级管理员并且没有注册时的手机号,那么你就麻烦了。需要登录gitLab服务器,然后执行sudo gitlab-rails runner 'User.find_each(&:disable_two_factor!)'来取消两步验证。

w1:BITCommonUnit jiaguoshang$ ssh root@192.168.1.157
root@192.168.1.156's password:
Last login: Mon Dec 17 17:18:44 2018 from gateway
[root@localhost ~]# sudo gitlab-rails runner 'User.find_each(&:disable_two_factor!)'
[root@localhost ~]#



相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
1月前
|
Linux 应用服务中间件 网络安全
linux安装Gitlab
linux安装Gitlab
110 0
|
1月前
|
缓存 数据安全/隐私保护 Docker
安装gitlab
安装gitlab
210 0
|
8月前
|
Prometheus 监控 Cloud Native
私有仓库Gitlab的安装与汉化
私有仓库Gitlab的安装与汉化
117 0
|
7月前
|
网络安全 开发工具 数据安全/隐私保护
Gitlab的安装
Gitlab的安装
94 0
|
10月前
|
JSON 网络安全 数据安全/隐私保护
gitlab--安装和配置
gitlab--安装和配置
|
1月前
|
存储 网络安全 数据安全/隐私保护
docker 安装gitlab,配置邮件,备份全流程
docker 安装gitlab,配置邮件,备份全流程
170 0
|
1月前
|
Linux 网络安全 数据安全/隐私保护
centos7安装gitlab-ce社区版全过程,详细到爆炸,这些面试官常问的开发面试题你都掌握好了吗
centos7安装gitlab-ce社区版全过程,详细到爆炸,这些面试官常问的开发面试题你都掌握好了吗
|
1月前
|
Linux 数据安全/隐私保护 Docker
源码管理新征程:CentOS 7上GitLab安装全程解析
源码管理新征程:CentOS 7上GitLab安装全程解析
44 0
源码管理新征程:CentOS 7上GitLab安装全程解析
|
1月前
|
NoSQL 关系型数据库 MySQL
Docker安装详细步骤及相关环境安装配置(mysql、jdk、redis、自己的私有仓库Gitlab 、C和C++环境以及Nginx服务代理)
Docker安装详细步骤及相关环境安装配置(mysql、jdk、redis、自己的私有仓库Gitlab 、C和C++环境以及Nginx服务代理)
367 0
|
1月前
|
Shell 网络安全 开发工具
docker 安装 gitlab 教程详解
docker 安装 gitlab 教程详解
88 0