简体   繁体   中英

ReplicaSet Info in MongoDB ConnectionString

This question is about specifying replicaSet in the connection String.

I have defined a following connection string in spring data:

mongodb://userName:password@DBSeedServer:port/NameOfDB

This connection string defines 1 seed server and without replica set information.

As per MongoDB documentation , If you only provide the connection point of a single mongod instance, and omit the replicaSet, the client will create a standalone connection.

Since DB is also provided in the connection string, it is still possible to get the replica set information from a single seed if it is available during bootstrap. I could not find out the driver documentation about it's inability to fetch the replica set information from the single seed.

Are there any reasons due to which driver could not establish the replica set information from the seed even if it is Secondary or part of the existing replica set?

Also, what other problems do you see with a single seed (i can think of one seed being single point of failure meaning that if the only provided seed is not available then primary cannot be identified, connections could not be made)

Since DB is also provided in the connection string, it is still possible to get the replica set information from a single seed if it is available during bootstrap. I could not find out the driver documentation about it's inability to fetch the replica set information from the single seed.

Are there any reasons due to which driver could not establish the replica set information from the seed even if it is Secondary or part of the existing replica set?

Drivers intentionally distinguish a standalone connection from a replica set connection as per the MongoDB Server Discovery and Monitoring (SDAM) specification . When connecting in standalone mode, the driver will not attempt to do any topology discovery or verification against the replica set configuration.

This can be useful if you want to connect against a specific member of a replica set (for example, in order to take backups or perform maintenance). Bypassing replica set discovery also allows you to connect to a replica set member using a hostname/port alias (for example, if you are forwarding a connection via a proxy/firewall). With a replica set connection clients are expected to use the hostnames and ports listed in the replica set configuration (not the seed list) so the client view always respects replica set failover and reconfiguration.

Also, what other problems do you see with a single seed (i can think of one seed being single point of failure meaning that if the only provided seed is not available then primary cannot be identified, connections could not be made)

Since replica sets exist for data redundancy and failover, only providing a single seed member undermines one of the basic goals of this deployment type. It is strongly recommended that you provide two or more members in the seed list to help ensure your application can successfully connect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM