6

I am working with Mongodb as a database for my asp.net mvc front end site. I have MongoDB running on 3 servers, in a replica set, a primary, secondary and an arbiter. Connecting to this is the 3 front end web servers that performs CRUD operations on the data held in Mongo. I have a number of questions on my setup that I would like clarification on.

This is my connection string from C#

server=myprimary.com:27017,mysecondary.com:27017;replicaset=MySet;safe=true;database=MyDatabase

Is it correct not to include arbiter in this connection string?

When I work with sql server, I set up all my connection strings with integrated security. What is the best practise for similar in Mongo connection strings?

1

2 Answers 2

3

Is it correct not to include arbiter in this connection string?

You don't need to provide the arbiter details, it will be automatically discovered by your app-driver.

The only thing you can provide in mongoURI is SSL option or username and password for the database that you want to connect. But let me remind you, some of the driver don't honor SSL or 'username' and 'password' in mongoURI.

http://docs.mongodb.org/manual/reference/connection-string/#uri.ssl

mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
Sign up to request clarification or add additional context in comments.

Comments

1

I'd suggest you consult the documentation. It can answer most of your questions. In addition, I see you are using the alternative connection string syntax. I'd highly suggest changing to the other connection string format as we will likely be deprecating the version you are using. The equivalent connection string would be

 mongodb://myprimary.com:27017,mysecondary.com:27017/MyDatabase/?replicaset=MySet.

Finally, you'll find documentation at the previous link regarding authentication. We don't have the "integrated security" option, but we do support SSPI integration (also called GSSAPI and kerberose). You'll find it referred to as External Authentication in our documentation. The caveat is that the MongoDB server you are running will need to be on a linux box and setup with kerberos. This can be a complicated process when used in conjunction with Active Directory to get the keytab file out.

2 Comments

Thanks for this information - I am running on windows server so what authentication options available to me?
If you are running the mongodb executable on a windows server, all you have is native authentication. As in, users and passwords stored in MongoDB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.