GitLab (v16.x) 简述及安装部署
GitLab 介绍
GitLab 的历史
- GitLab 最初是一个完全免费的开源软件,根据 MIT 许可证分发。2013 年 7 月,它被分为两个不同的版本 - GitLab CE(社区版)和 GitLab EE(企业版)。GitLab EE 处于受限许可证下,但源代码仍然公开可见,而 GitLab CE 许可模型保持不变。2017 年,GitLab 宣布他们的代码将在 MIT 许可证下完全开源。
为什么使用 GitLab?
GitLab是在集中式服务器上管理git仓库的好方法。GitLab让你完全控制你的仓库或项目,并允许你免费决定它们是公开还是私有的。
使用 GitLab 的主要好处是它允许所有团队成员在项目的每个阶段进行协作。GitLab 提供从规划到创建的跟踪,帮助开发人员自动化整个 DevOps 生命周期并实现最佳结果。越来越多的开发人员开始使用 GitLab,因为它具有广泛的功能和可用的代码块。
Git,GitHub 与 GitLab 的区别
Git是一种版本控制系统,是一种工具,用于跟踪修改和从远程资源推送或拉取代码的版本控制。
GitHub是一个目前全球最大的基于Git实现的在线代码仓库托管平台,是一个公开的、免费的服务,它要求所有的代码(除非你有一个付费账户)都是公开的。任何人都可以看到你推送到GitHub的代码,并提供改进建议。
GitLab是一个基于Git实现的在线代码仓库软件,你可以用GitLab自己搭建一个类似于GitHub一样的仓库,但是GitLab有完善的管理界面和权限控制,一般用于在企业、学校等内部网络搭建Git私服。
GitHub和GiLlab两个都是基于Web的Git远程仓库,它们都提供了分享开源项目的平台,为开发团队提供了存储、分享、发布和合作开发项目的中心化云存储的场所。从代码的私有性上来看,GitLab 是一个更好的选择。但是对于开源项目而言,GitHub 依然是代码托管的首选。
特点
GitLab免费托管您的(私有)软件项目。
GitLab是一个管理 Git 仓库的平台。
GitLab提供免费的公共和私有仓库、问题跟踪和维基。
GitLab是一个建立在Git之上的用户友好的网络界面层,它提高了使用Git的速度。
GitLab提供了自己的 持续集成 (CI)系统来管理项目,并提供用户界面和GitLab的其他功能。
优势
GitLab提供了 GitLab社区版 ,用户可以定位他们的代码在哪个服务器上。
GitLab免费提供无限数量的私有和公共仓库。
Snippet 部分可以分享一个项目中的少量代码,而不是分享整个项目。
缺点
在推送和提取仓库时,它没有GitHub快。
GitLab的界面在从一个页面切换到另一个页面时需要时间。
先决条件
建议使用至少具有以下各项的服务器:
- CPU 4 核是建议的最小核心数,最多支持500个用户。
- 内存 4 GB RAM 是所需的最小内存大小,最多支持500个用户。
GitLab 还要求文件系统准备好用于存储 Git 仓库和各种其它文件。
请注意,如果您使用 NFS(网络文件系统),文件将通过网络传输,根据实现,该网络需要打开端口 111 和 2049
GitLab 架构图
Gitlab组件:
repository
:代码库,可以是硬盘或 分布式文件系统。Nginx
:Web 入口。gitlab-workhorse
:轻量级反向代理服务器,可以处理一些大的HTTP请求(磁盘上的 CSS、JS 文件、文件上传下载等),处理 Git Push/Pull 请求,处理到Rails 的连接会反向代理给后端的unicorn(修改由 Rails 发送的响应或发送给 Rails 的请求,管理 Rails 的长期 WebSocket 连接等)。gitlab-shell
:用于 SSH 交互,而不是 HTTP。gitlab-shell 通过 Redis 与 Sidekiq 进行通信,并直接或通过 TCP 间接访问 Unicorn。用于处理Git命令和修改authorized keys列表。Unicorn
:Gitlab 自身的 Web 服务器(Ruby Web Server),包含了 Gitlab 主进程,负责处理快速/一般任务,与 Redis 一起工作,配置参考:CPU核心数 + 1 = unicorn workers数量。工作内容包括:通过检查存储在 Redis 中的用户会话来检查权限。
为 Sidekiq 制作任务。
从仓库(warehouse)取东西或在那里移动东西。
Redis
:缓存每个客户端的sessions和后台队列,负责分发任务。Redis需求的存储空间很小,大约每个用户25KB。Gitaly
:后台服务,专门负责访问磁盘以高效处理 gitlab-shell 和 gitlab-workhorse 的git 操作,并缓存耗时操作。所有的 git 操作都通过 Gitaly 处理,并向 GitLab web 应用程序提供一个 API,以从 git(例如 title, branches, tags, other meta data)获取属性,并获取 blob(例如 diffs,commits,files)。Sidekiq
:后台核心服务,可以从redis队列中提取作业并对其进行处理。后台作业允许GitLab通过将工作移至后台来提供更快的请求/响应周期。Sidekiq任务需要来自Redis。数据库(PostgreSQL/MySQL)
:包含以下信息:repository 中的数据(元数据,issue,合并请求 merge request 等)。
可以登录 Web 的用户(权限)。
mail_room
:处理邮件请求。回复 GitLab 发出的邮件时,GitLab 会调用此服务处理Sidekiq、Unicorn 和 GitLab-shell 的任务 。logrotate
:日志文件管理,切割。
组件操作命令
# nginx
gitlab-ctl start|stop|restart|status nginx
# unicorn
gitlab-ctl start|stop|restart|status unicorn
# sidekiq
gitlab-ctl start|stop|restart|status sidekiq
# postgresql
gitlab-ctl start|stop|restart|status postgresql
# redis
gitlab-ctl start|stop|restart|status redis
# gitlab
gitlab-ctl start|stop|restart|status|reconfigure
# supervisor
systemctl start|stop|restart|status gitlab-runsvdir.service
GitLab部署过程
准备环境
[root@GitServer ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@GitServer ~]# uname -r
3.10.0-1160.el7.x86_64
[root@GitServer ~]# setenforce 0
[root@GitServer ~]# sed -i.bak '7s/enforcing/disabled/' /etc/selinux/config
[root@GitServer ~]# systemctl stop firewalld
[root@GitServer ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@GitServer ~]# firewall-cmd --state
not running
安装
[root@GitLabServer ~]# yum install -y curl policycoreutils-python openssh-server perl postfix wget
[root@GitLabServer ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-16.4.2-ce.0.el7.x86_64.rpm
[root@GitLabServer ~]# yum localinstall gitlab-ce-16.4.2-ce.0.el7.x86_64.rpm
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. # 注意:设置external_url
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=16-0
Verifying : gitlab-ce-16.4.2-ce.0.el7.x86_64 1/1
Installed:
gitlab-ce.x86_64 0:16.4.2-ce.0.el7
Complete!
修改GitLab配置
[root@GitLabServer ~]# hostname -I
172.16.70.191
[root@GitLabServer ~]# cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb_bak
[root@GitLabServer ~]# diff /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb_bak
32c32
# 例如1:external_url 'http://IP' # 默认端口80
# 例如2:external_url 'http://IP:PORT'
< external_url 'http://172.16.70.191:91' # 修改此行内容, 设置为本机IP:PORT
---
> external_url 'http://gitlab.example.com'
# 重载配置
[root@GitLabServer ~]# gitlab-ctl reconfigure
可选设置
# 启动ssh服务&设置为开机启动
systemctl enable sshd && sudo systemctl start sshd
# 设置postfix开机自启,并启动,postfix支持gitlab发信功能
systemctl enable postfix && systemctl start postfix
# 如系统防火墙是开启状态,则需设置允许策略
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --zone=public --add-port=PORT/tcp --permanent
systemctl reload firewalld
查看GitLab版本信息
[root@GitLabServer ~]# gitlab-rake gitlab:env:info
System information
System:
Current User: git
Using RVM: no
Ruby Version: 3.0.6p216
Gem Version: 3.4.19
Bundler Version:2.4.19
Rake Version: 13.0.6
Redis Version: 7.0.13
Sidekiq Version:6.5.7
Go Version: unknown
GitLab information
Version: 16.4.2
Revision: 67c88353b76
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 13.11
URL: http://172.16.70.191:91
HTTP Clone URL: http://172.16.70.191:91/some-group/some-project.git
SSH Clone URL: git@172.16.70.191:some-group/some-project.git
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 14.28.0
Repository storages:
- default: unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Gitaly
- default Address: unix:/var/opt/gitlab/gitaly/gitaly.socket
- default Version: 16.4.2
- default Git Version: 2.42.0
Gitlab目录结构
/opt/gitlab/ # 主目录
/etc/gitlab/ # 放置配置文件
/var/opt/gitlab/ # 各个组件
/var/log/gitlab/ # 放置日志文件
/var/opt/gitlab/git-data/repositories # 数据库的地址
/var/opt/gitlab/postgresql/data # gitlab组和项目的地址
/etc/gitlab/gitlab.rb # gitlab配置文件
端口信息
[root@GitLabServer ~]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9229 0.0.0.0:* LISTEN 2637/gitlab-workhor
tcp 0 0 127.0.0.1:9168 0.0.0.0:* LISTEN 2653/ruby
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 2222/puma 6.3.1 (un
tcp 0 0 0.0.0.0:91 0.0.0.0:* LISTEN 2330/nginx: master # 对应前面设置external_url PORT
tcp 0 0 127.0.0.1:8082 0.0.0.0:* LISTEN 2252/sidekiq_export
tcp 0 0 127.0.0.1:9236 0.0.0.0:* LISTEN 2599/gitaly
tcp 0 0 127.0.0.1:8150 0.0.0.0:* LISTEN 2626/gitlab-kas
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1270/sshd
tcp 0 0 127.0.0.1:8151 0.0.0.0:* LISTEN 2626/gitlab-kas
tcp 0 0 127.0.0.1:8153 0.0.0.0:* LISTEN 2626/gitlab-kas
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 875/master
tcp 0 0 127.0.0.1:8154 0.0.0.0:* LISTEN 2626/gitlab-kas
tcp 0 0 127.0.0.1:8155 0.0.0.0:* LISTEN 2626/gitlab-kas
tcp 0 0 127.0.0.1:8092 0.0.0.0:* LISTEN 2250/sidekiq 6.5.7
tcp 0 0 0.0.0.0:8060 0.0.0.0:* LISTEN 2330/nginx: master
tcp 0 0 127.0.0.1:9121 0.0.0.0:* LISTEN 2655/redis_exporter
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 2662/prometheus
tcp 0 0 127.0.0.1:9187 0.0.0.0:* LISTEN 2688/postgres_expor
tcp 0 0 127.0.0.1:9093 0.0.0.0:* LISTEN 2678/alertmanager
tcp 0 0 127.0.0.1:9100 0.0.0.0:* LISTEN 2647/node_exporter
tcp6 0 0 ::1:9168 :::* LISTEN 2653/ruby
tcp6 0 0 :::22 :::* LISTEN 1270/sshd
tcp6 0 0 ::1:25 :::* LISTEN 875/master
tcp6 0 0 :::9094 :::* LISTEN 2678/alertmanager
GitLab 密码
获取初始登录密码,默认登录账号:root
设置初始密码:GitLab 14.0 开始引入。
默认情况下,Linux 软件包安装会自动为初始管理员用户账号 (root) 生成密码,并将其存储到 /etc/gitlab/initial_root_password 至少 24 小时。出于安全原因,24 小时后,此文件会被第一次 gitlab-ctl reconfigure 自动删除。
[root@GitLabServer ~]# grep Password: /etc/gitlab/initial_root_password
Password: JPbE/qElViuH3O1REgsnA+9hB669393vA0f19NAe8RY=
设置简体中文
其他设置
禁用注册
默认情况下,任何访问您的极狐GitLab 域名的用户都可以注册一个账户。对于运行面向公众的极狐GitLab 实例的客户,如果您不希望公众用户注册账户,我们强烈建议您考虑禁用新注册。
要禁用注册:
在左侧边栏中,选择 搜索或转到。
选择 管理中心。
选择 设置 > 通用。
展开 注册限制。
清除 已启用注册功能 复选框,然后选择 保存修改。
重置/修改root密码
使用Rake任务:GitLab 13.9 开始引入。
密码长度设置为最少8个字符,且必须符合复杂性要求。
[root@GitLabServer ~]# gitlab-rake "gitlab:password:reset[root]"
Enter password: # 输入新密码
Confirm password: # 再次输入
Password successfully updated for user with username root.
防止新用户创建顶级群组
# 编辑 /etc/gitlab/gitlab.rb 并添加以下行:
gitlab_rails['gitlab_default_can_create_group'] = false
gitlab-ctl reconfigure
gitlab-ctl restart
防止用户更改其用户名
默认情况下,新用户可以更改他们的用户名。要禁用您的用户更改其用户名的能力:
编辑 /etc/gitlab/gitlab.rb 并添加以下行:
gitlab_rails['gitlab_username_changing_enabled'] = false
gitlab-ctl reconfigure
gitlab-ctl restart
GitLab (v16.x) 简述及安装部署的更多相关文章
- DevOps实践之Gitlab安装部署
All GitLab packages are posted to our package server and can be downloaded. We maintain five repos: ...
- [转]Centos 7 安装部署 GitLab 服务器
Centos 7 安装部署 GitLab 服务器 转自:https://www.jianshu.com/p/79bfded68899 文前说明 作为码农中的一员,需要不断的学习,我工作之余将一些分析总 ...
- gitlab安装部署汉化
1.获取gitlab汉化包(要部署非汉化版,可以跳过这一块内容) 说明:gitlab中文社区版的项目,v7-v8.8是由Larry Li发起的“GitLab 中文社区版项目”(https://gitl ...
- 一、CentOS 7安装部署GitLab服务器
一.CentOS 7安装部署GitLab服务器 1.安装依赖软件 yum -y install policycoreutils policycoreutils-python openssh-serve ...
- 一文搞懂GitLab安装部署及服务配置
GitLab安装部署 Git,GitHub,GitLab,这三个东东长得好像呀,都是个啥? Git是Linus Torvalds(如果不知道这位大神是谁,请出门左转,慢走不送~)为了帮助管理Linux ...
- Centos7安装部署搭建gitlab平台、汉化
Centos7安装部署搭建gitlab平台.汉化 安装环境要求:内存不要小于4G,否则后期web界面可能会报错 一.准备工作 1.1 查看系统版本 首先查询系统版本,下载Gitlab的对应版本 [ro ...
- centos7安装部署gitlab服务器
[gitlab需要内存至少4GB] 我这里使用的是centos 7 64bit,我试过centos 6也是可以的! 1. 安装依赖软件 yum -y install policycoreutils ...
- centos下gitlab私服完整安装部署(nginx+MySQL+redis+gitlab-ce+gitlab-shell+)
系统环境cat /etc/redhat-release CentOS release 6.8 (Final) nginx -vnginx version: nginx/1.9.15 redis-cli ...
- 二、CentOS 7安装部署GitLab服务器(解决邮箱发信问题)
一.环境安装(10.0.0) 1.安装依赖软件 yum -y install policycoreutils policycoreutils-python openssh-server openssh ...
- centos 安装 部署 gitlab github
https://www.cnblogs.com/wenwei-blog/p/5861450.html 我这里使用的是centos 7 64bit,我试过centos 6也是可以的! 1. 安装依赖软件 ...
随机推荐
- 推荐一款接口自动化测试数据提取神器 JSonPath
在之前分享中,给大家介绍过一篇:如何快速审核接口返回值全部字段解决方案,详见原文:接口自动化测试,一键快速校验接口返回值全部字段 .当时,提到解决这类问题,市面上常见的解决方案有两种: 根据业务校验需 ...
- Mygin上下文之sync.Pool复用
sync.Pool 的作用 先看看官方文档怎样说的吧,我截取了官方文档的第一句. // A Pool is a set of temporary objects that may be individ ...
- PHP中GD库
PHP中GD库 一.GD库的介绍 1.GD库是什么? Graphic Device,图像工具库,gd库是php处理图形的扩展库,GD库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成 ...
- 一文详解应用安全防护ESAPI
本文分享自华为云社区<应用安全防护ESAPI>,作者: Uncle_Tom. 1. ESAPI 简介 OWASP Enterprise Security API (ESAPI)是一个免费. ...
- 24.3 向量化异常VEH--《Windows核心编程》
Windows 提供了向量化异常处理(vectored excepation handing,VEH)机制.程序可以注册一个函数,每当异常发送或者一个未处理异常脱离标准SEH的控制时,这个函数就会被调 ...
- FDConnection的事务测试讲解。。
总之用事务的宗旨是: 1.不用嵌套事务EnableNested设置为False 2.事务一定要回滚,避免发生异常的情况下,没有回滚 造成,不可估量的错误. try frmClientDm.MyMain ...
- 错误发布--如何配置最新的JDK21
如何配置最新的JDK21 时间:2024/2/3 官网 www.oracle.com 找到对应版本JDK21 可选择语言翻译版本 根据需求选择合适JDK版本.操作系统.位数 三个安装包格式:最简洁的是 ...
- Linux进程与线程的基本概念及区别
前言 假设你正在玩一款在线多人游戏,在游戏中,有多个角色需要进行不同的操作,例如攻击.移动.释放技能等等. 接下来,我们用玩游戏的例子,来解释进程和和线程的概念,以及进程和线程的区别. 进程的基本概念 ...
- Git实战系列教程
介绍 本文详细记录了Git一系列核心概念和工作中常用的操作命令,通篇以实际出发拒绝过度理论,值得典藏:). 概念 版本管理系统 版本控制是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的 ...
- Java中交换2个变量的三种方式
这一题是我之前找Java工作时的笔试题,比较有代表性,拿出来和大家分享. package com.dylan.practice.interview; /** * 交换2个整形变量的几种方式 * * @ ...