GitLab安装问题处理方案

1、Gitlab启动失败,或重新安装时出现卡的状态

问题现象:在卸载gitlab然后再次安装执行sudo gitlab-ctl reconfigure的时候往往会出现:ruby_block[supervise_redis_sleep] action run,一直卡无法往下进行!

解决办法:

1)按ctrl + c 强制结束
2)执行"systemctl restart gitlab-runsvdir" 命令
3)接着再执行"gitlab-ctl reconfigure"

如果Gitlab服务器重启后,启动"gitlab-ctl start"依旧失败,则重复上面的解决办法。

[root@gitlab ~]# systemctl restart gitlab-runsvdir
[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl start

2、Gitlab访问出现403"Forbidden"

原因分析:可能因较多的并发导致的访问被拒绝, Gitlab使用rack_attack做了并发访问的限制!

解决方法:

打开/etc/gitlab/gitlab.rb文件,查找 gitlab_rails[‘rack_attack_git_basic_auth’] 关键词,取消注释,

修改ip_whitelist白名单属性,加入Gitlab部署的IP地址。

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
......
 gitlab_rails['rack_attack_git_basic_auth'] = {
   'enabled' => true,
   'ip_whitelist' => ["127.0.0.1","172.24.143.126"],   //把gitlab服务器IP地址添加
   'maxretry' => 10,
   'findtime' => 60,
   'bantime' => 3600
 }  

然后重置GitLab配置

[root@gitlab ~]# gitlab-ctl reconfigure

3、Gitlab访问出现502

Gitlab访问出现:Whoops, GitLab is taking too much time to respond.

原因分析:

(1) unicorn原8080默认端口被容器中别的进程已经占用,必须调整为没用过的
(2)gitlab的timeout设置过小,默认为60

解决办法:

(1)关闭gitlab服务

[root@gitlab ~]# gitlab-ctl stop

(2)选择一个没有被系统占用的端口作为unicorn端口,比如8952端口(lsof -i:8952确认此端口没有被占用)

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
unicorn['port'] = 8952
gitlab_workhorse['auth_backend'] = "http://localhost:8952"

(3)重新生成配置,并进行重启。

[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl restart

4、Gitlab异常关机,导致gitlab启动失败!gitlab-runsvdir方式启动没反应

问题现象:Gitlab部署的服务器异常断电,机器重启后,尝试启动gitlab服务,启动失败!通过gitlab-runsvdir方式启动一直没有反应!一直在卡顿状态!日志也没有任务输入!

[root@gitlab ~]# gitlab-ctl start      ## 或者 "gitlab-ctl restart"
fail: alertmanager: runsv not running
fail: gitaly: runsv not running
fail: gitlab-monitor: runsv not running
fail: gitlab-workhorse: runsv not running
fail: logrotate: runsv not running
fail: nginx: runsv not running
fail: node-exporter: runsv not running
fail: postgres-exporter: runsv not running
fail: postgresql: runsv not running
fail: prometheus: runsv not running

尝试使用supervisor进程方式启动gitlab,一直在卡顿中,没有任何反应!

[root@gitlab ~]# systemctl restart gitlab-runsvdir

查看日志没有最新任务启动信息打印到日志中

[root@gitlab ~]``# /usr/bin/gitlab-ctl tail

执行下面的启动,虽然发现这个也会一直在卡顿中,但是不影响gitlab服务启动。

[root@gitlab ~]# /opt/gitlab/embedded/bin/runsvdir-start

重新打开一个终端窗口此时发现GitLab服务已经启动,已经有新的日志信息打印

 [root@gitlab ~]# /usr/bin/gitlab-ctl tail [root@gitlab ~]# ps -ef|grep gitlab

此时关闭执行"/opt/gitlab/embedded/bin/runsvdir-start"命令的卡顿的终端窗口,发现gitlab还是启动状态(ps -ef|grep gitlab)

[root@gitlab ~]# ps -ef|grep gitlab
[root@gitlab ~]# lsof -i:80
[root@gitlab ~]# gitlab-ctl status
run: alertmanager: (pid 691735) 4666s; run: log: (pid 366683) 13742s
run: gitaly: (pid 691808) 4666s; run: log: (pid 286444) 14661s
run: gitlab-exporter: (pid 691828) 4665s; run: log: (pid 365040) 13759s
run: gitlab-kas: (pid 691832) 4665s; run: log: (pid 289297) 14631s
run: gitlab-workhorse: (pid 691906) 4664s; run: log: (pid 363014) 13782s
run: logrotate: (pid 1006734) 1064s; run: log: (pid 285626) 14670s
run: nginx: (pid 692052) 4663s; run: log: (pid 363639) 13775s
run: node-exporter: (pid 692110) 4663s; run: log: (pid 364448) 13766s
run: postgres-exporter: (pid 692117) 4663s; run: log: (pid 367257) 13737s
run: postgresql: (pid 692173) 4663s; run: log: (pid 288332) 14641s
run: prometheus: (pid 692191) 4663s; run: log: (pid 365838) 13752s
run: puma: (pid 692205) 4662s; run: log: (pid 361393) 13801s
run: sidekiq: (pid 692221) 4662s; run: log: (pid 361959) 13794s
run: unicorn: (pid 29807) 1640s; run: log: (pid 29791) 1610s

查看日志也有最新启动的日志信息打印

[root@gitlab ~]# /usr/bin/gitlab-ctl tail 

5、Gitlab重新安装,在执行"gitlab-ctl reconfigure"配置环节报错

[root@gitlab ~]# gitlab-ctl reconfigure
.........
.........
STDERR: sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf": No such file or directory
sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-net.core.somaxconn.conf": No such file or directory
---- End output of sysctl -e --system ----
Ran sysctl -e --system returned 255

原因分析:
丢失了报错中的这两个配置文件,进入/etc/sysctl.d目录发现,这两个文件都是通过链接到/opt/gitlab/embedded/etc/目录下。
/opt/gitlab/embedded/etc/目录确实没有这两个文件。

[root@gitlab ~]# ll /etc/sysctl.d/
total 0
lrwxrwxrwx  1 root root 58 Nov 10 22:23 90-omnibus-gitlab-kernel.sem.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
lrwxrwxrwx  1 root root 61 Nov 10 22:23 90-omnibus-gitlab-kernel.shmall.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmall.conf
lrwxrwxrwx  1 root root 61 Nov 10 22:23 90-omnibus-gitlab-kernel.shmmax.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmmax.conf
lrwxrwxrwx  1 root root 66 Nov 10 22:25 90-omnibus-gitlab-net.core.somaxconn.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
lrwxrwxrwx. 1 root root 14 Oct 30 09:13 99-sysctl.conf -> ../sysctl.conf
  
[root@gitlab ~]# ll /opt/gitlab/embedded/etc
total 12
-rw-r--r-- 1 root root  24 Apr 12 23:18 90-omnibus-gitlab-kernel.shmall.conf
-rw-r--r-- 1 root root  28 Apr 12 23:17 90-omnibus-gitlab-kernel.shmmax.conf
-rwxr-xr-x 1 root root 196 Apr 12 23:16 gitconfig
  
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
ls: cannot access /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf: No such file or directory
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
ls: cannot access /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf: No such file or directory

解决办法

办法一:从其他备份机(或者在别的机器上重新安装一次,"gitlab-ctl reconfigure"之后生成这两个文件)将这两个文件拷贝回来!
  
办法二:修改配置文件

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
# unicorn['port'] = 8080
修改为:
unicorn['port'] = 8090

重新加载配置文件

[root@gitlab ~]# gitlab-ctl reconfigure

再次启动会报错,再修改/etc/gitlab/gitlab.rb,修改为原来的配置

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb

# unicorn['port'] = 8080

再次重新加载配置文件就可以了!

[root@gitlab ~]# gitlab-ctl reconfigure

再次查看,发现上面配置中报错的两个文件已经存在了

[root@gitlab ~]# ll /opt/gitlab/embedded/etc/
total 20
-rw-r--r-- 1 root root  30 Apr 12 23:33 90-omnibus-gitlab-kernel.sem.conf
-rw-r--r-- 1 root root  24 Apr 12 23:18 90-omnibus-gitlab-kernel.shmall.conf
-rw-r--r-- 1 root root  28 Apr 12 23:17 90-omnibus-gitlab-kernel.shmmax.conf
-rw-r--r-- 1 root root  26 Apr 12 23:35 90-omnibus-gitlab-net.core.somaxconn.conf
-rwxr-xr-x 1 root root 196 Apr 12 23:16 gitconfig
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
-rw-r--r-- 1 root root 30 Apr 12 23:33 /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
-rw-r--r-- 1 root root 26 Apr 12 23:35 /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf

最后再启动gitlab

[root@gitlab ~]# gitlab-ctl start

6、Gitlab使用外置Nginx

1)编辑gitlab配置文件禁用自带Nignx服务器

[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
...
#设置nginx为false,关闭自带Nginx
nginx['enable'] = false

2)检查默认nginx配置文件,并迁移至新Nginx服务 (即将下面两个gitlab自带nginx的配置文件迁移到自行编译的新的nginx配置中)
/var/opt/gitlab/nginx/conf/nginx.conf                #nginx配置文件,包含gitlab-http.conf文件
/var/opt/gitlab/nginx/conf/gitlab-http.conf          #gitlab核心nginx配置文件

[root@gitlab ~]# cp /var/opt/gitlab/nginx/conf/nginx.conf /etc/nginx/conf.d/
[root@gitlab ~]# cp /var/opt/gitlab/nginx/conf/gitlab-http.conf /etc/nginx/conf.d/

3)重新加载GitLab配置及重新启动GitLab服务

