【问题标题】:PgBouncer too many client connections for select()PgBouncer select() 的客户端连接过多
【发布时间】:2020-03-14 00:29:23
【问题描述】:

我创建了 PostgreSql v12(port 5432) 和 pgbouncer v1.9(port 6432)。然后我在 pgbouncer 服务器上创建了一个新的测试数据库。我按照以下步骤操作:

  1. pgbench -h localhost -p 6432 -U postgres -i -s 150 test
    

    它已经创建了 pgbench 表。

  2. pgbench -p 6432 -U postgres -c 200 -j 2 -P 60 -t 1000 -d test
    

    如果我使用-c 85,它将毫无错误地运行。当我将-c 增加到超过 85 或 90 时,我得到了too many client connections for select()

  3. 我已经配置了pgbouncer.inipostgresql.conf 文件。 在 pgbouncer 我添加了

    test = host=localhost port=5432 dbname=test & pool_mode = transaction,max_client_conn = 10000, default_pool_size = 20
    

    postgresql.conf 中,我将 max_connections 从 100 增加到 1000,将 shared_buffers 从 128 增加到 256MB。

    PgBouncer.ini
    Cmd ss
    PgBouncer
    postgres.conf
    db

我想清理包含 100 多个客户端的数据库。

【问题讨论】:

  • 您能解释一下“用客户端清空数据库”是什么意思吗?
  • 你的操作系统是什么?你是如何安装 PostgreSQL 和 pgbouncer 的?请不要发布文字图片。

标签: postgresql pgbouncer


【解决方案1】:

如果我使用 -c 85 它将无错误地运行。当我将 -c 增加到超过 85 或 90 时,我会为 select() 获得太多客户端连接。

文本“too many client connections for select()”出现在 pgbench 客户端中,而不是在 postgresql 服务器和 pgbouncer 中(我可以找到,它们可能是由较小的字符串拼凑而成的)。所以无论发生什么都在 pgbench 内部进行。但是,不清楚这实际上是什么,因为您显示的命令当然不需要超过 1024 个文件描述符。

为什么要在其中注入 pgbouncer?如果您希望所有连接同时打开和使用,pgbouncer 没有什么可以为您提供的。如果将 pgbench 直接指向数据库,是否会出现同样的错误?

我想清理包含 100 多个客户端的数据库。

为什么?

【讨论】:

  • 我想看看 pgbouncer 和 postgre 之间的 CPU 差异。我已通过 pgbecnh 将连接加载到 pgbouncer 和我的 postgresql 服务器。我已将此配置用于另一台笔记本电脑,并且它运行时没有错误。非常感谢您的回答。
猜你喜欢
  • 2013-08-06
  • 2023-04-11
  • 1970-01-01
  • 2011-08-14
  • 1970-01-01
  • 2020-11-06
  • 1970-01-01
  • 2015-10-27
  • 1970-01-01
相关资源
最近更新 更多