【问题标题】:Remote connection to postgreSQL server in google cloud VM instance远程连接到谷歌云虚拟机实例中的 postgreSQL 服务器
【发布时间】:2017-09-22 06:14:15
【问题描述】:

我无法从笔记本电脑远程访问谷歌云中 Ubuntu16.04 VM 实例中的 PostgreSQL 服务器。我已将我的笔记本电脑 IP 添加到 Google Cloud 中的 pg_hba.conf 并尝试了“md5”和“Trust”两种方法:

#IPv4 local connections: host all all 127.0.0.1/32 md5 host all all [mylocalIP]/32 md5

此外,我在 postgresql.conf 中尝试过 * 和 [mylocalIP]:

# - Connection Settings 
listen_addresses = '*'      # what IP address(es) to listen on;

在谷歌云防火墙中我有以下设置

default-allow-http  http-server     IP ranges: 0.0.0.0/0    tcp:80  Allow   1000    default
default-allow-https https-server    IP ranges: 0.0.0.0/0    tcp:443 Allow   1000    default
default-allow-psql  Apply to all    IP ranges: 0.0.0.0/0    tcp:5432Allow   1000    default
Laptop              Apply to all    IP ranges: [mylocalIP]/32   all     Allow   1000    default

我还可以使用 SSH 密钥对我的 Google Cloud VM 实例进行 putty,这样我就可以进行一些远程连接。

我认为这是 Google Cloud 防火墙问题,因为我可以在本地 VM(win 2012 服务器)中使用远程连接到我的 postgreSQL 服务器,并且以下设置没有问题。

提前致谢!

【问题讨论】:

    标签: postgresql google-app-engine google-compute-engine remote-connection


    【解决方案1】:

    在您的 pg_hba.conf 文件中,尝试添加该行

    host    all             all           0.0.0.0/0         md5
    

    您的防火墙规则似乎是正确的。对于 ip 范围 0.0.0.0/0,您只需要规则 tcp:5432

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多