Lately I updated to the latest PostgreSQL from the Ubuntu repositories and then I got the error “CET FATAL: could not create shared memory segment”.
As the following error message states, the SHMMAX value of the kernel is too less or the shared memory propery of PostgreSQL is too high.
The complete error message looked like this:
1 2 3 4 5 6 7 8 9 10 11 12 |
2014-02-28 09:26:04 CET FATAL: could not create shared memory segment: Invalid argument 2014-02-28 09:26:04 CET DETAIL: Failed system call was shmget(key=55432001, size=36954112, 03600). 2014-02-28 09:26:04 CET 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 36954112 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. |
My solution was to increase the SHMMAX kernel parameter as I have a lot of memory left on my server.
To see the current value of your SHMMAX parameter execute the following command :
1 |
cat /proc/sys/kernel/shmmax |
And to check the size of the shared memory of your PostgreSQL instance open up the file /etc/postgresql/<version>/main/postgresql.conf and search for the parameter shared_buffers .
To increase the SHMMAX parameter of your system you need to edit the /etc/sysctl.conf file and add the following at the end of the file:
1 |
kernel.shmmax = 104857600 |
That would increase the SHMMAX value to 100 mega bytes (104857600 bytes).
Next you need to reload the sysctl file with the following command:
1 |
sudo sysctl -p |
After that you should be able to restart the PostgreSQL server without any problems.
Cheers and have a nice weekend,
Guy
32,703 total views, 8 views today
2 Comments
Great solution!
After RTFM, this was just what i needed.
Thanks!