您的位置:首页 > 数据库 > Mongodb

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

2011-07-03 16:39 531 查看
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:

Another shard. (if using replica sets, each shard is a replica set)
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.
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: