[ZBXNEXT-8923] Add support for PgBouncer database name redirect support Created: 2024 Jan 04  Updated: 2024 Jan 05

Status: Need info
Project: ZABBIX FEATURE REQUESTS
Component/s: Frontend (F), Server (S)
Affects Version/s: 6.0.25, 6.4.10, 7.0.0alpha9
Fix Version/s: None

Type: New Feature Request Priority: Trivial
Reporter: Nick Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: PgBouncer, PostgreSQL
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2024-01-04-16-55-59-591.png     PNG File image-2024-01-04-20-54-14-524.png     PNG File image-2024-01-04-21-19-36-490.png    

 Description   

i try sets differrent pools size for server and frontend

root@zabbix-db-01:~# sudo -u postgres createdb -O zabbix zabbix
...
root@zabbix-db-01:~# cat /etc/pgbouncer/zabbix-db.conf
[databases]
db_web = dbname=zabbix user=zabbix_web auth_user=postgres pool_size=20
db_srv = dbname=zabbix user=zabbix_server auth_user=postgres pool_size=5 
...

with psql it works well

root@zabbix-web-01:~# psql -h 192.168.1.31 -p 6432 -U zabbix_web db_web
db_web=> \dt
...
 public | dashboard_user             | table | zabbix
 public | dashboard_usrgrp           | table | zabbix
 public | dbversion                  | table | zabbix
 public | dchecks                    | table | zabbix
 public | dhosts                     | table | zabbix
...
 

but web setup page report that the table "dbversion" was not found

if i rename in /etc/pgbouncer/zabbix-db.conf "db_web" to "zabbix" then its work

[databases]
;db_web = dbname=zabbix user=zabbix_web auth_user=postgres pool_size=20 
zabbix = dbname=zabbix user=zabbix_web auth_user=postgres pool_size=20 

 



 Comments   
Comment by Nick [ 2024 Jan 04 ]

of course i create users with

 

sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createuser --role=zabbix --pwprompt zabbix_web
sudo -u postgres createuser --role=zabbix --pwprompt zabbix_server

 

Comment by Nick [ 2024 Jan 04 ]

maybe this issue can be fixied with

db_web=> select current_database();
 current_database
------------------
 zabbix 

use $this->dbname only for connection then replace dbname var object to result from "select current_database()" function

p/s. zabbix_server also not working with pgbouncer redirect dbname feature

 

 


I would add this here. Sorry, i don't know much about PHP, but I know how to use brush in paint, he-he

Comment by Edgar Akhmetshin [ 2024 Jan 05 ]

Provide pg_bouncer configuration file, pg_hba.conf file and also postgresql.conf configuration.

 

Comment by Nick [ 2024 Jan 05 ]

pgbouncer.ini

// all by default with add last line
%include /etc/pgbouncer/zabbix-db.conf 

 
/etc/pgbouncer/zabbix-db.conf 

[databases]
db_web = dbname=zabbix user=zabbix_web auth_user=postgres pool_size=20
db_srv = dbname=zabbix user=zabbix_server auth_user=postgres pool_size=5

[pgbouncer]
logfile = /var/log/postgresql/pgbouncer.log
pidfile = /var/run/postgresql/pgbouncer.pid
listen_addr = *
listen_port = 6432
unix_socket_dir = /var/run/postgresql
auth_type = hba
auth_hba_file = /etc/pgbouncer/pg_hba.conf
admin_users = postgres
pool_mode = transaction
max_client_conn = 1500
default_pool_size = 20

 
/etc/pgbouncer/pg_hba.conf

host    all             all             192.168.1.0/24          scram-sha-256 

 
postgrest_db/zabbix/pg_hba.conf

local all postgres peer
local all zabbix trust
local all zabbix_web trust
local all zabbix_server trust
local all all scram-sha-256 

postgresql.conf

// all by default

 
/etc/zabbix/zabbix_server.conf

// all by default except
DBHost=192.168.1.40 
DBName=db_srv
DBUser=zabbix_server
DBPassword=***********
DBPort=6432
Comment by Edgar Akhmetshin [ 2024 Jan 05 ]

Thank you, Nick

Can confirm, that redirect will not work as described, but this is not a bug issue of the Zabbix product - PgBouncer is a third party product and db name redirect is an additional feature. Moved this issue to a feature request.

Please vote for it.

Generated at Sat May 31 03:08:52 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.