From: Greg Smith <greg@2ndquadrant.com>
To: Balkrishna Sharma <b_ki@hotmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Relation between RAM / shmmax / shmall / shared_buffers
Date: Fri, 28 May 2010 15:08:27 -0400
Message-ID: <4C0014AB.4060707@2ndquadrant.com> (raw)
In-Reply-To: <BAY149-w5102A9288345674F2C689AF0E80@phx.gbl>
References: <BAY149-w5102A9288345674F2C689AF0E80@phx.gbl>
Balkrishna Sharma wrote:
> 1. Keeping the kernel parameter kernel.shmmax at 75% of RAM (i.e. at
> 3GB )kernel.shmmax = 3221225472
> 2. Keeping the kernel parameter shmall at the same value. Because
> shmall is measured in number of pages and each page on my linux is
> 4096 bytes, having kernel.shmall = 786432 (786432 * 4096 =
> 3221225472, same as shmmax)
There's little reason to put shmmax at over 50% of RAM, because
shared_buffers is going to be significantly lower than that even. I use
the attached script for this job now; I got sick of doing the math
manually all the time. If you're on a system that supports returning
memory info using getconf, it outputs the lines you need to put into the
kernel configuration.
--
Greg Smith 2ndQuadrant US Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com www.2ndQuadrant.us
Attachments:shmsetup (text/plain, 914B) download
#!/bin/bash
# Output lines suitable for sysctl configuration based
# on total amount of RAM on the system. The output
# will allow up to 50% of physical memory to be allocated
# into shared memory.
# On Linux, you can use it as follows (as root):
#
# ./shmsetup >> /etc/sysctl.conf
# sysctl -p
# Early FreeBSD versions do not support the sysconf interface
# used here. The exact version where this works hasn't
# been confirmed yet.
page_size=`getconf PAGE_SIZE`
phys_pages=`getconf _PHYS_PAGES`
if [ -z "$page_size" ]; then
echo Error: cannot determine page size
exit 1
fi
if [ -z "$phys_pages" ]; then
echo Error: cannot determine number of memory pages
exit 2
fi
shmall=`expr $phys_pages / 2`
shmmax=`expr $shmall \* $page_size`
echo \# Maximum shared segment size in bytes
echo kernel.shmmax = $shmmax
echo \# Maximum number of shared memory segments in pages
echo kernel.shmall = $shmall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: greg@2ndquadrant.com, b_ki@hotmail.com
Subject: Re: Relation between RAM / shmmax / shmall / shared_buffers
In-Reply-To: <4C0014AB.4060707@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox