4. Kernel Tuning (if needed) - sergiocontrino/docs GitHub Wiki

If after restarting postgres you get something like FATAL: could not create shared memory segment you need to set the kernel parameter of your machine.

Get some kernel data:

getconf PAGE_SIZE

getconf _PHYS_PAGES

you should set

shmall = phys_pages / 2

shmmax = shmall * pagesize

your current setting can be seen with

sysctl -a | grep -E "shmall|shmmax"

(use sudo if necessary)

do your math and then edit the file

/etc/sysctl.d/30-postgresql-shm.conf with the new shmmax

source it

sudo sysctl -p /etc/sysctl.d/30-postgresql-shm.conf