In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The principle of GridFS is to divide a large file into several larger blocks and store each block as a separate document.
(1) blocks in GridFS are stored in a dedicated collection. Default is fs.chunks.
(2) in addition to storing each block of a file separately, you also need to put the meta-information of each block into a document store and set these documents in the fs.files collection by default.
For example, add an foo.txt document to the database foo:
[root@localhost] # echo "hello world" > foo.txt [root@localhost] # mongofiles-d foo put foo.txt connected to: 127.0.0.1 added file: {_ id: ObjectId ('54b3d62983047a88669bc529'), filename: "foo.txt", chunkSize: 261120, uploadDate: new Date (1421071914003), md5: "6f5902ac237024bdd0c176cb93063dc4", length: 12} done!
View the appropriate collection:
> show collections fs.chunks fs.files system.indexes >
View this document:
[root@localhost ~] # mongo foo MongoDB shell version: 2.6.6 connecting to: foo > db.fs.chunks.findOne () {"_ id": ObjectId ("54b51dc15caeb0e1a8722e8d"), "files_id": ObjectId ("54b51dc0c3ab6ae7c08f6028"), "n": 0, "data": BinData (0, "aGVsbG8gd29ybGQK")} >
Files_id: meta information of the file to which the block belongs
N: relative position of the block in the file
Data: binary data contained in a block
> db.fs.files.findOne () {"_ id": ObjectId ("54b51dc0c3ab6ae7c08f6028"), "filename": "foo.txt", "chunkSize": 261120, "uploadDate": ISODate ("2015-01-13T13:29:37.525Z"), "md5": "6f5902ac237024bdd0c176cb93063dc4", "length": 12} >
_ id: the unique ID of the file, which is consistent with the value of files_id in each block of the file
Length: the number of bytes contained in the file
ChunkSize: the size of each block that makes up the file, in bytes
UpdateDate: the time when the file was uploaded to GridFS
MD5: MD5 value of the file, calculated by the server
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.