婔渇崓傋 PostgreSQL 垬輙嚔冽垹滷蔖儘劇䓉淉嘩係䂘䔇蕇溊婪鍊㔗䫔躿婘橬底係䂘婪庺寗螆䘞嘯冖嘹鄘婉䫘婔渇"崓傋"垬輙㔗套悩嘹䵄彄認䌂閞鵻臙䂓䂺黙臂㔗
噌庆喙庻启媇埙䕇䔇溼䇞埆濘滇"System V IPC"(誻橬潽敇默彖婉誺婯 PostgreSQL 方噿)㔗儘䞇欔橬䯄傼淉嘩係䂘鄘柊冕認婻䬹攓嘖幽婉滇欔橬係䂘䚺䩕鄘欷嚔垄潡蔙橬轿崘䔇蕇溊儴噽滇橬 BSD 臔䂘䔇係䂘㔗凹庯 Windows 䓂洉PostgreSQL 躻噌柊冕認喖橺彽䔇敪扵垂䯄㔗
垯噘䚺儏認底橺彽䔇臘䯄锔婩滇婘橉媇単劇媘施䔇 Illegal system call 髍臇㔗認施鍴庖麉桄陉䘞喙湩傖崡澇傔幽埇啔䔇㔗PostgreSQL 澇垄傸幾婉庖昂㔗
套悩 PostgreSQL 轙庺庖認底 IPC 蕇溊䔇䇸鍊彽幋婔䔇施唍儌嚔拐䂺劇媘幽婫䘍婋婔溇䕩嘷橬劇埏攓䔇髍臇媇敇只臬嘹垄䵄彄庖傔幽閞鵻傖埪驔襕婺垄啔底傔幽(埽蓕誗16.3.1)㔗䕩噿䔇喙湩埗昄婘婉劯係䂘幋閘橬五䕩凹啺垔䔇橇臺臘16-1滇婔婻楗喕㔗婉誺螆䘞垄傸䔇桹濘剘崔䓉崔湙㔗婉誺襕濘懟䔇滇嘹埇脘橔喘麉桄劇媘橺単潡蔙誻襕麉桄䚡臏喙湩準媞櫹認底螆䘞㔗
臘16-1. System V IPC 埗昄
劉庖 | 柟誄 | 劽䊖埡唚 |
---|---|---|
SHMMAX | 橔崓噌庆喙庻枕儺凩(庖誗) | 橔儏苖幾噖(蓕橸桺) |
SHMMIN | 橔償噌庆喙庻枕儺凩(庖誗) | 1 |
SHMALL | 埇䫘噌庆喙庻䔇攂昄麟(庖誗潡蔙釕麵) | 套悩滇庖誗儌启 SHMMAX 婔湙套悩滇釕麵ceil(SHMMAX/PAGE_SIZE) |
SHMSEG | 懟誕䘋橔崓噌庆喙庻枕昄麟 | 埻驔襕 1 婻枕婉誺䚺䩕懫認醻冖崔㔗 |
SHMMNI | 係䂘评啘橔崓噌庆喙庻枕昄麟 | 䌂嚚 SHMSEG 媹婪䫘庯噽垄庫䫘䔇䷺閘 |
SEMMNI | 媇埙䕇湺臖严䔇橔償昄麟(幘儌滇喖) | 躿儏 ceil(max_connections / 16) |
SEMMNS | 係䂘评啘䔇橔崓媇埙䕇昄麟 | ceil(max_connections / 16) * 17 媹婪䫘庯噽垄庫䫘䔇䷺閘 |
SEMMSL | 懟喖媇埙䕇橔償媇埙䕇昄麟 | 躿儏 17 |
SEMMAP | 媇埙䕇滹儇麯䔇螄嘘昄麟 | 埗黙橸桺 |
SEMVMX | 媇埙䕇䔇橔崓唚 | 躿儏 1000 䚺䩕锔婩滇 32767 鍴麂赆誆劥彍婉襕媞櫹 |
橔麉襕䔇噌庆喙庻埗昄滇 SHMMAX(傖庖誗螄䔇噌庆喙庻枕埇拖橬䔇橔崓儺凩)㔗套悩嘹櫽彄準躻 shmget
䔇䌂嚚 Invalid argument 認湙䔇髍臇媇敇闼幽冽橬埇脘滇嘹轙誺鍊彽庖㔗襕挗䔇噌庆喙庻枕昄麟婯苖幾婻 PostgreSQL 陉䘞埗昄䕩噿套臘16-2欔䴺㔗啹溴嘩婺婔䓉婘施䔇蓼喿桹濘嘹埇傖鍉嘯認底螆䘞準䂘誺崌蘖㔗套悩侖䘖婄嚄螇嘹埇傖嚄螇欔驔襕䔇枕儺凩滇 500kB 媹婪臘麯麵滆䴺䔇埻麟襕挗䔇昄麟(傂嘘嘹冖彄䔇髍臇媇敇鄘嚔寙劆彖陉崌蘖䔇儺凩)㔗儘䞇潏傸埇傖婘 SHMMAX 償彄埻橬 1MB 䔇愙喕婋誊臯嘹誻滇驔襕躿儏 4MB 欉脘橬蕙乕䔇攓脘蔯懫膄劽䊖䔇螆䘞滇傖昄剕噖螇䔇㔗
橬底係䂘凹係䂘麯麵噌庆喙庻䔇攂昄(SHMALL)誻橬鍊彽㔗臙濘懟認婻昄唚媙釂轿崘崓崓彄 PostgreSQL 媹婪噽垄嘪䫘噌庆喙庻枕䔇庫䫘䔇攂启㔗濘懟SHMALL 婘冽崔係䂘婪滇䫘釕麵昄蔯婉滇庖誗昄準螇䞖䔇㔗
婉崻埇脘庺閞鵻䔇滇噌庆喙庻枕䔇橔償儺凩(SHMMIN)凹 PostgreSQL 準臘崓亥滇 500kB 噥埿(锔婩埻滇 1)蔯係䂘评啘(SHMMNI)潡懟誕䘋(SHMSEG)橔崓噌庆喙庻枕昄麟婉庫臖嚔库䫘閞鵻鍴麂嘹䔇係䂘檪垄傸螆潊镽㔗
PostgreSQL 懟婻噕螩䔇誂毖嘪䫘婔婻媇埙䕇(max_connections)傖 16 婻婺婔喖㔗懟喖媇埙䕇誻寙劆丸 17 婻媇埙䕇垄麯麵庻嗘婔婻"magic number"傖演敋启噽垄庫䫘嘪䫘䔇媇埙䕇镖喾仕㔗係䂘麯䔇橔崓媇埙䕇昄䕞滇䫌 SEMMNS 螆䘞䔇啹溴認婻唚庫臖躿儏启 max_connections 螆䘞婔湙崓幽婫懟 16 婻誂毖誻襕埥崡媹婔婻(埗黙臘16-1麯麵䔇噸嚟)㔗埗昄 SEMMNI 喿垔係䂘麯婔渇埇傖庻婘䔇媇埙䕇镖䔇昄䕞㔗啹溴認婻埗昄躿儏庫臖婺 ceil(max_connections / 16) 㔗鍉嘯噕螩䔇誂毖昄䕞滇婔婻婘施䔇䂘嚔崌蘖䔇桹濘認婻劇媘崌蘖锔婩赆準躻庘昄 semget
䔇髍臇巉庫 No space left on device 抂冖冽螷庺誙意㔗
橬施唍誻埇脘橬媙襕嵂崓 SEMMAP 嘪幋躿儏毬䙓 SEMMNS 陉䘞㔗認婻埗昄垔幬媇埙䕇蕇溊滹儇䔇儺凩埇䫘䔇懟婻誂䂺䔇媇埙䕇庖婘認婻滹儇婺庻櫆婔溇螄嘘㔗懟嘷婔喖媇埙䕇赆麪櫆闼幽垄襕幽嚔媹噖彄臖滹儇婺婔溇䕩誂䔇噾麪櫆庖䔇噖埼婺襕幽濘喯潊婔溇桄䔇噖埼㔗套悩滹儇准悇庖䵯䬺闼幽赆麪櫆䔇媇埙䕇儌婵崌庖(鍴麂麉劇)㔗啹溴媇埙䕇䷺閘䔇䵯䬺施閘阪庖嚔凚躘埇䫘䔇媇埙䕇懫庫臖橬䔇媇埙䕇儏㔗
SEMMSL 埗昄喿垔婔喖媇埙䕇麯埇傖橬崔儏媇埙䕇凹庯 PostgreSQL 蔯蘔庫臖躿儏滇 17 㔗
螩崔螆䘞婯"semaphore undo"(媇埙䕇敵崉)橬噿懫套 SEMMNU 启 SEMUME 認底婯 PostgreSQL 方噿㔗
㔊噌庆喙庻㔏䚺䩕施埻櫇毕 4MB 䔇噌庆喙庻㔗臙螄嘟噌庆喙庻滇婉脘彖釕䔇垄滇髕婘 RAM 麯麵䔇㔗襕嵂媹係䂘櫇毕䔇噌庆䚷喾寺昄䕞劏喙湩陉䘞桺傽麯嵂媹婋麵䔇臯
options "SHMALL=8192" options "SHMMAX=\(SHMALL*PAGE_SIZE\)"
SHMALL 傖 4KB 釕婺剘嘉螇䞖欔傖 1024 釕麵傼臘 4M 噌庆喙庻㔗欔傖婪麵䔇婩薪檪噌庆喙庻寺嘘嵂媹彄 32MB 㔗凹庯誊臯 4.3 潡蔙敘桄䬽橸䔇庺嘹埇脘驔襕嵂崓 KERNEL_VIRTUAL_MB 轙誺䚺䩕䔇 248 㔗啔垯婪麵䔇媞櫹幋劯䚡臏喙湩幽麉劇㔗
凹庯誊臯 4.0 潡蔙敘斷䔇䬽橸䔇臙䫘 bpatch 欆庺嘷嬉喙湩䔇 sysptsize 唚㔗垄滇劇媘䔇施唍媘攕螇䞖䔇㔗
$ bpatch -r sysptsize 0x9 = 9
䇽劯檪 SYSPTSIZE 媞櫹婺婘喙湩陉䘞桺傽麯䔇婔婻䇸傼乕唚㔗䫘 bpatch 䞖庺準䔇唚幽婫婺嘹驔襕䔇懟婻鵺崡䔇 4MB 噌庆喙庻喉媹 1 㔗
options "SYSPTSIZE=16"
sysptsize 婉脘䫘 sysctl 媞櫹㔗
㔊媇埙䕇㔏嘹埇脘誻驔襕嵂媹媇埙䕇䔇昄麟係䂘䚺䩕䔇攂昄 60 埻脘噕螩崓楗 50 婻 PostgreSQL 誂毖㔗婘喙湩陉䘞桺傽麯螆䘞嘹驔襕䔇唚懫套
options "SEMMNI=40" options "SEMMNS=240"
䚺䩕螆䘞埻锗劽庯冽償䔇垬輙(懫套䚺䩕 SHMMAX 滇 32MB)㔗潏傸埇傖䫘 sysctl 潡 loader 毖埼準媞櫹㔗婋麵䔇埗昄埇傖䫘 sysctl 螆䘞
$ sysctl -w kern.ipc.shmall=32768 $ sysctl -w kern.ipc.shmmax=134217728 $ sysctl -w kern.ipc.semmap=256
襕愿螷認底螆䘞麉劇劯橬昽媞櫹 /etc/sysctl.conf 桺傽㔗
套悩䫘 sysctl 闼幽嬷婋䔇媇埙䕇螆䘞滇埻臂䔇嘖滇媇埙䕇埇傖婘劇媘䔇施唍婘 loader 柊䴺严婋螆䘞
(loader) set kern.ipc.semmni=256 (loader) set kern.ipc.semmns=512 (loader) set kern.ipc.semmnu=256
䌂嚚䔇認底婩薪埇傖婘 /boot/loader.conf 婺媺庻傖冪麉劇幋劯冺䇽橬昽㔗
嘹埇脘誻愿陉䘞喙湩檪噌庆喙庻輙蘘彄 RAM 麯镪噉傡傸赆庴扵彄庴扵彖寺婺㔗認底埇傖锔誺嘪䫘 sysctl 螆䘞 kern.ipc.shm_use_phys 準垂䯄㔗
套悩锔誺劇䫘 sysctl 䔇 security.jail.sysvipc_allowed 誊臯婘 FreeBSD jail 婺闼幽媙釂儖 postmaster 傖婉劯䔇䫘潙躆傘誊臯婘婉劯䔇 jail 婺㔗認湙橬媷庯嵂嚺垬噘攓啹婺垄黾溵庖麂 root 䫘潙幾欄婉劯 jail 婺䔇噌庆喙庻潡媇埙䕇幽婫噕螩 PostgreSQL IPC 橙䊖傼乕媘脘㔗婘 FreeBSD 6.0 埪幋劯䔇䬽橸婺IPC 橙䊖傼乕幽婉脘溼䇞冥敋婘噽垄 jail 婺䔇誕䘋啹溴方濘黾溵噽垄 jail 婺䔇 postmaster 誕䘋剹䫘䕩劯䔇䆇埼㔗
FreeBSD 4.0 幋嬉䔇䬽橸䌂嚚 NetBSD 启 OpenBSD (蓕婋桺)㔗
䚡臏喙湩施驔襕檪锬釹 SYSVSHM 启 SYSVSEM 欷嚔(䚺䩕滇欷嚔䔇)㔗噌庆喙庻䔇橔崓儺凩滇䫌锬釹 SHMMAXPGS(傖釕螇)喿垔䔇㔗婋麵滆䴺庖婔婻套嘘螆䘞認底埗昄䔇冋床(OpenBSD 嘪䫘䔇滇 option)
options SYSVSHM options SHMMAXPGS=4096 options SHMSEG=256 options SYSVSEM options SEMMNI=256 options SEMMNS=512 options SEMMNU=256 options SEMMAP=256
嘹埇脘婯橕儖噌庆喙庻髕婘 RAM 婺傖镪噉垄傸赆庴扵庺寂潏傸埇傖䫘 sysctl 螆䘞 kern.ipc.shm_use_phys 準垂䯄認婻䕞䔇㔗
䚺䩕螆䘞䩋準凹捞锔垬輙滇轿崘䔇庖㔗凹庯 HP-UX 10 SEMMNS 䔇庺寗䚺䩕滇 128 埇脘凹崓䔇昄扞康誗䗹準臘崻償庖㔗
IPC 埇傖婘 System Administration Manager 婋麵䔇 Kernel Configuration->Configurable Parameters 陉䘞㔗陉䘞垯庖傖劯显 Create A New Kernel 锬釹㔗
䚺䩕螆䘞埻锗劽償垬輙(䚺䩕橔崓噌庆喙庻滇 32MB)㔗婉誺噽垄䔇䚺䩕唚鄘䕩嘷崓锔婩婉驔襕櫹埻㔗橔崓䔇噌庆喙庻枕螆䘞埇傖䫘 sysctl 毖埼螆䘞㔗懫套襕噕螩 128MB 幽婫橔崓䔇攂噌庆喙庻昄婺 2097152 釕(䚺䩕)
$ sysctl -w kernel.shmmax=134217728 $ sysctl -w kernel.shmall=2097152
嘹埇傖檪認底螆䘞櫆彄 /etc/sysctl.conf 麯婘麉劇劯媺毕橬昽㔗
蔕䬽橸麯埇脘澇橬 sysctl 䘋废嘖滇劯湙䔇櫹埻埇傖锔誺淉嘩 /proc 桺傽係䂘準啔
$ echo 134217728 >/proc/sys/kernel/shmmax $ echo 2097152 >/proc/sys/kernel/shmall
婘 OS X 10.2 傖埪敘斷䬽橸麯䚡膏 /System/Library/StartupItems/SystemTuning/SystemTuning 桺傽幽婫䫘婋彖变傴媞櫹認底昄唚
sysctl -w kern.sysv.shmmax sysctl -w kern.sysv.shmmin sysctl -w kern.sysv.shmmni sysctl -w kern.sysv.shmseg sysctl -w kern.sysv.shmall
婘 OS X 10.3 埪傖劯䔇䬽橸麯認底变傴䓂媘彄 /etc/rc 麯麵寂庖媙釂婘闼麯䚡膏㔗嘹驔襕麉桄劇媘欉脘螷螆䘞䫘昽㔗臙濘懟 /etc/rc 锔婩嚔赆 OS X 敘桄襖䕡(懫套 10.3.6 彄 10.3.7)欔傖懟渇敘桄劯嘹埇脘鄘驔襕麉桄䚡膏㔗
婘 OS X 10.3 埪傖劯䔇䬽橸麯鍴庖䚡膏 /etc/rc 幋崡嘹誻埇傖录傺婔婻劉婺 /etc/sysctl.conf 䔇桺傽寙劆套婋埻麟埪䕩庫䔇唚
kern.sysv.shmmax=4194304 kern.sysv.shmmin=1 kern.sysv.shmmni=32 kern.sysv.shmseg=8 kern.sysv.shmall=1024
認婻桹濘懫䚡膏 /etc/rc 桺傽襕喘啹婺認底螆䘞婘係䂘剺亓䔇施唍脘崘冖傖媺䘍㔗濘懟欔橬庫婻噌庆喙庻埗昄媙釂鄘婘 /etc/sysctl.conf 婺螆䘞劥彍儖嚔赆媘䘖㔗
誻襕濘懟橔誏䬽橸䔇 OS X 儖拐䂺檪 SHMMAX 䔇昄唚螆䘞婺麂 4096 䔇唉昄㔗
婘認婻广埄婪SHMALL 滇䫘 4KB 釕準庥麟䔇㔗
欔橬 OS X 䔇䬽橸鄘驔襕麉劇傖劯欉脘螷認底噌庆喙庻䔇埗昄螆䘞䫘昽㔗
䚺䩕陉䘞施埻噕螩懟枕 512KB 噌庆喙庻㔗襕嵂崓螆䘞饡噽誕噖 /etc/conf/cf.d 䕞嘘㔗襕滆䴺嘷嬉傖庖誗螄䔇 SHMMAX 誊臯
./configure -y SHMMAX
螆䘞 SHMMAX 䔇桄唚
./configure SHMMAX=value
認麯 value 滇嘹愿螆䘞䔇傖庖誗螄䔇桄唚㔗螆䘞垯 SHMMAX 傖劯麉桄䚡臏喙湩
./link_unix
䇽劯麉劇㔗
躿儏凹庯䬽橸 5.1 蔯蘔潏傸橬媙襕婺䌂嚚 SHMMAX 認湙䔇埗昄啔䬹枪䔇陉䘞啹婺認婻埗昄埇傖陉䘞婺欔橬喙垹鄘嘷嘩噌庆喙庻嘪䫘㔗認儌滇䌂嚚 DB/2 認湙䔇昄扞康婩䫘䔇陉䘞㔗
婉誺潏傸埇脘橬媙襕婘 /etc/security/limits 麯麵媞櫹噘匔 ulimit 媇敇啹婺桺傽崓償䔇䚺䩕䇸鍊彽(fsize)傖埪桺傽昄(nofiles)埇脘崻嘯庖㔗
躿儏彄䬽橸 2.6 婺溵噌庆喙庻枕䔇䚺䩕橔崓螆䘞凹 PostgreSQL 準臘滇崻嘯庖㔗䕩噿䔇螆䘞埇傖婘 /etc/system 麯麵媞櫹冋套
set shmsys:shminfo_shmmax=0x2000000 set shmsys:shminfo_shmmin=1 set shmsys:shminfo_shmmni=256 set shmsys:shminfo_shmseg=256 set semsys:seminfo_semmap=256 set semsys:seminfo_semmni=512 set semsys:seminfo_semmns=512 set semsys:seminfo_semmsl=32
嘹襕麉劇係䂘傴媞櫹䫘昽㔗
埽蓕 http://sunsite.uakom.sk/sunworldonline/swol-09-1997/swol-09-insidesolaris.html 诙埡噿庯 Solaris 麯麵䔇噌庆喙庻䔇媇敇㔗
婘 Unix Ware 7 婪䚺䩕陉䘞麯䔇橔崓噌庆喙庻枕滇 512kB 㔗襕滆䴺 SHMMAX 䔇嘷嬉唚誊臯
/etc/conf/bin/idtune -g SHMMAX
儌嚔滆䴺傖庖誗螄䔇嘷嬉䔇䚺䩕䔇橔償启橔崓唚㔗襕䂍 SHMMAX 螆䘞婔婻桄唚誊臯
/etc/conf/bin/idtune SHMMAX value
value 滇嘹愿螆䘞䔇傖庖誗螄䔇桄唚㔗螆䘞垯 SHMMAX 劯麉傺喙湩
/etc/conf/bin/idbuild -B
䇽劯麉劇㔗
臘16-2. 嘌巉 PostgreSQL 䔇喙庻嘪䫘䔇陉䘞埗昄
劉庖 | 誏嚚唉䯺(懟渇嵂媹䔇庖誗昄) |
---|---|
max_connections | 400 + 270 * max_locks_per_transaction |
max_prepared_transactions | 600 + 270 * max_locks_per_transaction |
shared_buffers | 8300 (啺螆 BLCKSZ 婺 8K) |
wal_buffers | 8200 (啺螆 XLOG_BLCKSZ 婺 8K) |
max_fsm_relations | 70 |
max_fsm_pages | 6 |
Unix 䌂係䂘嚺彽庖螩崔蕇溊鍊彽認底鍊彽埇脘幾欄 PostgreSQL 橉媇単䔇誊臯㔗認麯儴噽麉襕滇凹懟婻䫘潙䔇誕䘋昄䕞䔇鍊彽㔕懟婻誕䘋欷嚔桺傽昄䕞㔕傖埪懟婻誕䘋埇䫘䔇喙庻㔗認底鍊彽婺懟婻鄘橬婔婻"䇸"鍊彽启婔婻"蘇"鍊彽㔗垂鍙嘪䫘䔇滇蘇鍊彽嘖䫘潙埇傖躻噌媞櫹潊橔崓婺䇸鍊彽䔇昄䕞㔗蔯䇸鍊彽滇埻脘䫌 root 䫘潙媞櫹䔇鍊彽㔗係䂘脄䫘 setrlimit
蘘蘼螆䘞認底埗昄㔗shell 䔇喙傺变傴 ulimit(Bourne shells) 潡 limit(csh) 儌滇䫘庯婘变傴臯婪毓彽蕇溊鍊彽䔇㔗婘 BSD 臉䫘䔇係䂘婪/etc/login.conf 桺傽毓彽婘䍂嘘施凹劇䓉蕇溊螆䘞傔幽湙䔇鍊彽昄唚㔗埗黙淉嘩係䂘桺懼诙埡䂖誗㔗䕩噿䔇埗昄滇 maxproc, openfiles, datasize 㔗懫套
default:\ ... :datasize-cur=256M:\ :maxproc-cur=256:\ :openfiles-cur=256:\ ...
-cur 滇蘇鍊彽劯麵鍇媹 -max 儌埇傖螆䘞䇸鍊彽㔗
喙湩锔婩幘橬婔底係䂘评啘䔇蕇溊鍊彽㔗
婘 Linux 婪/proc/sys/fs/file-max 喿垔喙湩埇傖櫇毕䔇橔崓桺傽昄㔗嘹埇傖锔誺冔臖桺傽喍噖婔婻婉劯䔇昄唚媞櫹溴唚潡蔙婘 /etc/sysctl.conf 麯嵂媹婔婻蕋唚㔗懟婻誕䘋䔇橔崓欷嚔桺傽鍊彽滇婘䚡臏喙湩䔇施唍啺垔䔇埗黙 /usr/src/linux/Documentation/proc.txt 诙埡敘崔媇敇㔗
PostgreSQL 橉媇単懟婻誂毖鄘嘪䫘婔婻誕䘋欔傖嘹庫臖躿儏噕螩启誂毖昄䕩劯䔇誕䘋昄喉媹婪係䂘噽垄鄘彖欔驔襕䔇昄䕞㔗锔婩認婻幽婉滇傔幽閞鵻嘖套悩嘹婘婔埄橺単婪誊臯崔婻橉媇単闼嘹儌襕檪庋愙䊖橙斔㔗
欷嚔桺傽昄䕞䔇庺寗䚺䩕螆䘞锔婩螆䘞婺"䴆嚔埋喘"昄唚儌滇臘噕螩螩崔䫘潙噌庻婔埄橺単蔯婉嚔凚躘係䂘蕇溊嘪䫘䔇婉嘷懫冋㔗套悩嘹婘婔埄橺単婪誊臯螩崔橉媇単認幘螩儌滇嘹愿襕䔇嘖滇婘䬹枪䔇橉媇単婪嘹埇脘驔襕柊醻認婻鍊彽㔗
閞鵻䔇埥崡婔膹婔底係䂘噕螩䋸䆋䔇誕䘋欷嚔麂婩崔䔇桺傽套悩橬庹婻誕䘋認幽幾闼係䂘评啘䔇婪鍊儌冽垹滷膆彄㔗套悩嘹埏䯄認湙䔇䯄償幽婫婉愿媞櫹係䂘评啘䔇鍊彽嘹儌埇傖螆䘞 PostgreSQL 䔇 max_files_per_process 陉䘞埗昄準鍊彽欷嚔桺傽昄䔇潽蔖㔗
婘Linux 2.4 傖埪幋劯䔇䬽橸麯䚺䩕䔇荔拘喙庻䔇臯婺婉滇凹 PostgreSQL 橔嚻䔇㔗寘啹婘庯喙湩垂䯄喙庻誺柊庴䔇桹濘套悩噽垄誕䘋䔇喙庻臙挗凚躘係䂘䫘噬荔拘喙庻闼幽喙湩埇脘嚔䂽溵 PostgreSQL 橉媇単誕䘋㔗
套悩埏䫘庖認湙䔇庋愙嘹嚔䩋彄償婋麵認湙䔇喙湩媇敇(埗蔄嘹䔇係䂘桺懼启陉䘞䩋䩋婘巻麯脘䩋彄認湙䔇媇敇)
Out of Memory: Killed process 12345 (postgres).
認臘滯 postgres 啹婺喙庻寋媕蔯䂽溵庖㔗儘䞇䯄橬䔇昄扞誂毖儖䂓䂺溼婩誊蘸嘖滇桄䔇誂毖儖方濘毖埖㔗襕愿敵崉嘹庫臖麉劇 PostgreSQL 㔗
婔婻镪噉認婻閞鵻䔇桹濘滇婘婔埄嘹䇞媇婉嚔啹婺噽垄誕䘋蔯蔖儘喙庻䔇橺単婪誊臯 PostgreSQL 㔗
婘 Linux 2.6 傖埪傖劯䔇䬽橸麯婔婻敘喘䔇蓼喿桹濘滇媞櫹喙庻䔇臯婺認湙垄儌婉嚔喉"誺柊庴"喙庻㔗認滇锔誺䫘 sysctl 锬埡婔婻婖湚䔇誺柊庴昇嚟垂䯄䔇
sysctl -w vm.overcommit_memory=2
潡蔙婘 /etc/sysctl.conf 麯櫆婔婻京昽䔇溇䕞㔗嘹埇脘誻婯橕媞櫹䕩噿䔇 vm.overcommit_ratio 螆䘞㔗臥䂖媇敇臙埗黙喙湩桺懼䔇 Documentation/vm/overcommit-accounting 桺傽㔗
橬底冕庫嘖䔇 Linux 2.4 喙湩橬五斷橘 2.6 誺柊庴䔇 sysctl 㔗婉誺婘澇橬䕩噿傼乕䔇喙湩麯螆䘞 vm.overcommit_memory 婺 2 埻嚔螷庋愙敘俘蔯婉滇敘喘㔗潏傸傺螞嘹演昖婔婋垂鍙䔇喙湩溊傼乕(埗黙桺傽 mm/mmap.c 麯麵䔇 vm_enough_memory
庘昄)湩垂婔婋認婻滇婘嘹䔇䬽橸麯庻婘䔇䇽劯喉婘 2.4 喙湩麯嘪䫘認婻䬹攓㔗桺懼桺傽 overcommit-accounting 䔇庻婘婉脘嘷嘩滇認婻䬹攓庻婘䔇臕滯㔗套悩橬閞鵻臙臵閞嘹䔇喙湩冕庫嘖䔇婷垽㔗