【Gitlab】Gitlab 的 postgresql無法啟動

問題


裝了新版的gitlab,結果遇到這個
timeout: down: postgresql: 0s, normally up, want up
任何的錯誤都不能忽視阿....
剛剛就是下完 gitlab-ctl reconfigure 以後才發生的orz


追蹤


不死心,重新試了一變..
# gitlab-ctl start
ok: run: logrotate: (pid 2249) 0s
ok: run: nginx: (pid 2252) 1s
timeout: down: postgresql: 0s, normally up, want up
ok: run: redis: (pid 2265) 0s
ok: run: sidekiq: (pid 2269) 1s
ok: run: unicorn: (pid 2274) 0s
起不來!!!決定用指令檢查一下
# gitlab-rake gitlab:check
PG::Error: could not connect to server: No such file or directory
 Is the server running locally and accepting
 connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

好的,看起來prstgresql沒起來,為了確認我還是下了指令
# toptree
恩,果真沒有。 接下來看到底發生了什麼事情讓他起不來
# gitlab-ctl tail postgresql
2015-07-13_21:34:29.21282 FATAL:  could not create shared memory segment: Invalid argument
2015-07-13_21:34:29.21283 DETAIL:  Failed system call was shmget(key=5432001, size=2170888192, 03600).
2015-07-13_21:34:29.21284 HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter.  You can either reduce the request size or reconfigure the kernel with larger SHMMAX.  To reduce the request size (currently 2170888192 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
2015-07-13_21:34:29.21285  If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the request size or reconfiguring SHMMIN is called for.
事情明朗起來了!!


解決方案


1. 減少postgresql使用的記憶體量
大概這樣做,不過我沒用這個方案
# vi /var/opt/gitlab/postgresql/data/postgresql.conf
...
shared_buffers = 1000MB # min 128kB
把他改小
2. 增加kernel.shmmax使用量
因為這台是虛擬機,所以選擇2


解決方法


增加kernel.shmmax使用量
# vi /etc/sysctl.conf
kernel.shmmax = 4294967296
上面這行我改成4G 1024*1024*1024*4
# sysctl -p
# gitlab-ctl reconfigure
收工!

留言