linux环境搭建私有gitlab仓库

news2024/9/24 21:19:59
  1. 搭建之前,需要安装相应的依赖包,并且要启动sshd服务

(1).安装policycoreutils-python openssh-server openssh-clients

[root@VM-0-2-centos ~]# sudo yum install -y curl policycoreutils-python openssh-server openssh-clients 
[root@VM-0-2-centos ~]# sudo systemctl enable sshd 
[root@VM-0-2-centos ~]# sudo systemctl start sshd 

(2).在安装时可能会报错

在安装yum install -y curl policycoreutils-python openssh-server openssh-clients时可能会报如下错误:
Error: Unable to find a match: policycoreutils-python
产生这个错误的原因是未配置yum源,所以需要安装 EPEL 源,命令如下:
[root@VM-0-2-centos ~]# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

然后运行

[root@VM-0-2-centos ~]# yum install -y curl policycoreutils-python3 openssh-server openssh-clients

(3).安装postfix

gitlab配置需要用到邮件发送,所以需要安装postfix
[root@VM-0-2-centos ~]# yum -y install postfix
#安装完之后,启动postfix
[root@VM-0-2-centos ~]# systemctl start postfix
启动过程中如果报错:Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.
解决办法,vim打开/etc/postfix/main.cf, 修改如下两项,修改之前可以先备份:
#修改 /etc/postfix/main.cf的设置  
inet_protocols = ipv4  
inet_interfaces = all
修改完成后,再次启动,就不会报错了,设置postfix为开机自启动
[root@VM-0-2-centos ~]# systemctl enable postfix
查看启动状态
[root@VM-0-2-centos ~]# systemctl status postfix

2.gitlab安装

centos系统的下载地址: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
找最新版去下载 gitlab-ce-15.8.3-ce.0.el7.x86_64.rpm
下载rpm包并安装
[root@VM-0-2-centos ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.8.3-ce.0.el7.x86_64.rpm
[root@VM-0-2-centos ~]# mkdir /usr/local/gitlab
[root@VM-0-2-centos ~]# mv gitlab-ce-15.8.3-ce.0.el7.x86_64.rpm /usr/local/gitlab/
[root@VM-0-2-centos ~]# cd /usr/local/gitlab/
[root@VM-0-2-centos ~]# rpm -i itlab-ce-15.8.3-ce.0.el7.x86_64.rpm 
[root@VM-0-2-centos ~]#  warning: itlab-ce-15.8.3-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
[root@VM-0-2-centos ~]# error: Failed dependencies:
    policycoreutils-python is needed by itlab-ce-15.8.3-ce.0.el7.x86_64.rpm
# 如果出现上面这个报错就执行yum install policycoreutils-python

如果运行上面的yum install policycoreutils-python命令还是报错,解决办法:

可以在安装rpm包命令的后面加两个参数,如:

[root@VM-0-2-centos ~]# rpm -i itlab-ce-15.8.3-ce.0.el7.x86_64.rpm --nodeps --force
--force是强制安装
--nodeps是不依赖关系
加上那两个参数的意义就在于,
安装时不再分析包之间的依赖关系而直接安装,
也就不会再提示error: Failed dependencies:这样的错误了

上述 rpm -i itlab-ce-15.8.3-ce.0.el7.x86_64.rpm --nodeps --force命令成功后展示如下:

warning: gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
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官方文档地址https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

3.配置并启动gitlab-ce

gitlab安装完成后,需要设置一个访问地址(或域名),打开/etc/gitlab/gitlab.rb,将默认的external_url = 'http://git.example.com'修改为自己的IP地址:http://xxx.xx.xxx
[root@VM-0-2-centos ~]# vim /etc/gitlab/gitlab.rb

原来默认的external_url

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'http://git.example.com'

修改成自己定义的url地址,端口自己设置一个,别和已有的冲突了

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'http://152.26.xx.xx:8181'

修改完成后:wq保存退出,执行以下命令,让配置生效

[root@VM-0-2-centos ~]# gitlab-ctl reconfigure

启动Gitlab

[root@VM-0-2-centos ~]# gitlab-ctl start
[root@VM-0-2-centos ~]# gitlab-ctl start
ok: run: gitaly: (pid 6638) 186s
ok: run: gitlab-monitor: (pid 6656) 186s
ok: run: gitlab-workhorse: (pid 6659) 186s
ok: run: logrotate: (pid 6703) 185s
ok: run: nginx: (pid 6709) 185s
ok: run: node-exporter: (pid 6715) 184s
ok: run: postgres-exporter: (pid 6720) 184s
ok: run: postgresql: (pid 7324) 44s
ok: run: prometheus: (pid 6752) 171s
ok: run: redis: (pid 6761) 171s
ok: run: redis-exporter: (pid 6765) 170s
ok: run: sidekiq: (pid 7299) 45s
ok: run: unicorn: (pid 7476) 18s

启动完成后,在浏览器输入http://152.26.xx.xx:8181,就是gitlab的登录首页了

重启下服务,刷新页面就可以访问了

[root@VM-0-2-centos ~]# gitlab-ctl restart

为了避免8080端口冲突问题,可以修改下unicorn的默认端口,vim打开/etc/gitlab/gitlab.rb配置文件,新增一项unicorn['port'] = 8101

## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url 'http://152.26.xx.xx:8181'

unicorn['port'] = 8101

修改完成后:wq保存退出,执行gitlab-ctl reconfigure命令,让配置生效,再重新启动服务

[root@VM-0-2-centos ~]# gitlab-ctl reconfigure
[root@VM-0-2-centos ~]# gitlab-ctl stop
[root@VM-0-2-centos ~]# gitlab-ctl start
gitlab常用命令
启动服务:gitlab-ctl start
查看状态:gitlab-ctl status
停掉服务:gitlab-ctl stop
重启服务:gitlab-ctl restart
让配置生效:gitlab-ctl reconfigure

当运行命令gitlab-ctl reconfigure时,如果报错:STDERR: initdb: error: invalid locale settings; check LANG and L...,这是默认字符集问题

There was an error running gitlab-ctl reconfigure:

execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8] (postgresql::enable line 49) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.
STDERR: initdb: error: invalid locale settings; check LANG and LC_* environment variables
---- End output of /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 ----
Ran /opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8 returned 1

