代码编织梦想

gitlab

gitlab介绍

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的Web服务。安装方法是参考GitLab在GitHub上的Wiki页面。Gitlab是目前被广泛使用的基于git的开源代码管理平台, 基于Ruby on Rails构建, 主要针对软件开发过程中产生的代码和文档进行管理, Gitlab主要针对group和project两个维度进行代码和文档管理, 其中group是群组, project是工程项目, 一个group可以管理多个project, 可以理解为一个群组中有多项软件开发任务, 而一个project中可能包含多个branch, 意为每个项目中有多个分支, 分支间相互独立, 不同分支可以进行归并

gitllab特点

1.Web框架使用RubyonRails。
2.基于MIT代码发布协议。
3.需要gitolite协同工作。

gitlab部署

//关闭防火墙和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config

//安装epel
[root@loaclhost ~]# dnf -y install epel-release
 
//安装依赖包
[root@localhost ~]# dnf -y install git wget curl openssh-server openssh-clients postfix cronie

 //下载或上传policycoreutils-python和gitlab包
[root@localhost ~]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm
--2022-09-22 23:19:28--  http://mirror.centos.org/centos/7/os/x86_64/Packages/policycoreutils-python-2.5-34.el7.x86_64.rpm
Resolving mirror.centos.org (mirror.centos.org)... 147.75.93.85, 2401:78c0::e00e
Connecting to mirror.centos.org (mirror.centos.org)|147.75.93.85|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 468316 (457K) [application/x-rpm]
Saving to: ‘policycoreutils-python-2.5-34.el7.x86_64.rpm’

policycoreutils-pyt 100%[===================>] 457.34K   347KB/s    in 1.3s    

2022-09-22 23:19:30 (347 KB/s) - ‘policycoreutils-python-2.5-34.el7.x86_64.rpm’ saved [468316/468316]

[root@localhost ~]# cd /usr/src/
[root@localhost src]# ls
debug  kernels
[root@localhost src]# ls
debug  gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm  kernels

//安装gitlab
[root@localhost ~]# rpm -qa |grep policy
selinux-policy-3.14.3-58.el8.noarch
policycoreutils-2.9-9.el8.x86_64
selinux-policy-targeted-3.14.3-58.el8.noarch
[root@localhost ~]# rpm -e policycoreutils-2.9-9.el8.x86_64 --nodeps
[root@localhost ~]# rpm -ivh policycoreutils-python-2.5-34.el7.x86_64.rpm --nodeps
warning: policycoreutils-python-2.5-34.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:policycoreutils-python-2.5-34.el7################################# [100%]
ps
warning: policycoreutils-python-2.5-34.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
	package policycoreutils-python-2.5-34.el7.x86_64 is already installed
[root@localhost ~]# rpm -ivh gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm --nodeps
warning: gitlab-ce-15.3.3-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:gitlab-ce-15.3.3-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=15-3

//修改配置文件
[root@loaclhost ~]# vim /etc/gitlab/gitlab.rb 
external_url 'http://192.168.205.150'        //修改此处为本机ip或域名

//重载配置文件并重启gitlab
[root@localhost ~]# gitlab-ctl reconfigure
.....................................
[root@localhost ~]# gitlab-ctl restart
ok: run: alertmanager: (pid 16617) 0s
ok: run: gitaly: (pid 16625) 0s
ok: run: gitlab-exporter: (pid 16637) 0s
ok: run: gitlab-kas: (pid 16639) 0s
ok: run: gitlab-workhorse: (pid 16651) 1s
ok: run: logrotate: (pid 16661) 0s
ok: run: nginx: (pid 16667) 1s
ok: run: node-exporter: (pid 16672) 0s
ok: run: postgres-exporter: (pid 16676) 0s
ok: run: postgresql: (pid 16783) 0s
ok: run: prometheus: (pid 16792) 1s
ok: run: puma: (pid 16805) 0s
ok: run: redis: (pid 16810) 0s
ok: run: redis-exporter: (pid 16816) 1s
ok: run: sidekiq: (pid 16824) 0s

//查看当前的gitlab版本
[root@localhost ~]# head -1 /opt/gitlab/version-manifest.txt
gitlab-ce 15.3.3

//破解管理员密码
[root@localhost ~]# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
 GitLab:       15.3.3 (c629a47f87f) FOSS
 GitLab Shell: 14.10.0
 PostgreSQL:   13.6
------------------------------------------------------------[ booted in 26.31s ]
Loading production environment (Rails 6.1.6.1)
irb(main):001:0> user = User.where(id: 1).first
=> #<User id:1 @root>
irb(main):002:0> user.password = 'jiang123!'
=> "jiang123!"
irb(main):003:0> user.password_confirmation = 'jiang123!'
=> "jiang123!"
irb(main):004:0> user.save!
=> true
irb(main):005:0> exit

//设置服务开机自启
[root@localhost ~]# which gitlab-ctl
/usr/bin/gitlab-ctl
[root@localhost ~]# chmod +x /etc/rc.d/rc.local 
[root@localhost ~]# echo "/usr/bin/gitlab-ctl start " >> /etc/rc.d/rc.local 
[root@localhost ~]# cat /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local

/usr/bin/gitlab-ctl start 

gitlab管理

在浏览器中使用gitlab服务器的ip访问,页面如下图所示

请添加图片描述

管理页面如下图所示
请添加图片描述

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/m0_72915775/article/details/127002437