I have configured Sharding for MongoDB. My setup looks like this:
My current collection has as primary sharding Shard 1. All my data stored right now on Shard 1. Am I right that the data will be stored on Shard 2 as soon as my Shard 1 will get full ?
I'm testing now a failover scenario when my Shard 1 Server is down then the data should go to Shard 2 but it doesnt happen ? It should automatically auto reconnect to Shard 1 right ?
My current collection has as primary sharding Shard 1. All my data stored right now on Shard 1. Am I right that the data will be stored on Shard 2 as soon as my Shard 1 will get full ?
Sharding is about distributing data in a collection among shards. Sharding is enabled at database level, but actual data distribution on shards is at collection level. So, a sharded database can have sharded and unsharded collections. All the unsharded collections reside on primary shard. The sharded collection data is distributed on multiple shards (based on shard key). All queries to a sharded database (irrespective of sharded or unsharded collections) go thru the mongos router.
For a sharded collection, it is possible that the initial data is all stored on one shard. Later on as the data grows it is distributed to the next shard. See data partitioning with chunks.
I'm testing now a failover scenario when my Shard 1 Server is down then the data should go to Shard 2 but it doesnt happen ? It should automatically auto reconnect to Shard 1 right ?
Faliover is a process associated with replication, not sharding. A replica-set has multiple nodes (as specified in your shard configuration, each shard is a replica-set). When a primary node in the replica-set fails (or goes down) the remaining two secondaries hold an election and elect a new primary. The client applications will automatically connect to the new primary. When the previous primary node comes up again, it will become a seconday.
See replication failover.