码迷,mamicode.com
首页 > 其他好文 > 详细

gitlab

时间:2020-12-01 11:57:47      阅读:3      评论:0      收藏:0      [点我收藏+]

标签:火墙   nal   inux   audit   添加用户   tom   表示   pytho   python3   

gitlab介绍

gitlab部署

  • centos8
  • 关闭防火墙、SElinux
  • gitlab建议在纯净的服务器上部署(因为部署时会安装很多软件,可能影响原服务器上安装的软件)

安装yum源

[root@vm5 yum.repos.d]# yum -y install epel-release
.........................................
Installed:
  epel-release-8-8.el8.noarch                                                  

Complete!
[root@vm5 yum.repos.d]# ls
CentOS-AppStream.repo   CentOS-Extras.repo      CentOS-Vault.repo
CentOS-Base.repo        CentOS-fasttrack.repo   epel-modular.repo
CentOS-centosplus.repo  CentOS-HA.repo          epel-playground.repo
CentOS-CR.repo          CentOS-Media.repo       epel.repo
CentOS-Debuginfo.repo   CentOS-PowerTools.repo  epel-testing-modular.repo
CentOS-Devel.repo       CentOS-Sources.repo     epel-testing.repo

安装git

Git是一个版本控制系统(version control system),是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统.

[root@vm5 ~]# yum -y install git
Installed:
  emacs-filesystem-1:26.1-5.el8.noarch                                                
  git-2.18.4-2.el8_2.x86_64                                                         
  git-core-2.18.4-2.el8_2.x86_64                                                    
  git-core-doc-2.18.4-2.el8_2.noarch                                                
..........................................

安装依赖包

[root@vm5 ~]# yum -y install curl openssh-server openssh-clients postfix cronie
Running transaction
  Preparing        :                                                                1/1 
  Installing       : libicu-60.3-2.el8_1.x86_64                                     1/2 
  Running scriptlet: libicu-60.3-2.el8_1.x86_64                                     1/2 
  Running scriptlet: postfix-2:3.3.1-12.el8.x86_64                                  2/2 
  Installing       : postfix-2:3.3.1-12.el8.x86_64                                  2/2 
  Running scriptlet: postfix-2:3.3.1-12.el8.x86_64                                  2/2 
  Verifying        : libicu-60.3-2.el8_1.x86_64                                     1/2 
  Verifying        : postfix-2:3.3.1-12.el8.x86_64                                  2/2 

Installed:
  libicu-60.3-2.el8_1.x86_64                postfix-2:3.3.1-12.el8.x86_64            
[root@vm5 ~]# yum -y install python3-policycoreutils
.......................................
Installed:
  checkpolicy-2.9-1.el8.x86_64                                                          
  python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                  
  python3-libsemanage-2.9-2.el8.x86_64                                                  
  python3-policycoreutils-2.9-9.el8.noarch                                              
  python3-setools-4.2.2-2.el8.x86_64   
  
[root@vm5 ~]# yum -y install policycoreutils-python-utils

启动postfix服务

[root@vm5 ~]# systemctl enable --now postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
[root@vm5 ~]# ss -antl 
State      Recv-Q     Send-Q         Local Address:Port           Peer Address:Port     
LISTEN     0          128                  0.0.0.0:22                  0.0.0.0:*        
LISTEN     0          100                127.0.0.1:25                  0.0.0.0:*        
LISTEN     0          128                     [::]:22                     [::]:*        
LISTEN     0          100                    [::1]:25                     [::]:*     

安装gitlab RPM包

[root@vm5 opt]# pwd
/opt
[root@vm5 opt]# ls
gitlab-ce-13.6.1-ce.0.el8.x86_64.rpm
[root@vm5 opt]# rpm -ivh gitlab-ce-13.6.1-ce.0.el8.x86_64.rpm 
warning: gitlab-ce-13.6.1-ce.0.el8.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID f27eab47: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:gitlab-ce-13.6.1-ce.0.el8        ################################# [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

修改配置文件

  • /etc/gitlab/gitlab.rb
[root@vm5 opt]# vim /etc/gitlab/gitlab.rb
...............................
external_url ‘http://192.168.225.134‘    ##修改为gitlab服务器地址或域名
................................

重载配置文件并重启gitlab

[root@vm5 opt]# gitlab-ctl reconfigure
[root@vm5 opt]# gitlab-ctl restart 
ok: run: alertmanager: (pid 16607) 0s
ok: run: gitaly: (pid 16621) 0s
ok: run: gitlab-exporter: (pid 16636) 1s
ok: run: gitlab-workhorse: (pid 16640) 0s
ok: run: grafana: (pid 16650) 1s
ok: run: logrotate: (pid 16662) 0s
ok: run: nginx: (pid 16668) 0s
ok: run: node-exporter: (pid 16676) 1s
ok: run: postgres-exporter: (pid 16687) 0s
ok: run: postgresql: (pid 16736) 0s
ok: run: prometheus: (pid 16745) 0s
ok: run: puma: (pid 16855) 1s
ok: run: redis: (pid 16860) 0s
ok: run: redis-exporter: (pid 16865) 1s
ok: run: sidekiq: (pid 16875) 0s
[root@vm5 opt]# ss -antl 
State      Recv-Q     Send-Q         Local Address:Port           Peer Address:Port     
LISTEN     0          511                  0.0.0.0:8060                0.0.0.0:*        
LISTEN     0          1024               127.0.0.1:9121                0.0.0.0:*        
LISTEN     0          1024               127.0.0.1:9090                0.0.0.0:*        
LISTEN     0          1024               127.0.0.1:9187                0.0.0.0:*        
LISTEN     0          1024               127.0.0.1:9093                0.0.0.0:*        
LISTEN     0          1024               127.0.0.1:9100                0.0.0.0:*        
LISTEN     0          1024               127.0.0.1:9229                0.0.0.0:*        
LISTEN     0          1024               127.0.0.1:9168                0.0.0.0:*        
LISTEN     0          511                  0.0.0.0:80                  0.0.0.0:*        
LISTEN     0          1024               127.0.0.1:9236                0.0.0.0:*        
LISTEN     0          128                  0.0.0.0:22                  0.0.0.0:*        
LISTEN     0          1024               127.0.0.1:3000                0.0.0.0:*        
LISTEN     0          100                127.0.0.1:25                  0.0.0.0:*        
LISTEN     0          1024                       *:9094                      *:*        
LISTEN     0          1024                   [::1]:9168                   [::]:*        
LISTEN     0          128                     [::]:22                     [::]:*        
LISTEN     0          100                    [::1]:25                     [::]:*  

查看安装版本

[root@vm5 opt]# head -1 /opt/gitlab/version-manifest.txt 
gitlab-ce 13.6.1

gitlab管理

ip访问gitlab-web页面

  • ip(gitlab服务器地址)
  • 第一次登录需要设置gitlab的root账户密码
    技术图片

技术图片

破解密码

[root@vm5 ~]# gitlab-rails console -e production

--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
 GitLab:       13.6.1 (1b6a590b197) FOSS
 GitLab Shell: 13.13.0
 PostgreSQL:   11.9
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.3)
irb(main):001:0> 
irb(main):002:0> user = User.where(id:1).first    //id=1表示root
=> #<User id:1 @root>
irb(main):003:0> user.password = ‘12345678!‘
=> "12345678!"
irb(main):004:0> user.password_confirmation = ‘12345678!‘
=> "12345678!"
irb(main):005:0> user.save!
Enqueued ActionMailer::MailDeliveryJob (Job ID: 616ad49a-74b0-4a65-a711-ecb501081022) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007fcce10224d8 @uri=#<URI::GID gid://gitlab/User/1>>]}
=> true                                       //true表示设置成功
irb(main):007:0> exit

中文界面设置

技术图片

技术图片

用户管理

用户注册限制

技术图片

添加用户

技术图片

技术图片

技术图片

技术图片

管理用户

技术图片

创建成员组

技术图片

技术图片

技术图片

项目管理

  • tom 账户登录

技术图片

技术图片

技术图片

创建新仓库

[root@vm5 ~]# git clone http://192.168.225.134/helloworld/hello.git
Cloning into ‘hello‘...
Username for ‘http://192.168.225.134‘: tom
Password for ‘http://tom@192.168.225.134‘: 
warning: You appear to have cloned an empty repository.
[root@vm5 ~]# cd hello
[root@vm5 hello]# ls
[root@vm5 hello]# pwd
/root/hello
[root@vm5 hello]# touch README.md
[root@vm5 hello]# echo ‘hello world!‘ >> README.md 

推送仓库

[root@vm5 ~]# cd hello/
[root@vm5 hello]# ls
README.md
[root@vm5 hello]# git remote rename origin old-origin
[root@vm5 hello]# git remote add origin http://192.168.225.134/helloworld/hello.git

gitlab

标签:火墙   nal   inux   audit   添加用户   tom   表示   pytho   python3   

原文地址:https://www.cnblogs.com/fyjpeng/p/14040474.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!