How do I upgrade a single MongoDB node to sharding mode?

So the basic document on MongoDB.org is here:
http://www.mongodb.org/display/D...

Moving from single to sharded is not trivial. You need to add:

  1. Another shard. (if using replica sets, each shard is a replica set)
  2. At least one config DB (3 for production). The config DB is small, but should be housed on a separate computer. This DB basically contains information about which machines are in the cluster and what data they contain.
  3. A `mongos` process, known as the Router.

You'll also have to change your code. The Router points to the config DB, your code points to the router for all requests.

You will then need to connect to the router and issue some commands to start sharding:
http://www.mongodb.org/display/D...

Then you will need to pick a shard key and shard the appropriate collections. There's a whole document on choosing a shard key:
http://www.mongodb.org/display/D...

Once configured, MongoDB automatically balances the data across shards. This should be done "in the background", however, it will need read and write throughput to move data. Think of it this way, if you have 200GB of data, your disk is now going to have to move 100GB of data.

This movement will likely impact performance, so watch your server loads.


可以详细阅读下面这些文档:


其实官方已经有一个文档说如何在没有downtime的情况下,将Non-sharded system升级为sharding mode system, V5

http://www.mongodb.org/display/DOCS/Upgrading+from+a+Non-Sharded+System

一个简单的setup + configure sharding mode mongodb的例子:

http://www.mongodb.org/display/DOCS/A+Sample+Configuration+Session

详细介绍什么是mongodb sharding,架构和一些feature:

http://www.mongodb.org/display/DOCS/Sharding+Introduction

主要谈的是配置一个sharding mode的mongodb  cluster,包括如何sharding一个single mongodb node上的db/collection:

http://www.mongodb.org/display/DOCS/Configuring+Sharding

选择一个合格的shard key很重要,查看这里看应该注意哪些东西:

http://www.mongodb.org/display/DOCS/Choosing+a+Shard+Key


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值