首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用psql连接到Pgb强

无法使用psql连接到Pgb强
EN

Stack Overflow用户
提问于 2019-09-15 20:12:47
回答 1查看 1.1K关注 0票数 1

我已经为PGbouncer创建了一个码头容器。(码头形象来自- https://hub.docker.com/r/edoburu/pgbouncer)

代码语言:javascript
复制
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

上面的命令运行pgb强。来自码头集装箱的日志,

代码语言:javascript
复制
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。

代码语言:javascript
复制
psql -h 127.0.0.1 -p 8083 -U postgres events

我得到以下错误..。

代码语言:javascript
复制
(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?
  • 使用Mac
  • 本地安装的Postgresql。
  • userlist.txt只有"postgres",用户名和密码都是痛苦的文本。

任何解决这个问题的建议和解决方案都是非常感谢的。

如果你需要更清楚的话,请告诉我。

EN

回答 1

Stack Overflow用户

发布于 2019-10-01 12:00:45

您忽略了到docker run命令的端口映射标志,所以应该是docker run -p 8083:8083 ...

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57947859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档