如果要進(jìn)行GridFS sharding,則需進(jìn)行如下設(shè)置:
db.runCommand( { shardcollection : "test.fs.chunks", key : { _id : 1 } } ) {"ok" : 1} ,更多內(nèi)容參見(jiàn)http://eshilin.blog.163.com/blog/static/13288033020106215227346/ > db.printShardingStatus() --- Sharding Status --- sharding version: { "_id" : 1, "version" : 3 } shards: { "_id" : "shard0000", "host" : "localhost:27020" } { "_id" : "shard0001", "host" : "localhost:27021" } databases: { "_id" : "admin", "partitioned" : false, "primary" : "config" } { "_id" : "user001", "partitioned" : true, "primary" : "shard0000" } dnt_mongodb.posts1e chunks: { "name" : { $minKey : 1 } } -->> { "name" : { $maxKey : 1 } } on : shard0000 { "t" : 1000, "i" : 0
下面我用一個(gè)工具來(lái)批量向dnt_mongodb數(shù)據(jù)庫(kù)的 posts1表中導(dǎo)入數(shù)據(jù),大約是16萬(wàn)條數(shù)據(jù)。導(dǎo)入過(guò)程中mongos會(huì)顯示類(lèi)似如下信息:
Tue Sep 07 12:13:15 [conn14] autosplitting dnt_mongodb.posts1 size: 47273960 shard: ns:dnt_mongodb.posts1 at: shard0000:10.0.4.85:27020 lastmod: 1|0 min: { _id: MinKey } max: { _id: MaxKey } on: { _id: 19 }(splitThreshold 47185920) Tue Sep 07 12:13:15 [conn14] config change: { _id: "4_85-2010-09-07T04:13:15-0", server: "4_85", time: new Date(1283832795994), what: "split", ns: "dnt_mongodb.posts1", details: { before: { min: { _id: MinKey }, max: { _id: MaxKey } }, left: { min: { _id: MinKey }, max: { _id: 19 } }, right: { min: { _id: 19 }, max: {_id: MaxKey } } } } Tue Sep 07 12:13:16 [conn14] moving chunk (auto): ns:dnt_mongodb.posts1 at: shard0000:10.0.4.85:27020 lastmod: 1|1 min: { _id: MinKey } max: { _id: 19 } to: shard0001:10.0.4.85:27021 #objects: 0 Tue Sep 07 12:13:16 [conn14] moving chunk ns: dnt_mongodb.posts1 moving ( ns:dnt_mongodb.posts1 at: shard0000:10.0.4.85:27020 lastmod: 1|1 min: { _id: MinKey }max: { _id: 19 }) shard0000:10.0.4.85:27020 -> shard0001:10.0.4.85:27021 Tue Sep 07 12:13:23 [WriteBackListener] ~ScopedDBConnection: _conn != null Tue Sep 07 12:13:23 [WriteBackListener] ERROR: splitIfShould failed: ns: dnt_mongodb.posts1 findOne has stale config Tue Sep 07 12:13:28 [WriteBackListener] autosplitting dnt_mongodb.posts1 size: 54106804 shard: ns:dnt_mongodb.posts1 at: shard0000:10.0.4.85:27020 lastmod: 2|1min: { _id: 19 } max: { _id: MaxKey } on: { _id: 71452 }(splitThreshold 47185920) Tue Sep 07 12:13:28 [WriteBackListener] config change: { _id: "4_85-2010-09-07T04:13:28-1", server: "4_85", time: new Date(1283832808738), what: "split", ns: "dnt_mongodb.posts1", details: { before: { min: { _id: 19 }, max: { _id: MaxKey }}, left: { min: { _id: 19 }, max: { _id: 71452 } }, right: { min: { _id: 71452 }, max: { _id: MaxKey } } } }
出處:CSDN
責(zé)任編輯:bluehearts
上一頁(yè) 基于Mongodb進(jìn)行分布式數(shù)據(jù)存儲(chǔ) [2] 下一頁(yè) 基于Mongodb進(jìn)行分布式數(shù)據(jù)存儲(chǔ) [4]
◎進(jìn)入論壇網(wǎng)絡(luò)編程版塊參加討論
|