0

How can we Install multiple PG bouncer with different pool mode on a single server(Ubuntu18.04)?

when I tried to second time install it says already installed?

Is there any other way to install with a different port?

nikhil raj
  • 55
  • 1
  • 10
  • 1
    If this is via the apt packages, you can't directly. You don't want to install it twice anyway, what you want is to run two instances of the service on different ports. To do that you'll need to create your own custom systemd unit files. If you haven't done that before you'll want to read up on it and set aside a reasonable chunk of time. – Richard Huxton Feb 23 '21 at 14:03
  • 1
    The following blog post covers the general setup of multiple pgbouncers run from systemd. DO NOT BLINDLY FOLLOW IT - it isn't doing exactly what you want. You can use it to learn from though. Personally I would disable the default systemd service and run both as "custom" ones. https://www.2ndquadrant.com/en/blog/running-multiple-pgbouncer-instances-with-systemd/ – Richard Huxton Feb 23 '21 at 14:38

1 Answers1

1

You could install a container rungime (eg. docker) and run multiple containers, each containing a pgbouncer installation, eg. using this image: https://github.com/edoburu/docker-pgbouncer

First, install docker:

sudo apt install docker.io

Then, start can start as many pgbouncers as you like.

pgbouncer-1:

sudo docker run --rm -d \
    -n pgbouncer-session\
    -e DATABASE_URL="postgres://user:pass@postgres-host/database" \
    -e POOL_MODE=session \
    -p 5432:5432
    edoburu/pgbouncer

pgbouncer-2

sudo docker run --rm -d \
-n pgbouncer-transaction \
-e DATABASE_URL="postgres://user:pass@postgres-host/database" \
-e POOL_MODE=transaction \
-p 5433:5432
edoburu/pgbouncer

Note that the the containers use different ports on the host (first one uses 5432, second one uses 5433).

If you have lots of configuration, you might want to use a bind-mount for the configuration files.

Also, for a steady setup, I would recommend using docker-compose instead of raw docker commands.

antaxify
  • 324
  • 1
  • 6