Code Monkey home page Code Monkey logo

pgbouncer's Introduction

Synopsis

pgbouncer is a popular, small connection pooler for Postgresql. This is yet another docker image with pgbouncer, based on alpine.

Code Example

You can configure it by Environment variables:

$ docker run -d \
 --name=pgbouncer \
 -e DB_HOST=postgresql.example.com \
 -e DB_USER=admin \
 -e DB_PASSWORD=mypassword \
 brainsam/pgbouncer:latest

Or You can mount config file into docker container:

$ docker run -d \
 --name pgbouncer \
 -v pgbouncer-config-file:/etc/pgbouncer/pgbouncer.ini \
 brainsam/pgbouncer:latest

Installation

$ docker pull brainsam/pgbouncer:latest

Configuration

All configuration parameters of pgbouncer are available both by --env (use the same keys in upper case) and by mounting pgbouncer.ini into container.

Troubleshooting

docker logs <your-pgbouncer-container-name>

pgbouncer's People

Contributors

albertocsm avatar jeanmertz avatar larkost avatar larkost-fetch avatar shaneog avatar spootdev avatar yanc0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pgbouncer's Issues

Pgbouncer cannot connet to server

Hi,
I cannot connect to local postgres container 10.4 with pgbouncer 1.8.1. The Pooler Error is "pgbouncer cannot connect to server".

Following is my config:

docker-compose file:

version: '3.2'
services:
  pg:
    image: postgres:10.4-alpine
    volumes:
      - type: volume
        source: pg-data
        target: /var/lib/postgresql/data
      - type: volume
        source: pg-config
        target: /usr/local/share/postgresql
    environment:
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres
      POSTGRES_PASSWORD: postgres
    restart: unless-stopped
    ports:
      - "5432:5432"

  pgb:
    image: brainsam/pgbouncer:1.8.1
    environment:
      DB_HOST: 127.0.0.1
      DB_USER: postgres
      DB_PASSWORD: postgres
    volumes:
      - type: volume
        source: pgb-config
        target: /etc/pgbouncer
    restart: unless-stopped
    ports:
      - "6432:6432"
    depends_on:
      - pg

volumes:
  pg-data:
  pg-config:
  pgb-config:

pgbouncer.ini file:

[databases]
* = host=localhost port=5432 user=postgres password=postgres

[pgbouncer]
# Generic settings
pool_mode = session
listen_addr = *
listen_port = 6432
auth_type = any
ignore_startup_parameters = extra_float_digits
#logfile = /var/log/pgbouncer/pgbouncer.log
#pidfile = /var/run/pgbouncer/pgbouncer.pid
#unix_socket_dir = /var/run/postgresql
#unix_socket_mode = 0777
log_connections = 1
log_disconnections = 1
log_pooler_errors = 1

# Log settings
admin_users = postgres

# Connection sanity checks, timeouts

# TLS settings
server_tls_sslmode = disable
client_tls_sslmode = disable

postgresql.conf listen address is set to "*"

I would really appreciate if someone can help.

Thanks

Access to the pgbouncer admin console

This is probably more of a question than an issue. It may be that it's not possible or desirable, but is there any way of accessing the PGBouncer admin console whilst running this image?

For info I'm running the latest 1.7.2 image.

Client side TLS connection cause container crash

Hi,

I use this repo to fast boot multiple version of postgresql servers:

https://github.com/muccg/docker-postgres-ssl

Then, to prevent ssh-keygen / openssl command error (or my laziness), I just copy the original snail-oil cert and key from running containers:

docker cp <postgres 9.5>:/etc/ssl/server.crt server.crt
docker cp <postgres 9.5>:/etc/ssl/server.key server.key
docker cp <postgres 9.6>:/etc/ssl/client.crt client.crt
docker cp <postgres 9.6>:/etc/ssl/client.crt client.crt

And produce userlist.txt:

tee userlist.txt > /dev/null <<EOF
"postgres" "" ""
EOF

Launch with:

