CentOS 7 动手搭建GitLab社区版环境

环境准备

  1. 在Vmware中安装CentOS7系统
    在这里插入图片描述
  2. 下载GitLab的rpm镜像包(gitlab-ce-13.8.1-ce.0.el7.x86_64.rpm)
    地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.8.1-ce.0.el7.x86_64.rpm

开始安装

一、安装依赖

先检查本地gcc环境并升级

[root@localhost ~]# gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

升级gcc到最新版

[root@localhost ~]# yum install -y centos-release-scl
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-sclo-rh: mirrors.bfsu.edu.cn
 * centos-sclo-sclo: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 centos-release-scl-2-3.el7.centos.noarch 已安装并且是最新版本
无须任何处理
[root@localhost ~]# yum install -y devtoolset-9-gcc*
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-sclo-rh: mirrors.bfsu.edu.cn
 * centos-sclo-sclo: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 devtoolset-9-gcc-9.3.1-2.el7.x86_64 已安装并且是最新版本
软件包 devtoolset-9-gcc-c++-9.3.1-2.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 devtoolset-9-gcc-gdb-plugin.x86_64.0.9.3.1-2.el7 将被 安装
---> 软件包 devtoolset-9-gcc-gfortran.x86_64.0.9.3.1-2.el7 将被 安装
--> 正在处理依赖关系 devtoolset-9-libquadmath-devel = 9.3.1-2.el7,它被软件包 devtoolset-9-gcc-gfortran-9.3.1-2.el7.x86_64 需要
--> 正在处理依赖关系 libgfortran5 >= 8.1.1,它被软件包 devtoolset-9-gcc-gfortran-9.3.1-2.el7.x86_64 需要
---> 软件包 devtoolset-9-gcc-plugin-devel.x86_64.0.9.3.1-2.el7 将被 安装
--> 正在处理依赖关系 gmp-devel >= 4.1.2-8,它被软件包 devtoolset-9-gcc-plugin-devel-9.3.1-2.el7.x86_64 需要
--> 正在处理依赖关系 libmpc-devel >= 0.8.1,它被软件包 devtoolset-9-gcc-plugin-devel-9.3.1-2.el7.x86_64 需要
--> 正在处理依赖关系 mpfr-devel >= 2.2.1,它被软件包 devtoolset-9-gcc-plugin-devel-9.3.1-2.el7.x86_64 需要
--> 正在检查事务
---> 软件包 devtoolset-9-libquadmath-devel.x86_64.0.9.3.1-2.el7 将被 安装
--> 正在处理依赖关系 libquadmath(x86-64),它被软件包 devtoolset-9-libquadmath-devel-9.3.1-2.el7.x86_64 需要
---> 软件包 gmp-devel.x86_64.1.6.0.0-15.el7 将被 安装
---> 软件包 libgfortran5.x86_64.0.8.3.1-2.1.1.el7 将被 安装
---> 软件包 libmpc-devel.x86_64.0.1.0.1-3.el7 将被 安装
---> 软件包 mpfr-devel.x86_64.0.3.1.1-4.el7 将被 安装
--> 正在检查事务
---> 软件包 libquadmath.x86_64.0.4.8.5-44.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===================================================================================================================================
 Package                                     架构                版本                            源                           大小
===================================================================================================================================
正在安装:
 devtoolset-9-gcc-gdb-plugin                 x86_64              9.3.1-2.el7                     centos-sclo-rh              122 k
 devtoolset-9-gcc-gfortran                   x86_64              9.3.1-2.el7                     centos-sclo-rh               13 M
 devtoolset-9-gcc-plugin-devel               x86_64              9.3.1-2.el7                     centos-sclo-rh              1.5 M
为依赖而安装:
 devtoolset-9-libquadmath-devel              x86_64              9.3.1-2.el7                     centos-sclo-rh              171 k
 gmp-devel                                   x86_64              1:6.0.0-15.el7                  base                        181 k
 libgfortran5                                x86_64              8.3.1-2.1.1.el7                 base                        796 k
 libmpc-devel                                x86_64              1.0.1-3.el7                     base                         32 k
 libquadmath                                 x86_64              4.8.5-44.el7                    base                        190 k
 mpfr-devel                                  x86_64              3.1.1-4.el7                     base                         68 k

事务概要
===================================================================================================================================
安装  3 软件包 (+6 依赖软件包)

