Thread: postgres start problems with memory

postgres start problems with memory

From
Josh Close
Date:
I keep getting this error.

DETAIL:  Failed system call was shmget(key=5432001, size=34037760, 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 34037760 bytes), reduce
PostgreSQL's shared_buffers parameter (currently 2048) and/or its
max_connections parameter (currently 1024).
        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.

I've change kernel.shmmax and kernel.shmmin a couple of times, and I
can't get it to work.

I'm passing

-N 1024
-B 2048

to postmaster, it's the gentoo install default. This is what I have
right now for kernel values

root # sysctl -a | grep shm
kernel.shmmni = 4096
kernel.shmall = 31584400
kernel.shmmax = 31584400

Does the amount of RAM in the computer make a difference? I added more
RAM recently and upped the kernel to 4mb ram (something-or-rather) to
allow for over 1gig. It started up fine then. I restarted the computer
today and I can't get postgres to start now.

How can I fix this? What are some good standards? I've read this
http://www.postgresql.org/docs/7.4/interactive/kernel-resources.html
but it didn't help much.

Thanks.

-Josh

Re: postgres start problems with memory

From
Josh Close
Date:
On Thu, 30 Sep 2004 13:39:57 -0500, Josh Close <narshe@gmail.com> wrote:
> I keep getting this error.
>
> DETAIL:  Failed system call was shmget(key=5432001, size=34037760, 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 34037760 bytes), reduce
> PostgreSQL's shared_buffers parameter (currently 2048) and/or its
> max_connections parameter (currently 1024).
>         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.
>
> I've change kernel.shmmax and kernel.shmmin a couple of times, and I
> can't get it to work.
>
> I'm passing
>
> -N 1024
> -B 2048
>
> to postmaster, it's the gentoo install default. This is what I have
> right now for kernel values
>
> root # sysctl -a | grep shm
> kernel.shmmni = 4096
> kernel.shmall = 31584400
> kernel.shmmax = 31584400
>
> Does the amount of RAM in the computer make a difference? I added more
> RAM recently and upped the kernel to 4mb ram (something-or-rather) to
> allow for over 1gig. It started up fine then. I restarted the computer
> today and I can't get postgres to start now.
>
> How can I fix this? What are some good standards? I've read this
> http://www.postgresql.org/docs/7.4/interactive/kernel-resources.html
> but it didn't help much.
>
> Thanks.
>
> -Josh

Ok. I got it started by changing

kernel.shmmax = 134217728
kernel.shmall = 134217728

Why does this make it work? wasn't it high enough before? I went by
the "reasonable value" that the postgres docs says of

250 kB + 8.2 kB * shared_buffers + 14.2 kB * max_connections up to infinity

but that didn't work.

Can anyone explain this to me? I'd like to be able to customize
postgresql, and I'm getting 2 gigs of ram to put in.

Thanks.

-Josh

Re: postgres start problems with memory

From
Greg Stark
Date:
Josh Close <narshe@gmail.com> writes:

> To reduce the request size (currently 34037760 bytes),
...
> root # sysctl -a | grep shm
> kernel.shmmni = 4096
> kernel.shmall = 31584400
> kernel.shmmax = 31584400

So it's currently looking for 34M and you're setting the maximum to 31M.

--
greg

Re: postgres start problems with memory

From
Josh Close
Date:
On 30 Sep 2004 16:40:58 -0400, Greg Stark <gsstark@mit.edu> wrote:
>
> Josh Close <narshe@gmail.com> writes:
>
> > To reduce the request size (currently 34037760 bytes),
> ...
> > root # sysctl -a | grep shm
> > kernel.shmmni = 4096
> > kernel.shmall = 31584400
> > kernel.shmmax = 31584400
>
> So it's currently looking for 34M and you're setting the maximum to 31M.
>
> --
> greg


We'll, you're definitely right about that. Is there a certain standard
to this? Say if I use the "reasonable value" formula. What would be a
good size for the buffer then? Should it be a certain %age of
available RAM?

-Josh