Ubuntu

在 16GB Linode VPS 上調整 Postgresql

  • February 12, 2014

我在 16GB Linode(Ubuntu 12.04 32bit)上執行專用 PostgreSQL。我試過使用 pgtune,但我會遇到共享記憶體錯誤。IE

The PostgreSQL server failed to start. Please check the log output:
2014-02-10 08:32:39 EST FATAL:  could not create shared memory segment: Invalid argument
2014-02-10 08:32:39 EST DETAIL:  Failed system call was shmget(key=5432001, size=4107419648, 03600).
2014-02-10 08:32:39 EST 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 4107419648 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
   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

所以我繼續並開始調整 SHMAX,但我真的不確定我應該將它設置為什麼。我希望 pgtune 能讓我知道,或者我可以在@linode 找到一些關於此的文件。我假設這個值以字節為單位?我讀過它應該是總記憶體的 1/4 到 1/2(所以 4 或 8 GB),但當你使用 32 位時它不應該超過 4GB。

有什麼建議嗎?您建議將 SHMAX 設置為什麼?為什麼?我應該放棄 pgtune,還是將最大記憶體參數傳遞給它?

謝謝!

VPS 記憶體詳細資訊:

            total       used       free     shared    buffers     cached
Mem:      16617352     334320   16283032          0      18132     208400
-/+ buffers/cache:     107788   16509564
Swap:       524284          0     524284
  • 更新 -

遷移到 64 位基本上使一切正常。SHMAX 被接受(順便說一下,它以字節為單位)。弄清楚將其設置為什麼,我只使用了盒子上一半的可用 RAM(Ubuntu 上的“free -b”以字節為單位查看記憶體)。

我基本上對其餘的 pgtune 建議進行了一些小的調整。

apt-get install pgtune

您在具有 16GB RAM 的機器上安裝了 32 位作業系統。這是行不通的。即使 32 位作業系統在技術上可以使用超過 4GB 的 RAM,作業系統上的單個程序也不能超過該界限。重新開始並安裝 64 位作業系統,這個問題就會消失(以及您將遇到的所有其他問題)。

引用自:https://serverfault.com/questions/574452