Centos8 中安装GitLab

1,安装依赖

yum install -y curl policycoreutils-python openssh-server

centos8没有policycoreutils-python yum源,不用管

2,启动ssh并设置为开机自启动

systemctl enable sshd

systemctl start sshd

 

3,添加http服务到firewalld,pemmanent表示永久生效,若不加--permanent系统下次启动后就会失效

systemctl start firewalld

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
systemctl reload firewalld

 

4,启动postfix

systemctl enable postfix

systemctl start postfix

 

5,下载gitlab

去这个路径下找最新的: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8 ; 下面的命令对应也跟着修改
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-12.10.1-ce.0.el8.x86_64.rpm

 

6,安装

rpm -i gitlab-ce-12.10.1-ce.0.el8.x86_64.rpm

 


成功如图:

7,编辑ip和端口

 

vim /etc/gitlab/gitlab.rb

gitlab-ctl reconfigure

gitlab-ctl restart

 

8,访问gitlab ip+端口
如果输入端口和ip一直无法响应,可以关闭防火墙
systemctl stop firewalld

如果访问502,查看

https://www.cnblogs.com/fuhua/p/15414744.html

14.之后在本机浏览器输入地址 http://ip+端口 提示502错误!



15.gitlab官方文档中说的是当CPU到达100%时会返回502错误,这个错误来自包Unicorn。

由于我们安装的gitlab是14.3.3版本,Unicorn包已被弃用,改名为Puma,所以我们可以初步判断是Puma包导致的502报错。

参考链接:502 Gateway Timeout after Unicorn spins at 100% CPU

 

 

16.输入命令top查看cpu占用状态,发现command为bundle这个操作占用了99.3%的cpu,这明显是不合理的。

 

 17.实时打印 puma包的日志,发现输出"Errno::EADDRINUSE: Address already in use - bind(2) for "127.0.0.1" port 8080"。原因就很清晰了,是因为8080端口被占用。

#实时打印puma包的日志
sudo gitlab-ctl tail puma

 

15.查看占用端口为8080并且状态为LISTEN的进程

发现8080端口被进程Id:58799 进程名:nginx:maser 的进程占用了,这是gitlab自带的nginx默认的监听端口。

而包puma也需要监听8080端口,产生了冲突导致puma 执行build失败。

puma包在执行build失败之后会无限重试,导致了死循环把cpu跑到了100%。

netstat -anp |grep 8080

 

16.接下来只需要给puma包设置默认监听端口不是8080就好了,我这里设置为8081

vim /etc/gitlab/gitlab.rb

新增

puma['port'] = 8081

 

 17.依次执行下面命令
复制代码

#停止gitlab
gitlab-ctl stop

#重新加载gitlab配置
gitlab-ctl reconfigure

#重新运行gitlab
gitlab-ctl restart

#监视cpu状态
top

复制代码

 

18.可以看到两个CPU占用非常高的进程,此时如果您在本机访问搭建的gitlab地址,依旧会提示502。

因为此时gitlab正在构建,我们什么都不需要做。只需要等到这两个CPU占用很高的进程CPU降低后就可以访问了。

 

 

 

注:如果远程访问不是提示502错误,而是提示连接失败之类的。80%都是因为服务器防火墙限制或者云服务器提供商防火墙限制。

 

#停止服务器防火墙
sudo systemctl stop firewalld

 


重新配置并启动

gitlab-ctl reconfigure

gitlab-ctl restart
开启:
gitlab-ctl start
关闭:
gitlab-ctl stop

9,成功如图:

10,第一次登录需要修改root密码, 密码8位以上,修改完就可以登录
使用设置的新密码,登录

其他操作类似添加账号,仓库等等自己百度

 posted on 2022-01-13 13:30  wu小强  阅读(1092)  评论(0编辑  收藏  举报