Google Cloud Compute,PostgreSQL

myl*_*nid 1 postgresql google-cloud-platform

在stackoverflow的所有链接之后,我在计算实例上安装并设置了postgresql.它启动并运行以下配置 -

pg_hba.conf -- 
# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             all                                     peer
host    all             all             127.0.0.1/32            ident
host    all             all             0.0.0.0/0            md5

-bash-4.2$ cat postgresql.conf | grep listen
listen_addresses = '*'          # what IP address(es) to listen on;
Run Code Online (Sandbox Code Playgroud)

在监听IP和pg_hba.conf更改后,我重新启动了.发布服务已启动并运行 -

[xxxxxxx_gmail_com@python-postgres ~]$ sudo systemctl status postgresql-9.4
postgresql-9.4.service - PostgreSQL 9.4 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-9.4.service; enabled)
   Active: active (running) since Wed 2015-02-18 13:07:55 UTC; 12min ago

[xxxxxxx_gmail_com@python-postgres ~]$ netstat -a --numeric-ports | grep 5432
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN
tcp6       0      0 [::]:5432               [::]:*                  LISTEN
unix  2      [ ACC ]     STREAM     LISTENING     108412   /tmp/.s.PGSQL.5432
Run Code Online (Sandbox Code Playgroud)

外部端口仍然不可见,我无法使用PGadmin3连接到数据库.

Starting Nmap 6.40 ( http://nmap.org ) at 2015-02-18 13:23 UTC
Nmap scan report for 11x.21x.15x.10x.bc.googleusercontent.com (10x.15x.21x.11x)
Host is up (0.0013s latency).
Not shown: 996 filtered ports
PORT     STATE  SERVICE
22/tcp   open   ssh
80/tcp   closed http
443/tcp  closed https
3389/tcp closed ms-wbt-server
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?

谢谢,Manish

Sim*_*stö 6

您没有提及有关在计算实例上设置防火墙的任何信息.根据Google Compute Engine文档:

默认情况下,阻止来自网络外部的所有传入流量,并且在没有适当防火墙的情况下不允许任何数据包进入实例.要允许传入的网络流量,您需要设置防火墙以允许这些连接.每个防火墙代表一个规则,用于确定允许进入网络的流量.

因此,您必须至少设置防火墙,并在端口5432上打开传入流量.请查看此文档,并注意通常平台防火墙不会以任何方式显示给托管实例.

使用命令 -

gcloud compute firewall-rules create postgres --allow tcp:5432 icmp
Run Code Online (Sandbox Code Playgroud)