is this the optimal minimum setup for mongodb to allow for sharding/scaling?
3 instances for config servers
1 instance for webserver & mongos
1 instance for shard 1
then when i need to start more shards i c开发者_Python百科an just add more instances?
also, what is a replica set? if i had say 3 servers to shard 1 then is that a replica set?
A Replica Set is a set of computers that are clones of each other. (i.e.: replicas) Within a given set there is an elected master. By default reads and writes go to this elected master and the replicas just "tail" the changes to be up-to-date copies. If the master fails, a new one is elected and the system just keeps going. The documentation is here.
So you ask about scaling with MongoDB. There are two types of scaling:
- Read Scaling: use Replica Sets (see here)
- Write Scaling: use Sharding
The minimum config for Replica Sets is - 2 full replicas - 1 arbiter (lightweight process, breaks ties when voting)
The minimum config for Sharding is
- 1 config server
- 1 mongod
process (only one shard)
- 1 or more mongos
(generaly on app server)
However, you probably don't want to run like this in production. Running only a single DB, means that you only have one source for the data which can result in large down-times or total data loss. This is generally solved by using replica sets.
Additionally, the config server is quite important. MongoDB supports 1 or 3 config servers. Most production deployments use 3. Note that config servers and arbiters are very lightweight and can live on other boxes or on Amazon micro instances.
Most production deployments with sharding also involve replica sets. In fact, they usually start as replica sets.
then when i need to start more shards i can just add more instances?
From a sharding perspective it should be as easy as:
- start new shard server
- run the addshard
command from a mongos
Note that when you add a shard, you will need to allow for time and resources as data migrates between shards and everything re-balances.
精彩评论