home prev next

共有メモリのサイズ変更メモ


Ubuntu8.10 にて Postgres8.1.3 をインストールし、実行したところ次のエラーが発生して起動に失敗した。

# FATAL:  could not create shared memory segment: Invalid argument
DETAIL:  Failed system call was shmget(key=5432001, size=43753472, 03600).
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 43753472 bytes), reduce PostgreSQL's shared_buffers parameter (currently 5000) and/or its max_connections parameter (currently 100).
	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.
	The PostgreSQL documentation contains more information about shared memory configuration.

どうやら共有メモリが足りないようである。
現状のシステム構成を確認してみる。

# sysctl -a | grep shmmax
kernel.shmmax = 33554432

現状の SHMMAX は 32MB に対して Postgres が使用する共有メモリのサイズが上限を超えたことが原因である。
対策としては、共有メモリのサイズを変更するか、Postgres で使用する共有メモリのサイズを変更すれば良い。
尚、共有メモリのサイズを変更するにはカーネルを再構築する必要がある。
/etc/sysctl.conf を変更して sudo sysctl -p を実行して変更した内容を反映させる。

    SHMALL	使用可能な共有メモリの総量
        バイト指定の場合は SHMMAX と同じ値
        ページ指定の時は ceil(SHMMAX/PAGE_SIZE)
    SHMMAX	共有メモリセグメントの最大サイズ

... とすればいいんだけど面倒になってきたから postgres.conf の shared_buffer を 3000 くらいにすればいっか。

因みに SHMALL は 2097152 だったから PAGE_SIZE は 16 くらいかなー。


home prev next

Last-modified: Mon Feb 09 12:43:05 JSP 2009
Site admin:りお

Powerd by ninjatools

ふつう このページは Another HTML-lint gatewayふつうと判断されました。