У меня есть база данных PostgreSQL (9.6), которая развернута на виртуальной машине с Google Compute Engine. К сожалению, я могу понять, как получить к нему доступ с моей локальной машины. Я изменил файлы конфигурации для PostgreSQL следующим образом:
В /etc/postgresql/9.6/main/postgresql.conf
Я добавил следующую строку:
listen_addresses = '*' # what IP address(es) to listen on;
В /etc/postgresql/9.6/main/pg_hba.conf
У меня есть:
# IPv4 local connections:
host all all 0.0.0.0/0 md5
Я также добавил входящие и исходящие правила брандмауэра в GCP следующим образом (извините за плохое изображение): ![enter image description here](https://i.stack.imgur.com/El0ao.png)
Наконец, я включил переадресацию IP на своей виртуальной машине.
Журналы из PostgreSQL выглядят нормально:
2019-10-04 09:57:20.244 UTC [10015] LOG: received fast shutdown request
2019-10-04 09:57:20.244 UTC [10015] LOG: aborting any active transactions
2019-10-04 09:57:20.244 UTC [10020] LOG: autovacuum launcher shutting down
2019-10-04 09:57:20.247 UTC [10017] LOG: shutting down
2019-10-04 09:57:20.279 UTC [10015] LOG: database system is shut down
2019-10-04 09:57:21.346 UTC [10331] LOG: database system was shut down at 2019-10-04 09:57:20 UTC
2019-10-04 09:57:21.350 UTC [10331] LOG: MultiXact member wraparound protections are now enabled
2019-10-04 09:57:21.354 UTC [10335] LOG: autovacuum launcher started
2019-10-04 09:57:21.354 UTC [10330] LOG: database system is ready to accept connections
2019-10-04 09:57:21.814 UTC [10337] [unknown]@[unknown] LOG: incomplete startup packet
Но когда я пытаюсь подключиться к нему с локального компьютера, я получаю тайм-аут:
silveris:~$ psql -U admin -h xxx.xxx.xxx.xxx -p 5432 -d ipp
psql: could not connect to server: Connection timed out
Is the server running on host "xxx.xxx.xxx.xxx" and accepting
TCP/IP connections on port 5432?
Но когда я подключаюсь ку моей ВМ через SSH все работает нормально:
root@ipf-bdd-test:~# psql -U admin -h localhost -p 5432 -d ipp
Password for user admin:
psql (9.6.15)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
ipp=#
Можете ли вы указать мне, что мне не хватает?