Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No more connections allowed (max_client_conn) #152

Open
klobastov opened this issue Oct 23, 2024 · 0 comments
Open

No more connections allowed (max_client_conn) #152

klobastov opened this issue Oct 23, 2024 · 0 comments

Comments

@klobastov
Copy link

I think dbbe should close connection after each sql request or use once connection

image
docker exec -it -u root db_pgbouncer_1 psql -p 6432 -U postgres pgbouncer -c "show clients"

docker-compose.yml

version: "3.9"

services:
  db:
    image: postgres
    restart: always
    # set shared memory limit when using docker-compose
    shm_size: 128mb
    environment:
      POSTGRES_USER: postgres # define credentials
      POSTGRES_PASSWORD: example # define credentials
      POSTGRES_DB: postgres # define database
    volumes:
      - ./data:/var/lib/postgresql/data
      - ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
  pgbouncer:
    image: bitnami/pgbouncer
    restart: always
    environment:
      POSTGRESQL_PORT: 5432
      POSTGRESQL_HOST: db
      POSTGRESQL_USERNAME: postgres # define credentials
      POSTGRESQL_PASSWORD: example # define credentials
      PGBOUNCER_DATABASE: development
      PGBOUNCER_AUTH_TYPE: trust
      PGBOUNCER_POOL_MODE: transaction
      PGBOUNCER_STATS_USERS: postgres,developer
      PGBOUNCER_USERLIST_FILE: /bitnami/userlist.txt
    volumes:
      - ./userlist.txt:/bitnami/userlist.txt
    depends_on:
      - db
    links:
      - db:db
    ports:
      - 5555:6432 # PgBouncer port
    healthcheck:
      test: ["CMD", "pg_isready", "-h", "localhost"]
  adminer:
    image: adminer
    restart: always
    links:
      - db:db
    ports:
      - 8080:8080

userlist.txt

"developer" "example"

docker-entrypoint-initdb.d/init-user-db.sh

#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
	CREATE USER developer WITH PASSWORD 'example';
	CREATE DATABASE development;
	GRANT ALL PRIVILEGES ON DATABASE development TO developer;
	ALTER DATABASE development OWNER TO developer;
	GRANT USAGE, CREATE ON SCHEMA public TO developer;
	GRANT ALL PRIVILEGES ON TABLESPACE tsname TO developer;
EOSQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant