简体   繁体   中英

Initdb for PostgreSql gives shmget error

I am migrating from Win to Mac and have PostgreSql 9.2.4 installed on Mac X 10.8.3 through Homebrew

When I run the initdb command

initdb /usr/local/var/postgres -E utf8

I get the following error

DETAIL:  Failed system call was shmget(key=1, size=2072576, 03600).
HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded 
available memory or swap space, or exceeded your kernel's SHMALL parameter.  You can either 
reduce the request size or reconfigure the kernel with larger SHMALL.  To reduce the request 
size (currently 2072576 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing 
shared_buffers or max_connections.

In researching I found this thread

Setting SHMMAX etc values on MAC OS X 10.6 for PostgreSQL

and figured I will increase the shmall and hopefully that will help but I get the same error as above with the configuration below.

Contents of my /etc/sysctl.conf file are

kern.sysv.shmmax=33554432
kern.sysv.shmmin=1
kern.sysv.shmmni=256
kern.sysv.shmseg=64
kern.sysv.shmall=8192

Assuming the shmall is blocks of 4096 I seem to have more than enough memory for shmget unless bunch of it is being used by other parts of my system. The activity monitor shows I have more than 6GB free memory left.

Perhaps there is something basic I am missing here.

Thanks for your help.

-S

Use the ipcs -m command to know how much shared memory is already used out of shmmax ( 33554432 bytes).

Presumably it's near the maximum. The unused 6GB don't help if shmmax is so small.

Personally I wouldn't bother with such small values. Increase shmmax at something like 4Gb, shmall at the corresponding 1 million. There isn't any practical drawback to have high values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM