我为PGbouncer创建了一个docker容器。 (来自-https://hub.docker.com/r/edoburu/pgbouncer的Docker映像)
docker run -d -it --name=pb -e DB_NAME=events -e DB_HOST=localhost -e DB_USER=postgres -e DB_PASSWORD=postgres -e LISTEN_ADDR=127.0.0.1 -e LISTEN_PORT=8083 -e AUTH_TYPE=any -e AUTH_FILE=/Users/nandeeshnaik/Desktop/pg/userlist.txt brainsam/pgbouncer:latest
以上命令运行pgbouncer。 来自docker容器的日志,
adduser: user 'postgres' in use
#pgbouncer.ini
# Description
# Config file is in “ini” format. Section names are between “[” and “]”.
# Lines starting with “;” or “#” are taken as comments and ignored.
# The characters “;” and “#” are not recognized when they appear later in the line.
[databases]
* = host=localhost port=5432 user=postgres password=postgres
[pgbouncer]
# Generic settings
listen_addr = 127.0.0.1
listen_port = 8083
auth_file = /Users/nandeeshnaik/Desktop/pg/userlist.txt
auth_type = any
ignore_startup_parameters = extra_float_digits
# Log settings
admin_users = postgres
# Connection sanity checks, timeouts
# TLS settings
# Dangerous timeouts
################## end file ##################
Starting pgbouncer...
2019-09-15 20:05:23.309 1 LOG File descriptor limit: 1048576 (H:1048576), max_client_conn: 100, max fds possible: 110
2019-09-15 20:05:23.309 1 LOG listening on 127.0.0.1:8083
2019-09-15 20:05:23.309 1 LOG listening on unix:/tmp/.s.PGSQL.8083
2019-09-15 20:05:23.309 1 LOG process up: pgbouncer 1.8.1, libevent 2.1.8-stable (epoll), adns: c-ares 1.13.0, tls: OpenSSL 1.0.2n 7 Dec 2017
在此之后,我尝试使用postgres客户端(PSQL)连接到pgbouncer。
psql -h 127.0.0.1 -p 8083 -U postgres events
我收到以下错误。
(base) MUMCAP0120:pg nandeeshnaik$ psql -h 127.0.0.1 -p 8083 -U postgres events
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 8083?
任何解决该问题的建议和解决方案都将受到赞赏。
如果您需要进一步的说明,请告诉我。
答案 0 :(得分:0)
您错过了docker run
命令的端口映射标志,因此应该为docker run -p 8083:8083 ...
:
docker run -d -p 8083:8083 -it --name=pb -e DB_NAME=events -e DB_HOST=localhost -e DB_USER=postgres -e DB_PASSWORD=postgres -e LISTEN_ADDR=127.0.0.1 -e LISTEN_PORT=8083 -e AUTH_TYPE=any -e AUTH_FILE=/Users/nandeeshnaik/Desktop/pg/userlist.txt brainsam/pgbouncer:latest