Installed. Now what?

Started by Phoenix Kiulaover 14 years ago43 messagesgeneral
Jump to latest
#1Phoenix Kiula
phoenix.kiula@gmail.com

Hi.

I use CentOS 5, 64bit.

PG is 9.0.5.

I did "yum install pgbouncer" and got this:

---------------
Running Transaction
Installing : libevent
1/2
Installing : pgbouncer
2/2
warning: /etc/pgbouncer.ini created as /etc/pgbouncer.ini.rpmnew

Installed:
pgbouncer.x86_64 0:1.4.2-1.rhel5

Dependency Installed:
libevent.x86_64 0:2.0.12-1.rhel5

---------------

Now what?

1. Do I need to set up the "/etc/pgbouncer.ini.rpmnew" as
"/etc/pgbouncer.ini" and then change settings in it? What do I change?
How? The FAQ is super geeky and unhelpful. As is the sparse info on
the PG Wiki on pgbouncer. How can I tune pgbouner settings?

2. Does pgbouncer start automatically every time PG starts, or do I
have to setup a script to do so? How does pgbouncer start and keep
running?

3. How do I access pgbouncer inside my PHP code? Do I need to change
anything at all, can I just use the usual "pg_connect()" function?

Thanks!

#2Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Phoenix Kiula (#1)
Re: Installed. Now what?

1. Do I need to set up the "/etc/pgbouncer.ini.rpmnew" as
"/etc/pgbouncer.ini" and then change settings in it? What do I change?
How? The FAQ is super geeky and unhelpful. As is the sparse info on
the PG Wiki on pgbouncer. How can I tune pgbouner settings?

Just a quick update. By googling for an hour, I basically set up a
working ini file. It looks like this:

[pgbouncer]
logfile = /var/log/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
; ip address or * which means all ip-s
listen_addr = 127.0.0.1
listen_port = 6543
auth_type = trust
auth_file = /var/lib/pgsql/pgbouncer.txt

admin_users = postgres
stats_users = stats, root
pool_mode = session
server_reset_query = DISCARD ALL

;;; Connection limits
; total number of clients that can connect
max_client_conn = 100
default_pool_size = 20

So now pgbouncer basically starts. Both processes are running (psql
and pgbouncer) --

service postgres start
service pgbouncer start

When the two "services" are started like the above, are they working
together? The manual says psql should be restarted with the pgbouncer
port number, for these to be working together. But what if my server
does not have a "psql" process, but a service of postgres?

From within my PHP code, if I add the port number of pgbouncer in my
"pg_connect()" function, it does not work.

Thanks for any insight.

#3Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Phoenix Kiula (#2)
Re: Installed. Now what?

On Saturday, November 19, 2011 12:20:07 am Phoenix Kiula wrote:

service postgres start
service pgbouncer start

When the two "services" are started like the above, are they working
together? The manual says psql should be restarted with the pgbouncer
port number, for these to be working together. But what if my server
does not have a "psql" process, but a service of postgres?

Not all that confusing. Clients talk to pgbouncer, which in turn talks to
server. All the manual is saying is that you need to redirect your requests to
the pgbouncer port from the Postgres port, using psql as an example.

From within my PHP code, if I add the port number of pgbouncer in my
"pg_connect()" function, it does not work.

Did you take a look at:

http://pgbouncer.projects.postgresql.org/doc/config.html

I have never used pgbouncer, but from above it would seem you need to set up a
[databases] section to tie pgbouncer to the Postgres server.
See:
SECTION [databases]

Thanks for any insight.

--
Adrian Klaver
adrian.klaver@gmail.com

#4Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Adrian Klaver (#3)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 2:13 AM, Adrian Klaver <adrian.klaver@gmail.com> wrote:

http://pgbouncer.projects.postgresql.org/doc/config.html

I have never used pgbouncer, but from above it would seem you need to set up a
[databases] section to tie pgbouncer to the Postgres server.
See:
SECTION [databases]

Thanks Adrian. All this is done.

The config file link just describes what each option means. There's
zero information about how to actually tweak or wisely set the stuff!
:(

Anyway, with half a day of googling or so, and looking at sundry blogs
and such, I have pgbouncer running on port 6432. PG runs on the usual
5432.

I still keep seeing the "Sorry, too many clients already" error.

From my PHP code, what line should I use? This does NOT work:

$link = pg_connect("host=localhost dbname=$db user=$user password=$pass");

If I remove the port number, it works. Is it then connecting straight
to the DB? What am I missing? Pgbouncer is working, but not accepting
PHP pg_connect() call. The username and password are correct for sure.

Any thoughts?

#5Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Phoenix Kiula (#4)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 2:39 AM, Phoenix Kiula <phoenix.kiula@gmail.com> wrote:

On Sun, Nov 20, 2011 at 2:13 AM, Adrian Klaver <adrian.klaver@gmail.com> wrote:

http://pgbouncer.projects.postgresql.org/doc/config.html

I have never used pgbouncer, but from above it would seem you need to set up a
[databases] section to tie pgbouncer to the Postgres server.
See:
SECTION [databases]

Thanks Adrian. All this is done.

The config file link just describes what each option means. There's
zero information about how to actually tweak or wisely set the stuff!
:(

Anyway, with half a day of googling or so, and looking at sundry blogs
and such, I have pgbouncer running on port 6432. PG runs on the usual
5432.

I still keep seeing the "Sorry, too many clients already" error.

From my PHP code, what line should I use? This does NOT work:

 $link   = pg_connect("host=localhost dbname=$db user=$user password=$pass");

If I remove the port number, it works. Is it then connecting straight
to the DB? What am I missing? Pgbouncer is working, but not accepting
PHP pg_connect() call. The username and password are correct for sure.

Any thoughts?

I mean this does not work:

$link   = pg_connect("host=localhost port=6432 dbname=$db
user=$user password=$pass");

When I remove that port number, it works. I suppose it connects
directly to PG. And this is still leading to too many connections.

Also, this does NOT work:

psql snipurl -E "snipurl_snipurl" -p 6543

Shows me this error:

psql: ERROR: no working server connection

How come? The pgbouncer is on!

ps aux | grep pgbouncer

postgres 5567 0.0 0.0 16880 508 ? R 13:50 0:00
pgbouncer -d /etc/pgbouncer.ini
root 5583 0.0 0.0 61188 764 pts/2 R+ 13:50 0:00
grep pgbouncer

Any thoughts? How can I make my PHP connect to the pgbouncer?

#6Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Phoenix Kiula (#4)
Re: Installed. Now what?

On Saturday, November 19, 2011 10:39:42 am Phoenix Kiula wrote:

On Sun, Nov 20, 2011 at 2:13 AM, Adrian Klaver <adrian.klaver@gmail.com>

wrote:

http://pgbouncer.projects.postgresql.org/doc/config.html

I have never used pgbouncer, but from above it would seem you need to set
up a [databases] section to tie pgbouncer to the Postgres server.
See:
SECTION [databases]

Thanks Adrian. All this is done.

Well in the .ini file you posted there is no [databases] section. From what I
read lack of one would explain the problem you are seeing.

--
Adrian Klaver
adrian.klaver@gmail.com

#7Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Adrian Klaver (#6)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 3:35 AM, Adrian Klaver <adrian.klaver@gmail.com> wrote:

Well in the .ini file you posted there is no [databases] section. From what I
read lack of one would explain the problem you are seeing.

Yes. Because that's private to post on a public mailing list like this.

Here's my INI file below, with the private DB name etc sanitizes --
and trust me, all info related to password and ports is absolutely
correctly entered. Both pgbouncer and postgresql are live and running.

Just that pg_connect() function in PHP is not working if I point is to
pgbouncer's port instead of the direct postgresql port.

[databases]
MYDB = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8 port=5432

;; Configuation section
[pgbouncer]
logfile = /var/log/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
; ip address or * which means all ip-s
listen_addr = 127.0.0.1
listen_port = 6543
auth_type = trust
auth_file = /var/lib/pgsql/pgbouncer.txt

admin_users = postgres
stats_users = stats, root
pool_mode = session
server_reset_query = DISCARD ALL

;;; Connection limits
; total number of clients that can connect
max_client_conn = 1500
default_pool_size = 50

#8Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Phoenix Kiula (#7)
Re: Installed. Now what?

On Saturday, November 19, 2011 2:44:04 pm Phoenix Kiula wrote:

On Sun, Nov 20, 2011 at 3:35 AM, Adrian Klaver <adrian.klaver@gmail.com>

wrote:

Well in the .ini file you posted there is no [databases] section. From
what I read lack of one would explain the problem you are seeing.

Yes. Because that's private to post on a public mailing list like this.

Here's my INI file below, with the private DB name etc sanitizes --
and trust me, all info related to password and ports is absolutely
correctly entered. Both pgbouncer and postgresql are live and running.

Just that pg_connect() function in PHP is not working if I point is to
pgbouncer's port instead of the direct postgresql port.

I would first work on establishing that psql works.

From a previous post:
"
Also, this does NOT work:

psql snipurl -E "snipurl_snipurl" -p 6543

Shows me this error:

psql: ERROR: no working server connection

How come? The pgbouncer is on!
"

Not sure what platform you are on but:
http://www.postgresql.org/docs/9.0/interactive/app-psql.html
"Not all of these options are required; there are useful defaults. If you omit
the host name, psql will connect via a Unix-domain socket to a server on the
local host, or via TCP/IP to localhost on machines that don't have Unix-domain
sockets"

You have pgbouncer listening on 127.0.0.1. In your psql connection string you
are not specifying a host, so if you are on a Unix platform it is trying to
connect to a socket which would account for the error. I found when working with
new software explicit is better than implicit. Eliminate possible sources of
error by fully qualifying everything.

--
Adrian Klaver
adrian.klaver@gmail.com

#9Amitabh Kant
amitabhkant@gmail.com
In reply to: Phoenix Kiula (#7)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 4:14 AM, Phoenix Kiula <phoenix.kiula@gmail.com>wrote:

On Sun, Nov 20, 2011 at 3:35 AM, Adrian Klaver <adrian.klaver@gmail.com>
wrote:<snip>

[databases]
MYDB = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8
port=5432

;; Configuation section
[pgbouncer]
logfile = /var/log/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
; ip address or * which means all ip-s
listen_addr = 127.0.0.1
listen_port = 6543
auth_type = trust
auth_file = /var/lib/pgsql/pgbouncer.txt

admin_users = postgres
stats_users = stats, root
pool_mode = session
server_reset_query = DISCARD ALL

;;; Connection limits
; total number of clients that can connect
max_client_conn = 1500
default_pool_size = 50

I am assuming the difference in the port numbers between your config file
and php code is a typing error.

Does the auth file (/var/lib/pgsql/pgbouncer.txt) contain valid login
credentials to your database? If I remember correctly, it should have the
username and password to your database.

Amitabh

#10Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Adrian Klaver (#8)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 8:08 AM, Adrian Klaver <adrian.klaver@gmail.com> wrote:

You have pgbouncer listening on 127.0.0.1. In your psql connection string you
are not specifying a host, so if you are on a Unix platform it is trying to
connect to a socket which would account for the error. I found when working with
new software explicit is better than implicit. Eliminate possible sources of
error by fully qualifying everything.

Thanks for bearing.

Specifying the host is not it.

psql -h 127.0.0.1 MYDB -E "MYDB_MYDB" -p 6543

psql: ERROR: no working server connection

ps aux | grep pgbou

postgres 5567 0.0 0.0 17096 960 ? S 13:50 0:00
pgbouncer -d /etc/pgbouncer.ini
root 24437 0.0 0.0 61192 788 pts/0 S+ 21:31 0:00 grep pgbou

In the "/var/log/pgbouncer.log" I see a message about failing password.

The pgbouncer password in the "auth_file", does it need to be plain
text? Auth_type in my case is "trust". Do I need to md5 the password?

#11Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Amitabh Kant (#9)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 10:33 AM, Amitabh Kant <amitabhkant@gmail.com> wrote:

I am assuming the difference in the port numbers between your config file
and php code is a typing error.
Does the auth file (/var/lib/pgsql/pgbouncer.txt) contain valid login
credentials to your database? If I remember correctly, it should have the
username and password to your database.

Port numbers are correct.

Auth_file has text in this format:

"username" "password in plain text"
"username2" "password2 in plain text"
..

Is this incorrect?

#12Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Phoenix Kiula (#10)
Re: Installed. Now what?

On Saturday, November 19, 2011 6:35:11 pm Phoenix Kiula wrote:

On Sun, Nov 20, 2011 at 8:08 AM, Adrian Klaver <adrian.klaver@gmail.com>

wrote:

You have pgbouncer listening on 127.0.0.1. In your psql connection string
you are not specifying a host, so if you are on a Unix platform it is
trying to connect to a socket which would account for the error. I found
when working with new software explicit is better than implicit.
Eliminate possible sources of error by fully qualifying everything.

Thanks for bearing.

Specifying the host is not it.

psql -h 127.0.0.1 MYDB -E "MYDB_MYDB" -p 6543

psql: ERROR: no working server connection

I don't see a user specified. You sure you are connecting as correct user?
Remember absent a -U the user will be either your system user name or what is
specified in a ENV variable.

ps aux | grep pgbou

postgres 5567 0.0 0.0 17096 960 ? S 13:50 0:00
pgbouncer -d /etc/pgbouncer.ini
root 24437 0.0 0.0 61192 788 pts/0 S+ 21:31 0:00 grep pgbou

In the "/var/log/pgbouncer.log" I see a message about failing password.

The pgbouncer password in the "auth_file", does it need to be plain
text? Auth_type in my case is "trust". Do I need to md5 the password?

According to docs:
http://pgbouncer.projects.postgresql.org/doc/config.html#_generic_settings
"auth_type

How to authenticate users.

md5: Use MD5-based password check. auth_file may contain both MD5-encrypted or
plain-text passwords. This is the default authentication method.

crypt

Use crypt(3) based password check. auth_file must contain plain-text
passwords.
plain

Clear-text password is sent over wire.
trust

No authentication is done. Username must still exist in auth_file.
any

Like the trust method, but the username given is ignored. Requires that all
databases are configured to log in as specific user. Additionally, the console
database allows any user to log in as admin.
"

--
Adrian Klaver
adrian.klaver@gmail.com

#13Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Phoenix Kiula (#11)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 10:37 AM, Phoenix Kiula <phoenix.kiula@gmail.com> wrote:

On Sun, Nov 20, 2011 at 10:33 AM, Amitabh Kant <amitabhkant@gmail.com> wrote:

I am assuming the difference in the port numbers between your config file
and php code is a typing error.
Does the auth file (/var/lib/pgsql/pgbouncer.txt) contain valid login
credentials to your database? If I remember correctly, it should have the
username and password to your database.

Port numbers are correct.

Auth_file has text in this format:

"username" "password in plain text"
"username2" "password2 in plain text"
..

Is this incorrect?

I just did some testing.

If the password is wrong, then it shows me the "authentication failed"
message right in the terminal window, immediately.

If the password is correct (plain text or md5 of that plain text --
both have similar requests), it shows me the second error "no working
connection" below.

[host] > psql -h 127.0.0.1 MYDB -E "MYDB_MYDB" -p 6543psql: ERROR:
password authentication failed for user "MYDB_MYDB"[coco] ~ > [coco] ~

pico /var/lib/pgsql/pgbouncer.txt

[host] ~ > psql -h 127.0.0.1 MYDB -E "MYDB_MYDB" -p 6543
psql: ERROR: no working server connection

But in the second case, the error in the pgbouncer log is the same --
authentication is failing.

Why this inconsistent and utterly inane behavior from pgbouncer? Why
can't we see transparently what the error is?

Nowhere in the docs does it clearly specify with an example how the
auth_file format should be.

Any pointers please? I'm fresh out of google keywords to search for,
two days later.

Thank you!

#14Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Adrian Klaver (#12)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 10:51 AM, Adrian Klaver <adrian.klaver@gmail.com> wrote:

I don't see a user specified. You sure you are connecting as correct user?
Remember absent a -U the user will be either your system user name or what is
specified in a ENV variable.

Adrian, all this is not helping.

To be sure, I tried this. Hope this command is MUCH simpler and puts
this to rest:

psql --host=127.0.0.1 --dbname=MYDB --username="MYDB_MYDB" --port=6543

psql: ERROR: no working server connection

tail -4 /var/log/pgbouncer.log

2011-11-19 22:16:49.139 26439 WARNING server login failed: FATAL
password authentication failed for user "MYDB_MYDB"
2011-11-19 22:16:49.139 26439 LOG S-0x15b61fe0:
MYDB/MYDB_MYDB@127.0.0.1:5432 closing because: login failed (age=0)
2011-11-19 22:17:13.490 26439 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us

Please note that the word "MYDB" is a replacement of my private actual
word. As you can see, the password is failing.

I have read the segment of the manual you copy pasted, of course. I have

auth_type = any
auth_file = /var/lib/pgsql/pgbouncer.txt

I have tried "trust" and "md5" too. Same results as previously posted.
Just for convenience, here's how the file looks:

cat /var/lib/pgsql/pgbouncer.txt

"MYDB_MYDB" "mypassword here"

Anything else?

#15Amitabh Kant
amitabhkant@gmail.com
In reply to: Phoenix Kiula (#1)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 12:12 PM, Tomas Vondra <tv@fuzzy.cz> wrote:

Dne 20.11.2011 04:21, Phoenix Kiula napsal(a):
<snip>
My guess is that you actually require a password when connecting to the
database, but you haven't specified a password in the pgbouncer.ini
file. You have to specify it in the MYDB line, i.e. something like

[databases]
MYDB = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8
port=5432 password='mypassword'

The auth_file is used only for connecting to the pgbouncer, it's not
forwarded to the database server - the pgbouncer opens the connection on
behalf of the users, and you may actually have a completely different
users on the connection pooler.

Tomas

I just checked my pgbouncer config file, and ye it does require a password
in the db connection line.

Amitabh

#16Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Amitabh Kant (#15)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 1:57 PM, Amitabh Kant <amitabhkant@gmail.com> wrote:

On Sun, Nov 20, 2011 at 12:12 PM, Tomas Vondra <tv@fuzzy.cz> wrote:

Dne 20.11.2011 04:21, Phoenix Kiula napsal(a):
<snip>
My guess is that you actually require a password when connecting to the
database, but you haven't specified a password in the pgbouncer.ini
file. You have to specify it in the MYDB line, i.e. something like

[databases]
MYDB  = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8
port=5432 password='mypassword'

The auth_file is used only for connecting to the pgbouncer, it's not
forwarded to the database server - the pgbouncer opens the connection on
behalf of the users, and you may actually have a completely different
users on the connection pooler.

OK. So I specified the password enclosed in double quotes.

[databases]
MYDB  = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8
port=5432 password="mypassword"

Then restarted pgbouncer:

service pgbouncer restart

And this shows up as this:

lsof -i | grep pgbouncer

pgbouncer 8558 postgres 7u IPv4 26187618 TCP
localhost:lds-distrib (LISTEN)

Is this normal? Shouldn't the port number be somewhere? What's "lds-distrib"?

Thanks for all the help.

#17Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Phoenix Kiula (#16)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 2:16 PM, Phoenix Kiula <phoenix.kiula@gmail.com> wrote:

On Sun, Nov 20, 2011 at 1:57 PM, Amitabh Kant <amitabhkant@gmail.com> wrote:

On Sun, Nov 20, 2011 at 12:12 PM, Tomas Vondra <tv@fuzzy.cz> wrote:

Dne 20.11.2011 04:21, Phoenix Kiula napsal(a):
<snip>
My guess is that you actually require a password when connecting to the
database, but you haven't specified a password in the pgbouncer.ini
file. You have to specify it in the MYDB line, i.e. something like

[databases]
MYDB  = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8
port=5432 password='mypassword'

The auth_file is used only for connecting to the pgbouncer, it's not
forwarded to the database server - the pgbouncer opens the connection on
behalf of the users, and you may actually have a completely different
users on the connection pooler.

OK. So I specified the password enclosed in double quotes.

[databases]
MYDB  = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8
port=5432 password="mypassword"

Then restarted pgbouncer:

  service pgbouncer restart

And this shows up as this:

  > lsof -i | grep pgbouncer
  pgbouncer  8558 postgres    7u  IPv4 26187618       TCP
localhost:lds-distrib (LISTEN)

Is this normal? Shouldn't the port number be somewhere? What's "lds-distrib"?

I changed the port to the usual 6432 in the pgbouncer.ini. Restarted.
Now I see this:

lsof -i | grep pgbounc

pgbouncer 10854 postgres 7u IPv4 26257796 TCP localhost:6432 (LISTEN)

So this is live and working. Pgbouncer is working. And yet, this is a problem:

psql MYDB -E "MYDB_MYDB" -p 6432 -W

Password for user MYDB_MYDB:
psql: ERROR: no working server connection

From the log file:

2011-11-20 01:28:57.775 10854 WARNING server login failed: FATAL
password authentication failed for user "MYDB_MYDB"
2011-11-20 01:28:57.775 10854 LOG S-0x1ae2efc0:
MYDB/MYDB_MYDB@127.0.0.1:5432 closing because: login failed (age=0)
2011-11-20 01:29:46.413 10854 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us

The password I am entering in the terminal is right for sure. I've
tried it a few times, checked the caps lock, etc. Also, if the log
carries this "FATAL password authentication failed", why does the
terminal give the vague error "no working server connection"?

Thanks.

#18Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Phoenix Kiula (#14)
Re: Installed. Now what?

Dne 20.11.2011 04:21, Phoenix Kiula napsal(a):

tail -4 /var/log/pgbouncer.log

2011-11-19 22:16:49.139 26439 WARNING server login failed: FATAL
password authentication failed for user "MYDB_MYDB"
2011-11-19 22:16:49.139 26439 LOG S-0x15b61fe0:
MYDB/MYDB_MYDB@127.0.0.1:5432 closing because: login failed (age=0)
2011-11-19 22:17:13.490 26439 LOG Stats: 0 req/s, in 0 b/s, out 0 b/s,query 0 us

Please note that the word "MYDB" is a replacement of my private actual
word. As you can see, the password is failing.

I have read the segment of the manual you copy pasted, of course. I have

auth_type = any
auth_file = /var/lib/pgsql/pgbouncer.txt

I have tried "trust" and "md5" too. Same results as previously posted.
Just for convenience, here's how the file looks:

cat /var/lib/pgsql/pgbouncer.txt

"MYDB_MYDB" "mypassword here"

My guess is that you actually require a password when connecting to the
database, but you haven't specified a password in the pgbouncer.ini
file. You have to specify it in the MYDB line, i.e. something like

[databases]
MYDB = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8
port=5432 password='mypassword'

The auth_file is used only for connecting to the pgbouncer, it's not
forwarded to the database server - the pgbouncer opens the connection on
behalf of the users, and you may actually have a completely different
users on the connection pooler.

Tomas

#19Amitabh Kant
amitabhkant@gmail.com
In reply to: Phoenix Kiula (#17)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 12:02 PM, Phoenix Kiula <phoenix.kiula@gmail.com>wrote:

On Sun, Nov 20, 2011 at 2:16 PM, Phoenix Kiula <phoenix.kiula@gmail.com>
wrote:

On Sun, Nov 20, 2011 at 1:57 PM, Amitabh Kant <amitabhkant@gmail.com>

wrote:

On Sun, Nov 20, 2011 at 12:12 PM, Tomas Vondra <tv@fuzzy.cz> wrote:

Dne 20.11.2011 04:21, Phoenix Kiula napsal(a):
<snip>
My guess is that you actually require a password when connecting to the
database, but you haven't specified a password in the pgbouncer.ini
file. You have to specify it in the MYDB line, i.e. something like

[databases]
MYDB = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8
port=5432 password='mypassword'

The auth_file is used only for connecting to the pgbouncer, it's not
forwarded to the database server - the pgbouncer opens the connection

on

behalf of the users, and you may actually have a completely different
users on the connection pooler.

OK. So I specified the password enclosed in double quotes.

[databases]
MYDB = host=127.0.0.1 dbname=MYDB user=MYUSER client_encoding=utf8
port=5432 password="mypassword"

Then restarted pgbouncer:

service pgbouncer restart

And this shows up as this:

lsof -i | grep pgbouncer

pgbouncer 8558 postgres 7u IPv4 26187618 TCP
localhost:lds-distrib (LISTEN)

Is this normal? Shouldn't the port number be somewhere? What's

"lds-distrib"?

I changed the port to the usual 6432 in the pgbouncer.ini. Restarted.
Now I see this:

lsof -i | grep pgbounc

pgbouncer 10854 postgres 7u IPv4 26257796 TCP localhost:6432
(LISTEN)

So this is live and working. Pgbouncer is working. And yet, this is a
problem:

psql MYDB -E "MYDB_MYDB" -p 6432 -W

Password for user MYDB_MYDB:
psql: ERROR: no working server connection

From the log file:

2011-11-20 01:28:57.775 10854 WARNING server login failed: FATAL
password authentication failed for user "MYDB_MYDB"
2011-11-20 01:28:57.775 10854 LOG S-0x1ae2efc0:
MYDB/MYDB_MYDB@127.0.0.1:5432 closing because: login failed (age=0)
2011-11-20 01:29:46.413 10854 LOG Stats: 0 req/s, in 0 b/s, out 0
b/s,query 0 us

The password I am entering in the terminal is right for sure. I've
tried it a few times, checked the caps lock, etc. Also, if the log
carries this "FATAL password authentication failed", why does the
terminal give the vague error "no working server connection"?

Thanks.

Just a trial: try password without quotes in your pgbouncer config file.
That's how I have specified in mine, and it is working.

Amitabh

#20Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Amitabh Kant (#19)
Re: Installed. Now what?

On Sun, Nov 20, 2011 at 2:45 PM, Amitabh Kant <amitabhkant@gmail.com> wrote:

On Sun, Nov 20, 2011 at 12:02 PM, Phoenix Kiula <phoenix.kiula@gmail.com>
wrote:

Just a trial: try password without quotes in your pgbouncer config file.
That's how I have specified in mine, and it is working.

Already done. Same problem.

#21Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Phoenix Kiula (#17)
#22Amitabh Kant
amitabhkant@gmail.com
In reply to: Phoenix Kiula (#21)
#23John R Pierce
pierce@hogranch.com
In reply to: Phoenix Kiula (#21)
#24Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: John R Pierce (#23)
#25Marko Kreen
markokr@gmail.com
In reply to: Phoenix Kiula (#17)
#26Scott Mead
scottm@openscg.com
In reply to: Marko Kreen (#25)
#27Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Scott Mead (#26)
#28Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Phoenix Kiula (#27)
#29Scott Marlowe
scott.marlowe@gmail.com
In reply to: Phoenix Kiula (#27)
#30Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Phoenix Kiula (#28)
#31Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Adrian Klaver (#30)
#32Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Phoenix Kiula (#1)
#33Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Phoenix Kiula (#27)
#34Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Phoenix Kiula (#31)
#35Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Amitabh Kant (#9)
#36Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Phoenix Kiula (#1)
#37Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Phoenix Kiula (#13)
#38Tomas Vondra
tomas.vondra@2ndquadrant.com
In reply to: Phoenix Kiula (#32)
#39Steve Crawford
scrawford@pinpointresearch.com
In reply to: Phoenix Kiula (#36)
#40Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Steve Crawford (#39)
#41Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Phoenix Kiula (#40)
#42Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Phoenix Kiula (#41)
#43Phoenix Kiula
phoenix.kiula@gmail.com
In reply to: Adrian Klaver (#42)