You can follow the normal Sharding documentations like
With two exceptions:
- You don't actually want to shard your _data_, just add one shard to your "cluster" (e.g.
do not run the sh.shardCollection() or sh.enableSharding("<database>")), you can
short-circuit the tutorials at this point
- mongos needs to be started up with: --setParameter
"releaseConnectionsAfterResponse=true"
You could then have as many mongos' as you want, say, 1 per frontend server.
To make it easier for you in the future when you do actually want to shard your
data I strongly recommend you follow the guidelines of having 3x config servers.
To quickly workaround your current problem you "could" add just one config server,
or even make your current ReplicaSet be the config server too...
I do however not recommend that as the system is simply not designed for that and
could cause you issues in the future.
Assuming your MongoDB Replicaset is called "RSNAME", where one of the ReplicaSet
something like:
- Startup 3x config servers on 3 different servers
$ mkdir /data/configdb
$ mongod --configsvr --dbpath /data/configdb --port 27019
$ mkdir /data/configdb
$ mongod --configsvr --dbpath /data/configdb --port 27019
$ mkdir /data/configdb
$ mongod --configsvr --dbpath /data/configdb --port 27019
- Startup ONE mongos
- Configure one shard, without any sharded data
> exit
- Startup mongos' wherever you choose (one per frontend server? dedicated servers?)
Now you have multiple mongos running, with one shard, and can start connecting to them
from your application. To do so you have to modify your connection string:
- Remove the "replicaSet=RSNAME" option from your connection string/arguments
- Change your seedlist from connecting to the ReplicaSet hosts, to connect to the mongos'
There should not be anything else you would have to change in your application,
unless you are somehow relying on connection counts, specific statistics, or
otherwise not-recommended strange procedures.
-Hannes