не могу подключить postgres на сервере к postico на моем локальном - PullRequest
1 голос
/ 11 июля 2020

когда я подключаю 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 с помощью почтальона, кажется, работает. Я использую ma c, в настоящее время брандмауэр не включен, у меня есть сервер в digitalocean, использующий Ubuntu 16.04.6 (LTS) x64.

Это путь к postgres файлам

postgres@borroupapi:~/9.5/main$

когда я запускаю find / -name postgresql .conf, я получаю это

/usr/lib/tmpfiles.d/postgresql.conf

, но я не могу найти путь, который вошел в систему postgres пользователь

1 Ответ

0 голосов
/ 15 июля 2020

попробуйте это, чтобы исправить проблему в postgres 9.5 postgresql .conf и файлы pg_hba.conf расположены в

/etc/postgresql/9.5/main/

не в

/var/lib/postgresql/9.5/main/

вам необходимо войдите в систему как пользователь сервера root и запустите каждую команду, и это даст, где находятся файлы

find / -name postgresql.conf

find / -name pg_hba.conf

в моем экземпляре, когда я запустил команду, я получил это

/var/lib/postgresql/9.5/main/postgresql.conf
/etc/postgresql/9.5/main/postgresql.conf
/usr/lib/tmpfiles.d/postgresql.conf
...