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.
Due to following reasons database sharding holds an important place in MongoDB –
Follow the given steps to create a database shard-
mongod –rest –shardsvr –port 10000 –dbpath data/localhost10000 –logpath data/localhost10000/log.txt
mongod –rest –shardsvr –port 10001 –dbpath data/localhost10001 –logpath data/localhost10001/log.txt
Download Interview Questions asked by top MNCs in 2019?