首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >配置为dockerized postgres时,pgbouncer无法启动

配置为dockerized postgres时,pgbouncer无法启动
EN

Stack Overflow用户
提问于 2021-05-26 22:37:04
回答 1查看 264关注 0票数 0

我正在尝试第一次配置pgbouncer。

我的postgres DB作为容器运行(使用端口5011)

我的操作系统是debian 10。

我使用apt-install安装了pgbouncer:

代码语言:javascript
运行
复制
sudo apt-get install pgbouncer

然后可以看到pgbouncer状态为OK:

代码语言:javascript
运行
复制
# sudo systemctl status pgbouncer
● pgbouncer.service - LSB: start pgbouncer
   Loaded: loaded (/etc/init.d/pgbouncer; generated)
   Active: active (running) since Wed 2021-05-26 16:15:49 IDT; 11min ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 2 (limit: 4915)
   Memory: 2.4M
   CGroup: /system.slice/pgbouncer.service
           └─4392 /usr/sbin/pgbouncer -d /etc/pgbouncer/pgbouncer.ini

我的数据库名为mydb,postgres容器在端口5011上运行,因此我将/etc/pgbouncer/pgbouncer.ini配置为:

代码语言:javascript
运行
复制
[databases]
octopus-bouncer = host=10.1.1.1 port=5011 user=dbauser dbname=mydb

;; Configuration section
[pgbouncer]
auth_file = userlist.txt

; IP address or * which means all IPs
listen_addr = *
listen_port = 6432

; any, trust, plain, crypt, md5, cert, hba, pam
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt

; total number of clients that can connect
max_client_conn = 100

; default pool size.  20 is good number when transaction pooling
; is in use, in session pooling it needs to be the number of
; max clients you want to handle at any moment
default_pool_size = 20

最后,我将我的用户放到/etc/pgbouncer/userlist.txt:

代码语言:javascript
运行
复制
"dbauser" "mypassword"

然后我重启了pgbouncer --但是失败了:

代码语言:javascript
运行
复制
# sudo systemctl restart pgbouncer
Job for pgbouncer.service failed because the control process exited with error code.
See "systemctl status pgbouncer.service" and "journalctl -xe" for details.

状态仅显示以下内容:

代码语言:javascript
运行
复制
# sudo systemctl status pgbouncer
● pgbouncer.service - LSB: start pgbouncer
   Loaded: loaded (/etc/init.d/pgbouncer; generated)
   Active: failed (Result: exit-code) since Wed 2021-05-26 17:04:00 IDT; 2min 3s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 28111 ExecStart=/etc/init.d/pgbouncer start (code=exited, status=1/FAILURE)

May 26 17:04:00 Octopus systemd[1]: Starting LSB: start pgbouncer...
May 26 17:04:00 Octopus pgbouncer[28111]: Starting PgBouncer: pgbouncer failed!
May 26 17:04:00 Octopus systemd[1]: pgbouncer.service: Control process exited, code=exited, status=1/FAILURE
May 26 17:04:00 Octopus systemd[1]: pgbouncer.service: Failed with result 'exit-code'.
May 26 17:04:00 Octopus systemd[1]: Failed to start LSB: start pgbouncer.

我是不是遗漏了什么?我如何调试这个问题?

EN

回答 1

Stack Overflow用户

发布于 2021-09-30 09:24:06

您可以将KillSignal=SIGINT添加到服务单元文件:

代码语言:javascript
运行
复制
cat /usr/lib/systemd/system/pgbouncer.service
[Unit]
Description=A lightweight connection pooler for PostgreSQL
Documentation=man:pgbouncer(1)
After=syslog.target network.target

[Service]
RemainAfterExit=yes

User=postgres
Group=postgres

# Path to the init file
Environment=BOUNCERCONF=/etc/pgbouncer/pgbouncer.ini

#Environment=SYSTEMD_LOG_LEVEL=debug

ExecStart=/usr/bin/pgbouncer -q ${BOUNCERCONF}
ExecReload=/usr/bin/pgbouncer -R -q ${BOUNCERCONF}
KillSignal=SIGINT

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

来自pgbouncer man的:

代码语言:javascript
运行
复制
Signals
   SIGHUP Reload config.  Same as issuing the command RELOAD on the console.
   SIGINT Safe shutdown.  Same as issuing PAUSE and SHUTDOWN on the console.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67707138

复制
相关文章

相似问题

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