Understanding MongoDb Connection Strings

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

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 an arbiter in this connection string?

When I work with sql server, I configured all my connection strings with built-in security. What is the best practice for similar strings in a Mongo join?

+6
source share
2 answers

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

You do not need to provide information about the arbitration, it will be automatically detected by your application.

The only thing you can provide in mongoURI is the SSL option or username and password for the database that you want to connect. But let me remind you that some of the drivers do not respect SSL or the "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]] 
+3
source

I suggest you turn to the documentation . He can answer most of your questions. In addition, I see that you are using alternative connection string syntax. I highly recommend switching to a different connection string format, as we are likely to condemn the version you are using. The equivalent connection string will be

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

Finally, you will find the documentation from the previous link regarding authentication. We do not have the "integrated security" option, but we support SSPI integration (also called GSSAPI and kerberose). You will find a link to external authentication in our documentation. The caveat is that the MongoDB server you are running on must be in a Linux box and configured using kerberos. This can be a tricky process when used in conjunction with Active Directory to get a keytab file.

0
source

Source: https://habr.com/ru/post/945288/


All Articles