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

(1)安装依赖
yum -y install policycoreutils openssh-server openssh-clients postfix

如:

[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 ~]#
(2)设置postfix开机自启,并启动postfix
systemctl enable postfix
systemctl start postfix

如:

[root@localhost ~]# systemctl enable postfix
[root@localhost ~]# systemctl start postfix
[root@localhost ~]#
(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
(4)安装gitlab
rpm -i gitlab-ce-14.2.5-ce.0.el7.x86_64.rpm

[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]#
(5)修改配置文件
 vi /etc/gitlab/gitlab.rb

如下,将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'
(6)查看防火墙已经放开的端口
firewall-cmd --list-all

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

[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]#
(7)防火墙开放上述设置的端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload

如:

[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]#
(8)重新加载gitlab的配置并重新启动gitlab
gitlab-ctl reconfigure  # 此命令可能需要执行几分钟,耐心等待
gitlab-ctl restart

如果执行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

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

gitlab-ctl stop
chmod 755 /var/opt/gitlab/postgresql
systemctl restart gitlab-runsvdir
gitlab-ctl reconfigure
(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

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

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

则将端口修改为8181

vi /etc/gitlab/gitlab.rb

如下,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'

然后执行

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

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

firewall-cmd --zone=public --add-port=8181/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all

如:

[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 ~]#

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

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

如下:密码为: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 ~]#
(10)依次点击【头像】-【Edit profile】-【password】

在这里插入图片描述

(11)然后修改密码

在这里插入图片描述

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

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

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

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

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

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

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要在CentOS 7上部署GitLab CI持续集成,您可以按照以下步骤进行操作: 1. 安装GitLab的依赖项,包括curl、openssh-server、openssh-clients、postfix和policycoreutils。您可以使用以下命令进行安装: ``` yum install -y curl openssh-server openssh-clients postfix policycoreutils ``` 2. 下载GitLab的yum源并进行安装。您可以使用以下命令下载并安装yum源: ``` curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash ``` 3. 安装GitLab CE: ``` yum install -y gitlab-ce ``` 4. 进行GitLab的配置。这一步可能需要一些时间,请耐心等待: ``` gitlab-ctl reconfigure ``` 5. 安装GitLab插件。进入系统管理页面,点击"管理插件",并选择安装gitlab-plugin和gitlab hook-plugin。如果找不到这些插件,只需安装gitlabgitlab hook即可。 完成上述步骤后,您的CentOS 7系统就可以部署GitLab CI持续集成了。 <span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Cento7部署基于Jenkins和Gitlab的持续集成与部署架构](https://blog.csdn.net/xixixilalalahaha/article/details/106546320)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [CentOS 7 部署Gitlab+Jenkins持续集成(CI)环境](https://blog.csdn.net/a790308/article/details/102258147)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

redrose2100

您的鼓励是我最大的创作动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值