How to fix postgresql – ‘could not create shared memory segment: Invalid argument (shmget) ‘ error?

I recently updated my Postgresql’s ‘max_connections’ to 450 ( in postgresql.conf) which makes my postgresql server to fail during start-up :


FATAL: could not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(key=5432001, size=35274752, 03600).
HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter. You can ...currently 454).
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 reque...s called for.
The PostgreSQL documentation contains more information about shared memory configuration.
[FAILED]

This is because of your shared memory.

1) Check your maximum shared memory :
$ sudo cat /proc/sys/kernel/shmmax
33554432

You need to increase the shared memory to fix this.

2) To fix it temporarily, run this command :
$ sudo sysctl -w kernel.shmmax=134217728

3) To fix this permenantly, set this in your configuration:
$ sudo vi /etc/sysctl.conf
kernel.shmmax = 134217728

4) Now start your pgsql server, It will work.

Advertisements

3 thoughts on “How to fix postgresql – ‘could not create shared memory segment: Invalid argument (shmget) ‘ error?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s