总下载量:16 M
安装大小:51 M
Downloading packages:
(1/9): devtoolset-9-libquadmath-devel-9.3.1-2.el7.x86_64.rpm                                                | 171 kB  00:00:00     
(2/9): devtoolset-9-gcc-gdb-plugin-9.3.1-2.el7.x86_64.rpm                                                   | 122 kB  00:00:01     
(3/9): gmp-devel-6.0.0-15.el7.x86_64.rpm                                                                    | 181 kB  00:00:01     
(4/9): devtoolset-9-gcc-plugin-devel-9.3.1-2.el7.x86_64.rpm                                                 | 1.5 MB  00:00:01     
(5/9): libmpc-devel-1.0.1-3.el7.x86_64.rpm                                                                  |  32 kB  00:00:00     
(6/9): libgfortran5-8.3.1-2.1.1.el7.x86_64.rpm                                                              | 796 kB  00:00:02     
(7/9): libquadmath-4.8.5-44.el7.x86_64.rpm                                                                  | 190 kB  00:00:00     
(8/9): mpfr-devel-3.1.1-4.el7.x86_64.rpm                                                                    |  68 kB  00:00:00     
(9/9): devtoolset-9-gcc-gfortran-9.3.1-2.el7.x86_64.rpm                                                     |  13 MB  00:00:17     
-----------------------------------------------------------------------------------------------------------------------------------
总计                                                                                               936 kB/s |  16 MB  00:00:17     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 1:gmp-devel-6.0.0-15.el7.x86_64                                                                                1/9 
  正在安装    : mpfr-devel-3.1.1-4.el7.x86_64                                                                                  2/9 
  正在安装    : libquadmath-4.8.5-44.el7.x86_64                                                                                3/9 
  正在安装    : libgfortran5-8.3.1-2.1.1.el7.x86_64                                                                            4/9 
  正在安装    : devtoolset-9-libquadmath-devel-9.3.1-2.el7.x86_64                                                              5/9 
  正在安装    : libmpc-devel-1.0.1-3.el7.x86_64                                                                                6/9 
  正在安装    : devtoolset-9-gcc-plugin-devel-9.3.1-2.el7.x86_64                                                               7/9 
  正在安装    : devtoolset-9-gcc-gfortran-9.3.1-2.el7.x86_64                                                                   8/9 
  正在安装    : devtoolset-9-gcc-gdb-plugin-9.3.1-2.el7.x86_64                                                                 9/9 
  验证中      : libgfortran5-8.3.1-2.1.1.el7.x86_64                                                                            1/9 
  验证中      : libquadmath-4.8.5-44.el7.x86_64                                                                                2/9 
  验证中      : mpfr-devel-3.1.1-4.el7.x86_64                                                                                  3/9 
  验证中      : 1:gmp-devel-6.0.0-15.el7.x86_64                                                                                4/9 
  验证中      : libmpc-devel-1.0.1-3.el7.x86_64                                                                                5/9 
  验证中      : devtoolset-9-gcc-gfortran-9.3.1-2.el7.x86_64                                                                   6/9 
  验证中      : devtoolset-9-libquadmath-devel-9.3.1-2.el7.x86_64                                                              7/9 
  验证中      : devtoolset-9-gcc-gdb-plugin-9.3.1-2.el7.x86_64                                                                 8/9 
  验证中      : devtoolset-9-gcc-plugin-devel-9.3.1-2.el7.x86_64                                                               9/9 

已安装:
  devtoolset-9-gcc-gdb-plugin.x86_64 0:9.3.1-2.el7                   devtoolset-9-gcc-gfortran.x86_64 0:9.3.1-2.el7                
  devtoolset-9-gcc-plugin-devel.x86_64 0:9.3.1-2.el7                

作为依赖被安装:
  devtoolset-9-libquadmath-devel.x86_64 0:9.3.1-2.el7   gmp-devel.x86_64 1:6.0.0-15.el7     libgfortran5.x86_64 0:8.3.1-2.1.1.el7  
  libmpc-devel.x86_64 0:1.0.1-3.el7                     libquadmath.x86_64 0:4.8.5-44.el7   mpfr-devel.x86_64 0:3.1.1-4.el7        

完毕!
[root@localhost ~]# scl enable devtoolset-9 bash
[root@localhost ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) 

至此gcc版本升级完成,已升级至9.3.1版本

安装其他依赖项

[root@localhost ~]# yum -y install policycoreutils
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-sclo-rh: mirrors.bfsu.edu.cn
 * centos-sclo-sclo: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 policycoreutils-2.5-34.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# yum -y install openssh-server
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-sclo-rh: mirrors.bfsu.edu.cn
 * centos-sclo-sclo: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 openssh-server-7.4p1-21.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# yum -y install openssh-clients
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-sclo-rh: mirrors.bfsu.edu.cn
 * centos-sclo-sclo: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 openssh-clients-7.4p1-21.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# yum -y install postfix
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-sclo-rh: mirrors.bfsu.edu.cn
 * centos-sclo-sclo: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 2:postfix-2.10.1-9.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# yum -y install policycoreutils-python
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-sclo-rh: mirrors.bfsu.edu.cn
 * centos-sclo-sclo: mirrors.bfsu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 policycoreutils-python-2.5-34.el7.x86_64 已安装并且是最新版本
