1

I followed the steps from http://www.guguncube.com/1692/pgbouncer-installation-and-configuration-in-ubuntu for pgbouncer setup.

When I start pgbouncer, I get the error

Cannot open logfile: 'pgbouncer.log': Permission denied

Debug transcript:

rajavelu-1469@rajavelu-1469:/etc/pgbouncer$ pgbouncer -d -v pgbouncer.ini 
2014-12-29 15:39:31.045 18299 DEBUG parse_ini_file: [databases]
2014-12-29 15:39:31.045 18299 DEBUG parse_ini_file: '*' = 'host=localhost port=5432 user=$USER'
2014-12-29 15:39:31.045 18299 DEBUG parse_ini_file: '*' = 'host=localhost port=5432 user=$USER' ok:1
2014-12-29 15:39:31.045 18299 DEBUG parse_ini_file: [pgbouncer]
2014-12-29 15:39:31.046 18299 DEBUG parse_ini_file: 'listen_port' = '5433'
2014-12-29 15:39:31.046 18299 DEBUG parse_ini_file: 'listen_port' = '5433' ok:1
2014-12-29 15:39:31.046 18299 DEBUG parse_ini_file: 'listen_addr' = 'localhost'
2014-12-29 15:39:31.046 18299 DEBUG parse_ini_file: 'listen_addr' = 'localhost' ok:1
2014-12-29 15:39:31.046 18299 DEBUG parse_ini_file: 'auth_type' = 'any'
2014-12-29 15:39:31.046 18299 DEBUG parse_ini_file: 'auth_type' = 'any' ok:1
2014-12-29 15:39:31.046 18299 DEBUG parse_ini_file: 'logfile' = 'pgbouncer.log'
2014-12-29 15:39:31.046 18299 **FATAL Cannot open logfile: 'pgbouncer.log': Permission denied**

When I start pgbouncer with sudo I got the error

@src/main.c:736 in function main(): PgBouncer should not run as root".

Debug transcript:

rajavelu-1469@rajavelu-1469:/etc/pgbouncer$ sudo pgbouncer -d -v pgbouncer.ini 
2014-12-29 15:39:54.861 18302 DEBUG parse_ini_file: [databases]
2014-12-29 15:39:54.861 18302 DEBUG parse_ini_file: '*' = 'host=localhost port=5432 user=$USER'
2014-12-29 15:39:54.861 18302 DEBUG parse_ini_file: '*' = 'host=localhost port=5432 user=$USER' ok:1
2014-12-29 15:39:54.861 18302 DEBUG parse_ini_file: [pgbouncer]
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'listen_port' = '5433'
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'listen_port' = '5433' ok:1
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'listen_addr' = 'localhost'
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'listen_addr' = 'localhost' ok:1
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'auth_type' = 'any'
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'auth_type' = 'any' ok:1
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'logfile' = 'pgbouncer.log'
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'logfile' = 'pgbouncer.log' ok:1
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'pidfile' = 'pgbouncer.pid'
2014-12-29 15:39:54.862 18302 DEBUG parse_ini_file: 'pidfile' = 'pgbouncer.pid' ok:1
2014-12-29 15:39:54.862 18302 **FATAL @src/main.c:736 in function main(): PgBouncer should not run as root**

My pgbouncer.ini file is:

[databases]
* = host=localhost port=5432 user=$USER
[pgbouncer]
listen_port = 5433
listen_addr = localhost
auth_type = any
logfile = pgbouncer.log
pidfile = pgbouncer.pid
2
  • Now, I downloaded source from pgfoundry.org
    – Raja
    Commented Jan 8, 2015 at 8:39
  • Pgbouncer started using the steps from michael.otacoo.com/postgresql-2/… . But when trying to connect as "psql -p 5433 postgres" met err: psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"?
    – Raja
    Commented Jan 8, 2015 at 8:45

2 Answers 2

0

I know this is old but i just encountered this error today in my FreeBSD box. The default installation is OK, but I needed to run a different pgbouncer instance.

To fix this I had to change the rc.d/pgbouncer to add -u to execute.

. /etc/rc.subr

name="pgbouncer_slave"
rcvar=pgbouncer_enable

load_rc_config "$name"
: ${pgbouncer_enable="NO"}
: ${pgbouncer_user="pgbouncer"}
: ${pgbouncer_conf="/usr/local/etc/$name.ini"}

extra_commands="reload"

command="/usr/local/bin/pgbouncer"
pidfile="/var/run/pgbouncer/$name.pid"
required_files="${pgbouncer_conf}"
command_args="-d ${pgbouncer_conf} -u pgbouncer"

run_rc_command "$1"
-1

Make sure the log file is owned by the postgres user.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .