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

Missing sample connection URL in README #6

Open
djensen47 opened this issue Jan 13, 2018 · 4 comments
Open

Missing sample connection URL in README #6

djensen47 opened this issue Jan 13, 2018 · 4 comments

Comments

@djensen47
Copy link

djensen47 commented Jan 13, 2018

It might be nice to include what the connection URL would be inside the cluster for this setup.

It seems like it would be:

mongodb://mongod-0.mongodb-service,mongod-1.mongodb-service,mongod-2.mongodb-service:27017/dbname
@flauc
Copy link

flauc commented Jan 28, 2018

Did you ever manage to connect? I can't seem to figure it out, this is the url I'm trying:

`mongodb://${MONGO_CONFIG.auth.user}:${MONGO_CONFIG.auth.password}@mongod-0.mongodb-service,mongod-1.mongodb-service,mongod-2.mongodb-service:27017/${DB_NAME}`

@djensen47
Copy link
Author

The url I posted works for me.

@flauc
Copy link

flauc commented Jan 29, 2018

@djensen47 thanks 👍

@caiobegotti
Copy link

I would rather leave the primary/secondary handling for the service itself, so I am using this: mongodb://user:[email protected]/?replicaSet=MainRepSet&authSource=admin (I also have 3 replicas)

That gives you this (I am debugging it with a Java app), note the other replica hostnames handled automatically:

org.mongodb.driver.cluster: Monitor thread successfully connected to server with description ServerDescription{address=mongodb-0.mongodb.default.svc.cluster.local:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, ..., setName='MainRepSet', canonicalAddress=mongodb-0.mongodb.default.svc.cluster.local:27017, hosts=[mongodb-2.mongodb.default.svc.cluster.local:27017, mongodb-0.mongodb.default.svc.cluster.local:27017, mongodb-1.mongodb.default.svc.cluster.local:27017], ..., primary='mongodb-0.mongodb.default.svc.cluster.local:27017', ...}
org.mongodb.driver.cluster: Setting max election id to 7fffffff0000000000000001 from replica set primary mongodb-0.mongodb.default.svc.cluster.local:27017
org.mongodb.driver.cluster: Setting max set version to 1 from replica set primary mongodb-0.mongodb.default.svc.cluster.local:27017
org.mongodb.driver.cluster: Discovered replica set primary mongodb-0.mongodb.default.svc.cluster.local:27017

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

3 participants