【发布时间】:2020-07-11 04:09:24
【问题描述】:
当我将服务器上的 postgres 连接到本地的 postico 时,出现此错误
could not connect to server: Operation timed out
Is the server running on host "http://159.65.65.203/" (92.242.140.2) and accepting
TCP/IP connections on port 5432?
我在任何地方都找不到 postgresql.conf 和 pg_hba.conf 文件,所以我创建了这些文件,如下图所示
我找到了这个解释,但仍然没有解决我的问题
Ubuntu does not use the standard pg_ctl for postgreSQL. Instead, it
uses pg_ctlcluster.
That in turn controls the different PostgreSQL clusters. When you do
an install of a new cluster, pg_ctlcluster is smart enough to put
postgresql.conf & pg_hba.conf into separate dirs.
So to be specific, /usr/lib/tmpfiles.d/postgresql.conf is just a tmp
file that you can ingnore, /etc/postgresql/9.4/main/postgresql.conf is
the original version for the 9.4 cluster and
/var/lib/postgresql/9.4/main/postgresql.auto.conf is the actual, live
version of the 9.4 cluster that you need to change to affect the 9.4
cluster. Likewise for the pg_hba.conf.
reference https://www.postgresql.org/message-
id/CANu8FiygR5CdeqRTiE0YM+BQk6aK+qZyw2frH_FWV27J1exong@mail.gmail.com
这里是我如何配置 postgresql.conf
port=5432
listen_addresses='*'
这里是我如何配置 pg_hba.conf
host all all 0.0.0.0/0 md5
host all all ::/0 md5
当我跑步时
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program
name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
29761/postgres
tcp6 0 0 :::22 :::* LISTEN -
显然 5432 并未对所有连接开放。 当我使用邮递员进行 api 调用时似乎可以工作。 我使用 mac 目前没有打开防火墙,我的服务器在 digitalocean 上使用 Ubuntu 16.04.6 (LTS) x64。
这是postgres文件的路径
postgres@borroupapi:~/9.5/main$
当我运行 find / -name postgresql.conf 我得到这个
/usr/lib/tmpfiles.d/postgresql.conf
但我找不到登录 postgres 用户的路径
【问题讨论】:
-
????????请在此处以纯文本形式发布代码、错误、示例数据或文本输出,而不是难以阅读、无法复制粘贴以帮助测试代码或在答案中使用的图像,并且对依赖的人构成障碍在屏幕阅读器上。您可以编辑问题以在问题正文中添加代码。为了便于格式化,请使用
{}按钮标记代码块,或使用四个空格缩进以获得相同的效果。 屏幕截图的内容无法搜索、作为代码运行或复制和编辑以创建解决方案。 -
如果这是一个新安装,请记住 Postgres 9.5 几乎是古老的历史。不能用更新的版本吗? 12.3 是发货版本。
-
@tadman 你认为升级会解决问题吗?这是一个很好的升级链接吗gist.github.com/Prototype-X/c484f9054b9c185dc76e295fb97690a0
-
在升级 Postgres 时总是需要备份,但您应该将备份作为例行公事。升级后,您应该能够使用与服务器版本匹配的正确
pg_restore二进制文件进行恢复。在升级之前,请通过在另一台机器或 VM 上进行测试来确定该过程是否有效。 -
对于 DBA 的建议,这真的应该在 the DBA site。
标签: ruby postgresql psql