【问题标题】:Error while connecting to remote Postgres on centos在 centos 上连接远程 Postgres 时出错
【发布时间】:2016-05-18 16:08:46
【问题描述】:

当我尝试连接到远程云上的 Postgres 时。它正在显示:

psql: server closed the connection unexpectedly
      This probably means the server terminated abnormally
      before or while processing the request.

本地系统 -- Postgres 9.3 (windows)
远程系统在 Azure -- Postgres 9.2(centos)

我正在使用的命令:psql -h "abc.cloudapp.net" -p 5432

我已在 azure 中将端点设置为 5432 将 postgresql.conf 更改为“*”以允许连接 并将 pg_hba 更改为 (host all all ip/24 md5)

请帮我解决这个问题。

【问题讨论】:

    标签: postgresql azure centos


    【解决方案1】:

    端点没问题,还需要设置网络安全组。

    尝试不仅定义 5432,还定义端口范围(例如 1024-65536)。

    UPD:我能够创建 CentOs 7.0 + PostgreSQL 并连接到该实例:

    sudo yum install postgresql-server postgresql-contribs
    sudo postgresql-setup initdb
    sudo vi /var/lib/pgsql/data/pg_hba.conf
    

    将 127.0.0.1/32 编辑为 0.0.0.0/0

    sudo systemctl start postgresql
    sudo systemctl enable postgresql    
    sudo vim /var/lib/pgsql/data/postgresql.conf
    sudo service postgresql restart   
    sudo service postgresql restart   
    sudo -u postgres createuser --superuser azureuser -P
    

    然后我下载了pgAdmin 并连接到它。 (看截图)(不用关注test1数据库,直接改成postgres)。

    【讨论】:

    • 在 azure 经典门户中哪里可以找到这个。请分享截图。
    • 啊,有道理。您是否在经典门户上创建了您的虚拟机,对吗?
    • 是的,我确实创建了,但在较新的门户中我没有网络安全组
    • 好吧,你没有资格去聊天 :( 让我们在这里尝试一下。你配置了 5432 端口和虚拟机内部的任何设置?
    • 我没有声望
    猜你喜欢
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    • 2012-07-24
    • 2023-04-02
    • 2016-01-04
    • 1970-01-01
    • 1970-01-01
    • 2017-03-25
    相关资源
    最近更新 更多