Shared memory errors during initdb in Mac OS X
Here's the error and the helpful advice:
---
% /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user
"postgres".
This user must also own the server process.
[...]
creating configuration files... ok
creating template1 database in /usr/local/pgsql/data/base/1... FATAL: could
not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(key=1, size=1081344, 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 1081344 bytes), reduce PostgreSQL's
shared_buffers parameter (currently 50) and/or its max_connections parameter
(currently 10).
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.
initdb: failed
---
Of course, I'v already set all the shared memory params, and have been
runing 7.4.1 quite successfully with them. Immediately after the error
above, I ran this to check the values:
% sysctl -a | egrep shm
kern.sysv.shmmax: 10485760
kern.sysv.shmmin: 1
kern.sysv.shmmni: 10240
kern.sysv.shmseg: 4096
kern.sysv.shmall: 33554432
Since 1081344 is less than 10485760, I'm not sure what to do. I'd take the
error message' advice and adjust shared_buffers or max_connections, but
those params don't even exist yet since initdb is supposed to create the
postgres.conf file that they're found in.
Any suggestions? What should I try next?
-John
On 3/22/04 1:45 PM, John Siracusa wrote:
Of course, I'v already set all the shared memory params, and have been runing
7.4.1 quite successfully with them. Immediately after the error above, I ran
this to check the values:% sysctl -a | egrep shm
kern.sysv.shmmax: 10485760
kern.sysv.shmmin: 1
kern.sysv.shmmni: 10240
kern.sysv.shmseg: 4096
kern.sysv.shmall: 33554432Since 1081344 is less than 10485760, I'm not sure what to do. I'd take the
error message' advice and adjust shared_buffers or max_connections, but those
params don't even exist yet since initdb is supposed to create the
postgres.conf file that they're found in.Any suggestions? What should I try next?
Okay, I changed the settings to this:
kern.sysv.shmmax: 268435456
kern.sysv.shmmin: 1
kern.sysv.shmmni: 10240
kern.sysv.shmseg: 4096
kern.sysv.shmall: 65536
and then restarted. Now it works, but I'm not sure if it was the change in
settings or the restart that fixed it. Obviously I had to restart to make
the changes take effect, but my theory before I bit the bullet and restarted
was that some stale shared memory was lurking, making too little available
for Postgres. I wanted to clean it out using ipcs, but that command doesn't
seem to exist in OS X. (Incidentally, Postgres's ipcclean command doesn't
work on OS X due to the lack of an ipcs command.)
This leads to me next question: is there an equivalent to the ipcs command
for Mac OS X?
-John
John Siracusa <siracusa@mindspring.com> writes:
and then restarted. Now it works, but I'm not sure if it was the change in
settings or the restart that fixed it. Obviously I had to restart to make
the changes take effect, but my theory before I bit the bullet and restarted
was that some stale shared memory was lurking, making too little available
for Postgres.
I was wondering about that as I read your message, but my recollection
is that you get a different kernel error code (not "Invalid argument")
if the request size would be legal by itself but is rejected due to
other pre-existing allocations. You might want to try deliberately
provoking such a situation and see what error you get.
This leads to me next question: is there an equivalent to the ipcs command
for Mac OS X?
Not that I've found. It's a very annoying omission :-(. I'm not sure
if Darwin is sufficiently BSD-ish that it would work to compile up ipcs
from one of the BSD distributions, but you could try ...
regards, tom lane
The default allocation of shared memory on mac os x is a bit small from
/etc/rc: sysctl -w kern.sysv.shmmax=4194304
I ran into a problem when I tried to do a make test on the distribution,
there is not enought shared memory for two instances.
I googled and found an ipcs package that I was able to compile with just
a little bit of finagling here is the output:
macjerry:/Library/StartupItems root# ipcs -b
SVID messages facility not configured in the system
Shared Memory:
T ID KEY MODE OWNER GROUP SEGSZ
m 65536 5432001 --rw------- postgres staff 3809280
Semaphores:
T ID KEY MODE OWNER GROUP NSEMS
You might want to increase shmmax in /etc/rc
==Jerry
On Mar 22, 2004, at 4:02 PM, Tom Lane wrote:
Show quoted text
John Siracusa <siracusa@mindspring.com> writes:
and then restarted. Now it works, but I'm not sure if it was the
change in
settings or the restart that fixed it. Obviously I had to restart to
make
the changes take effect, but my theory before I bit the bullet and
restarted
was that some stale shared memory was lurking, making too little
available
for Postgres.I was wondering about that as I read your message, but my recollection
is that you get a different kernel error code (not "Invalid argument")
if the request size would be legal by itself but is rejected due to
other pre-existing allocations. You might want to try deliberately
provoking such a situation and see what error you get.This leads to me next question: is there an equivalent to the ipcs
command
for Mac OS X?Not that I've found. It's a very annoying omission :-(. I'm not sure
if Darwin is sufficiently BSD-ish that it would work to compile up ipcs
from one of the BSD distributions, but you could try ...regards, tom lane
---------------------------(end of
broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)
On 3/22/04 4:20 PM, Jerry LeVan wrote:
I googled and found an ipcs package that I was able to compile with just
a little bit of finagling
Can you put the patched source up on the web somewhere, or post the patch to
the list along with a URL for the original source?
-John