Thursday, November 17, 2011

Setting kernel's SHMMAX and SHMALL parameters (Installing Postgresql)

Between the common issues that the developers ought pass is the correct installation of the database, worth noting that some databases are easier than others, but in this case i'll talk about a particular issue of postgres.

Usually when we will start our postgres server, we use the follow command

pg_ctl start -D /installation_directory

the installation directory, outgth to have a file called postgresql.conf

if your system is not configured with acceptable parameters to SHMMAX and SHMALL the before command will display an error like this:

FATAL: could not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(key=5432001, size=16498688, 03600).
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 16498688 bytes), reduce PostgreSQL's shared_buffers parameter (currently 1536) and/or its max_connections parameter (currently 104).
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.

in order to fix this, we have to configure these parameters correctly, to do this we have to execute the following commands.

Brayans-MacBook:~ brayancastrop$ sudo sysctl -w kern.sysv.shmmax=1073741824
kern.sysv.shmmax: 4194304 -> 1073741824
Brayans-MacBook:~ brayancastrop$ sudo sysctl -w kern.sysv.shmall=1073741824
kern.sysv.shmall: 1024 -> 1073741824

And that is it. now start your server

pg_ctl start -D /installation_directory

And go ahead!!!

No comments:

Post a Comment