Mongo DB 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.

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

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值