且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):

更新时间:2022-04-25 11:06:14

  gitlab可以成功clone和push,但是提交后的文件却无法查看。从页面上看的话只显示出500错误。

    gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):

  查了下gitlab的日志

tail -f /var/log/gitlab/gitlab-rails/production.log

  显示如下异常:

gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):
Started GET "/gitlab/root/test/commit/e83228ea1bbf183a0f3199f11f995731b23bc1f7" for 14.23.93.99 at 2016-07-04 17:49:08 +0800
Processing by Projects::CommitController#show as HTML
  Parameters: {"namespace_id"=>"root", "project_id"=>"test", "id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7"}
Completed 200 OK in 224ms (Views: 156.4ms | ActiveRecord: 14.7ms)
Started GET "/gitlab/root/test/commit/e83228ea1bbf183a0f3199f11f995731b23bc1f7/branches" for 14.23.93.99 at 2016-07-04 17:49:09 +0800
Processing by Projects::CommitController#branches as HTML
  Parameters: {"namespace_id"=>"root", "project_id"=>"test", "id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7"}
Completed 500 Internal Server Error in 291ms (ActiveRecord: 3.1ms)

Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):
  lib/gitlab/popen.rb:23:in `popen'
  app/models/repository.rb:648:in `refs_contains_sha'
  app/models/repository.rb:664:in `branch_names_contains'
  app/controllers/projects/commit_controller.rb:64:in `branches'
  lib/gitlab/middleware/go.rb:16:in `call'


Started GET "/gitlab/root/test/autocomplete_sources?type=Commit&type_id=e83228ea1bbf183a0f3199f11f995731b23bc1f7" for 14.23.93.99 at 2016-07-04 17:49:10 +0800
Processing by ProjectsController#autocomplete_sources as JSON
  Parameters: {"type"=>"Commit", "type_id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7", "namespace_id"=>"root", "id"=>"test"}
Completed 200 OK in 170ms (Views: 83.8ms | ActiveRecord: 9.9ms)
Started GET "/gitlab/root/test/notes?target_id=e83228ea1bbf183a0f3199f11f995731b23bc1f7&target_type=commit&last_fetched_at=1467625748" for 14.23.93.99 at 2016-07-04 17:49:24 +0800
Processing by Projects::NotesController#index as JSON
  Parameters: {"target_id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7", "target_type"=>"commit", "last_fetched_at"=>"1467625748", "namespace_id"=>"root", "project_id"=>"test"}
Completed 200 OK in 47ms (Views: 0.3ms | ActiveRecord: 3.6ms)
gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):

   查了下内存为2G,已经满足gitlab最小内存1G的要求。

[root@xxxxxx ~]# free -h
             total       used       free     shared    buffers     cached
Mem:          1.8G       1.7G        63M        43M       9.7M       140M
-/+ buffers/cache:       1.6G       213M
Swap:           0B         0B         0B

  但是非常诡异的是swap为0,网上找了发现也有人遇到相应的问题。于是修改下swap的大小

gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):
[root@xxxx ~]# free -h
             total       used       free     shared    buffers     cached
Mem:          1.8G       1.7G        63M        43M       9.7M       140M
-/+ buffers/cache:       1.6G       213M
Swap:           0B         0B         0B
[root@xxxx ~]# mkdir /swapfile
[root@xxxx ~]# cd /swapfile
[root@xxxx swapfile]# sudo dd if=/dev/zero of=swap bs=1024 count=2000000
2000000+0 records in
2000000+0 records out
2048000000 bytes (2.0 GB) copied, 39.1198 s, 52.4 MB/s
[root@xxxx swapfile]# sudo mkswap -f  swap
Setting up swapspace version 1, size = 1999996 KiB
no label, UUID=75b00bde-7aed-48f3-b373-126a2054ad26
[root@xxxx swapfile]# sudo swapon swap
swapon: /swapfile/swap: insecure permissions 0644, 0600 suggested.
[root@xxxx swapfile]# free -h
             total       used       free     shared    buffers     cached
Mem:          1.8G       1.7G        93M        43M       1.2M        23M
-/+ buffers/cache:       1.7G       118M
Swap:         1.9G         0B       1.9G
[root@xxx swapfile]# 
gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):

   修改后再次查看,果断地出来了,记录于此。








本文转自秋楓博客园博客,原文链接:http://www.cnblogs.com/rwxwsblog/p/5641278.html,如需转载请自行联系原作者