gitlab可以成功clone和push,但是提交后的文件却无法查看。从页面上看的话只显示出500错误。
查了下gitlab的日志
tail -f /var/log/gitlab/gitlab-rails/production.log
显示如下异常:
Started GET "/gitlab/root/test/commit/e83228ea1bbf183a0f3199f11f995731b23bc1f7" for 14.23.93.99 at -- :: +
Processing by Projects::CommitController#show as HTML
Parameters: {"namespace_id"=>"root", "project_id"=>"test", "id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7"}
Completed OK in 224ms (Views: .4ms | ActiveRecord: .7ms)
Started GET "/gitlab/root/test/commit/e83228ea1bbf183a0f3199f11f995731b23bc1f7/branches" for 14.23.93.99 at -- :: +
Processing by Projects::CommitController#branches as HTML
Parameters: {"namespace_id"=>"root", "project_id"=>"test", "id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7"}
Completed Internal Server Error in 291ms (ActiveRecord: .1ms) Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):
lib/gitlab/popen.rb::in `popen'
app/models/repository.rb::in `refs_contains_sha'
app/models/repository.rb::in `branch_names_contains'
app/controllers/projects/commit_controller.rb::in `branches'
lib/gitlab/middleware/go.rb::in `call' Started GET "/gitlab/root/test/autocomplete_sources?type=Commit&type_id=e83228ea1bbf183a0f3199f11f995731b23bc1f7" for 14.23.93.99 at -- :: +
Processing by ProjectsController#autocomplete_sources as JSON
Parameters: {"type"=>"Commit", "type_id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7", "namespace_id"=>"root", "id"=>"test"}
Completed OK in 170ms (Views: .8ms | ActiveRecord: .9ms)
Started GET "/gitlab/root/test/notes?target_id=e83228ea1bbf183a0f3199f11f995731b23bc1f7&target_type=commit&last_fetched_at=1467625748" for 14.23.93.99 at -- :: +
Processing by Projects::NotesController#index as JSON
Parameters: {"target_id"=>"e83228ea1bbf183a0f3199f11f995731b23bc1f7", "target_type"=>"commit", "last_fetched_at"=>"", "namespace_id"=>"root", "project_id"=>"test"}
Completed OK in 47ms (Views: .3ms | ActiveRecord: .6ms)
查了下内存为2G,已经满足gitlab最小内存1G的要求。
[root@xxxxxx ~]# free -h
total used free shared buffers cached
Mem: .8G .7G 63M 43M 9.7M 140M
-/+ buffers/cache: .6G 213M
Swap: 0B 0B 0B
但是非常诡异的是swap为0,网上找了发现也有人遇到相应的问题。于是修改下swap的大小
[root@xxxx ~]# free -h
total used free shared buffers cached
Mem: .8G .7G 63M 43M 9.7M 140M
-/+ buffers/cache: .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= count=
+ records in
+ records out
bytes (2.0 GB) copied, 39.1198 s, 52.4 MB/s
[root@xxxx swapfile]# sudo mkswap -f swap
Setting up swapspace version , size = KiB
no label, UUID=75b00bde-7aed-48f3-b373-126a2054ad26
[root@xxxx swapfile]# sudo swapon swap
swapon: /swapfile/swap: insecure permissions , suggested.
[root@xxxx swapfile]# free -h
total used free shared buffers cached
Mem: .8G .7G 93M 43M 1.2M 23M
-/+ buffers/cache: .7G 118M
Swap: .9G 0B .9G
[root@xxx swapfile]#
修改后再次查看,果断地出来了,记录于此。