2012-09-27 127 views
11

大家好!postgresql共享內存設置

我們現時與共享存儲器中的以下參數:

postgres的

shared_buffers = 7GB 
max_connections = 1 500 
max_locks_per_transaction = 1 024 
max_prepared_transactions = 0 (not set) 

系統

SHMALL = 2 097 152 
SHMMAX = 17 670 512 640 
SHMMNI = 4096 

的RAM的量是24 693 176k中

我們需要增加MAX_CONNECTIONS〜3 000當我們試圖做到這一點,我們得到了一個錯誤

[1-1] FATAL: could not create shared memory segment: No space left on device 
[2-1] DETAIL: Failed system call was shmget(key=5432001, size=8964661248, 03600) 
[3-1] HINT: This error does *not* mean that you have run out of disk space. 
It occurs either if all available shared memory IDs have been taken, in which 
case you need to raise the SHMMNI parameter in your kernel, or because the 
system's overall limit for shared memory has been reached. If you cannot 
increase the shared memory limit, reduce PostgreSQL's shared memory request 
(currently 8964661248 bytes), perhaps by reducing shared_buffers or 
max_connections. 
The PostgreSQL documentation contains more information about shared memory 
configuration. 

該提示建議提高SHMMNI內核參數,但我不知道如何很多補充:)另外,我相信所有這些參數都會以某種方式相關,所以我們需要相應地更改其他參數嗎?

由於提前,

亞歷山大

回答

17

增加SHMMNI不會幫助,那就是這裏的重要暗示的第二部分。

使用shell命令getconf PAGE_SIZE獲取系統的頁面大小。
通常是4096.乘以SHMALL

在你的情況下應該是2097152 * 4096 = 8589934592,這正好是8Gb。 這是您當前的最大共享內存,與SHMMNI無關。

PostgreSQL錯誤消息表明它需要多一點。

結論:增加SHMALL

+2

非常感謝答案! – shutyaev

+1

注意:根據文檔中的linux部分(postgresql.org/docs/9.0/static/kernel-resources.html),SHMALL的值應該是PAGE_SIZE除以SHMAX。 –