Ich versuche python manage.py syncdb
auf einer Django-Installation zu tun, aber ich halte OperationalError: ERROR: pgbouncer cannot connect to server
bekommen. pgbouncer.log enthält Zeilen wie:OperationalError: ERROR: pgbouncer kann keine Verbindung zum Server
2017-09-19 19:44:15.107 1128 LOG C-0x8a9930: mydb/[email protected]:6432 closing because: pgbouncer cannot connect to server (age=0)
2017-09-19 19:44:15.107 1128 WARNING C-0x8a9930: mydb/[email protected]:6432 Pooler Error: pgbouncer cannot connect to server
2017-09-19 19:44:15.107 1128 LOG S-0x8c72e0: mydb/[email protected]:5432 new connection to server
2017-09-19 19:44:15.107 1128 LOG C-0x8a9930: mydb/[email protected]:6432 login failed: db=mydb user=myuser
2017-09-19 19:44:30.108 1128 LOG S-0x8c72e0: mydb/[email protected]:5432 closing because: connect failed (age=15)
Bei Bedarf ps -aef | grep pgbouncer
ergibt:
postgres 1128 1 0 18:38 ? 00:00:00 /usr/sbin/pgbouncer -d /etc/pgbouncer/pgbouncer.ini
myuser 1919 1533 0 19:45 pts/0 00:00:00 grep --color=auto pgbouncer
Außerdem grep port /etc/pgbouncer/pgbouncer.ini
ergibt:
;; dbname= host= port= user= password=
mydb = host=xx.xxx.xxx.xxx port=5432 dbname=mydb
;forcedb = host=127.0.0.1 port=300 user=baz password=foo client_encoding=UNICODE datestyle=ISO connect_query='SELECT 1'
listen_port = 6432
Schließlich sind die relevanten Teile settings.py
enthalten :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydb',
'USER': 'myuser',
'PASSWORD': 'mypassword',
'HOST': '/var/run/postgresql',
'PORT': '6432',
}
Ich drehte log_connections
zu on
in postgresql.conf, startete PG neu und versuchte es erneut. Hier die entsprechenden Zeilen:
2017-09-20 07:50:59 UTC LOG: database system is ready to accept connections
2017-09-20 07:50:59 UTC LOG: autovacuum launcher started
2017-09-20 07:51:00 UTC LOG: connection received: host=[local]
2017-09-20 07:51:00 UTC LOG: incomplete startup packet
2017-09-20 07:51:00 UTC LOG: connection received: host=[local]
2017-09-20 07:51:00 UTC LOG: connection authorized: user=postgres database=postgres
2017-09-20 07:51:01 UTC LOG: connection received: host=[local]
2017-09-20 07:51:01 UTC LOG: connection authorized: user=postgres database=postgres
2017-09-20 07:51:01 UTC LOG: connection received: host=[local]
2017-09-20 07:51:01 UTC LOG: connection authorized: user=postgres database=postgres
Es scheint, die Verbindung durchmacht, aber die user
und database
Name ist postgres
. Diese Zugangsdaten sind nicht das, was ich in pgbouncer.ini
geliefert habe.
jedoch explizit in pgbouncer.ini
beschrieben myuser
in der Verbindungszeichenfolge Zugabe führt zu:
2017-09-20 09:37:37 UTC FATAL: Peer authentication failed for user "myuser"
2017-09-20 09:37:37 UTC DETAIL: Connection matched pg_hba.conf line 90: "local all all peer"
Völlig ratlos.
Was sagen die PostgreSQL-Protokolle darüber? Läuft PostgreSQL am Ziel? –
Sie haben den ersten Teil meines Kommentars nicht gelesen. Schalten Sie 'log_connections' auf' on' und überprüfen Sie das PostgreSQL-Protokoll. –
settings.py hat Socket-Verzeichnis als Host definiert, aber Sie haben in '/ etc/pgbouncer/pgbouncer.ini' localhost - Änderung'/var/run/postgresql' zu '127.0.0.1' bitte in' settings.py' –