日期:2014-05-16  浏览次数:20613 次

mongodb我的实践

一直以为都没机会玩分布式数据库,所以没有什么经验,因为oracle的配置让人望而生畏.

现在有了mongo,这种轻量级,配置起横竖分层的架构很方便.

?

大部分知识网上都能搜到.

现在唯一个还有疑问就是

db.runCommand({enablesharding:'db1'})

按理说到了这一步,此时在db1里添加各个collection应该是分片的(不指collection里的数据).但是却不是.文档上说明

?

?

Once enabled, ? will place new collections on the primary shard for that database. Existing collections within the database will stay on the mongos

original shard. To enable real partitioning of data, we have to shard an individual collection.

?

也就是说此时增加collection还是跟着db1的primary走.

只有shardcollection以后,分片才有意义.也就是说只有对数据集里的数据分片才有意义.

这点有点儿让我奇怪.

?