Re: Preventing OOM kills - Mailing list pgsql-general

From Devrim GÜNDÜZ
Subject Re: Preventing OOM kills
Date
Msg-id 1306285050.27309.17.camel@lenovo01-laptop03.gunduz.org
Whole thread Raw
In response to Preventing OOM kills  (Yang Zhang <yanghatespam@gmail.com>)
List 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

Attachment

pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Preventing OOM kills
Next
From: John R Pierce
Date:
Subject: Re: Preventing OOM kills