Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Shmmax, Shmall, I just can't win ;)

I've tried changing around my /etc/sysctl.d/30-postgresql-shm.conf file a fair bit uncommenting and changing the kernel.shmmax and kernel.shmall a bit but it didn't seem to help.

#/etc/sysctl.d/30-postgresql-shm.conf 
# Shared memory settings for PostgreSQL

# Note that if another program uses shared memory as well, you will have to
# coordinate the size settings between the two.

# Maximum size of shared memory segment in bytes
#kernel.shmmax = 33554432  # Original
#kernel.shmmax = 41943040  # Tried this (bigger)
kernel.shmmax = 943040  # and this (smaller)

# Maximum total size of shared memory in pages (normally 4096 bytes)
#kernel.shmall = 2097152  # Tried with and without this commented out

Then (the error):

$ sudo /etc/init.d/postgresql start
* Starting PostgreSQL 9.2 database server    
* The PostgreSQL server failed to start. Please check the log output:
2013-04-27 16:21:33 EDT FATAL:  could not create shared memory segment: Invalid argument
2013-04-27 16:21:33 EDT DETAIL:  Failed system call was shmget(key=5432001, size=30490624, 03600).
2013-04-27 16:21:33 EDT 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 30490624 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.

Note: How would I 'raise the request size' as that is the only thing I haven't tried that was listed.

share|improve this question
2  
Have you done sudo sysctl -p to reload the configs? Also have you tried to place those settings directly in /etc/sysctl.conf? –  Salem Apr 27 '13 at 20:39
1  
My kernel.shmmax has kernel.shmmax=8589934592 (8G * 1024 * 1024 * 1024), any suggestion for the change? –  Michael Durrant Apr 27 '13 at 20:42
    
I tried commenting out the stuff after the first number, that didn't help. –  Michael Durrant Apr 27 '13 at 20:44
    
I am doing /etc/sysctl.conf each time, yes, thanks and after the last change didn't actually show any error (but postgres stil doesn't start). –  Michael Durrant Apr 27 '13 at 20:45
    
But AHHH changing /etc/sysctl.conf to have kernel.shmmax=89934592 (two digits shorter than the original kernel.shmmax=8589934592) just for kiks... worked! ` * Starting PostgreSQL 9.2 database server [ OK ] durrantm$` –  Michael Durrant Apr 27 '13 at 20:49

1 Answer 1

up vote 2 down vote accepted

Well after experimenting a fair bit I found changing /etc/sysctl.conf to have kernel.shmmax=89934592 (two digits shorter than the original kernel.shmmax=8589934592) just for kicks... worked!

* Starting PostgreSQL 9.2 database server [ OK ] durrantm$
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.