GitLab 502问题的解决
?
問(wèn)題:
502 Whoops, GitLab is taking too much time to respond.
?
?
?
日志:
[root@cs12-66-gitlab ~]# my gitlab-ctl tail -bash: my: command not found [root@cs12-66-gitlab ~]# gitlab-ctl tail ==> /var/log/gitlab/gitlab-shell/gitlab-shell.log <== # Logfile created on 2018-02-02 14:34:26 +0800 by logger.rb/56438==> /var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-2018-02-02-14-34-39.log <==-> 0.3182s== Seed from /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/001_admin.rb Administrator account created:login: root password: You'll be prompted to create one on your first visit.== Seed from /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/010_settings.rb==> /var/log/gitlab/gitlab-rails/production.log <== Started GET "/" for 10.100.16.218 at 2018-02-02 14:54:06 +0800 Started GET "/-/metrics" for 127.0.0.1 at 2018-02-02 14:54:06 +0800 Processing by MetricsController#index as HTML Completed 200 OK in 3ms (Views: 0.8ms | ActiveRecord: 0.0ms) Processing by RootController#index as HTML Redirected to http://git.tuandai888.com/users/sign_in Filter chain halted as :redirect_unlogged_user rendered or redirected Completed 302 Found in 9ms (ActiveRecord: 0.0ms) Started GET "/users/sign_in" for 10.100.16.218 at 2018-02-02 14:54:10 +0800 Processing by SessionsController#new as HTML==> /var/log/gitlab/gitlab-rails/grpc.log <== # Logfile created on 2018-02-02 14:41:50 +0800 by logger.rb/56438==> /var/log/gitlab/gitlab-rails/production_json.log <== {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"duration":3.63,"view":0.5,"db":0.0,"time":"2018-02-02T06:52:06.991Z","params":{},"remote_ip":null,"user_id":null,"username":null} {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"duration":4.42,"view":0.96,"db":0.0,"time":"2018-02-02T06:52:21.998Z","params":{},"remote_ip":null,"user_id":null,"username":null} {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"duration":17.59,"view":13.91,"db":0.0,"time":"2018-02-02T06:52:38.632Z","params":{},"remote_ip":null,"user_id":null,"username":null} {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"duration":4.71,"view":1.08,"db":0.0,"time":"2018-02-02T06:52:52.001Z","params":{},"remote_ip":null,"user_id":null,"username":null} {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"duration":3.6,"view":0.55,"db":0.0,"time":"2018-02-02T06:53:06.992Z","params":{},"remote_ip":null,"user_id":null,"username":null} {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"duration":4.08,"view":0.54,"db":0.0,"time":"2018-02-02T06:53:21.984Z","params":{},"remote_ip":null,"user_id":null,"username":null} {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"duration":3.64,"view":0.42,"db":0.0,"time":"2018-02-02T06:53:36.985Z","params":{},"remote_ip":null,"user_id":null,"username":null} {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"duration":4.94,"view":0.73,"db":0.0,"time":"2018-02-02T06:53:51.985Z","params":{},"remote_ip":null,"user_id":null,"username":null} {"method":"GET","path":"/-/metrics","format":"html","controller":"MetricsController","action":"index","status":200,"duration":4.72,"view":0.84,"db":0.0,"time":"2018-02-02T06:54:06.991Z","params":{},"remote_ip":null,"user_id":null,"username":null} {"method":"GET","path":"/","format":"html","controller":"RootController","action":"index","status":302,"duration":10.83,"view":0.0,"db":0.0,"location":"http://git.tuandai888.com/users/sign_in","time":"2018-02-02T06:54:10.479Z","params":{},"remote_ip":"10.100.16.218","user_id":null,"username":null}==> /var/log/gitlab/gitlab-rails/api_json.log <== # Logfile created on 2018-02-02 14:41:51 +0800 by logger.rb/56438==> /var/log/gitlab/gitlab-rails/application.log <== # Logfile created on 2018-02-02 14:42:32 +0800 by logger.rb/56438 February 02, 2018 14:42: User "Administrator" (admin@example.com) was created==> /var/log/gitlab/logrotate/current <====> /var/log/gitlab/unicorn/current <== 2018-02-02_06:42:37.56441 starting new unicorn master 2018-02-02_06:49:48.90547 adopted new unicorn master 3906==> /var/log/gitlab/unicorn/unicorn_stderr.log <== I, [2018-02-02T14:49:47.581121 #4594] INFO -- : worker=0 ready I, [2018-02-02T14:49:47.612613 #4597] INFO -- : worker=1 ready I, [2018-02-02T14:49:47.674536 #4600] INFO -- : worker=2 ready I, [2018-02-02T14:49:47.710865 #4603] INFO -- : worker=3 ready I, [2018-02-02T14:49:47.756704 #4606] INFO -- : worker=4 ready I, [2018-02-02T14:49:47.825869 #3906] INFO -- : master process ready I, [2018-02-02T14:49:47.836401 #4609] INFO -- : worker=5 ready I, [2018-02-02T14:49:47.887782 #4612] INFO -- : worker=6 ready I, [2018-02-02T14:49:47.909891 #4615] INFO -- : worker=7 ready I, [2018-02-02T14:49:47.940642 #4618] INFO -- : worker=8 ready==> /var/log/gitlab/unicorn/unicorn_stdout.log <====> /var/log/gitlab/sidekiq/current <== 2018-02-02_06:52:59.51350 127.0.0.1 - - [02/Feb/2018:14:52:59 CST] "GET /metrics HTTP/1.1" 200 25 2018-02-02_06:52:59.51358 - -> /metrics 2018-02-02_06:53:14.51410 127.0.0.1 - - [02/Feb/2018:14:53:14 CST] "GET /metrics HTTP/1.1" 200 25 2018-02-02_06:53:14.51417 - -> /metrics 2018-02-02_06:53:29.51384 127.0.0.1 - - [02/Feb/2018:14:53:29 CST] "GET /metrics HTTP/1.1" 200 25 2018-02-02_06:53:29.51390 - -> /metrics 2018-02-02_06:53:44.51387 127.0.0.1 - - [02/Feb/2018:14:53:44 CST] "GET /metrics HTTP/1.1" 200 25 2018-02-02_06:53:44.51392 - -> /metrics 2018-02-02_06:53:59.51637 127.0.0.1 - - [02/Feb/2018:14:53:59 CST] "GET /metrics HTTP/1.1" 200 25 2018-02-02_06:53:59.51640 - -> /metrics==> /var/log/gitlab/gitlab-workhorse/current <== 2018-02-02_06:46:40.87969 10.100.12.66 @ - - [2018-02-02 14:46:40.877704109 +0800 CST] "GET / HTTP/1.1" 502 2916 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 0.001910 2018-02-02_06:46:40.89513 2018/02/02 14:46:40 Send static file "/opt/gitlab/embedded/service/gitlab-rails/public/favicon.ico" ("") for GET "/favicon.ico" 2018-02-02_06:46:40.89566 10.100.12.66 @ - - [2018-02-02 14:46:40.89417661 +0800 CST] "GET /favicon.ico HTTP/1.1" 200 5430 "http://10.100.12.66/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 0.001187 2018-02-02_06:47:25.68625 2018/02/02 14:47:25 error: GET "/": badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory 2018-02-02_06:47:25.68697 git.tuandai888.com @ - - [2018-02-02 14:47:25.683237091 +0800 CST] "GET / HTTP/1.1" 502 2916 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 0.003579 2018-02-02_06:47:25.87230 2018/02/02 14:47:25 Send static file "/opt/gitlab/embedded/service/gitlab-rails/public/favicon.ico" ("") for GET "/favicon.ico" 2018-02-02_06:47:25.87285 git.tuandai888.com @ - - [2018-02-02 14:47:25.871579483 +0800 CST] "GET /favicon.ico HTTP/1.1" 200 5430 "http://git.tuandai888.com/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 0.001192 2018-02-02_06:47:45.63429 2018/02/02 14:47:45 error: GET "/": badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory 2018-02-02_06:47:45.63501 git.tuandai888.com @ - - [2018-02-02 14:47:45.631742962 +0800 CST] "GET / HTTP/1.1" 502 2916 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 0.003081 2018-02-02_06:54:10.49117 git.tuandai888.com @ - - [2018-02-02 14:54:06.631802992 +0800 CST] "GET / HTTP/1.1" 302 105 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 3.859047==> /var/log/gitlab/nginx/current <====> /var/log/gitlab/nginx/error.log <====> /var/log/gitlab/nginx/gitlab_access.log <== 10.100.16.218 - - [02/Feb/2018:14:46:40 +0800] "GET / HTTP/1.1" 502 2916 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 10.100.16.218 - - [02/Feb/2018:14:46:40 +0800] "GET /favicon.ico HTTP/1.1" 200 5430 "http://10.100.12.66/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 10.100.16.218 - - [02/Feb/2018:14:46:40 +0800] "GET / HTTP/1.1" 502 2916 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 10.100.16.218 - - [02/Feb/2018:14:46:40 +0800] "GET /favicon.ico HTTP/1.1" 200 5430 "http://10.100.12.66/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 10.100.16.218 - - [02/Feb/2018:14:46:40 +0800] "GET / HTTP/1.1" 502 2916 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 10.100.16.218 - - [02/Feb/2018:14:46:40 +0800] "GET /favicon.ico HTTP/1.1" 200 5430 "http://10.100.12.66/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 10.100.16.218 - - [02/Feb/2018:14:47:25 +0800] "GET / HTTP/1.1" 502 2916 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 10.100.16.218 - - [02/Feb/2018:14:47:25 +0800] "GET /favicon.ico HTTP/1.1" 200 5430 "http://git.tuandai888.com/" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 10.100.16.218 - - [02/Feb/2018:14:47:45 +0800] "GET / HTTP/1.1" 502 2916 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" 10.100.16.218 - - [02/Feb/2018:14:54:10 +0800] "GET / HTTP/1.1" 302 105 "" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"?
安裝好GitLab,開(kāi)啟服務(wù),發(fā)現(xiàn)有502錯(cuò)誤。這是開(kāi)始尋找解決辦法,各種百度。?
1.找到/var/log/gitlab/nginx中的錯(cuò)誤日志文件,發(fā)現(xiàn)有如下錯(cuò)誤/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket failed (2: No such file or directory),然后用 nc命令創(chuàng)建了這個(gè)socket文件,最終權(quán)限設(shè)為srwxrwxrwx,用戶和組設(shè)置為git:git,但發(fā)現(xiàn)這個(gè)方法行不通。
2.這時(shí)我跑到GitLab的官網(wǎng)去尋找解決辦法,https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md?
ctrl+f 502 找到官方教程中說(shuō)502出現(xiàn)的問(wèn)題
Note that on a single-core server it may take up to a minute to restart Unicorn and Sidekiq. Your GitLab instance will give a 502 error until Unicorn is up again.
It is also possible to start, stop or restart individual components.
sudo gitlab-ctl restart sidekiq?
Unicorn supports zero-downtime reloads. These can be triggered as follows:
sudo gitlab-ctl hup unicorn?
Note that you cannot use a Unicorn reload to update the Ruby runtime.
嘗試用上面兩個(gè)命令解決,發(fā)現(xiàn)沒(méi)有用。?
這時(shí)我怒了,不斷的輸入gitlab-ctl status,發(fā)現(xiàn)unicorn的pid一直在變大。而其他幾個(gè)服務(wù)的pid沒(méi)有變化。
3.這時(shí)差不多找到了問(wèn)題的所在了,應(yīng)該就是unicorn的問(wèn)題。然后看官方教程,可以使用gitlab-ctl tail unicorn?來(lái)跟蹤unicorn的狀態(tài),這時(shí)候悲催的發(fā)現(xiàn)原來(lái)時(shí)權(quán)限不夠,chmod -R 777?/var/log/gitlab
?
?
502 Whoops, GitLab is taking too much time to respond。經(jīng)搜索梳理網(wǎng)上幾篇相同問(wèn)題的解決方案,歸納原因可能如下:
1、unicorn原8080默認(rèn)端口被容器中別的進(jìn)程已經(jīng)占用,必須調(diào)整為沒(méi)用過(guò)的
2、gitlab的timeout設(shè)置過(guò)小,默認(rèn)為60
從這兩個(gè)原因著手,開(kāi)始調(diào)整配置:
1、使用以下命令編輯gitlab配置文件:
sudo docker exec -it gitlab vim /etc/gitlab/gitlab.rb
經(jīng)試驗(yàn),應(yīng)該修改以下配置項(xiàng):
unicorn['port'] = 8888
gitlab_workhorse['auth_backend'] = "http://localhost:8888"?
注意:unicorn['port']與gitlab_workhorse['auth_backend']的端口必須相同
2、調(diào)整timout時(shí)長(zhǎng),從60秒改為90秒
gitlab_rails['webhook_timeout'] = 90?
gitlab_rails['git_timeout']=90
?
以上配置修改完成后,使用以下命令重啟容器:
docker restart gitlab
docker logs gitlab
?
也可以通過(guò)以下命令進(jìn)入容器,查看gitlab啟動(dòng)狀態(tài)和動(dòng)態(tài)日志:
sudo docker exec -it gitlab /bin/bash
cd /usr/bin
gitlab-ctl status
gitlab-ctl tail
?
3、初始鏡像、容器的創(chuàng)建步驟是這樣的:
sudo docker pull gitlab/gitlab-ce
chmod 777 /var/log/gitlab
sudo docker run --detach --hostname devops --publish 443:443 --publish 80:80 --publish 20022:22 --name gitlab --env GITLAB_OMNIBUS_CONFIG="external_url 'http://devops/'; gitlab_rails['lfs_enabled'] = true;" --restart always --volume /home/linyu/gitlab/config:/etc/gitlab --volume /home/linyu/gitlab/logs:/var/log/gitlab --volume /home/linyu/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest
?
4、也可以進(jìn)入容器后,根據(jù)容器創(chuàng)建時(shí)映射的--volume目錄,在里面修改配置,然后重啟gitlab:
gitlab-ctl reconfigure
gitlab-ctl retart
gitlab-ctl status
gitlab-ctl tail
?
轉(zhuǎn)載于:https://www.cnblogs.com/linkenpark/p/8405327.html
總結(jié)
以上是生活随笔為你收集整理的GitLab 502问题的解决的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: div内元素的居中
- 下一篇: 停止复制代理后AWT缓存组的行为