解决办法

  1. 确保服务器内存在4G以上

  1. 修改配置

vim /etc/profile
# 将以下内容添加到配置文件末尾
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# 重读环境变量
[root@localhost src]# source /etc/profile
# 重新加载
[root@localhost src]# gitlab-ctl reconfigure
第一次进入最好修改密码

4.搭建GItLab以后出现卡顿

(1).原因分析

gitlab 启动运行占用了大量的内存,2G内存在启动后已经所剩无几,想再进行git 相关操作自然也就会出现卡顿现象.正常 centos 应该是启用 swap 分区的,但是阿里云,腾讯云的服务器却没有swap分区
通过以下命令查看swap分区情况:
cat /proc/swaps

(2).解决方法

1).创建 swap 分区(这里需要等待几秒)

dd if=/dev/zero of=/swap bs=512 count=8388616
注意:创建swap大小为bs*count=4294971392(4G)

2).通过mkswap命令将上面新建出的文件做成swap分区

mkswap /swap

3).查看内核参数vm.swappiness中的数值是否为0,如果为0则根据实际需要调整成60

# 查看参数
cat /proc/sys/vm/swappiness
# 设置参数
# sysctl -w vm.swappiness=60

4).启用 swap 分区

swapon /swap
 
echo “/swap swap swap defaults 0 0” >> /etc/fstab

5).再次使用cat /proc/swaps 查看swap分区是否启动

可以看到,swap分区已经启用,现在通过 gitlab 进行操作会发现很流畅

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/355001.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

(API)接口测试的关键技术

接口测试也就是API测试,从名字上可以知道是面向接口的测试活动。所以在讲API测试之前,我们应该说清楚接口是什么,那么接口就是有特定输入和特定输出的一套逻辑处理单元,而对于接口调用方来说,不用知道自身的内部实现逻…

Spring 中经典的 9 种设计模式

1.简单工厂(非23种设计模式中的一种) 2.工厂方法 3.单例模式 4.适配器模式 5.装饰器模式 6.代理模式 7.观察者模式 8.策略模式 9.模版方法模式 Spring中涉及的设计模式总结 1.简单工厂(非23种设计模式中的一种) 实现方式: BeanFactory。Spring中的BeanFa…

Android 初代 K-V 存储框架 SharedPreferences,旧时代的余晖?

本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 [彭旭锐] 提问。 前言 大家好,我是小彭。 SharedPreferences 是 Android 平台上轻量级的 K-V 存储框架,亦是初代 K-V 存储框架,至今被很多应用沿用。 有的…

【C语言】大小端字节序问题

一、大小端字节序问题 大小端是由CPU决定的,大小端可以理解为字节顺序,所以大小端全称叫大端字节序、小端字节序。其实大端、小端这两个词是从《格列佛游记》里出来的。《格列佛游记》有一段讲的是吃鸡蛋是从大的那头敲开还是小的那头敲开的问题&#xf…

拯救了大批爬虫程序员,因为一个简单的神器

相信大家应该都写过爬虫,简单的爬虫只需要使用 requests 即可。遇到复杂的爬虫,就需要在程序里面加上请求头和参数信息。类似这种:我们一般的步骤是,先到浏览器的网络请求中找到我们需要的请求,然后将请求头和参数信息…

CI/CD --- 什么才是真正的自动化平台

