I’m trying to set up clustering using only Sharding, without replicaSet, so I created 3 instances with the following replSetName shard1, shard2, shard3, and sharding.clusterRole “shardsvr” on all 3. I created an instance with the replSetName config and sharding.clusterRole “configsvr”. And finally, I created a route instance that I didn’t make any specific configuration in the mongod.conf file.
I opened a connection to this route and ran:
~$mongos --configdb config/mongo_config_ip:27017
I opened another connection to this route and ran:
So far, everything seems to be working. My question now is how do I create a connection string to connect, should I connect only to the “route” mongo?”
With a sharded cluster you should only connect via the mongos, so it would be like this if you have 1 mongos only:
#if you don't have authentication enabled mongodb://mongos_host:mongos_port #if you have authentication mongodb://username:password@mongos_host:mongos_port/?authSource=<authdb>