2011-12-18 35 views
3

新手使用蒙戈2.0.1上试图测试出碎片如下窗口32位:MongoDB的分片例如

(4)的过程:2个碎片+配置srver + mongos瓦特微小CHUNKSIZE

mongod.exe --shardsvr --port 10001 --dbpath <folder1>  > shard1.log 
mongod.exe --shardsvr --port 10002 --dbpath <folder2>  > shard2.log 
mongod.exe --configsvr --port 20000 --dbpath <configfolder> > config.log 
mongos.exe --configdb localhost:20000 --chunkSize 1   > mongos.log 

我跑了壳,并设置2个碎片:

mongos> use admin 
switched to dbadmin 

mongos> db.runCommand({ addshard : "localhost:10001" }); 
{ "shardAdded" : "shard0000", "ok" : 1 } 

mongos> db.runCommand({ addshard : "localhost:10002" }); 
{ "shardAdded" : "shard0001", "ok" : 1 } 

然后我启用了分片的测试数据库(dbTest)和集合(CTEST):

mongos> db.runCommand({ enablesharding : "dbTest" }); 
{ "ok" : 1 } 

mongos> db.runCommand({ shardcollection : "dbTest.cTest", key : { Name : 1 } }); 
{ "collectionssharded" : "dbTest.cTest", "ok" : 1 } 

最后我填充CTEST集合(按姓名索引)与1000005个样品记录:

mongos> use dbTest 
switched to db dbTest 

db.cTest.drop(); 
db.cTest.ensureIndex({ Name : 1 }); 
db.cTest.save({Name: "Frank", Age:56, Job: "Accountant", State: "NY"}); 
db.cTest.save({Name: "Bill" , Age:23,     State: "CA"}); 
db.cTest.save({Name: "Janet", Age:34, Job: "Dancer"     }); 
db.cTest.save({Name: "Andy", Age:44        }); 
db.cTest.save({Name: "Zach", Age:23, Job: "Fireman", State: "CA"}); 
i=1; 
while(i<=1000) 
{ 
    j=1; 
    while (j<=1000) 
    { 
    db.cTest.save({Name:"Person("+i+","+j+")", Age:i+j}); 
    j = j+1 
    }; 
    i=i+1; 
}; 

无论其...

看来,没有什么实际拿到分片。在配置数据库中,db.chunks.count()为零,我可以从windows explorer文件大小中看到所有数据进入第一个分片的物理文件设置设置,而第二个分片没有。

任何人都可以发现我做错了什么,并提供一些关于如何管理的提示&调试这种类型的东西&看看发生了什么?

谢谢

回答

5

一旦你“shardcollection”,不要放弃它。它将删除有关分片收集的元数据。

+0

谢谢,纳特就是这样。 (我可以一直盯着那几天而不留意!) – tpascale 2011-12-19 15:56:19