2014-02-25 79 views
1

如何将转储的mongodb转换为平面文件? 我继承了MongoDB的使用GridFS的像mongodb gridfs到平面文件

foo.files.bson 
    foo.chunks.bson 

我进口他们使用mongorestore。 但现在我怎么能转储每个对象到外部文件? 所有的长度大约是29,000,而块大小 是262,144,所以块应该是自包含的。

> db.foo.files.find()[0] 
{ 
    "_closed" : true, 
    "_id" : ObjectId("4e9c69e93e3c092c02000001"), 
    "chunkSize" : 262144, 
    "comment" : ObjectId("4e9c69e93e3c092c02000000"), 
    "compression" : "bz2", 
    "filename" : "my/file", 
    "is_dft" : true, 
    "is_gw" : false, 
    "length" : 22760, 
    "md5" : "f58c497a0f6127fe70f8240c12d482b6", 
    "sha512" : "19e3...a2338", 
    "uploadDate" : ISODate("2011-10-17T17:46:17.312Z"), 
    "uploader" : null 
} 


> db.OUTCARs.chunks.find()[0] 
{ 
    "_id" : ObjectId("4e9c69e93e3c092c02000002"), 
    "n" : 0, 
    "data" : BinData(0,"QlpoOTFsEAjf...UJA8CxbBA="), ******* this is the data to save to a flat file 
    "files_id" : ObjectId("4e9c69e93e3c092c02000001") 
} 

回答

0

如果我正确理解你的问题,你想在导入转储读取文件 - 此作业MongoDB的客户端工具MongoFiles是 - http://docs.mongodb.org/manual/reference/program/mongofiles/

只需键入的命令提示符下mongofiles /终端和你会看到像put/get/list/search这样的子命令。你的答案在于使用get和list。