Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 465EB632CAD for ; Fri, 28 May 2010 16:08:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 64497-06 for ; Fri, 28 May 2010 19:08:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by mail.postgresql.org (Postfix) with ESMTP id EC1F66327DE for ; Fri, 28 May 2010 16:08:30 -0300 (ADT) Received: from [192.168.0.105] (pool-96-244-14-10.bltmmd.fios.verizon.net [96.244.14.10]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0MBFrN-1OSHeL44LV-00At3K; Fri, 28 May 2010 21:08:29 +0200 Message-ID: <4C0014AB.4060707@2ndquadrant.com> Date: Fri, 28 May 2010 15:08:27 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Balkrishna Sharma CC: pgsql-admin@postgresql.org Subject: Re: Relation between RAM / shmmax / shmall / shared_buffers References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------050204070503070109050300" X-Provags-ID: V01U2FsdGVkX1/i9wamoLhOf9WZYyae7ibSPvJB9RHZgwkLbLR l4KCvLEOzJciYIgNktDBT5KQZ+8SsPJGp1W6TtFVEqPf7B1p8A 7x8UKS2IUfmI0QkeE2RQrvvE1u+B+qK X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.5 tagged_above=-10 required=5 tests=BAYES_05=-0.5, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201005/286 X-Sequence-Number: 34759 This is a multi-part message in MIME format. --------------050204070503070109050300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------050204070503070109050300 Content-Type: text/plain; name="shmsetup" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="shmsetup" #!/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 --------------050204070503070109050300--