今天在阿里云上配置GitLab,不过一直出现错误502错误。

502 
GitLab is not responding. 
Please contact your GitLab administrator if this problem persists.

gitlab出现的502错误

经过一个下午的查找终于发现了错误,原来是在服务器上还开启了一个tomcat服务,占用了8080端口,使GitLab的unicorn服务不能开启。 
最后在/etc/gitlab/gitlab.rb 中做出如下修改

<code class="hljs bash has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">unicorn[<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'port'</span>] = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9090</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

gitlab-ctl reconfigure 重启配置,这样GitLab服务器就可以正常运行了。


这里记录一下解决问题的大概经过,也算给自己长经验。 
安装好GitLab,开启服务,发现有502错误。这是开始寻找解决办法,各种百度。 
1.找到/var/log/gitlab/nginx中的错误日志文件,发现有如下错误/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket failed (2: No such file or directory),然后用 nc命令创建了这个socket文件,最终权限设为srwxrwxrwx,用户和组设置为git:git,但发现这个方法行不通。

2.这时我跑到GitLab的官网去寻找解决办法,https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md 
ctrl+f 502 找到官方教程中说502出现的问题

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.

尝试用上面两个命令解决,发现没有用。 
这时我怒了,不断的输入gitlab-ctl status,发现unicorn的pid一直在变大。而其他几个服务的pid没有变化。

3.这时差不多找到了问题的所在了,应该就是unicorn的问题。然后看官方教程,可以使用gitlab-ctl tail unicorn 来跟踪unicorn的状态,这时候悲催的发现原来时权限不够,chmod -R 777 /var/log/gitlab

2015-05-09_14:17:29.67447 /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:732:in `initialize': Permission denied @ rb_sysopen - /var/log/gitlab/unicorn/unicorn_stderr.log (Errno::EACCES)
2015-05-09_14:17:29.67466 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:732:in `open'
2015-05-09_14:17:29.67469 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:732:in `redirect_io'
2015-05-09_14:17:29.67473 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:177:in `stderr_path='
2015-05-09_14:17:29.67478 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/lib/unicorn/configurator.rb:111:in `block in commit!'
2015-05-09_14:17:29.67482 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/lib/unicorn/configurator.rb:108:in `each'
2015-05-09_14:17:29.67486 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/lib/unicorn/configurator.rb:108:in `commit!'
2015-05-09_14:17:29.67491 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:121:in `initialize'
2015-05-09_14:17:29.67496 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/bin/unicorn:126:in `new'
2015-05-09_14:17:29.67500 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/gems/unicorn-4.6.3/bin/unicorn:126:in `<top (required)>'
2015-05-09_14:17:29.67504 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/unicorn:23:in `load'
2015-05-09_14:17:29.67509 from /opt/gitlab/embedded/service/gem/ruby/2.1.0/bin/unicorn:23:in `<main>'
2015-05-09_14:17:29.68708 master failed to start, check stderr log for details


<ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li></ul>

4.好了,终于发现了问题的所在。这时候的选择就变成了是把原来8080端口的服务给杀了还是将unicorn的端口换一个呢。这个就看自己的具体需求了。我这边是将unicorn端口换成了9090,方法就是开头讲的方法了

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