[root@gitlab ~]# gitlab-ctl reconfigure  
[root@gitlab ~]# gitlab-ctl restart

4)重启nginx服务

[root@gitlab ~]# systemctl restart nginx

如果访问报502。原因是nginx用户无法访问gitlab用户的socket文件。 重启gitlab需要重新授权。

[root@gitlab ~]# chmod -R o+x /var/opt/gitlab/gitlab-rails 
  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
GitLab 是一个用于源代码管理、项目协作和持续集成/持续部署(CI/CD)的开源平台。如果你想要卸载并重新安装 GitLab,这里是一般的步骤: **卸载 GitLab:** 1. **停止服务(如果已运行):** 在 Linux 上,可以通过命令 `sudo systemctl stop gitlab` 或 `sudo service gitlab stop` 停止 GitLab服务。 2. **查找安装路径:** 使用 `which gitlab-ctl` 或 `whereis gitlab` 查找 GitLab 控制台的执行文件路径。 3. **卸载应用程序:** 对于 Debian/Ubuntu,使用 `sudo apt-get remove gitlab Omnibus-gitlab`;对于 CentOS/RHEL,用 `sudo yum remove gitlab-ce`. 4. **删除数据目录:** 删除 `/var/opt/gitlab` (Omnibus 包) 或 `/opt/gitlab/embedded/service/gitlab-rails` (自定义安装) 和其下的所有内容。 5. **移除配置文件和日志文件:** 清理 `/etc/gitlab` 和 `/var/log/gitlab` 目录。 **重新安装 GitLab:** 1. **更新包列表:** 更新系统包列表,如 `sudo apt-get update` 或 `sudo yum update`. 2. **根据官方文档安装:** 官方文档提供了不同发行版的安装指南,可以从 GitLab 官网找到:https://docs.gitlab.com/ee/install/ - 根据你的操作系统选择相应的安装方法,例如使用包管理器或二进制包。 3. **配置新安装GitLab:** 完成安装后,按照向导进行配置,包括数据库连接、初始化等步骤。 **相关问题--:** 1. 如何确认 GitLab 是否完全卸载? 2. 重新安装过程中如何处理现有的项目备份? 3. 如何防止卸载后数据丢失?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值