2017-09-19 18 views
1

장고 설치에서 python manage.py syncdb을 수행하려고하는데, 계속 OperationalError: ERROR: pgbouncer cannot connect to server이 계속됩니다.OperationalError : 오류 : pgbouncer가 서버에 연결할 수 없습니다.

;; 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 

마지막 settings.py의 관련 부분이 포함되어

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) 
필요한 경우

, ps -aef | grep pgbouncer 수율 :에 grep port /etc/pgbouncer/pgbouncer.ini 결과 또한

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 

, pgbouncer.log 같은 라인을 포함 :

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.postgresql_psycopg2', 
     'NAME': 'mydb', 
     'USER': 'myuser', 
     'PASSWORD': 'mypassword', 
     'HOST': '/var/run/postgresql', 
     'PORT': '6432', 
    } 

postgresql.conf에서 log_connectionson으로 설정하고 PG를 다시 시작한 후 다시 시도했습니다. 다음은 관련 라인이다 :

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 

연결이 겪고있는 것 같다,하지만 userdatabase 이름은 postgres입니다. 그 자격 증명은 내가 pgbouncer.ini에서 제공 한 것이 아닙니다.

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" 

모두 난처한 :

그러나 명시 pgbouncer.ini에 기재된 연결 문자열 myuser을 첨가하여 리드.

'PORT': '6432', 

나는 그것을 주석과 pgbouncer는 일을 시작 :

+0

PostgreSQL 로그에서 그 점에 관해 무엇을 말하고 있습니까? PostgreSQL은 대상에서 실행됩니까? –

+0

내 의견의 첫 부분을 읽지 않았습니다. 'log_connections'을'on'으로 바꾸고 PostgreSQL 로그를 확인하십시오. –

+0

settings.py는 소켓 디렉토리를 호스트로 정의했지만 localhost는'/ etc/pgbouncer/pgbouncer.ini'에 있습니다 -'/ var/run/postgresql'을'127.0.0.1'로 변경하십시오'settings.py' –

답변

0

settings.py이 줄에서 발산 침습 구성을 보인다.

'이유'가 확실하지 않지만

어쩌면이 포트에 충돌이있을 수 있습니다. 필자의 경우 단일 서버에 Pgbouncer와 PG가 공존합니다. 과거에 다른 VM을 사용하여 문제없이 설정할 수있었습니다. (덧글을 쓸 필요가 없습니다. 'PORT': '6432',)