teketeke_55の日記

技術メモとか

nginx+unicorn+gitlabの組み合わせでgitlabが起動しなくなった際の対応メモ。

AWS EC2 で表題構成のgitlabを運用していたのだが、EBSの初期値を使いきってしまったためDISKの拡張をした。
拡張後サーバを起動したのだがgitlabのWEBUIにアクセスできない。プロセスを見るとunicornが立ち上がっていないようだった。
手動で起動すると以下のメッセージ出力されて起動しない。

 # /etc/init.d/gitlab start
  Starting Gitlab service: master failed to start, check stderr log for details
 unicorn.

nginx側のログを見ると下記の出力が。

 2012/12/27 16:31:55 [error] 7692#0: *2 connect() to unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket failed (111: Connection refused) while connecting to upstream, client: 113.xxx.xxx.xxx, server: 54.xxx.xxx.xxx, request: "GET / HTTP/1.1", upstream: "http://unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket:/", host: "gitlab.xxx.net"

色々調べて見たがよくわからない。
 
psで再びプロセスを確認してみたところredisも起動していないことに気づいた。
起動スクリプトを叩いても起動しない。
redisのLOGを見てみると、

 [1083] 27 Dec 15:52:13 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
 [1083] 27 Dec 15:52:14 # Short read or OOM loading DB. Unrecoverable error, aborting now.

どうやらDISKを使い切った際にredisの何かが壊れたらしい。
 
redisのdumpファイルrenameしてそれぞれを起動したところうまく行った。
(vm.overcommitの設定はOOM killerが起きやすくなりそうなので設定はしなかった)

 mv /var/lib/redis/dump.rdb /var/lib/redis/dump.rdb.bk
 /etc/init.d/redis-server start
 Starting redis-server: redis-server.
 /etc/init.d/gitlab start
 Starting Gitlab service: unicorn.

参考文献:
http://rfs.jp/server/aws
https://groups.google.com/forum/?fromgroups=#!topic/redis-db/P7F3jBPu6lM
http://passingloop.tumblr.com/post/11957331420/overcommit-and-oom-killer