如何将转储的mongodb转换为平面文件? 我继承了一个像
这样的gridfs的mongodb 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 :(得分:0)
如果我正确理解您的问题,您想要读取导入转储中的文件 - 此作业的mongodb客户端工具是mongofiles - http://docs.mongodb.org/manual/reference/program/mongofiles/
只需在命令提示符/终端上键入mongofiles,您将看到put / get / list / search等子命令。你的答案在于使用get和list。