Import pgbouncer.

PgBouncer is a lightweight connection pooler for PostgreSQL.

With tweaks from jasper@
ok jasper@
This commit is contained in:
pea 2010-07-08 16:18:06 +00:00
parent ab1529e5eb
commit 7e1ada58fb
10 changed files with 193 additions and 0 deletions

View File

@ -0,0 +1,41 @@
# $OpenBSD: Makefile,v 1.1.1.1 2010/07/08 16:18:06 pea Exp $
COMMENT = lightweight connection pooler for PostgreSQL
DISTNAME = pgbouncer-1.3.3
CATEGORIES = databases
HOMEPAGE = http://wiki.postgresql.org/wiki/PgBouncer
MAINTAINER = Pierre-Emmanuel Andre <pea@openbsd.org>
# BSD
PERMIT_PACKAGE_FTP = Yes
PERMIT_PACKAGE_CDROM = Yes
PERMIT_DISTFILES_FTP = Yes
PERMIT_DISTFILES_CDROM =Yes
WANTLIB = c event
MASTER_SITES = http://pgfoundry.org/frs/download.php/2677/
BUILD_DEPENDS = ::devel/libeventextra
CONFIGURE_STYLE = gnu
CONFIGURE_ARGS = --with-libevent=${LOCALBASE}
USE_GMAKE = Yes
# The actual regress tests are (cd ${WRKSRC}/test; ./test.sh)
# They want to create full postgres install and also play with
# firewall (iptables)
NO_REGRESS = Yes
post-install:
${SUBST_CMD} -c ${FILESDIR}/README.OpenBSD \
${PREFIX}/share/doc/pgbouncer/README.OpenBSD
chown ${SHAREOWN}:${SHAREGRP} \
${PREFIX}/share/doc/pgbouncer/README.OpenBSD
.include <bsd.port.mk>

View File

@ -0,0 +1,5 @@
MD5 (pgbouncer-1.3.3.tar.gz) = Lr0dkH24UYy540U0NyASrA==
RMD160 (pgbouncer-1.3.3.tar.gz) = j/GS3Uuw33iVhYAmyM9H83Xbjms=
SHA1 (pgbouncer-1.3.3.tar.gz) = JI9OSYwBKVQSd7bB2sUsyqoe61I=
SHA256 (pgbouncer-1.3.3.tar.gz) = bIbik6KJ9Z6G0AUOKtNuGnjMR42zR0Y1/PH8rCYERjY=
SIZE (pgbouncer-1.3.3.tar.gz) = 167476

View File

@ -0,0 +1,28 @@
$OpenBSD: README.OpenBSD,v 1.1.1.1 2010/07/08 16:18:06 pea Exp $
1) Carefully edit ${SYSCONFDIR}/pgbouncer/pgbouncer.ini and
${SYSCONFDIR}/pgbouncer/userlist.txt to fit your needs.
2) Launch pgbouncer in foreground mode to see if everything
is ok:
# install -d -o _pgbouncer /var/run/pgbouncer
# pgbouncer -u _pgbouncer /etc/pgbouncer/pgbouncer.ini
3) Add the following to your /etc/rc.local:
if [ -x ${TRUEPREFIX}/bin/pgbouncer ]; then
echo -n 'pgbouncer'
install -d -o _pgbouncer /var/run/pgbouncer
${TRUEPREFIX}/bin/pgbouncer -d -u _pgbouncer \
/etc/pgbouncer/pgbouncer.ini
fi
Random hints:
* Check /var/log/pgbouncer/pgbouncer.log if something
goes wrong

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-Makefile,v 1.1.1.1 2010/07/08 16:18:06 pea Exp $
--- Makefile.orig Wed Jan 28 11:59:26 2009
+++ Makefile Wed Jun 16 11:22:46 2010
@@ -104,6 +104,7 @@ install: $(exe) doc-install
mkdir -p $(DESTDIR)$(docdir)
$(BININSTALL) -m 755 $(exe) $(DESTDIR)$(bindir)
$(INSTALL) -m 644 $(srcdir)/etc/pgbouncer.ini $(DESTDIR)$(docdir)
+ $(INSTALL) -m 644 $(srcdir)/etc/userlist.txt $(DESTDIR)$(docdir)
ifeq ($(PORTNAME),win32)
$(BININSTALL) -m 755 $(dll) $(DESTDIR)$(bindir)
endif

View File

@ -0,0 +1,34 @@
$OpenBSD: patch-etc_pgbouncer_ini,v 1.1.1.1 2010/07/08 16:18:06 pea Exp $
--- etc/pgbouncer.ini.orig Wed Apr 21 12:02:50 2010
+++ etc/pgbouncer.ini Wed Jun 16 15:29:18 2010
@@ -22,8 +22,8 @@ nondefaultdb = pool_size=50 reserve_pool=10
;;; Administrative settings
;;;
-logfile = pgbouncer.log
-pidfile = pgbouncer.pid
+logfile = /var/log/pgbouncer/pgbouncer.log
+pidfile = /var/run/pgbouncer/pgbouncer.pid
;;;
;;; Where to wait for clients
@@ -39,16 +39,16 @@ unix_socket_dir = /tmp
;;;
; any, trust, plain, crypt, md5
-auth_type = trust
+auth_type = md5
#auth_file = 8.0/main/global/pg_auth
-auth_file = etc/userlist.txt
+auth_file = /etc/pgbouncer/userlist.txt
;;;
;;; Users allowed into database 'pgbouncer'
;;;
; comma-separated list of users, who are allowed to change settings
-admin_users = user2, someadmin, otheradmin
+admin_users = admin, pgbouncer
; comma-separated list of users who are just allowed to use SHOW command
stats_users = stats, root

View File

@ -0,0 +1,8 @@
$OpenBSD: patch-etc_userlist_txt,v 1.1.1.1 2010/07/08 16:18:06 pea Exp $
--- etc/userlist.txt.orig Wed Jun 16 12:27:35 2010
+++ etc/userlist.txt Wed Jun 16 12:27:56 2010
@@ -1,3 +1,2 @@
-"marko" "asdasd"
-"postgres" "asdasd"
+"admin" "admin"
"pgbouncer" "fake"

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-src_util_c,v 1.1.1.1 2010/07/08 16:18:06 pea Exp $
--- src/util.c.orig Wed Jun 23 09:44:05 2010
+++ src/util.c Wed Jun 23 09:51:41 2010
@@ -68,7 +68,7 @@ static void render_time(char *buf, int max)
struct tm *tm;
struct timeval tv;
gettimeofday(&tv, NULL);
- tm = localtime(&tv.tv_sec);
+ tm = localtime((time_t *)&tv.tv_sec);
snprintf(buf, max, "%04d-%02d-%02d %02d:%02d:%02d.%03d",
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec,

View File

@ -0,0 +1,30 @@
PgBouncer is a lightweight connection pooler for PostgreSQL.
Features:
* Several levels of brutality when rotating connections:
+ Session pooling
Most polite method. When client connects, a server connection will
be assigned to it for the whole duration it stays connected. When
client disconnects, the server connection will be put back into
pool. This mode supports all PostgeSQL features.
+ Transaction pooling
Server connection is assigned to client only during a transaction.
When PgBouncer notices that transaction is over, the server will be
put back into pool. This mode breaks few session-based features of
PostgreSQL. You can use it only when application cooperates by not
using features that break. See the table below for incompatible
features.
+ Statement pooling
Most aggressive method. This is transaction pooling with a twist -
multi-statement transactions are disallowed. This is meant to
enforce "autocommit" mode on client, mostly targeted for PL/Proxy.
* Low memory requirements (2k per connection by default). This is due to
the fact that PgBouncer does not need to see full packet at once.
* It is not tied to one backend server, the destination databases can reside
on different hosts.
* Supports online reconfiguration for most of the settings.
* Supports online restart/upgrade without dropping client connections.
* Supports protocol V3 only, so backend version must be >= 7.4.

View File

@ -0,0 +1,2 @@
Please see ${PREFIX}/share/doc/pgbouncer/README.OpenBSD for
a brief intro to using pgbouncer on OpenBSD.

View File

@ -0,0 +1,22 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2010/07/08 16:18:06 pea Exp $
@newgroup _pgbouncer:653
@newuser _pgbouncer:653:653:daemon:pgbouncer:/nonexistent:/sbin/nologin
@bin bin/pgbouncer
@man man/man1/pgbouncer.1
@man man/man5/pgbouncer.5
@owner _pgbouncer
@sample ${SYSCONFDIR}/pgbouncer/
@owner
share/doc/pgbouncer/
share/doc/pgbouncer/README.OpenBSD
@mode 640
@group _pgbouncer
share/doc/pgbouncer/pgbouncer.ini
@sample ${SYSCONFDIR}/pgbouncer/pgbouncer.ini
share/doc/pgbouncer/userlist.txt
@sample ${SYSCONFDIR}/pgbouncer/userlist.txt
@mode
@owner _pgbouncer
@group
@sample /var/log/pgbouncer/
@extraunexec rm -rf /var/log/pgbouncer