What is Sharding?

Database Sharding is considered to be the horizontal partitioning of a database or the search engine where each partition is called as a Shard. This is a process of compressing the data collections by splitting the database instances across multiple databases. This in turn fastens the speed of MongoDB CRUD operations. MongoDB creates Shard keys which distribute the data across multiple shards.

sharding

Purpose of database sharding

Due to following reasons database sharding holds an important place in MongoDB –

  • Scaling out to multiple nodes
  • Easy to add new machines
  • Automatic balance of load
  • Zero downtime
  • Automatic failure recovery

Big data

Process of creating database shard

Follow the given steps to create a database shard-

  1. Create a batch file with the name bat at the root of MongoDB’s bin folder.
  2. Write following lines on the batch file:

mkdir“data/localhost10000”

mongod –rest –shardsvr –port 10000 –dbpath data/localhost10000 –logpath data/localhost10000/log.txt
PAUSE

  1. Create another batch file with the name bat at the root of MongoDB’s bin folder.
  2. Write following lines on the batch file:

mkdir “data/localhost10001”
mongod –rest –shardsvr –port 10001 –dbpath data/localhost10001 –logpath data/localhost10001/log.txt
PAUSE

  1. Run RunServer10000.bat
  2. Run RunServer10001.bat

 

Course Schedule

Name Date Details
MongoDB Training 30 Mar 2024(Sat-Sun) Weekend Batch
View Details
MongoDB Training 06 Apr 2024(Sat-Sun) Weekend Batch
View Details
MongoDB Training 13 Apr 2024(Sat-Sun) Weekend Batch
View Details

Find MongoDB Training in Other Regions

Bangalore Chennai Delhi Hyderabad London Sydney United States