docker run -it \
-e DB_HOST=10.0.0.3 \
-e DB_PORT=5433 \
-e AUTH_TYPE=trust \
-e AUTH_FILE=/etc/pgbouncer/userlist.txt \
-e LISTEN_PORT=5436 \
-e SERVER_TLS_SSLMODE=require \
-e SERVER_TLS_KEY_FILE=/etc/ssl/server.crt \
-e SERVER_TLS_CERT_FILE=/etc/ssl/server.key \
-e SERVER_TLS_PROTOCOLS=secure \
-e CLIENT_TLS_SSLMODE=require \
-e CLIENT_TLS_KEY_FILE=/etc/ssl/client.crt \
-e CLIENT_TLS_CERT_FILE=/etc/ssl/client.key \
-e CLIENT_TLS_PROTOCOLS=secure \
-v `pwd`/userlist.txt:/etc/pgbouncer/userlist.txt \
-v `pwd`/server.crt:/etc/ssl/server.crt \
-v `pwd`/server.key:/etc/ssl/server.key \
-v `pwd`/client.crt:/etc/ssl/client.crt \
-v `pwd`/client.key:/etc/ssl/client.key \
-p 5436:5436 brainsam/pgbouncer

Then it crashed with:

latest: Pulling from brainsam/pgbouncer
0a8490d0dfd3: Already exists
3f90153ef7db: Pull complete
a31b3890eb5b: Pull complete
Digest: sha256:9d3aba1b9d57f78445de84e60787c8b2b8985faa2506250a303d143eb13adafb
Status: Downloaded newer image for brainsam/pgbouncer:latest
create pgbouncer config in /etc/pgbouncer
adduser: user 'postgres' in use
...
...
Starting pgbouncer...
2018-01-11 10:35:12.469 1 FATAL TLS setup failed: failed to load certificate file

Would you mind to point where I missed?

Can not connect to PgBouncer by timeout

When i run in docker-compose and access to my database via Dbeaver. Its connect timeout.
pgbouncer_1 | 2020-04-08 05:18:17.585 UTC [1] LOG S-0x559298d8f0e0: postgres/postgres@(bad-af):0 closing because: connect timeout (age=15s)

postgres:
    image: postgres:11.7
    environment:
      POSTGRES_USER: postgres     # define credentials
      POSTGRES_PASSWORD: postgres # define credentials
      POSTGRES_DB: postgres       # define database
    ports:
      - 5432:5432   
    # command: postgres -c 'max_connections=10000' -c 'shared_buffers=512MB'
  # Postgres database.
  pgbouncer:
    image: brainsam/pgbouncer:1.12.0
    environment:
      DB_HOST: postgres
      DB_USER: postgres           # define credentials
      DB_PASSWORD: postgres       # define credentials
      DB_port: 5432
      POOL_MODE: transaction
      DEFAULT_POOL_SIZE: 56
      MAX_CLIENT_CONN: 10000
    # volumes:
    #   - ./pgbouncer:/etc/pgbouncer
    links:
      - postgres:postgres
    ports:
      - 6433:6432 

No License

There is no license listed on this repo. No license effectively means I cant (you dont grant me the right to) use this repo/docker image for anything.

Install py-docutils

Currently the build for 1.9.0 is failing with:

/bin/sh: rst2man: not found
make[1]: *** [Makefile:19: pgbouncer.1] Error 127
make: *** [Makefile:157: doc/pgbouncer.1] Error 2

To fix the issue, add:

- RUN apk --update add git build-base automake libtool m4 autoconf libevent-dev openssl-dev c-ares-dev && \
+ RUN apk --update add git build-base automake libtool m4 autoconf libevent-dev openssl-dev c-ares-dev py-docutils && \

Don't reveal the password on startup

When I get the logs of my container, I get something like:

create pgbouncer config in /etc/pgbouncer
#pgbouncer.ini
# Description
# Config file is in “ini” format. Section names are between “[” and “]”.
# Lines starting with “;” or “#” are taken as comments and ignored.
# The characters “;” and “#” are not recognized when they appear later in the line.
[databases]
* = host=aux-db.gambit port=5432 user=grafana password=THE_REAL_PASSWORD
[...]

Now, THE_REAL_PASSWORD is supposed to be secret, I would prefer it if it weren't logged!

TLS server config seems to be ignored

Using:

SERVER_TLS_SSLMODE=require

I can see in the logs the generated ini file:

[databases]
* = host=host port=5432 user=user password=pw

[pgbouncer]
# Generic settings
listen_addr = 0.0.0.0
auth_type = any
ignore_startup_parameters = extra_float_digits

# Log settings
admin_users = postgres

# Connection sanity checks, timeouts

# TLS settings
server_tls_sslmode = prefer

# Dangerous timeouts
################## end file ##################

But when trying to connect:

login attempt: db=db user=uder tls=no
new connection to server (from 172.17.0.3:45586)
WARNING TLS handshake error: handshake failed: error:27069065:OCSP routines:OCSP_basic_verify:certificate verify error
closing because: server conn crashed? (age=0)

Notice: tls=no

Is it possible the image is missing some ssl lib?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.