FAQ

[CentOS] CentOS 6: Increase shared memory limits permanently

Alexander Farber
Oct 4, 2011 at 11:45 am
Hello again,

on CentOS 6 / 64 bit what is please the best way
to permanently increase the shared memory?

I'd like to give shared_buffers = 4096MB
to PostgreSQL 8.4 on my machine with
16 GB RAM, but I currently only have:

# sysctl -A|grep shm
kernel.shmmax = 33554432
kernel.shmall = 2097152
kernel.shmmni = 4096

and this produces the error in
/var/lib/pgsql/pgstartup.log:

FATAL: could not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(keyT32001, sizeC99202304, 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 4399202304 bytes),
reduce PostgreSQL's shared_buffers parameter (currently 524288) and/or
its max_connections parameter (currently 103).
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.

And I wonder if I should set shmmax
or shmall and also if these 2 limits
are total for all machine processes
or per process? (i.e. should I allow
a bit more for processes besides PostgreSQL)?

Thank you
Alex
reply

Search Discussions

5 responses

  • John R Pierce at Oct 4, 2011 at 11:53 am

    On 10/04/11 8:45 AM, Alexander Farber wrote:
    on CentOS 6 / 64 bit what is please the best way
    to permanently increase the shared memory?
    /etc/sysctl.conf



    --
    john r pierce N 37, W 122
    santa cruz ca mid-left coast
  • Yavor Nikolov at Oct 4, 2011 at 12:06 pm
    * shmall is total for all processes (in pages)
    * shmmax is the maximum size of single contiguous shared memory segment (in
    bytes)
    Both should be tuned to be large enough (obviously shmmax should be able to
    fit into shmall)

    If the memory is locked you may need to tune /etc/security/limits.conf too.

    Another setting which affects shared memory are huge pages (I don't know if
    PostgreSQL could utilize that feature)
    On Tue, Oct 4, 2011 at 18:53, John R Pierce wrote:
    On 10/04/11 8:45 AM, Alexander Farber wrote:
    on CentOS 6 / 64 bit what is please the best way
    to permanently increase the shared memory?
    /etc/sysctl.conf



    --
    john r pierce N 37, W 122
    santa cruz ca mid-left coast

    _______________________________________________
    CentOS mailing list
    CentOS at centos.org
    http://lists.centos.org/mailman/listinfo/centos
  • Mark Roth at Oct 4, 2011 at 1:14 pm

    Alexander Farber wrote:
    Hello again,

    on CentOS 6 / 64 bit what is please the best way
    to permanently increase the shared memory?

    I'd like to give shared_buffers = 4096MB
    to PostgreSQL 8.4 on my machine with
    16 GB RAM, but I currently only have:

    # sysctl -A|grep shm
    kernel.shmmax = 33554432
    kernel.shmall = 2097152
    kernel.shmmni = 4096

    and this produces the error in
    /var/lib/pgsql/pgstartup.log: <snip>
    And I wonder if I should set shmmax
    Yes. As a point of information, you do this for Oracle as well.

    mark
  • Alexander Farber at Oct 4, 2011 at 2:56 pm
    Thanks, I've put (for my 16GB RAM / 64 bit machine)
    into /etc/sysctl.conf: kernel.shmmax = 5000000000

    And into postgresql.conf: shared_buffers = 4096MB

    I didn't change shmall from the default -

    # sysctl -A|grep shm
    kernel.shmmax = 5000000000
    kernel.shmall = 2097152
    kernel.shmmni = 4096

    because

    # getconf PAGE_SIZE
    4096

    and 2097152 * 4096 < 5000000000, correct?

    Now PostgreSQL 8.4.x seems to run ok

    Regards
    Alex
  • Yavor Nikolov at Oct 4, 2011 at 3:45 pm
    Seems OK for PostgreSQL. You should also take into account the requirements
    of the other applications on that server too (if any).
    Actually it's 5 000 000 000 < 2097152 * 4096 == 8 589 934 592. Which is OK.

    You can use ipcs monitor the allocated shared memory segments and their
    actual size.

    http://www.postgresql.org/docs/8.4/static/kernel-resources.html
    http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Oracle_Tuning_Guide/(This
    is for Oracle but its memory tuning is quite similar and you may find
    some useful information in this guide).

    On Tue, Oct 4, 2011 at 21:56, Alexander Farber
    wrote:
    Thanks, I've put (for my 16GB RAM / 64 bit machine)
    into /etc/sysctl.conf: kernel.shmmax = 5000000000

    And into postgresql.conf: shared_buffers = 4096MB

    I didn't change shmall from the default -

    # sysctl -A|grep shm
    kernel.shmmax = 5000000000
    kernel.shmall = 2097152
    kernel.shmmni = 4096

    because

    # getconf PAGE_SIZE
    4096

    and 2097152 * 4096 < 5000000000, correct?

    Now PostgreSQL 8.4.x seems to run ok

    Regards
    Alex
    _______________________________________________
    CentOS mailing list
    CentOS at centos.org
    http://lists.centos.org/mailman/listinfo/centos

Related Discussions

Discussion Navigation
viewthread | post