gpt4 book ai didi

linux - 多个端口上的 pgBouncer?

转载 作者:太空狗 更新时间:2023-10-29 11:20:57 26 4
gpt4 key购买 nike

我在 5432 上运行 Postgres 数据库,在 6432 上运行 pgBouncer。

我所有的脚本都指向 6432,但我们有一个指向 5432 的大型遗留代码库,我们也希望它有用户 pgBouncer。

我们想到的最好的方法是在 4432 上运行 Postgres,在 5432 和 6432 上运行 pgBouncer。不幸的是,我们只能找到一种方法让 pbBouncer 监听一个端口。

是否可以让 pgBouncer 监听两个端口?

我们也尝试过使用 IPTables 将 6432 透明转发到 5432,但没有成功:

sudo iptables -t nat -I PREROUTING -p tcp --dport 6432 -j REDIRECT --to-ports 5432
sudo iptables -t nat -I OUTPUT -p tcp -o lo --dport 6432 -j REDIRECT --to-ports 5432

仍然报错:

psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.6432"?

有什么建议(除了“更新遗留代码库”,这是最后的手段)?

最佳答案

我觉得你的 iptables 没问题,但不要忘记启用 ip 转发:

sysctl net.ipv4.ip_forward=1

关于linux - 多个端口上的 pgBouncer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49542106/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com