[MongoDB] massive storage mechanism of MongoDB database, massive storage of mongodb

Source: Internet
Author: User

[MongoDB] massive storage mechanism of MongoDB database, massive storage of mongodb

GridFS is a file specification that stores large files in Mongodb databases.

I. How to implement massive storage

Because the size of bson objects in Mongodb is limited, the gridfs specification provides a transparent mechanism to split a large file into multiple smaller files. This mechanism allows you to effectively store objects of large files, especially those large files, such as videos and high-definition images. This specification specifies a standard for splitting files, each file stores a metadata object in the collection object. One or more block objects can be combined in a chunk collection. Mongodb mainly uses the program files tool.

Grifs uses two tables to store data:

Files (including metadata objects)

Chunks)

To name multiple gridfs as a single database, files and blocks have a prefix. By default, the prefix is fs. Therefore, any default gridfs storage will include the namespace fs. files and fs. chunks.

2. the command line tool program files is a tool used to operate gridfs from the command line. For example, you can save the "testfile" file to the database and perform the following operations. First, let's take a look at program files:

The instance stores files in the database.


Description of db. fs. files. find () parameters:
Filename: name of the storage file; chunksize: chunks size uploaddate: storage time md5: file md5 code length: file size (unit: bytes)
Db. fs. chunks. find () parameter description:
N: indicates the chunks sequence number, which starts from 0. The data field is the actually stored data.
Extract data from the database:
D:\Program Files\mongodb\bin>mongofiles get test.txtconnected to: 127.0.0.1done write to: test.txt

The gridfs file can also create an index, and a block can use its file_id and n values for retrieval.

Description of db. fs. files. find () parameters:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.