近2年在软件开发中比较火的两个术语,一个是敏捷开发,另外一个就是CI/CD了;敏捷开发顾名思义就是“以用户的需求进化为核心,采用迭代、循序渐进的方法进行软件开发”。那CI/CD(Continuous Integration、 Continuous Del…

自抗扰控制ADRC之微分器TD

目录 前言 1 全程快速微分器 1.1仿真分析 1.2仿真模型 1.3仿真结果 1.4结论 2 Levant微分器 2.1仿真分析 2.2仿真模型 2.3仿真结果 3.总结 前言 工程上信号的微分是难以得到的,所以本文采用微分器实现带有噪声的信号及其微分信号提取,从而实现…

0216-0218复习:继承

目录 继承 一、基本介绍 二、示意图 三、基本语法 四、入门案例 父类 子类1 子类2 main方法 五、继承细节 第一条 第二条 第三条 第四条 ​编辑 第五条 第六条 第七条 第八条 第九条 第十条 六、继承本质 七、练习题 第三题 继承 一、基本介绍 继承可以…

RAY - 小记

文章目录关于 RAYRAY 结构关于 RAY Ray is a unified framework for scaling AI and Python applications. Ray consists of a core distributed runtime and a toolkit of libraries (Ray AIR) for accelerating ML workloads. RAY 是一个简单、通用的分布式计算框架。 RAY 解…

TikTok话题量超30亿,这款承载美好记忆的剪贴簿引发讨论

回忆风剪贴簿在TikTok引起关注小超在浏览超店有数后台时发现,有一款平平无奇的剪贴簿的种草视频爆火,在24h内收获了9.9K点赞,播放量更是突破了100W,直接冲到了【种草视频飙升榜】第六名的位置,并且这个数字目前仍在继续…

利用5G工业网关实现工业数字化的工业互联网解决方案

5G工业网关是一种用于将工业生产环境中的数据连接到工业互联网的解决方案。它可以利用高带宽、高速率、低时延的5G网络连接工业现场的PLC、传感器、工业设备和云端数据中心,从而实现工业数字化。 物通博联工业互联网解决方案 物通博联5G工业网关的使用步骤&#x…

XXL-JOB分布式任务调度框架(二)-策略详解

文章目录1.引言2.任务详解2.1.执行器2.2.基础配置3.路由策略(第一个)-案例4.路由策略(最后一个)-案例5.轮询策略-案例6.随机选取7.轮询选取8.一致性hash9.最不经常使用 (LFU)10.最近最久未使用(LRU)11.故障转移12.忙碌转移7.分片广播任务1.引言 本篇文章…

中外互免签证协定一览表(普通护照与公务普通护照)

普通护照:由公安部出入境管理机构或者公安部委托的县级以上地方人民政府公安机关出入境管理机构以及中华人民共和国驻外使馆、领馆和外交部委托的其他驻外机构签发,主要颁发给出国定居、探亲、访友、继承财产、留学、就业、旅游等因私事出国的中国公民。…

[REDIS]redis的一些配置文件

修改配置文件 vim /etc/redis/redis.conf目录 protected-mode tcp-backlog timeout tcp-keepalive daemonize pidfile loglevel databases 设置密码 maxclients maxmemory maxmemory-policy maxmemory-samples 默认情况下 bind127.0.0.1 只能接受本机的访问请求。在不写的情况…

算法导论【字符串匹配】—朴素算法、Rabin-Karp、有限自动机、KMP

算法导论【字符串匹配】—朴素算法、Rabin Karp、有限自动机、KMP朴素字符串匹配算法Rabin-Karp算法有限自动机KMP算法朴素字符串匹配算法 预处理时间:0匹配时间:O((n-m1)m) Rabin-Karp算法 预处理时间:Θ(m),需要预先算出匹…

Lua脚本执行redis指令报错【java.lang.IllegalStateException】

Lua脚本执行redis指令报错【java.lang.IllegalStateException】 问题出现背景 今天在学习redis时,为了让redis的多条指令(取锁、比锁、释放锁)保障原子性,我通过使用一个lua脚本统一去执行redis的的多条指令。在执行lua脚本时报错…

Python3 File(文件) 方法讲解

open() 方法 Python open() 方法用于打开1个文件,并返回文件对象。 在对文件进行处理过程都需要使用到这个函数,如果这个文件无法被打开,会抛出 OSError。 注意:使用 open() 方法一定要保证关闭文件对象,即调用 clo…

vrrp+mstp+osfp经典部署案例

LSW1和LSW2和LSW3和LSW4上面启用vrrpmstp组网: vlan 10 全走LSW1出再走AR2到外网,vlan 20 全走LSW2出再走AR3到外网 配置注意:mstp实例的根桥在哪,vrrp的主设备就是谁 ar2和ar3上开nat ar2和ar3可以考虑换成两台防火墙来做&…

Java基础 -- List集合

Java基础 -- List集合1. Introduction1.1 好处1.2 常用泛型2. 交集,差集等2.1 自身的方法2.2 1.8jdk stream 新特性2.3 Apache的CollectionUtils工具类(推荐)3. 限定泛型范围4. Awakening1. Introduction 1.1 好处 代码复用,多种…

分布式任务处理:XXL-JOB分布式任务调度框架

文章目录1.业务场景与任务调度2.任务调度的基本实现2.1 多线程方式实现2.2 Timer方式实现2.3 ScheduledExecutor方式实现2.4 第三方Quartz方式实现3.分布式任务调度4.XXL-JOB介绍5.搭建XXL-JOB —— 调度中心5.1 下载与查看XXL-JOB5.2 创建数据库表5.3 修改默认的配置信息5.4 启…