
| ・ |
ドキュメントセンターを初めてご利用する方や運営方針についての基本的な姿勢をご覧になりたい方へ。
|
| ご利用の皆様から多く寄せられる質問にお答えしています。 |
|
| ・ |
ディーエーオフィスなどが利用する用語に関する解説を行います。
|
|
|
 |
 |  |
PostgreSQLに関連したメモリ調整方法 |
メモリの状況をチェックして、出来るだけ多くの割り当てを行うのがポイントとなるようです。ipcs -MでOS全体のメモリ状況を把握し、shmmax値を変更します。さらに、PostgreSQL側で割り当てられたメモリをpostgresql.confにてshared_buffersを変更します。
# 現在の共有メモリの状態
ipcs -M
# メモリの設定はここで変更を行うようです。
ee /etc/sysctl.conf
# 未確認
---
kern.ipc.shmmax=33554432,67108864,133554432,134217728
kern.ipc.shmall=32768
---
# 再起動せずに割り当てが変更できるようです。ただし、ここで設定したものは再起動後に元へ戻ります。
# 各値のチェック例
sysctl kern.ipc.shmmax
sysctl kern.ipc.shmall
sysctl kern.ipc.shmmaxpgs # これはunknown oid
# 各値の変更例
sysctl kern.ipc.shmmax=33554432 #デフォルト
sysctl kern.ipc.shmall=8192 #デフォルト
sysctl kern.ipc.shmmax=67108864 or 134217728
sysctl kern.ipc.shmall=32768
# sysctlに関しては以下を参考。
http://www.freebsd.org/doc/ja_JP.eucJP/books/handbook/configtuning-sysctl.html
# メモリ関連のまとめは以下を参考。
http://ml.postgresql.jp/pgsql-jp-old/pgsql-jp/2000Apr/msg00375.html
# FreeBSD では SHMMAX を使わないようにしてください。SHMMAXPGS を使うようにしましょう。
# http://www.freebsd.org/doc/ja_JP.eucJP/books/handbook/linuxemu-oracle.html
# ただこの設定についてはsysctl.conf上でどう設定するのかは不明。SHMMAXを使用中。
# FreeBSD4.9 Memory1GB Pentium4でひとまず設定した値
# ひとまずメモリ確保という意味では十分効果があった
sysctl kern.ipc.shmmax=134217728
sysctl kern.ipc.shmall=32768
postgresql.confのshared_buffersは10000
# 関連項目
vacuum analyze
vacuum full
# メモリも気になるが、速度低下の大半の問題はこちらの要素の方が大きいといつも感じる。
---
以下、未検証。
# 参考。PostgreSQL利用の方が書いていらっしゃるコメント。
http://apex.wind.co.jp/tetsuro/f-bsd/kernel.html
# 現在のセマフォの状態
ipcs -S
# 大規模サイトの為のFreeBSDカーネルチューニング
# 参考 http://www.nxhack.tarumi.kobe.jp/FreeBSD_kernel_tuning.html
# binding ShmemCreateを確認
postmaster -B 256 -d 3 -i
# Bオプションはバッファー。postgresql.confのshared_buffersに同じ。
# ハード制限 limitコマンド
ee /etc/login.conf
# 設定例。カーネルの再構築が必要となっているが、FreeBSD4.9では不要だった。
---
options SYSVSHM
options SHMMAXPGS=4096
options SHMSEG=256
options SYSVSEM
options SEMMNI=256
options SEMMNS=512
options SEMMNU=256
options SEMMAP=256
---
# 参考 http://www.postgresql.jp/document/pg721doc/admin/kernel-resources.html
メモリの割り当てが出来なかったときは以下のようなエラーが表示される。
FATAL: could not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(key=5432001, size=41033728, 03600).
HINT: This error usually means that PostgreSQL’s request for a shared memory se
gment exceeded your kernel’s SHMMAX parameter. You can either reduce the reques
t size or reconfigure the kernel with larger SHMMAX. To reduce the request size
(currently 41033728 bytes), reduce PostgreSQL’s shared_buffers parameter (curre
ntly 4800) and/or its max_connections parameter (currently 40).
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 recon
figuring SHMMIN is called for.
The PostgreSQL documentation contains more information about shared memo
ry configuration.
postmaster successfully started
|
| 文書番号 |
00814 |
| 日付 |
2004.04.16 |
| 参照数 |
1759 |
|