vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on "Patroni" and DCS "etcd" or "consul"). Automating with Ansible.
MIT License
1.29k stars 353 forks source link

DNS is unable to connect from postgres port #540

Closed kumarashish071092 closed 4 months ago

kumarashish071092 commented 4 months ago

The DNS is getting a “connection timeout error” when connecting with Postgres port but it is working fine for pgbouncer port and haproxy port.

image

do we need to make any changes in the configuration file? I have verified that the firewall is not blocking it.

vitabaks commented 4 months ago

Hi @kumarashish071092

but it is working fine for pgbouncer port and haproxy port.

Why do you want to connect directly via the postgres port? use the haproxy port

getting a “connection timeout error” when connecting with Postgres port

Check postgresql.listen option in patroni.yml. Perhaps your DNS refers to another IP address.

I can assume that the connection is made by VIP address, but postgres does not listen to it directly when using haproxy or pgbouncer. So that it is not possible to connect directly to the database.

Code: https://github.com/vitabaks/postgresql_cluster/blob/master/roles/patroni/templates/patroni.yml.j2#L123

If you still need it for some reason, then make a change to the patroni configuration and restart the service. Or use the IP address of the database server.

kumarashish071092 commented 4 months ago

HI Vitaliy,

The Postgres port is used for making LDAP connections .

the DNS is pointing to Virtual IP and the subdomain is allowed for all ports.

if the issue is with DNS , then it should not work for pgbouncer and HAproxy port as well.

Thoughts?

Regards, Ashish


From: Vitaliy Kukharik @.> Sent: Wednesday, December 27, 2023 3:47 PM To: vitabaks/postgresql_cluster @.> Cc: Kumar Ashish @.>; Mention @.> Subject: Re: [vitabaks/postgresql_cluster] DNS is unable to connect from postgres port (Issue #540)

[Email from a non-Nagarro source: please exercise caution with links and attachments]

Hi @kumarashish071092https://github.com/kumarashish071092

but it is working fine for pgbouncer port and haproxy port.

Why do you want to connect directly via the postgres port? use the haproxy port

getting a “connection timeout error” when connecting with Postgres port

  1. Check postgresql.listen option in patroni.yml. Perhaps your DNS refers to another IP address.
  2. Check the Postgres logs.

— Reply to this email directly, view it on GitHubhttps://github.com/vitabaks/postgresql_cluster/issues/540#issuecomment-1870158893, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVXUU3SRXBMQS4ZB6MZIXZ3YLPYU5AVCNFSM6AAAAABBD67XTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZQGE2TQOBZGM. You are receiving this because you were mentioned.Message ID: @.***>

kumarashish071092 commented 4 months ago

sharing the listen addresses in the patroni.yml file :

[cid:8c3097d7-8df5-408f-bc5f-62b88484e1db]

restapi: listen: 10.10.9.119:8009 connect_address: 10.10.9.119:8009

listen_addresses: 0.0.0.0

postgresql: listen: 10.10.9.119,127.0.0.1:35432 connect_address: 10.10.9.119:35432

connection details :

primary IP : 10.10.9.119 secondary IP : 10.10.9.120

VIP (DNS) : 10.10.9.118


From: Kumar Ashish @.> Sent: Wednesday, December 27, 2023 4:24 PM To: vitabaks/postgresql_cluster @.>; vitabaks/postgresql_cluster @.> Cc: Mention @.> Subject: Re: [vitabaks/postgresql_cluster] DNS is unable to connect from postgres port (Issue #540)

HI Vitaliy,

The Postgres port is used for making LDAP connections .

the DNS is pointing to Virtual IP and the subdomain is allowed for all ports.

if the issue is with DNS , then it should not work for pgbouncer and HAproxy port as well.

Thoughts?

Regards, Ashish


From: Vitaliy Kukharik @.> Sent: Wednesday, December 27, 2023 3:47 PM To: vitabaks/postgresql_cluster @.> Cc: Kumar Ashish @.>; Mention @.> Subject: Re: [vitabaks/postgresql_cluster] DNS is unable to connect from postgres port (Issue #540)

[Email from a non-Nagarro source: please exercise caution with links and attachments]

Hi @kumarashish071092https://github.com/kumarashish071092

but it is working fine for pgbouncer port and haproxy port.

Why do you want to connect directly via the postgres port? use the haproxy port

getting a “connection timeout error” when connecting with Postgres port

  1. Check postgresql.listen option in patroni.yml. Perhaps your DNS refers to another IP address.
  2. Check the Postgres logs.

— Reply to this email directly, view it on GitHubhttps://github.com/vitabaks/postgresql_cluster/issues/540#issuecomment-1870158893, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVXUU3SRXBMQS4ZB6MZIXZ3YLPYU5AVCNFSM6AAAAABBD67XTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZQGE2TQOBZGM. You are receiving this because you were mentioned.

vitabaks commented 4 months ago

Use 10.10.9.119 instead of 10.10.9.118 for direct connection to the database.

But if it needs the application to use a direct connection then just add 10.10.9.118 to patroni.yml file.

postgresql:
  listen: 10.10.9.118,10.10.9.119,127.0.0.1:35432

But then the question arises why did you install pgbouncer if you don't use it?

kumarashish071092 commented 4 months ago

Hi Vitaliy,

The application is using pgbouncer but for direct ldap connection from pgadmin/dbeaver , we use Postgres port only.

My primary ip is 10.10.9.119 and vip is 10.10.9.118

Can you suggest what to change in the patroni.yml file?

Get Outlook for iOShttps://aka.ms/o0ukef


From: Vitaliy Kukharik @.> Sent: Wednesday, December 27, 2023 5:11:11 PM To: vitabaks/postgresql_cluster @.> Cc: Kumar Ashish @.>; Mention @.> Subject: Re: [vitabaks/postgresql_cluster] DNS is unable to connect from postgres port (Issue #540)

[Email from a non-Nagarro source: please exercise caution with links and attachments]

Use 10.10.9.119 instead of 10.10.9.120 for direct connection to the database.

But if it needs the application to use a direct connection then just add 10.10.9.120 to patroni.yml file. But then the question arises why did you install pgbouncer if you don't use it?

— Reply to this email directly, view it on GitHubhttps://github.com/vitabaks/postgresql_cluster/issues/540#issuecomment-1870228497, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVXUU3XA5NMX2ECPG27F56DYLQCNPAVCNFSM6AAAAABBD67XTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZQGIZDQNBZG4. You are receiving this because you were mentioned.Message ID: @.***>

vitabaks commented 4 months ago

listen option. Must contain a VIP address.

See the example above.

kumarashish071092 commented 4 months ago

thanks for the detailed explanation. Working fine now. we can close this issue

kumarashish071092 commented 4 months ago

making changes in patroni.yml file for parameter : postgresql: listen: 10.10.X.X,10.10.X.X,127.0.0.1:35432 connect_address: 10.10.X.X:35432