无须任何处理

一顿操作下来,结果发现都已经安装好了,囧~~

好了,废话不多说,正式开撸~

二、安装GitLab

执行命令 rpm -ivh gitlab-ce-13.8.1-ce.0.el7.x86_64.rpm

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

[root@localhost opt]# 

激动人心,gitlab已经安装完成,接下来就是配置相关信息

开始使用之前需要先配置gitlab,指定IP地址和端口号,输入**vim /etc/gitlab/gitlab.rb**

修改配置之前需要检查本机ip地址

[root@localhost gitlab]# vim /etc/gitlab/gitlab.rb
## 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://电脑IP地址:端口号'

执行gitlab-ctl reconfigure使配置生效,第一次时间会比较长,可以先撸两行代码等一等

[root@localhost ~]# gitlab-ctl reconfigure
Starting Chef Infra Client, version 15.14.0
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
  - gitlab (0.0.1)
  - package (0.1.0)
  - logrotate (0.0.0)
  - postgresql (0.1.0)
  - redis (0.1.0)
  - monitoring (0.1.0)
  - mattermost (0.1.0)
  - registry (0.1.0)
  - consul (0.1.0)
  - gitaly (0.1.0)
  - praefect (0.1.0)
  - gitlab-kas (0.1.0)
  - gitlab-pages (0.1.0)
  - letsencrypt (0.1.0)
  - nginx (0.1.0)
  - crond (0.1.0)
  - acme (4.1.1)
  - runit (5.1.3)
Installing Cookbook Gems:
Compiling Cookbooks...
.....
.....
.....
.....
Running handlers:
Running handlers complete
Chef Infra Client finished, 582/1550 resources updated in 06 minutes 11 seconds

Notes:
It seems you haven't specified an initial root password while configuring the GitLab instance.
On your first visit to  your GitLab instance, you will be presented with a screen to set a
password for the default admin account with username `root`.

gitlab Reconfigured!

看到gitlab Reconfigured! 说明配置成功了,然后重启一下gitlab服务

[root@localhost ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 8744) 0s
ok: run: gitaly: (pid 8753) 0s
ok: run: gitlab-exporter: (pid 8773) 0s
ok: run: gitlab-workhorse: (pid 8775) 1s
ok: run: grafana: (pid 8791) 0s
ok: run: logrotate: (pid 8803) 1s
ok: run: nginx: (pid 8809) 0s
ok: run: node-exporter: (pid 8815) 0s
ok: run: postgres-exporter: (pid 8897) 0s
ok: run: postgresql: (pid 8910) 0s
ok: run: prometheus: (pid 8919) 0s
ok: run: puma: (pid 8998) 0s
ok: run: redis: (pid 9003) 0s
ok: run: redis-exporter: (pid 9008) 1s
ok: run: sidekiq: (pid 9023) 0s

相关命令:
启动:gitlab-ctl start
停止:gitlab-ctl stop
重启:gitlab-ctl restart

三、访问GitLab

在浏览器地址栏中输入输入刚在配置好的ip地址+端口号http://localhost:80
在这里插入图片描述
如果看到这个修改超级管理员密码的页面,恭喜你,GitLab安装成功,下面开始尽情的happy吧。。。
在这里插入图片描述
输入账号密码,进入后就可以尽情地玩耍啦。。。

四、其他gitlab相关命令

检查redis的日志
[root@localhost ~]# gitlab-ctl tail redis
检查postgresql的日志
[root@localhost ~]# gitlab-ctl tail postgresql
检查gitlab-workhorse的日志
[root@localhost ~]# gitlab-ctl tail gitlab-workhorse
检查logrotate的日志
[root@localhost ~]# gitlab-ctl tail logrotate
检查nginx的日志
[root@localhost ~]# gitlab-ctl tail nginx
检查sidekiq的日志
[root@localhost ~]# gitlab-ctl tail sidekiq
检查unicorn的日志
[root@localhost ~]# gitlab-ctl tail unicorn

注:每次修改完配置,记得启动配置更新。
到这里gitlab已经安装完成,如果觉得能帮助到你,记得点点赞,点点关注,给我一点鼓励~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

wu575437

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值