【问题标题】:Is there a way to make postgresql listen on different ports?有没有办法让 postgresql 在不同的端口上监听?
【发布时间】:2021-12-14 10:24:37
【问题描述】:

我正在运行 PostgreSQL,我必须在端口 5432 和 5433 之间切换。

如何配置 Postgres 以同时侦听两个端口?

【问题讨论】:

  • 你不能。 Postgres 只能监听一个单个端口。
  • 你可以即兴创作一个(中间人)接力,例如使用 netcat。

标签: postgresql postgresql-11


【解决方案1】:

不可能在多个端口上运行 Postgres 服务器。但你可以在 Linux 中使用socatip tables 或使用pgbouncer 之类的代理

但是示例方法可以使用socat 连接在另一个端口进行监听

# Postgres service listen in port 5432
socat -dddd TCP4-LISTEN:5433,reuseaddr,fork TCP4:my-postgres-address:5432

【讨论】:

  • 当我运行它时,我收到以下错误2021/12/14 14:15:21 socat[31284] E getaddrinfo("my-postgres-address", "NULL", {1,2,1,6}, {}): Name or service not known
  • 您应该将my-postgres-address 更改为域或IP 地址。喜欢:socat -dddd TCP4-LISTEN:5433,reuseaddr,fork TCP4:192.168.1.1:5432
猜你喜欢
  • 2021-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-07
  • 1970-01-01
  • 1970-01-01
  • 2020-12-06
  • 1970-01-01
相关资源
最近更新 更多