Postgresql FATAL: could not create semaphores: No space left on device
阿新 • • 發佈:2018-12-26
轉自:http://blog.163.com/dazuiba_008/blog/static/363349812016314739538/
今天做恢復的時候,資料庫做完恢復後,無法啟動報錯FATAL: could not create semaphores: No space left on device DETAIL: Failed system call was semget(xxxxxxxxxx). 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.
看提示是空間不足,其實不是空間不足,是訊號量不足
這裡是共享記憶體段的限制,沒有報錯,簡單介紹一下 如果資料庫報FATAL: could not create shared memory segment:Cannot allocate memory 錯誤,可以考慮修改以下相關引數 #ipcs -lm ------ Shared Memory Limits --------
#cat /proc/sys/kernel/shmmax 68719476736
# cat /proc/sys/kernel/shmmni 4096 SHMMNI 共享記憶體段最大個數
# cat /proc/sys/kernel/shmall 4294967296 SHMALL系統中共享記憶體也總數,至少為ceil(shmmax/PAGE_SIZE)
獲取page_size值 # getconf PAGE_SIZE 4096 可以根據實際情況修改以上引數值,在/etc/sysctl.conf配置檔案中
今天遇到的錯誤,主要解決以下引數的限制才能解決我們資料庫啟動的報錯 # 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 每個訊號量set中訊號量最大個數 SEMMNS linux系統中訊號量最大個數 SEMOPM semop系統呼叫允許的訊號量最大個數設定,設定成和SEMMSL一樣即可 SEMMNI linux系統訊號量set最大個數
所以SEMMNS=SEMMSL*SEMMNI
所以要麼增大訊號量,要麼減少max_connect引數 這裡我選擇增大訊號量
修改 vi /etc/sysctl.conf 的以下引數 kernel.sem = 50100 128256000 50100 2560
修改完成後,執行: # sysctl -p
使修改引數生效
ipcs -ls
------ Semaphore Limits -------- max number of arrays = 2560 max semaphores per array = 50100 max semaphores system wide = 128256000 max ops per semop call = 50100 semaphore max value = 32767
重新啟動資料庫並無報錯
Name | Description | Reasonable values |
---|---|---|
SHMMAX | Maximum size of shared memory segment (bytes) | at least 1kB (more if running many copies of the server) |
SHMMIN | Minimum size of shared memory segment (bytes) | 1 |
SHMALL | Total amount of shared memory available (bytes or pages) | if bytes, same as SHMMAX; if pages, ceil(SHMMAX/PAGE_SIZE) |
SHMSEG | Maximum number of shared memory segments per process | only 1 segment is needed, but the default is much higher |
SHMMNI | Maximum number of shared memory segments system-wide | like SHMSEG plus room for other applications |
SEMMNI | Maximum number of semaphore identifiers (i.e., sets) | at least ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16) |
SEMMNS | Maximum number of semaphores system-wide | ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16) * 17 plus room for other applications |
SEMMSL | Maximum number of semaphores per set | at least 17 |
SEMMAP | Number of entries in semaphore map | see text |
SEMVMX | Maximum value of semaphore | at least 1000 (The default is often 32767; do not change unless necessary) |