【问题标题】:502 Whoops, GitLab is taking too much time to respond502 糟糕,GitLab 响应时间过长
【发布时间】:2016-01-20 03:25:18
【问题描述】:

我在 Raspberry Pi2 上安装了 Gitlab,几个月来一直运行良好。但是自从关闭了 RPi 的电源后,它就不再起作用了。网页返回502错误。

502 糟糕,GitLab 响应时间过长。

所以我尝试重新配置 (sudo gitlab-ctl reconfigure) 但失败并显示错误消息:

FATAL: Errono::EAFNOSUPPORT: Address family not supported by protocol - socket(2)

我不知道如何解决这个问题。

【问题讨论】:

  • gitlab-ctl tail 显示了什么?这绝对应该给你一个关于这个问题的提示。
  • @vikas027 它在unicorn_stderr.log 文件中显示很长的错误日志。报错信息为FATAL -- : error adding listener addr=127.0.0.1:8080 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:147:in 'initialize': Cannot assign requested address - bind(2) for "127.0.0.1" port 8080 (Errno::EADDRNOTAVAIL)如何解决?

标签: gitlab


【解决方案1】:

我多次看到这样的问题。

如果 GitLab 运行良好,请不要碰任何东西。等一下。 GitLab 似乎没有正确启动:(

我的意思是,在启动系统后,您必须等待 1-2 分钟才能使用 GitLab。 GitLab 需要一些时间来启动。

【讨论】:

  • 等待对我没有帮助,添加更多内存对我有帮助。
  • @9swampy,你如何添加更多内存?
  • 我在 Ubuntu VM 上运行 GitLab 时看到了这个问题;分配更多的内存有帮助;从内存中我从 1 GB 增加到 2 GB。
【解决方案2】:

我没有添加评论,因为我的答案需要一些好的格式。

也就是说,您的端口 8080 已被使用。我建议停止 GitLab,并将 unicorn 端口从 8080 更改为 8081 (或一些未使用的端口)。

启动/重启 GitLab 后等待 2 分钟,你应该没问题。如果没有,请再次检查 gitlab-ctl tail 是否有任何错误。

# gitlab-ctl stop

# vi /etc/gitlab/gitlab.rb   (change only these lines, uncomment if required)
unicorn['port'] = 8081
gitlab_git_http_server['auth_backend'] = "http://localhost:8081"

# gitlab-ctl reconfigure  (to apply the changes)
# gitlab-ctl restart
# lsof -i:8081        (check whether unicorn has started properly)

您需要是 root 或 sudo 用户(具有 root 权限)才能运行这些命令。

【讨论】:

  • 我将端口号 8080 更改为 8081 并在 gitlab.rb 文件中添加了一行 gitlab_git_http_server['auth_backend'] = "http://localhost:8081",因为它不存在。但是,它仍然给出相同的错误信息。 FATAL -- : error adding listener addr=127.0.0.1:8080
  • 该行肯定存在,但使用端口 8080,您必须取消注释并将其更改为端口 8081。
  • 我再次尝试重新配置。 /var/log/gitlab/postgresql/currentLOG: received fast shutdown request LOG: database system is shut down LOG: could not bind socket for statistics collector: Cannot assign requested address LOG: trying another address for the statistics collector LOG: could not create socket for statistics collector: Address family not supported by protocol LOG: disabling statistics collector for lack of working socket WARNING: autovacuum not started because of misconfiguration HINT: Enable the "track_counts" option.还有一个错误日志
  • gitlab-ctl status 显示了什么?所有进程都启动了吗?您可能需要对 postgres 进行故障排除。试试lsof -i:5432sudo -u postgres psql template1
  • 所有进程都在运行(logrotate、nginx、postgresql、redis、sidekiq、unicorn)。也许端口 5432 未使用。 sudo lsof -i:5432 不返回任何消息。
【解决方案3】:

在检查了 gitlab-ctl tail(重启循环)后,发现内存不足(2GB),并且我的新 Ubuntu 设置中没有交换文件。

如上所述in requirements GitLab 至少需要 2GB RAM + 2GB 交换内存 ...

所以要创建交换文件,请按照以下步骤操作:

  1. gitlab-ctl stop

  2. mkdir /swap && touch /swap/swapfile.img

  3. dd if=/dev/zero of=/swap/swapfile.img bs=1024 count=2M#如果要4G的话2M改成4M
  4. chmod 0600 /swap/swapfile.img
  5. mkswap /swap/swapfile.img
  6. nano /etc/fstab 并添加“/swap/swapfile.img swap swap sw 0 0”
  7. swapon /swap/swapfile.img
  8. 验证它是否有效:cat /proc/swaps

    Filename                Type        Size    Used    Priority
    
    /swap/swapfile.img      file        2097148 0       -1
    
  9. gitlab-ctl start

有关创建交换的更多信息:here

【讨论】:

  • 我遇到502错误,我将虚拟盒子内存从1GB更改为2GB,错误消失了。
【解决方案4】:

您可以按照以下步骤解决此类问题。

  1. unicorn['port']更新为****。(系统中不用于进程的不同端口)
  2. nginx['port']更新为****。(系统中不用于进程的不同端口)
  3. 更新此文件中的web_server 用户名和web_server 组,并将其设置为apache/httpd 的用户名和组

然后执行gitlab-ctl reconfiguregitlab-ctl restart

【讨论】:

    【解决方案5】:

    您应该更改您的独角兽设置 如果您需要调整 Unicorn 超时时间或工作人员数量,您可以使用 /etc/gitlab/gitlab.rb 中的以下设置。 更改以下内容:

    unicorn['worker_processes'] = 3
    unicorn['worker_timeout'] = 120 # or any suitable timeout for your server
    

    如果有注释,不要忘记删除行开头的#。 运行sudo gitlab-ctl reconfigure 以使更改生效。

    【讨论】:

      【解决方案6】:

      由于未满足安装 Gitlab 的最低要求,系统(在您的情况下为 Raspberry Pi2(在我的情况下为 t2.micro AWS EC2 实例))也会发生此错误。

      那是内存不足(t2.micro 是 1GiB,但 Gitlab 需要 4GiB)用于进一步处理。因此,正确提供所有要求(我占用了一个 4GiB 的 t2.medium 实例而不是 t2.micro)。 如果系统已准确启用,将是合适的。

      【讨论】:

        【解决方案7】:

        需要设置nginx['listen_port']unicorn['port']。 例如:

        nginx['listen_port'] = 8081
        unicorn['port'] = 8082 #the ports should be different
        

        然后:

        sudo gitlab-ctl reconfigure
        sudo gitlab-ctl restart
        

        【讨论】:

        • 这与3438276 有何不同?此外,指出需要更改的文件总是一个好主意。
        【解决方案8】:

        我的站点发生了端口冲突。 Jenkins 已经在我的站点上运行,它也使用 8080 端口。

        更改 Gitlab 或 Jenkins 端口。

        【讨论】:

          【解决方案9】:

          有东西在监听 8080 端口,所以 Unicorn 无法启动。 下面的命令说明了什么? Redis、PostgreSQL 和 Puma 的端口可以在

          中覆盖

          /etc/gitlab/gitlab.rb

          如下:

              redis['port'] = 1234
              postgresql['port'] = 2345
              puma['port'] = 3456
          

          有关 NGINX 端口更改,请参阅 settings/nginx.md。

          https://docs.gitlab.com/omnibus/common_installation_problems/#tcp-ports-for-gitlab-services-are-already-taken (GitLab 服务的 TCP 端口已经占用)

          【讨论】:

            【解决方案10】:

            请注意,如果您收到 502 Whoops,GitLab 响应时间过长 在每一步都走这么多之前

            • 确保您的服务器至少有 4GB 内存
            • 如果您使用的是数字海洋水滴,请给她的服务器至少 10 分钟

            【讨论】:

              【解决方案11】:

              您可能已经更改了一些配置文件,请在终端中使用以下行:

              sudo gitlab-ctl reconfigure
              sudo gitlab-ctl restart
              

              现在等待几分钟,然后重试。

              【讨论】:

                【解决方案12】:

                您应该只更改external_url http://xxx.xxx.xxx.xx:9090。不要更改# unicorn['port'] = 8080

                【讨论】:

                • 好吧,我杀了一晚上又一晚上,试图了解我的情况出了什么问题,我尝试了如上所述的不同端口,最后我只是将 RAM 扩展到 8gb,因为我在 ubuntu 下使用wmware 和 502 不见了。我之前读过 ofdoc 一段时间,但我认为,即使 RAM 更少,gitlab 也可以运行。这种行为对我来说有点奇怪:(
                猜你喜欢
                • 2021-07-23
                • 2016-10-24
                • 2016-07-20
                • 2018-11-19
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2021-08-21
                相关资源
                最近更新 更多