pg.ddx.io pgsql-pkg-debian@postgresql.org mailing list archive
help / color / mirror / Atom feed"ulimit -n" in postgresql/pgbouncer init scripts.
4+ messages / 4 participants
[nested] [flat]
* "ulimit -n" in postgresql/pgbouncer init scripts.
@ 2012-12-26 11:43 Kirill Kuznetsov <kir@evilmartians.com>
2012-12-26 17:24 ` Re: "ulimit -n" in postgresql/pgbouncer init scripts. Greg Smith <greg@2ndQuadrant.com>
2012-12-28 11:56 ` Re: "ulimit -n" in postgresql/pgbouncer init scripts. Christoph Berg <myon@debian.org>
0 siblings, 2 replies; 4+ messages in thread
From: Kirill Kuznetsov @ 2012-12-26 11:43 UTC (permalink / raw)
To: pgsql-pkg-debian
Hello!
I'm the devops engineer at Evil Martians (evilmartians.com). We use
postgresql+pgbouncer (9.1.6; 1.5.3) for most of the projects we are
involved in. Till now we maintained our own repository with postgresql
and pgbouncer packages. We want to switch to using your repository.
But we actually need to set open files limit (ulimit -n) for these
processes. In our packages we modified init.d script so that it
invokes "ulimit -n" command.
e.g: for pgbouncer our modification looks like:
…
ULIMIT=1024
# Include pgbouncer defaults if available
if [ -f /etc/default/pgbouncer ] ; then
. /etc/default/pgbouncer
fi
…
case "$1" in
start)
…
ulimit -n $ULIMIT
$SSD --start --chuid $RUNASUSER --oknodo -- $OPTS 2> /dev/null
;;
…
Is it possible for something like this to appear in PGDG packages or
are we doing it wrong?
Thank you.
Kirill
--
Sent via pgsql-pkg-debian mailing list (pgsql-pkg-debian@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-pkg-debian
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: "ulimit -n" in postgresql/pgbouncer init scripts.
2012-12-26 11:43 "ulimit -n" in postgresql/pgbouncer init scripts. Kirill Kuznetsov <kir@evilmartians.com>
@ 2012-12-26 17:24 ` Greg Smith <greg@2ndQuadrant.com>
1 sibling, 0 replies; 4+ messages in thread
From: Greg Smith @ 2012-12-26 17:24 UTC (permalink / raw)
To: Kirill Kuznetsov <kir@evilmartians.com>; +Cc: pgsql-pkg-debian
On 12/26/12 6:43 AM, Kirill Kuznetsov wrote:
> But we actually need to set open files limit (ulimit -n) for these
> processes. In our packages we modified init.d script so that it
> invokes "ulimit -n" command.
> ULIMIT=1024
> ulimit -n $ULIMIT
> Is it possible for something like this to appear in PGDG packages or
> are we doing it wrong?
That would be B) doing it wrong. Packages aren't the right place to be
touching ulimit values. On Debian there are other ways to approach this
problem. One way is that you can:
-Add lines to /etc/security/limits.conf (or its include files, see [1])
to increase the values for the user like this:
postgres hard nofile 1024
postgres soft nofile 1024
Modify with the user names you want to change. * changes all users
*except* for the superuser, so that might not impact how you're running
things.
[1] You can create a file in /etc/security/limits.d/ instead with these
changes. That might be a cleaner way to manage things in your
environment. It's a good idea to check if any limit changes are
happening in that directory too, they can override yours if read in the
wrong order.
-Edit either /etc/pam.d/su and/or /etc/pam.d/common-session and make
sure this line is there:
session required pam_limits.so
That makes the way PAM is involved in switching users references the new
user's ulimit values.
There's more information about things like checking if this works as you
expect at
http://serverfault.com/questions/397553/how-does-ulimit-come-into-effect-on-the-fly
and
http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/
--
Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.com
--
Sent via pgsql-pkg-debian mailing list (pgsql-pkg-debian@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-pkg-debian
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: "ulimit -n" in postgresql/pgbouncer init scripts.
2012-12-26 11:43 "ulimit -n" in postgresql/pgbouncer init scripts. Kirill Kuznetsov <kir@evilmartians.com>
@ 2012-12-28 11:56 ` Christoph Berg <myon@debian.org>
2013-01-02 11:07 ` Re: "ulimit -n" in postgresql/pgbouncer init scripts. Dimitri Fontaine <dimitri@2ndQuadrant.fr>
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Berg @ 2012-12-28 11:56 UTC (permalink / raw)
To: Kirill Kuznetsov <kir@evilmartians.com>; Greg Smith <greg@2ndQuadrant.com>; +Cc: pgsql-pkg-debian
Re: Greg Smith 2012-12-26 <50DB32C7.50608@2ndQuadrant.com>
> -Edit either /etc/pam.d/su and/or /etc/pam.d/common-session and make
> sure this line is there:
>
> session required pam_limits.so
>
> That makes the way PAM is involved in switching users references the
> new user's ulimit values.
I agree that this should be the prefered way to get this resolved,
except that pg_ctlcluster doesn't invoke su(1), but does the uid
change in pure perl. We should probably fix postgresql-common to use
PAM.
That said, there's nothing really wrong with editing
/etc/default/pgbouncer or /etc/init.d/postgresql to do the ulimit
changes. These files are "conffiles", i.e. changes to them will be
preserved on package upgrades. (Of course using PAM would be nicer,
but we are not there yet.)
Christoph
--
cb@df7cb.de | http://www.df7cb.de/
Attachments:
signature.asc (application/pgp-signature, 835B) download
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: "ulimit -n" in postgresql/pgbouncer init scripts.
2012-12-26 11:43 "ulimit -n" in postgresql/pgbouncer init scripts. Kirill Kuznetsov <kir@evilmartians.com>
2012-12-28 11:56 ` Re: "ulimit -n" in postgresql/pgbouncer init scripts. Christoph Berg <myon@debian.org>
@ 2013-01-02 11:07 ` Dimitri Fontaine <dimitri@2ndQuadrant.fr>
0 siblings, 0 replies; 4+ messages in thread
From: Dimitri Fontaine @ 2013-01-02 11:07 UTC (permalink / raw)
To: Christoph Berg <myon@debian.org>; +Cc: Kirill Kuznetsov <kir@evilmartians.com>; Greg Smith <greg@2ndQuadrant.com>; pgsql-pkg-debian
Christoph Berg <myon@debian.org> writes:
> That said, there's nothing really wrong with editing
> /etc/default/pgbouncer or /etc/init.d/postgresql to do the ulimit
One trick here that I've used in the past is that /etc/default/pgbouncer
is actually sources as a shell script, so you can add your ulimit
command directly in the default file. Works nice.
Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
--
Sent via pgsql-pkg-debian mailing list (pgsql-pkg-debian@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-pkg-debian
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2013-01-02 11:07 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-12-26 11:43 "ulimit -n" in postgresql/pgbouncer init scripts. Kirill Kuznetsov <kir@evilmartians.com>
2012-12-26 17:24 ` Greg Smith <greg@2ndQuadrant.com>
2012-12-28 11:56 ` Christoph Berg <myon@debian.org>
2013-01-02 11:07 ` Dimitri Fontaine <dimitri@2ndQuadrant.fr>
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