10 KiB
ERROR
问题一:GitLab容器一直重启
使用docker logs命令查询
$ docker log CONTAINER_ID
...
...
System Info:
------------
chef_version=14.13.11
platform=ubuntu
platform_version=16.04
ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
program_name=/opt/gitlab/embedded/bin/chef-client
executable=/opt/gitlab/embedded/bin/chef-client
Running handlers:
There was an error running gitlab-ctl reconfigure:
/etc/gitlab/gitlab.rb:1: unexpected fraction part after numeric literal
external_url = 192.168.0.144:7002
^~~~~~~
/etc/gitlab/gitlab.rb:1: syntax error, unexpected tINTEGER, expecting end-of-input
external_url = 192.168.0.144:7002
^~~
Running handlers complete
Chef Client failed. 0 resources updated in 01 seconds
发现是external_url配置失误导致。解决方法如下:
- 停止
gitlab容器 - 修改配置文件(在主机中)
/srv/gitlab/config/gitlab.rb - 重新启动容器
问题二:GitLab导致8080端口冲突
问题复现
安装完GitLab后,修改配置文件/etc/gitlab/gitlab.rb
##external_url 'http://gitlab.example.com'
external_url 'http://localhost:8800'
本以为这样就能修改GitLab端口号为8800了,没想到再次登录8080仍旧出现了GitLab页面
问题解析
查询哪个程序监听了8080端口
# netstat -lnp | grep 8080
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 26436/config.ru
查询相应的进程
# netstat -lnp | grep 26436
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 26436/config.ru
unix 2 [ ACC ] STREAM LISTENING 343538 26436/config.ru /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket
仍然是GitLab在监听8080端口,参考gitlab 8.13 80 8080端口冲突问题,查看配置文件unicorn.rb
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.
# What ports/sockets to listen on, and what options for them.
listen "127.0.0.1:8080", :tcp_nopush => true
默认情况下unicorn同样监听8080端口,查询/etc/gitlab/gitlab.rb中相应的设置
# cat gitlab.rb | grep unicorn
#unicorn['port'] = 8800
解决方案
需要在gitlab.rb上同时修改unicorn监听端口号,修改配置文件/etc/gitlab/gitlab.rb如下
##external_url 'http://gitlab.example.com'
external_url 'http://localhost:8800'
unicorn['port'] = 8801
重新启动GitLab
# gitlab-ctl reconfigure
# gitlab-ctl restart
查询配置文件/var/opt/gitlab/gitlab-rails/etc/unicorn.rb
# cat unicorn.rb | grep listen
# What ports/sockets to listen on, and what options for them.
listen "127.0.0.1:8801", :tcp_nopush => true
测试端口号
$ curl localhost:8080
curl: (7) Failed to connect to localhost port 8080: Connection refused
$ curl localhost:8800
<!DOCTYPE html>
<html>
<head>
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
...
...
# curl localhost:8801
<html><body>You are being <a href="http://localhost:8801/users/sign_in">redirected</a>.</body></html>
问题三: [GitLab][Webhook]不允许本地连接
在gitlab仓库中设置Webhook,使用本地连接出现如下错误:
Url is blocked: Requests to the local network are not allowed
参考:gitlab使用webhook向jenkins发送请求,报错 Requests to the local network are not allowed
登录root账户,点击Configure Gitlab选项
进入Settings -> Network,展开Outbound requests,选中Allow requests to the local network from web hooks and services
问题四:GitLab: You are not allowed to force push code to a protected branch on this project
强制上传代码到Gitlab仓库的dev分支出错,提示如下:
GitLab: You are not allowed to force push code to a protected branch on this project
参考:解决 GitLab: You are not allowed to force push code to a protected branch on this project问题
是由于分支保护的原因,需要进入仓库setting -> Repository -> Protected Branches
允许dev分支能够强制推送
问题五:unicorn出错
问题描述
通过docker部署gitlab一段时间后,突然出现502错误
查看容器状态,显示不健康
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
89481faa2ed1 gitlab/gitlab-ce:latest "/assets/wrapper" 2 weeks ago Up 7 hours (unhealthy)
浏览容器日志,发现如下错误:
==> /var/log/gitlab/unicorn/unicorn_stdout.log <==
bundler: failed to load command: unicorn (/opt/gitlab/embedded/bin/unicorn)
==> /var/log/gitlab/unicorn/unicorn_stderr.log <==
ArgumentError: Already running on PID:460 (or pid=/opt/gitlab/var/unicorn/unicorn.pid is stale)
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid='
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start'
/opt/gitlab/embedded/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn:126:in `<top (required)>'
/opt/gitlab/embedded/bin/unicorn:23:in `load'
/opt/gitlab/embedded/bin/unicorn:23:in `<top (required)>'
==> /var/log/gitlab/unicorn/current <==
2019-12-18_12:27:47.34406 failed to start a new unicorn master
2019-12-18_12:27:47.35882 starting new unicorn master
2019-12-18_12:27:47.91735 master failed to start, check stderr log for details
问题解析
看样子是unicorn的问题,参考:
gitlab docker Web界面打开反应迟钝的解决办法
进入容器内部,查看unicorn状态
$ docker exec -it xxxx bash
# gitlab-ctl tail unicorn
发现每次unicorn显示的PID都不同,修改/etc/gitlab/gitlab.rb,添加
unicorn['listen'] = 'localhost'
unicorn['port'] = 8999
更新并重启后,gitlab服务恢复正常
# gitlab-ctl reconfigure
# gitlab-ctl restart
问题六:版本更新后database出错
问题描述
拉取了最新的Docker Gitlab镜像,部署时发现了如下错误:
gitlab | System Info:
gitlab | ------------
gitlab | chef_version=14.14.29
gitlab | platform=ubuntu
gitlab | platform_version=16.04
gitlab | ruby=ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
gitlab | program_name=/opt/gitlab/embedded/bin/chef-client
gitlab | executable=/opt/gitlab/embedded/bin/chef-client
gitlab |
gitlab |
gitlab | Running handlers:
gitlab | There was an error running gitlab-ctl reconfigure:
gitlab |
gitlab | bash[migrate gitlab-rails database] (gitlab::database_migrations line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
gitlab | ---- Begin output of "bash" "/tmp/chef-script20200618-23-sfpkhu" ----
gitlab | STDOUT: rake aborted!
gitlab | PG::ConnectionBad: could not connect to server: No such file or directory
gitlab | Is the server running locally and accepting
gitlab | connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
gitlab | /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:48:in `block (3 levels) in <top (required)>'
gitlab | /opt/gitlab/embedded/bin/bundle:23:in `load'
gitlab | /opt/gitlab/embedded/bin/bundle:23:in `<main>'
gitlab | Tasks: TOP => gitlab:db:configure
gitlab | (See full trace by running task with --trace)
gitlab | STDERR:
gitlab | ---- End output of "bash" "/tmp/chef-script20200618-23-sfpkhu" ----
gitlab | Ran "bash" "/tmp/chef-script20200618-23-sfpkhu" returned 1
问题解决
在网上查了一些资料,说是新旧版本的配置格式不一致,需要删除之前的配置数据。幸好在本地保存了之前使用的镜像,打包该镜像后上传到服务器重新加载即可
问题七:Prometheus吃磁盘空间
在云服务器上部署Gitlab,今天发现无法登录了。登上云服务器后发现磁盘容量没有了,通过查找发现Prometheus目录下占据了30GB的空间(总共50GB)
参考:
Monitoring GitLab with Prometheus
Prometheus eats disk space in /var/opt/gitlab/prometheus/data
GitLab 官方镜像内部集成 Prometheus 历史数据过大的问题处理
Prometheus是一个监控服务,会保存历史监控数据,下面尝试关闭该服务并删除之前的数据(在Docker Gitlab上操作)
- 修改配置文件
/srv/gitlab/config/gitlab.rb,添加
prometheus_monitoring['enable'] = false
-
关闭
gitlab并删除/srv/gitlab/data/prometheus文件夹数据 -
重启
gitlab,问题解决
问题八:Access deined: You do not have permission push to this repository
在gitee上新建了一个账户,在上面新建一个仓库,将其ssh链接设置到本地已存在的仓库上,想要把本地仓库推送到远程仓库,出现如下错误:
$ git push origin master
Access deined: You do not have permission push to this repository
fatal: 无法读取远程仓库。
请确认您有正确的访问权限并且仓库存在。
其原因在于本地新建了两个ssh密钥,设置在gitee的不同账户上,ssh使用之前的密钥读取gitee远程仓库,导致出错。参考如何使用特定的SSH Key提交GIT
在~/.ssh/config文件上添加如下内容
Host gitee.com
HostName gitee.com
User git
IdentityFile 私钥文件路径
IdentitiesOnly yes
重新提交即可



