Re: Preventing OOM kills

From: Devrim GÜNDÜZ <devrim(at)gunduz(dot)org>
To: Yang Zhang <yanghatespam(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Preventing OOM kills
Date: 2011-05-25 00:57:30
Message-ID: 1306285050.27309.17.camel@lenovo01-laptop03.gunduz.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2011-05-24 at 17:32 -0700, Yang Zhang wrote:
> PG tends to be picked on by the Linux OOM killer, so lately we've been
> forcing the OOM killer to kill other processes first with this script:
>
> while true; do
> for i in `pgrep postgres`; do
> echo -17 > /proc/$i/oom_adj
> done
> sleep 60
> done
>
> Is there a Better Way? Thanks in advance.

Why don't you start postmaster with this value? Here is what we do in
RPM init scripts.

PG_OOM_ADJ=-17
test x"$PG_OOM_ADJ" != x && echo "$PG_OOM_ADJ" > /proc/self/oom_adj
$SU -l postgres -c "$PGENGINE/postmaster -p '$PGPORT' -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null

Regards,
--
Devrim GÜNDÜZ
Principal Systems Engineer @ EnterpriseDB: http://www.enterprisedb.com
PostgreSQL Danışmanı/Consultant, Red Hat Certified Engineer
Community: devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.gunduz.org Twitter: http://twitter.com/devrimgunduz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2011-05-25 01:01:31 Re: Preventing OOM kills
Previous Message Scott Marlowe 2011-05-25 00:53:33 Re: Preventing OOM kills