Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to connect to PostgreSQL cluster? #4054

Closed
youngerong opened this issue Jul 27, 2017 · 7 comments
Closed

How to connect to PostgreSQL cluster? #4054

youngerong opened this issue Jul 27, 2017 · 7 comments

Comments

@youngerong
Copy link
Contributor

Deploy two PostgreSQL in two machine for high available, how to make Parse connect to the cluster? For example, 'mongodb://' + "10.43.159.58:9927,10.43.159.58:9928" + '/test?replicaSet=volunteer_test&readPreference=primaryPreferred, but PostgreSQL support this style?

@flovilmart
Copy link
Contributor

flovilmart commented Sep 10, 2017

You should have a look at the cluster documentations:

https://www.postgresql.org/docs/8.3/static/creating-cluster.html
https://wiki.postgresql.org/wiki/Replication,_Clustering,_and_Connection_Pooling

and probably pg-promise that we use under the hood, we pass the URL with a parser so it can be used to connect through the pg-promise library, @vitaly-t any idea?

@vitaly-t
Copy link
Contributor

It doesn't exist in the driver, see brianc/node-postgres#932

From the pg-promise point of view, one would be creating 2 separate Database objects, with connection details for each cluster.

@flovilmart
Copy link
Contributor

Thanks @vitaly-t !

@shreeramk
Copy link

@vitaly-t does pg-promise supports multiple host connection since for replica, it would be required or is there any other alternative ?

@vitaly-t
Copy link
Contributor

vitaly-t commented Nov 7, 2019

@shreeramk pg-promise is neutral to this, it is the driver underneath that's expected to support it, as per this issue. They claim that the Native Binding supports it, but I never saw it working, so cannot say.

@shreeramk
Copy link

@vitaly-t okay. Is there any other way? Like writing a wrapper?

Consider if a wrapper is written on top of node-postgres, to handle separate connections to primary and multiple secondary's. Then, if I have total 5 nodes(1 - primary, 4 - secondary) that means using node-postgres i hv to create 5 separate connections. Would you recommend that?

Also, if any automatic failover libraries are used at postgres level, then obviously there are chances that if primary goes down then one of the secondary will promoted to primary so how do we handle that scenario in nodejs code.

@vitaly-t
Copy link
Contributor

vitaly-t commented Nov 7, 2019

@shreeramk There is little I can suggest about it presently. And in any case, you will do better asking about it in that issue, and not here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants