Gitlab 本地搭建

着手搭建gitlab

 

1.更新本地yum缓存

sudo yum makecache

2. 添加 GitLab 镜像源并安装

curl -sS http://packages.gitlab.com.cn/install/gitlab-ce/script.rpm.sh | sudo bash
[root@mail etc]# curl -sS http://packages.gitlab.com.cn/install/gitlab-ce/script.rpm.sh | sudo bash
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: http://packages.gitlab.cc/install/gitlab-ce/config_file_centos_7.list
done.
Installing pygpgme to verify GPG signatures...
已加载插件:fastestmirror
Repository gitlab-ce is listed more than once in the configuration


Error getting repository data for gitlab_gitlab-ce, repository not found
Installing yum-utils...
已加载插件:fastestmirror
Repository gitlab-ce is listed more than once in the configuration


Error getting repository data for gitlab_gitlab-ce, repository not found

WARNING: 
The yum-utils package could not be installed. This means you may not be able to install source RPMs or use other yum features.

Generating yum cache for gitlab_gitlab-ce...
Repository gitlab-ce is listed more than once in the configuration


Error getting repository data for gitlab_gitlab-ce, repository not found

The repository is setup! You can now install packages.
sudo yum install gitlab-ce
[root@mail etc]# sudo yum install gitlab-ce
已加载插件:fastestmirror
Repository gitlab-ce is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.cn99.com
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 gitlab-ce.x86_64.0.11.4.4-ce.0.el6 将被 安装
--> 正在处理依赖关系 policycoreutils-python,它被软件包 gitlab-ce-11.4.4-ce.0.el6.x86_64 需要
--> 正在检查事务
---> 软件包 policycoreutils-python.x86_64.0.2.5-22.el7 将被 安装
--> 正在处理依赖关系 policycoreutils = 2.5-22.el7,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 setools-libs >= 3.3.8-2,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libsemanage-python >= 2.5-9,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 audit-libs-python >= 2.1.3-4,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 python-IPy,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.4)(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.2)(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libcgroup,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libapol.so.4(VERS_4.0)(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 checkpolicy,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1()(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libapol.so.4()(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在检查事务
---> 软件包 audit-libs-python.x86_64.0.2.8.1-3.el7_5.1 将被 安装
--> 正在处理依赖关系 audit-libs(x86-64) = 2.8.1-3.el7_5.1,它被软件包 audit-libs-python-2.8.1-3.el7_5.1.x86_64 需要
---> 软件包 checkpolicy.x86_64.0.2.5-6.el7 将被 安装
---> 软件包 libcgroup.x86_64.0.0.41-15.el7 将被 安装
---> 软件包 libsemanage-python.x86_64.0.2.5-11.el7 将被 安装
--> 正在处理依赖关系 libsemanage = 2.5-11.el7,它被软件包 libsemanage-python-2.5-11.el7.x86_64 需要
---> 软件包 policycoreutils.x86_64.0.2.5-17.1.el7 将被 升级
---> 软件包 policycoreutils.x86_64.0.2.5-22.el7 将被 更新
---> 软件包 python-IPy.noarch.0.0.75-6.el7 将被 安装
---> 软件包 setools-libs.x86_64.0.3.3.8-2.el7 将被 安装
--> 正在检查事务
---> 软件包 audit-libs.x86_64.0.2.7.6-3.el7 将被 升级
--> 正在处理依赖关系 audit-libs(x86-64) = 2.7.6-3.el7,它被软件包 audit-2.7.6-3.el7.x86_64 需要
---> 软件包 audit-libs.x86_64.0.2.8.1-3.el7_5.1 将被 更新
---> 软件包 libsemanage.x86_64.0.2.5-8.el7 将被 升级
---> 软件包 libsemanage.x86_64.0.2.5-11.el7 将被 更新
--> 正在检查事务
---> 软件包 audit.x86_64.0.2.7.6-3.el7 将被 升级
---> 软件包 audit.x86_64.0.2.8.1-3.el7_5.1 将被 更新
--> 解决依赖关系完成

依赖关系解决

====================================================================================================================================
 Package                                 架构                    版本                              源                          大小
====================================================================================================================================
正在安装:
 gitlab-ce                               x86_64                  11.4.4-ce.0.el6                   gitlab-ce                  424 M
为依赖而安装:
 audit-libs-python                       x86_64                  2.8.1-3.el7_5.1                   updates                     75 k
 checkpolicy                             x86_64                  2.5-6.el7                         base                       294 k
 libcgroup                               x86_64                  0.41-15.el7                       base                        65 k
 libsemanage-python                      x86_64                  2.5-11.el7                        base                       112 k
 policycoreutils-python                  x86_64                  2.5-22.el7                        base                       454 k
 python-IPy                              noarch                  0.75-6.el7                        base                        32 k
 setools-libs                            x86_64                  3.3.8-2.el7                       base                       619 k
为依赖而更新:
 audit                                   x86_64                  2.8.1-3.el7_5.1                   updates                    247 k
 audit-libs                              x86_64                  2.8.1-3.el7_5.1                   updates                     99 k
 libsemanage                             x86_64                  2.5-11.el7                        base                       150 k
 policycoreutils                         x86_64                  2.5-22.el7                        base                       867 k

事务概要
====================================================================================================================================
安装  1 软件包 (+7 依赖软件包)
升级           ( 4 依赖软件包)

总计:427 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/gitlab-ce/packages/gitlab-ce-11.4.4-ce.0.el6.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID f27eab47: NOKEY
从 https://packages.gitlab.com/gpg.key 检索密钥


源 "gitlab-ce" 的 GPG 密钥已安装,但是不适用于此软件包。请检查源的公钥 URL 是否配置正确。


 失败的软件包是:gitlab-ce-11.4.4-ce.0.el6.x86_64
 GPG  密钥配置为:https://packages.gitlab.com/gpg.key

[root@mail etc]# cd yum
yum/         yum.conf     yum.repos.d/ 
[root@mail etc]# cd yum.repos.d/
[root@mail yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo  gitlab_gitlab-ce.repo  mysql-community-source.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  gitlab-ce.repo     mysql-community.repo   zabbix.repo
[root@mail yum.repos.d]# rm -rf gitlab
gitlab-ce.repo         gitlab_gitlab-ce.repo  
[root@mail yum.repos.d]# rm -rf gitlab-ce.repo 
[root@mail yum.repos.d]# sudo yum makecache
已加载插件:fastestmirror
base                                                                                                         | 3.6 kB  00:00:00     
extras                                                                                                       | 3.4 kB  00:00:00     
gitlab-ce                                                                                                    | 2.9 kB  00:00:00     
Not using downloaded gitlab-ce/repomd.xml because it is older than what we have:
  Current   : Mon Nov  5 14:55:39 2018
  Downloaded: Mon Nov  5 01:55:00 2018
mysql-connectors-community                                                                                   | 2.5 kB  00:00:00     
mysql-tools-community                                                                                        | 2.5 kB  00:00:00     
mysql80-community                                                                                            | 2.5 kB  00:00:00     
updates                                                                                                      | 3.4 kB  00:00:00     
zabbix                                                                                                       | 2.9 kB  00:00:00     
zabbix-non-supported                                                                                         |  951 B  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.cn99.com
 * updates: mirrors.163.com
元数据缓存已建立
[root@mail yum.repos.d]# curl -sS http://packages.gitlab.com.cn/install/gitlab-ce/script.rpm.sh | sudo bash
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: http://packages.gitlab.cc/install/gitlab-ce/config_file_centos_7.list
done.
Installing pygpgme to verify GPG signatures...
已加载插件:fastestmirror


Error getting repository data for gitlab_gitlab-ce, repository not found
Installing yum-utils...
已加载插件:fastestmirror


Error getting repository data for gitlab_gitlab-ce, repository not found

WARNING: 
The yum-utils package could not be installed. This means you may not be able to install source RPMs or use other yum features.

Generating yum cache for gitlab_gitlab-ce...


Error getting repository data for gitlab_gitlab-ce, repository not found

The repository is setup! You can now install packages.
[root@mail yum.repos.d]# sudo yum install gitlab-ce
已加载插件:fastestmirror
gitlab-ce                                                                                                    | 2.9 kB  00:00:00     
Not using downloaded gitlab-ce/repomd.xml because it is older than what we have:
  Current   : Mon Nov  5 14:55:39 2018
  Downloaded: Mon Nov  5 01:55:00 2018
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.cn99.com
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 gitlab-ce.x86_64.0.11.4.4-ce.0.el6 将被 安装
--> 正在处理依赖关系 policycoreutils-python,它被软件包 gitlab-ce-11.4.4-ce.0.el6.x86_64 需要
--> 正在检查事务
---> 软件包 policycoreutils-python.x86_64.0.2.5-22.el7 将被 安装
--> 正在处理依赖关系 policycoreutils = 2.5-22.el7,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 setools-libs >= 3.3.8-2,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libsemanage-python >= 2.5-9,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 audit-libs-python >= 2.1.3-4,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 python-IPy,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.4)(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1(VERS_1.2)(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libcgroup,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libapol.so.4(VERS_4.0)(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 checkpolicy,它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libqpol.so.1()(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在处理依赖关系 libapol.so.4()(64bit),它被软件包 policycoreutils-python-2.5-22.el7.x86_64 需要
--> 正在检查事务
---> 软件包 audit-libs-python.x86_64.0.2.8.1-3.el7_5.1 将被 安装
--> 正在处理依赖关系 audit-libs(x86-64) = 2.8.1-3.el7_5.1,它被软件包 audit-libs-python-2.8.1-3.el7_5.1.x86_64 需要
---> 软件包 checkpolicy.x86_64.0.2.5-6.el7 将被 安装
---> 软件包 libcgroup.x86_64.0.0.41-15.el7 将被 安装
---> 软件包 libsemanage-python.x86_64.0.2.5-11.el7 将被 安装
--> 正在处理依赖关系 libsemanage = 2.5-11.el7,它被软件包 libsemanage-python-2.5-11.el7.x86_64 需要
---> 软件包 policycoreutils.x86_64.0.2.5-17.1.el7 将被 升级
---> 软件包 policycoreutils.x86_64.0.2.5-22.el7 将被 更新
---> 软件包 python-IPy.noarch.0.0.75-6.el7 将被 安装
---> 软件包 setools-libs.x86_64.0.3.3.8-2.el7 将被 安装
--> 正在检查事务
---> 软件包 audit-libs.x86_64.0.2.7.6-3.el7 将被 升级
--> 正在处理依赖关系 audit-libs(x86-64) = 2.7.6-3.el7,它被软件包 audit-2.7.6-3.el7.x86_64 需要
---> 软件包 audit-libs.x86_64.0.2.8.1-3.el7_5.1 将被 更新
---> 软件包 libsemanage.x86_64.0.2.5-8.el7 将被 升级
---> 软件包 libsemanage.x86_64.0.2.5-11.el7 将被 更新
--> 正在检查事务
---> 软件包 audit.x86_64.0.2.7.6-3.el7 将被 升级
---> 软件包 audit.x86_64.0.2.8.1-3.el7_5.1 将被 更新
--> 解决依赖关系完成

依赖关系解决

====================================================================================================================================
 Package                                 架构                    版本                              源                          大小
====================================================================================================================================
正在安装:
 gitlab-ce                               x86_64                  11.4.4-ce.0.el6                   gitlab-ce                  424 M
为依赖而安装:
 audit-libs-python                       x86_64                  2.8.1-3.el7_5.1                   updates                     75 k
 checkpolicy                             x86_64                  2.5-6.el7                         base                       294 k
 libcgroup                               x86_64                  0.41-15.el7                       base                        65 k
 libsemanage-python                      x86_64                  2.5-11.el7                        base                       112 k
 policycoreutils-python                  x86_64                  2.5-22.el7                        base                       454 k
 python-IPy                              noarch                  0.75-6.el7                        base                        32 k
 setools-libs                            x86_64                  3.3.8-2.el7                       base                       619 k
为依赖而更新:
 audit                                   x86_64                  2.8.1-3.el7_5.1                   updates                    247 k
 audit-libs                              x86_64                  2.8.1-3.el7_5.1                   updates                     99 k
 libsemanage                             x86_64                  2.5-11.el7                        base                       150 k
 policycoreutils                         x86_64                  2.5-22.el7                        base                       867 k

事务概要
====================================================================================================================================
安装  1 软件包 (+7 依赖软件包)
升级           ( 4 依赖软件包)

总计:427 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : audit-libs-2.8.1-3.el7_5.1.x86_64                                                                              1/16 
  正在更新    : libsemanage-2.5-11.el7.x86_64                                                                                  2/16 
  正在安装    : libsemanage-python-2.5-11.el7.x86_64                                                                           3/16 
  正在更新    : policycoreutils-2.5-22.el7.x86_64                                                                              4/16 
  正在安装    : audit-libs-python-2.8.1-3.el7_5.1.x86_64                                                                       5/16 
  正在安装    : python-IPy-0.75-6.el7.noarch                                                                                   6/16 
  正在安装    : checkpolicy-2.5-6.el7.x86_64                                                                                   7/16 
  正在安装    : libcgroup-0.41-15.el7.x86_64                                                                                   8/16 
  正在安装    : setools-libs-3.3.8-2.el7.x86_64                                                                                9/16 
  正在安装    : policycoreutils-python-2.5-22.el7.x86_64                                                                      10/16 
  正在安装    : gitlab-ce-11.4.4-ce.0.el6.x86_64                                                                              11/16 
  正在更新    : audit-2.8.1-3.el7_5.1.x86_64                                                                                  12/16 
  清理        : policycoreutils-2.5-17.1.el7.x86_64                                                                           13/16 
  清理        : libsemanage-2.5-8.el7.x86_64                                                                                  14/16 
  清理        : audit-2.7.6-3.el7.x86_64                                                                                      15/16 
  清理        : audit-libs-2.7.6-3.el7.x86_64                                                                                 16/16 
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

  验证中      : gitlab-ce-11.4.4-ce.0.el6.x86_64                                                                               1/16 
  验证中      : libsemanage-python-2.5-11.el7.x86_64                                                                           2/16 
  验证中      : libsemanage-2.5-11.el7.x86_64                                                                                  3/16 
  验证中      : audit-2.8.1-3.el7_5.1.x86_64                                                                                   4/16 
  验证中      : setools-libs-3.3.8-2.el7.x86_64                                                                                5/16 
  验证中      : policycoreutils-python-2.5-22.el7.x86_64                                                                       6/16 
  验证中      : libcgroup-0.41-15.el7.x86_64                                                                                   7/16 
  验证中      : checkpolicy-2.5-6.el7.x86_64                                                                                   8/16 
  验证中      : python-IPy-0.75-6.el7.noarch                                                                                   9/16 
  验证中      : audit-libs-2.8.1-3.el7_5.1.x86_64                                                                             10/16 
  验证中      : policycoreutils-2.5-22.el7.x86_64                                                                             11/16 
  验证中      : audit-libs-python-2.8.1-3.el7_5.1.x86_64                                                                      12/16 
  验证中      : audit-libs-2.7.6-3.el7.x86_64                                                                                 13/16 
  验证中      : libsemanage-2.5-8.el7.x86_64                                                                                  14/16 
  验证中      : policycoreutils-2.5-17.1.el7.x86_64                                                                           15/16 
  验证中      : audit-2.7.6-3.el7.x86_64                                                                                      16/16 

已安装:
  gitlab-ce.x86_64 0:11.4.4-ce.0.el6                                                                                                

作为依赖被安装:
  audit-libs-python.x86_64 0:2.8.1-3.el7_5.1     checkpolicy.x86_64 0:2.5-6.el7                 libcgroup.x86_64 0:0.41-15.el7    
  libsemanage-python.x86_64 0:2.5-11.el7         policycoreutils-python.x86_64 0:2.5-22.el7     python-IPy.noarch 0:0.75-6.el7    
  setools-libs.x86_64 0:3.3.8-2.el7             

作为依赖被升级:
  audit.x86_64 0:2.8.1-3.el7_5.1               audit-libs.x86_64 0:2.8.1-3.el7_5.1          libsemanage.x86_64 0:2.5-11.el7         
  policycoreutils.x86_64 0:2.5-22.el7         

完毕!

 

安装完成之后,打开配置文件 /etc/gitlab/gitlab.rb 将 external_url = 'http://git.example.com' 修改为自己的 IP 地址:external_url 'http://ip_address' ,然后执行下面的命令,对 GitLab 进行编译

gitlab-ctl reconfigure

完成后,使用浏览器访问:http://ip_address 可进入 GitLab 登录页面,首次访问系统会让你重新设置管理员的密码,默认的管理员账号是 root,如果你想更改默认管理员账号,登录系统后可以修改帐号名。

配置端口

GitLab 的相关参数配置都存在 /etc/gitlab/gitlab.rb 文件里。自 GitLab 7.6 开始的新安装包, 已经默认将所有的参数写入到 /etc/gitlab/gitlab.rb配置文件中。

GitLab 默认使用 80 端口对外提供服务,因为 80 端口被其他服务占用,所以需要更改。打开 /etc/gitlab/gitlab.rb 配置文件,修改 external_url 'http://ip_address' 为 external_url 'http://ip_address:new-port'

重新编译配置:

gitlab-ctl reconfigure

这时候就可以通更改后的 IP + 端口号码进行访问了。

邮箱配置

以下是 163 邮箱的配置参考,打开 /etc/gitlab/gitlab.rb 配置文件,添加以下内容:

gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "test@163.com"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['gitlab_email_from'] = "test@163.com"

注意: test@163.com 和 password 更新为自己邮箱地址和密码;邮箱需要开启 SMTP 协议。

重新编译配置即可生效:

gitlab-ctl reconfigure

其它邮箱的配置可参考:https://doc.gitlab.cc/omnibus/settings/smtp.html

 

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        # 查看日志;

 

附上:

清华大学镜像开源站: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

 

本文版权所有,转载请附上原文链接地址https://blog.csdn.net/mu5532123/article/details/83790336


版权声明:本文为mu5532123原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。