前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >HTTP 502: Whoops, GitLab is taking too much time to respond.

HTTP 502: Whoops, GitLab is taking too much time to respond.

作者头像
拓荒者
发布2019-09-24 11:54:08
3.5K0
发布2019-09-24 11:54:08
举报
文章被收录于专栏:运维经验分享

HTTP 502: Whoops, GitLab is taking too much time to respond.

这次排错过程主要是思路,视野打开后会觉得豁然开朗,原来这其实是个小问题[尴尬]。

1、没注重应用启动的各服务及其用途,只会简单查看 status;

2、看到错误第一时间想到的是 Baidu(没其他意思),找找 logpath 先看日志不好吗?

3、未认识到服务之间的关联关系(比如 postgresql 与 unicorn 之间),前面一直知道 unicorn 启动后没正常监听到端口,但是日志并没啥特别信息(嗯,可能是因为看错了文件)[苦笑]

 一、错误信息

二、排错过程

1、启动 unicorn 未监听端口

日志路径 :   /var/log/gitlab/unicorn/unicorn_stderr.log

代码语言:javascript
复制
PG::ConnectionBad: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?

  /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
  /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
  /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
  /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
  /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
  /opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'

··· ···
··· ···

信息显示是因为连不上PG,所以启动 postgresql 后重启即可正常(嗯,是酱)。。

2、postgresql down

代码语言:javascript
复制
down: postgresql: 0s, normally up, want up; run: log: (pid 623) 15816094s

通过 PG 的日志路径 : /var/log/gitlab/postgresql/current 可以查看到如下信息

代码语言:javascript
复制
2018-11-01_08:18:09.49669 FATAL:  could not map anonymous shared memory: Cannot allocate memory
2018-11-01_08:18:09.49671 HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 4292984832 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
2018-11-01_08:18:09.49671 LOG:  database system is shut down

也可以通过命令 `gitlab-ctl tail postgresql`,得到一样的信息,于是可以确定问题。。

代码语言:javascript
复制
This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 4292984832 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
2018-11-01_07:52:06.63024 LOG:  database system is shut down

于是在配置文件中对 postgresql 的 shared_buffers 和 max_connections 两项进行了限制

代码语言:javascript
复制
[root@V2 ~]# cat /etc/gitlab/gitlab.rb |grep -v ^$ |grep -v ^#
external_url 'http://xxx.xxx.xxx.xxx.xxx:8090'
unicorn['worker_timeout'] = 60
unicorn['worker_processes'] = 3
unicorn['listen'] = 'xxx.xxx.xxx.xxx.xxx'
unicorn['port'] = 8870
postgresql['enable'] = true
postgresql['data_dir'] = "/var/opt/gitlab/postgresql/data"
postgresql['shared_buffers'] = "256MB"   # ! **recommend value is 1/4 of total RAM, up to 14GB.**      
postgresql['max_connections'] = 200
nginx['listen_addresses'] = ['*']
nginx['listen_port'] = 8090

配置完成保存,之后更新配置,重启应用即可。

代码语言:javascript
复制
gitlab-ctl reconfigure       # 更新配置
gitlab-ctl restart           # 重启应用
gitlab-ctl status            # 查看服务状态

参考资料

1. 502-Whoops, GitLab is taking to

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • HTTP 502: Whoops, GitLab is taking too much time to respond.
  •  一、错误信息
  • ?
  • 二、排错过程
    • 1、启动 unicorn 未监听端口
      • 2、postgresql down
      • 参考资料
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档