Comparison with RDBMS
Here ,
- Collection is Table
- Database is Database
- Document(JSON) is Record/Row stored as binary which is BSON
BSON
Documents are schema less i.e. we can add info to any objects in single collection unlike RDBMS in which adds column by altering schema structure.
In the context of MongoDB, “cluster” is the word usually used for either a replica set or a sharded cluster
Mongos : The instances provide the interface between the client applications and the sharded cluster
Config servers : Stores the meta data for a sharded cluster
Client : Connects mongo server through the drivers
Replication sets:
Replica type : Master-Slave
Heartbeat happens for every 10sec between the replicas and if the machine is down, one of the nodes is elected as primary. Once the failover server is up it will be acting as secondary.. and waits for other failovers.
We can read and write on primary server which is elected among the sets
Writing on primary will enter in Oplog and secondary servers replicates from Oplog
Write operation must go only on primary node while read operation can go either primary or secondary nodes for load balancing
Setup : Install three nodes, create replica in each node and initiate replication on any one node
Sharding
It is a method for distributing data across multiple machines
Sharding is based on collection
Each shard has a set of value and split across the other shards,
For example Shard 1 has 1-100, Shard2 has 100-200 and so on...
Start mongodb now.. click here
Configuring Sharded cluster
- Start config servers replicaset
- Start shard servers replicasets
- Start mongos instance by configuring the config servers replicaset
- Add shards in mongos instance
- We don't shard a database We shard a collection*
- Enable sharding databse before using the database in sharding
Comments
Post a Comment