当前位置:   article > 正文

Gitlab安装部署----CentOS7系统_ruby_block[authorize grafana with gitlab] (monitor

ruby_block[authorize grafana with gitlab] (monitoring::grafana line 101) had
(1)安装依赖
yum -y install policycoreutils openssh-server openssh-clients postfix
  • 1

如:

[root@localhost ~]# yum -y install policycoreutils openssh-server openssh-clients postfix
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
软件包 policycoreutils-2.5-34.el7.x86_64 已安装并且是最新版本
软件包 openssh-server-7.4p1-21.el7.x86_64 已安装并且是最新版本
软件包 openssh-clients-7.4p1-21.el7.x86_64 已安装并且是最新版本
软件包 2:postfix-2.10.1-9.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
(2)设置postfix开机自启,并启动postfix
systemctl enable postfix
systemctl start postfix
  • 1
  • 2

如:

[root@localhost ~]# systemctl enable postfix
[root@localhost ~]# systemctl start postfix
[root@localhost ~]#
  • 1
  • 2
  • 3
(3)下载gitlab

从 https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/ 找一个比较新的版本,右键拷贝链接地址,然后使用wget下载
如:

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.2.5-ce.0.el7.x86_64.rpm --no-check-certificate
  • 1
(4)安装gitlab
rpm -i gitlab-ce-14.2.5-ce.0.el7.x86_64.rpm
  • 1

[root@localhost opt]# rpm -i gitlab-ce-14.2.5-ce.0.el7.x86_64.rpm
警告:gitlab-ce-14.2.5-ce.0.el7.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
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-2

[root@localhost opt]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
(5)修改配置文件
 vi /etc/gitlab/gitlab.rb
  • 1

如下,将external_url 设置为具体的ip加端口号:

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://192.168.1.210:8080'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
(6)查看防火墙已经放开的端口
firewall-cmd --list-all
  • 1

如下,表示当前没有端口放开

[root@localhost opt]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: dhcpv6-client ssh
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@localhost opt]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
(7)防火墙开放上述设置的端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
  • 1
  • 2

如:

[root@localhost opt]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@localhost opt]# firewall-cmd --reload
success
[root@localhost opt]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: dhcpv6-client ssh
  ports: 8080/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@localhost opt]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
(8)重新加载gitlab的配置并重新启动gitlab
gitlab-ctl reconfigure  # 此命令可能需要执行几分钟,耐心等待
gitlab-ctl restart
  • 1
  • 2

如果执行gitlab-ctl reconfigure 报如下错误,

Running handlers:
There was an error running gitlab-ctl reconfigure:

ruby_block[authorize Grafana with GitLab] (monitoring::grafana line 101) had an error: Mixlib::ShellOut::CommandTimeout: Command timed out after 600s:
Command exceeded allowed execution time, process terminated
---- Begin output of /opt/gitlab/bin/gitlab-rails runner -e production 'app = Doorkeeper::Application.where(redirect_uri: "http://192.168.1.210:8080/-/grafana/login/gitlab", name: "GitLab Grafana").first_or_create;puts app.uid.concat(" ").concat(app.secret);' ----
STDOUT:
STDERR:
---- End output of /opt/gitlab/bin/gitlab-rails runner -e production 'app = Doorkeeper::Application.where(redirect_uri: "http://192.168.1.210:8080/-/grafana/login/gitlab", name: "GitLab Grafana").first_or_create;puts app.uid.concat(" ").concat(app.secret);' ----
Ran /opt/gitlab/bin/gitlab-rails runner -e production 'app = Doorkeeper::Application.where(redirect_uri: "http://192.168.1.210:8080/-/grafana/login/gitlab", name: "GitLab Grafana").first_or_create;puts app.uid.concat(" ").concat(app.secret);' returned
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

一般来说是内存不够,可以将虚拟机内存设置为4G,然后依次执行如下命令:

gitlab-ctl stop
chmod 755 /var/opt/gitlab/postgresql
systemctl restart gitlab-runsvdir
gitlab-ctl reconfigure
  • 1
  • 2
  • 3
  • 4
(9)浏览器打开 http://192.168.1.210:8080/

如果出现502 Whoops, GitLab is taking too much time to respond. 的错误,则首先检查一下端口是否被占用,如下,表示8080被占用了

[root@localhost ~]# netstat -tunlp |grep 8080
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      4378/nginx: master
  • 1
  • 2

在修改端口之前,首先检查一下新的端口是否被占用,如下,表示8181未被占用

[root@localhost ~]# netstat -tunlp |grep 8181
[root@localhost ~]#
  • 1
  • 2

则将端口修改为8181

vi /etc/gitlab/gitlab.rb
  • 1

如下,external_url 中端口修改为8181

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://192.168.1.210:8181'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

然后执行

gitlab-ctl reconfigure  # 此命令可能需要执行几分钟,耐心等待
gitlab-ctl restart
  • 1
  • 2

并注意将防火墙开放新的端口号

firewall-cmd --zone=public --add-port=8181/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all
  • 1
  • 2
  • 3

如:

[root@localhost ~]# firewall-cmd --zone=public --add-port=8181/tcp --permanent
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: dhcpv6-client ssh
  ports: 8080/tcp 8181/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@localhost ~]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

此时在浏览器中打开 http://192.168.1.210:8181/ ,即OK了
在这里插入图片描述

(9)查看root用户默认的密码
cat /etc/gitlab/initial_root_password
  • 1

如下:密码为:x+WKarjgzbQEU9vJ2a5c0UfeUc8X/0RtxwLUraO786g=

[root@localhost ~]# 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: x+WKarjgzbQEU9vJ2a5c0UfeUc8X/0RtxwLUraO786g=

# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
[root@localhost ~]#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
(10)依次点击【头像】-【Edit profile】-【password】

在这里插入图片描述

(11)然后修改密码

在这里插入图片描述

(12)至此,gitlab已经部署OK,并且已经成功登录并修改密码

Gitlab安装部署----CentOS7系统

Gitlab安装部署----Docker方式

Gitlab安装部署----安装注册Gitlab Runner

Gitlab安装部署----卸载Gitlab Runner

GitLabCICD实战----在.gitlab-ci.yml文件的步骤中使用git clone 另一个代码仓报错的解决办法

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/525328
推荐阅读
相关标签
  

闽ICP备14008679号