當(dāng)前位置:首頁 > IT技術(shù) > 數(shù)據(jù)庫 > 正文

postgresql設(shè)置max_connections太大無法啟動(dòng)
2021-10-11 15:10:30

在postgres中,當(dāng)max_connect設(shè)置過大,啟動(dòng)的時(shí)候會(huì)報(bào)錯(cuò):

FATAL: ?could not create semaphores: No space left on device

創(chuàng)建semaphores時(shí)空間參數(shù)不夠,查詢官網(wǎng),有這么一段解釋:

HINT: ?This error does *not* mean that you have run out of disk space. ?It occurs when either the system limit for the maximum number of semaphore sets (SEMMNI), or the system wide maximum number of semaphores (SEMMNS), would be exceeded. ?You need to raise the respective kernel parameter. ?Alternatively, reduce PostgreSQL's consumption of semaphores by reducing its max_connections parameter.
The PostgreSQL documentation contains more information about configuring your system for PostgreSQL.
解決的方法是改小max_connect,當(dāng)業(yè)務(wù)不允許的情況下,修改內(nèi)核參數(shù),max_connect相關(guān)的內(nèi)核參數(shù)有:

?

?

?

?下面介紹如何修改內(nèi)核參數(shù)

# ipcs -ls
 
------ Semaphore Limits --------
max number of arrays = 1280
max semaphores per array = 50100
max semaphores system wide = 64128000
max ops per semop call = 50100
semaphore max value = 32767
 
 
# cat  /proc/sys/kernel/sem
SEMMSL   SEMMNS         SEMOPM  SEMMNI
50100   128256000       50100   2560
SEMMSL?每個(gè)信號(hào)量set中信號(hào)量最大個(gè)數(shù)
SEMMNS?linux系統(tǒng)中信號(hào)量最大個(gè)數(shù)
SEMOPM?semop系統(tǒng)調(diào)用允許的信號(hào)量最大個(gè)數(shù)設(shè)置,設(shè)置成和SEMMSL一樣即可
SEMMNI ?linux系統(tǒng)信號(hào)量set最大個(gè)數(shù)
?
所以SEMMNS=SEMMSL*SEMMNI
修改?vi /etc/sysctl.conf 的以下參數(shù)
kernel.sem = 50100 128256000 50100 2560
sysctl -p生效
重啟數(shù)據(jù)庫即可

本文摘自 :https://www.cnblogs.com/

開通會(huì)員,享受整站包年服務(wù)立即開通 >