【CentOS-7.4】gitlab

【CentOS-7.4】gitlab

参考:

https://about.gitlab.com/

https://docs.gitlab.com/


【GitLab 介绍】
GitLab 是一个基于 Git 实现的在线代码仓库托管软件,你可以用 gitlab 自己搭建一个类似于 Github 一样的系统,一般用于在企业、学校等内部网络搭建 git 私服。
功能:Gitlab 是一个提供代码托管、提交审核和问题跟踪的代码管理平台。对于软件工程质量管理非常重要。
版本:GitLab 分为社区版(CE) 和企业版(EE)。
配置:建议CPU2核,内存2G以上。

Gitlab 的服务构成:
Nginx:静态 web 服务器。
gitlab-shell:用于处理 Git 命令和修改 authorized keys 列表。(Ruby)
gitlab-workhorse: 轻量级的反向代理服务器。(go)

GitLab Workhorse 是一个敏捷的反向代理。它会处理一些大的 HTTP 请求,比如文件上传、文件下载、Git push/pull 和 Git 包下载。其它请求会反向代理到 GitLab Rails 应用,即反向代理给后端的 unicorn。

logrotate:日志文件管理工具。
postgresql:数据库。
redis:缓存数据库。
sidekiq:用于在后台执行队列任务(异步执行)。(Ruby)
unicorn:An HTTP server for Rack applications,GitLab Rails 应用是托管在这个服务器上面的。(Ruby Web Server,主要使用 Ruby 编写)


【下载】文件

# 官方源,比较慢
wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-12.7.5-ce.0.el7.x86_64.rpm/download.rpm

或者

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

# 国内源,快
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.7.5-ce.0.el7.x86_64.rpm

或者

# 添加 gitlab 源
vi /etc/yum.repos.d/gitlab-ce.repo

[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

# 安装
yum makecache
yum install gitlab-ce -y

【安装】

# 
yum install gitlab-ce-12.7.5-ce.0.el7.x86_64.rpm 


Loaded plugins: fastestmirror
Examining gitlab-ce-12.7.5-ce.0.el7.x86_64.rpm: gitlab-ce-12.7.5-ce.0.el7.x86_64
Marking gitlab-ce-12.7.5-ce.0.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package gitlab-ce.x86_64 0:12.7.5-ce.0.el7 will be installed
--> Processing Dependency: policycoreutils-python for package: gitlab-ce-12.7.5-ce.0.el7.x86_64
Loading mirror speeds from cached hostfile
gitlab_gitlab-ce/x86_64/signature                                                                             |  836 B  00:00:00     
gitlab_gitlab-ce/x86_64/signature                                                                             | 1.0 kB  00:00:00 !!! 
gitlab_gitlab-ce-source/signature                                                                             |  836 B  00:00:00     
gitlab_gitlab-ce-source/signature                                                                             |  951 B  00:00:00 !!! 
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-33.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-33.el7.x86_64
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
 Package                           Arch              Version                      Repository                                    Size
=====================================================================================================================================
Installing:
 gitlab-ce                         x86_64            12.7.5-ce.0.el7              /gitlab-ce-12.7.5-ce.0.el7.x86_64            1.5 G
Installing for dependencies:
 audit-libs-python                 x86_64            2.8.5-4.el7                  base                                          76 k
 checkpolicy                       x86_64            2.5-8.el7                    base                                         295 k
 libcgroup                         x86_64            0.41-21.el7                  base                                          66 k
 libsemanage-python                x86_64            2.5-14.el7                   base                                         113 k
 policycoreutils-python            x86_64            2.5-33.el7                   base                                         457 k
 python-IPy                        noarch            0.75-6.el7                   base                                          32 k
 setools-libs                      x86_64            3.3.8-4.el7                  base                                         620 k

Transaction Summary
=====================================================================================================================================
Install  1 Package (+7 Dependent packages)

Total size: 1.5 G
Installed size: 1.5 G
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                   1/8 
  Installing : libcgroup-0.41-21.el7.x86_64                                                                                      2/8 
  Installing : audit-libs-python-2.8.5-4.el7.x86_64                                                                              3/8 
  Installing : libsemanage-python-2.5-14.el7.x86_64                                                                              4/8 
  Installing : python-IPy-0.75-6.el7.noarch                                                                                      5/8 
  Installing : checkpolicy-2.5-8.el7.x86_64                                                                                      6/8 
  Installing : policycoreutils-python-2.5-33.el7.x86_64                                                                          7/8 
  Installing : gitlab-ce-12.7.5-ce.0.el7.x86_64                                                                                  8/8 
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

  Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                      1/8 
  Verifying  : policycoreutils-python-2.5-33.el7.x86_64                                                                          2/8 
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                      3/8 
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                              4/8 
  Verifying  : gitlab-ce-12.7.5-ce.0.el7.x86_64                                                                                  5/8 
  Verifying  : audit-libs-python-2.8.5-4.el7.x86_64                                                                              6/8 
  Verifying  : libcgroup-0.41-21.el7.x86_64                                                                                      7/8 
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                   8/8 

Installed:
  gitlab-ce.x86_64 0:12.7.5-ce.0.el7                                                                                                 

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.5-4.el7       checkpolicy.x86_64 0:2.5-8.el7                   libcgroup.x86_64 0:0.41-21.el7      
  libsemanage-python.x86_64 0:2.5-14.el7       policycoreutils-python.x86_64 0:2.5-33.el7       python-IPy.noarch 0:0.75-6.el7      
  setools-libs.x86_64 0:3.3.8-4.el7           

Complete!

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 配置文件

# 先关闭 gitlab 服务
gitlab-ctl stop

# gitlab 默认监听 80 端口,修改服务器自定义端口

# 第一处 
vi /opt/gitlab/embedded/conf/nginx.conf

     36         listen       666;
     37         server_name  localhost;

# 第二处
vi /etc/gitlab/gitlab.rb

     29 # external_url 'http://gitlab.example.com'
                # 将 external_url 变量的地址修改为 gitlab 所在 centos 的 ip 地址
     30         external_url 'http://8.8.8.8'

    765 ### Advanced settings
    766 # unicorn['listen'] = 'localhost'
    767 unicorn['port'] = 666
    768 # unicorn['socket'] = '/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket'
    769 # unicorn['pidfile'] = '/opt/gitlab/var/unicorn/unicorn.pid'
    770 # unicorn['tcp_nopush'] = true
    771 # unicorn['backlog_socket'] = 1024

【重新配置】

gitlab-ctl reconfigure

【重启】

gitlab-ctl restart

常用命令

# 启动所有 gitlab 组件;
gitlab-ctl start

# 停止所有 gitlab 组件;
gitlab-ctl stop 

# 重启所有 gitlab 组件;
gitlab-ctl restart

# 查看服务状态;
gitlab-ctl status

# 启动服务;
gitlab-ctl reconfigure

# 修改默认的配置文件;
vi /etc/gitlab/gitlab.rb

# 检查gitlab;
gitlab-rake gitlab:check SANITIZE=true --trace

# 查看日志;
gitlab-ctl tail

【参考】

https://www.jianshu.com/p/7a1b1cb86d8d

发布了15 篇原创文章 · 获赞 4 · 访问量 2922

猜你喜欢

转载自blog.csdn.net/qu6zhi/article/details/104163308