Distributed small file storage system

By using the Master-Slave architecture and the redis database cluster to store the file directory tree in the distributed file storage system, combined with the gRPC and SocketStream protocols, the memory bottleneck and data loss problems of massive small file storage are solved, and efficient and low-latency file storage is achieved. Storage and recovery.

CN113076298BActive Publication Date: 2024-10-01SHANGHAI ZHUO STEEL CHAIN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110404012.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-15
Publication Date
2024-10-01
Estimated Expiration
2041-04-15

AI Technical Summary

Technical Problem

Existing distributed file storage systems have memory bottlenecks, data loss, and low recovery efficiency when storing massive small files. In particular, FastDFS lacks a backup notification mechanism and automatic recovery mechanism, and Hadoop's architecture is not suitable for low-latency data access.

Method used

Using the Master-Slave architecture, the file directory tree is stored in the redis database cluster. The MasterNode node manages the file directory tree and synchronizes with the SecondaryMasterNode node. Communication between DataNode nodes is achieved through the gRPC protocol and SocketStream, and file upload between the client and the DataNode node is achieved. and read operations, use editslog logs and fsimage files for data backup and recovery.

Benefits of technology

It solves the memory bottleneck problem, improves the storage efficiency of massive small files, ensures high availability and fault tolerance of data, shortens the recovery time of MasterNode node downtime, and achieves low-latency data access and efficient file storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113076298B_ABST
    Figure CN113076298B_ABST
Patent Text Reader

Abstract

The present invention discloses a distributed small file storage system, comprising a MasterNode node and a plurality of DataNode nodes deployed in a Master-Slave architecture; the MasterNode node is used to operate and manage a file directory tree, and manage the DataNode node; the DataNode node is used to store file data recorded in the file directory tree; the file directory tree is stored in a redis database cluster, and when the MasterNode node operates the file directory tree, the file directory tree is obtained from the redis database cluster. The present invention solves the problem of being unable to efficiently store a large number of small files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data storage, and in particular relates to a distributed small file storage system. Background Art

[0002] The present invention is mainly based on two backgrounds: one is the accelerated digital transformation of enterprises, which has led to the demand for massive data storage; the other is the rapid development of massive distributed file systems, especially the development of current big data technology, which has led to the widespread application of distributed file storage in enterprises, and the technology has become relatively mature.

[0003] At present, distributed file storage has been more and more widely used in enterprises, playing an important role in data storage, data backup, data mining, machine learning, etc. With the further improvement of technology, more and more functions of distributed file storage systems are being developed. The basic function of a distributed file storage system is file storage. It provides multiple interfaces for users to store files on the server, and provides storage and backup functions. The server can store a variety of files more conveniently.

[0004] Secondly, the wide application of distributed file storage system is also an important background of the present invention. The distributed file storage system is a system based on file reading, writing and file management. It can store files on the server, that is, write files to the server's disk, and can also download and view files from the server, that is, read files from the server disk. At the same time, it also manages the file directory of the entire file system.

[0005] The distributed file storage systems that are widely used at present are mainly FastDFS developed in C language and Haoop developed in Java language.

[0006] The FastDFS system lacks a backup notification mechanism. As long as one copy is written to the storage, it will succeed. When synchronizing to other storage backups, once the source storage fails, user data may be lost. The loss of user data is unacceptable for the file storage system. Secondly, FastDFS lacks an automatic recovery mechanism, and the data recovery efficiency is low.

[0007] Hadoop is a product of big data storage. Although it has the characteristics of high reliability, high scalability, and high fault tolerance, its architecture makes it unsuitable for low-latency data access. Secondly, Hadoop uses memory to manage file directory trees, which has a memory bottleneck. Massive small files will occupy a large amount of memory space, so it cannot efficiently store massive small files. Summary of the invention

[0008] The technical problem to be solved by the present invention is to provide a distributed small file storage system to address the deficiencies in the above-mentioned prior art and solve the problem of being unable to efficiently store massive small files.

[0009] To solve the above technical problems, the technical solution adopted by the present invention is: a distributed small file storage system, including a MasterNode node and multiple DataNode nodes deployed using a Master-Slave architecture;

[0010] The MasterNode node is used to operate and manage the file directory tree, and manage the DataNode node; the DataNode node is used to store the file data recorded in the file directory tree; the file directory tree is stored in the redis database cluster, and when the MasterNode node operates the file directory tree, it obtains the file directory tree from the redis database cluster.

[0011] The above-mentioned distributed small file storage system also includes a SecondaryMasterNode node, in which the same file directory tree as that in the MasterNode node is maintained; the MasterNode node's operation on the file directory tree will synchronize the SecondaryMasterNode node; after the SecondaryMasterNode synchronizes the file directory tree, the file directory tree is synchronized to the redis database cluster.

[0012] In the above-mentioned distributed small file storage system, the operation of the MasterNode node on the file directory tree will generate an editslog log file; at every T time interval, the SecondaryMasterNode node backs up the file directory tree, and the backed-up fsimage file is synchronized to the MasterNode node, and the MasterNode node clears the editslog log file before the fsimage file is generated.

[0013] In the above-mentioned distributed small file storage system, the operations of the MasterNode node on the file directory tree include adding data operations, deleting data operations, querying data operations and / or modifying data operations on the file directory tree.

[0014] In the above-mentioned distributed small file storage system, multiple DataNode nodes communicate with each other through the gRPC protocol.

[0015] In the above-mentioned distributed small file storage system, each of the DataNode nodes sends a heartbeat packet to the MasterNode through the gRPC protocol to report its own status.

[0016] The above-mentioned distributed small file storage system also includes a client, which is used for users to access the MasterNode node to operate the file directory tree, and to upload files to the DataNode node and / or read files from the DataNode node.

[0017] In the above-mentioned distributed small file storage system, the client uploads a file to the DataNode node, including the following steps:

[0018] Step 1: The client sends a file upload request to the MasterNode.

[0019] Step 2: The MasterNode queries the file directory tree to determine whether the ID of the uploaded file has been recorded in the file directory tree. If so, it returns a message to the client asking "whether to overwrite the file". If so, it proceeds to the next step; if not, it proceeds to the next step.

[0020] Step 3: The MasterNode queries the DataNode list information and returns the location of the DataNode that is closest to the file upload according to the network distance; the network distance is the communication distance between the client and the DataNode;

[0021] Step 4: The client establishes a pipeline request with the returned DataNode node. After the pipeline request is established, the client uploads the file to the DataNode node in streaming data through SocketStream.

[0022] Step 5: When the DataNode receives the data, it writes the data into the file in the form of IO stream and synchronizes the data to the backup DataNode in the form of SocketStream stream.

[0023] Step 6: After the DataNode node finishes writing the data, it returns a message that the file has been written successfully to the MasterNode node and the client.

[0024] The distributed small file storage system described above, wherein the client reads the file from the DataNode node, includes the following steps:

[0025] Step a: The client sends a request to the MasterNode to read the file name.

[0026] Step b, the MasterNode node retrieves the location of the file according to the file name;

[0027] Step c: The MasterNode returns the location of the file to the client according to the network distance; the network distance is the communication distance between the client and the DataNode;

[0028] Step d: The client goes to the DataNode to read the file based on the returned file location.

[0029] Compared with the prior art, the present invention has the following advantages: by storing the file directory tree in the redis database cluster, the memory bottleneck problem is solved.

[0030] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a system block diagram of the present invention.

[0032] Figure 2 It is a schematic diagram of the file uploading process of the present invention.

[0033] Figure 3 It is a schematic diagram of the file reading process of the present invention. DETAILED DESCRIPTION

[0034] like Figure 1 As shown in the figure, the distributed small file storage system includes a MasterNode node and multiple DataNode nodes deployed using a Master-Slave architecture;

[0035] The MasterNode node is used to operate and manage the file directory tree, and manage the DataNode node; the DataNode node is used to store the file data recorded in the file directory tree; the file directory tree is stored in the redis database cluster, and when the MasterNode node operates the file directory tree, it obtains the file directory tree from the redis database cluster.

[0036] It should be noted that by building a redis database cluster as a metadata center to store the file directory tree, the problem of insufficient memory is greatly improved, and the Hadoop memory bottleneck problem is further solved, so that massive small files can be stored.

[0037] The distributed small file storage system also includes a SecondaryMasterNode node, which is an assistant node of the MasterNode node. Since the MasterNode node has a heavier task, a node is needed to help the MasterNode complete the file directory backup operation; the SecondaryMasterNode node maintains the same file directory tree as that in the MasterNode node; the MasterNode node's operation on the file directory tree will synchronize the SecondaryMasterNode node; after the SecondaryMasterNode synchronizes the file directory tree, the file directory tree is synchronized to the redis database cluster.

[0038] The distributed small file storage system also includes a client, which is used for users to access the MasterNode node to operate the file directory tree, and to upload files to the DataNode node and / or read files from the DataNode node.

[0039] It should be noted that the client DFSClient is a module in the system of the present invention that provides an interface for users. Users can use the DFSClient module to create, view, and delete directories and upload, download, and delete files. Of course, this module can also be relied on by other systems, so that other systems can access the cluster through a specific API to operate the system.

[0040] In this embodiment, the MasterNode node's operation on the file directory tree generates an editslog log file; every T time interval, T can be set according to actual needs; the SecondaryMasterNode node backs up the file directory tree, and the backed-up fsimage file is synchronized to the MasterNode node, and the MasterNode node clears the editslog log file before the fsimage file is generated.

[0041] It should be noted that the MasterNode node is a main core module in the system of the present invention, and the module is mainly used to provide services and manage file directory trees, manage operation logs, manage DataNode nodes and other functions. All requests from the client are first to the MasterNode node, and the MasterNode node responds differently according to different request types after receiving the request. In addition, the most important function of the MasterNode is to manage the operation log. All operations of the client to the file system are recorded in the editslog file. In this way, when the MasterNode node fails, after restarting the MasterNode node, it can be replayed from the edislog file according to the operation log, thereby obtaining a complete file directory tree, so that data will not be lost. In addition, since edislog is constantly written, the size of this file is constantly increasing. If no measures are taken, it will cause the MasterNode to read the editlog file too large, resulting in performance degradation. Therefore, the segmented preservation mechanism can be adopted for the editlog file to complete the preservation, so that the system only needs to read a very small section of the file, which greatly improves efficiency. Secondly, it takes a lot of time to read the editslog log data for playback. Therefore, as the number of operation logs increases, the recovery time will be too long when the MasterNode is restored after a downtime. Based on this problem, SecondaryMasterNode also provides the fsimage mirror directory function. Every once in a while, SecondaryMasterNode will write the file directory tree backup in the redis database into the fsimage file, synchronize the fsimage file to the MasterNode, and clear the editslog before that time point. In this way, when the MasterNode is restored after a downtime, it only needs to read the file from the fsimage and replay part of the operation from the editslog file to get the complete file directory. This greatly shortens the time for MasterNode to recover after a downtime.

[0042] In addition, specifically, the operations of the MasterNode node on the file directory tree include adding data operations, deleting data operations, querying data operations and / or modifying data operations on the file directory tree.

[0043] like Figure 1 As shown, multiple DataNode nodes communicate with each other through the gRPC protocol. Each DataNode node sends a heartbeat packet to the MasterNode through the gRPC protocol to report its own status. Maintaining communication through the gRPC protocol ensures efficient and low-latency use of the entire cluster.

[0044] like Figure 2 As shown, the client uploads a file to the DataNode node, including the following steps:

[0045] Step 1: The client sends a file upload request to the MasterNode.

[0046] Step 2: The MasterNode queries the file directory tree to determine whether the ID of the uploaded file has been recorded in the file directory tree. If so, it returns a message to the client asking "whether to overwrite the file". If so, it proceeds to the next step; if not, it proceeds to the next step.

[0047] Step 3: The MasterNode queries the DataNode list information and returns the location of the DataNode that is closest to the file upload according to the network distance; the network distance is the communication distance between the client and the DataNode;

[0048] Step 4: The client establishes a pipeline request with the returned DataNode node. After the pipeline request is established, the client uploads the file to the DataNode node in streaming data through SocketStream.

[0049] Step 5: When the DataNode receives the data, it writes the data into the file in the form of IO stream and synchronizes the data to the backup DataNode in the form of SocketStream stream.

[0050] Step 6: After the DataNode node finishes writing the data, it returns a message that the file has been written successfully to the MasterNode node and the client.

[0051] like Figure 3 As shown in the figure, the client reads the file from the DataNode node, including the following steps:

[0052] Step a: The client sends a request to the MasterNode to read the file name.

[0053] Step b, the MasterNode node retrieves the location of the file according to the file name;

[0054] Step c: The MasterNode returns the location of the file to the client according to the network distance; the network distance is the communication distance between the client and the DataNode;

[0055] Step d: The client goes to the DataNode to read the file based on the returned file location.

[0056] It should be noted that the present invention satisfies the distributed storage of a large number of small file systems and can respond in a timely and fast manner. The system has a general API interface, and only needs to simply introduce DFSClient and simple configuration to access the operation cluster. Since the system is designed for small files, the bottleneck problem and high availability and high expansion problem encountered by small file storage are fully considered, and the problem of MasterNode node file directory backup is creatively solved by introducing SecondaryMasterNode nodes, ensuring the high availability and high fault tolerance of the entire cluster. The distributed file storage system of the present invention has low requirements for computer hardware, and only needs a few cheap computer servers to form a cluster to provide efficient and reliable file storage services, and can be expanded relatively easily. In theory, as long as the DataNode nodes are continuously added, data storage can be unlimited.

[0057] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any simple modification, change and equivalent structural change made to the above embodiment based on the technical essence of the present invention still falls within the protection scope of the technical solution of the present invention.

Claims

1. Distributed small file storage system, characterized by: It includes a MasterNode node and multiple DataNode nodes deployed using a Master-Slave architecture; the MasterNode node is used to operate and manage a file directory tree, and manage DataNode nodes; the DataNode node is used to store file data recorded in the file directory tree; the file directory tree is stored in a redis database cluster, and when the MasterNode node operates the file directory tree, it obtains the file directory tree from the redis database cluster; It also includes a SecondaryMasterNode node, in which the same file directory tree as that in the MasterNode node is maintained; the operation of the MasterNode node on the file directory tree will synchronize the SecondaryMasterNode node; after the SecondaryMasterNode synchronizes the file directory tree, the file directory tree is synchronized to the redis database cluster; The operation of the MasterNode node on the file directory tree will generate an editslog log file; at every T time interval, the SecondaryMasterNode node backs up the file directory tree, and the backed-up fsimage file is synchronized to the MasterNode node, and the MasterNode node clears the editslog log file before the fsimage file is generated; The multiple DataNode nodes communicate with each other through the gRPC protocol; Each of the DataNode nodes sends a heartbeat packet to the MasterNode via the gRPC protocol to report its own status; It also includes a client, which is used for users to access the MasterNode node to operate the file directory tree, and upload files to the DataNode node and / or read files from the DataNode node; The client uploads a file to the DataNode node, including the following steps: Step 1, the client sends a file upload request to the MasterNode node; Step 2, the MasterNode node queries the file directory tree to determine whether the ID of the uploaded file is recorded in the file directory tree, if it is recorded, it returns "whether to overwrite the written file" to the client, if so, proceed to the next step; if not, proceed to the next step; Step 3, the MasterNode queries the DataNode list information, and returns the location of the DataNode node that is closest to the file upload according to the network distance; the network distance is the communication distance between the client and the DataNode; Step 4, the client establishes a pipeline request with the returned DataNode node, after the pipeline request is established, the client uploads the file to the DataNode node through SocketStream in streaming data.

2. The distributed small file storage system according to claim 1, characterized in that: The operations of the MasterNode node on the file directory tree include adding data operations, deleting data operations, querying data operations and / or modifying data operations on the file directory tree.

3. The distributed small file storage system according to claim 1, characterized in that: Also includes: Step 5: When the DataNode receives the data, it writes the data into the file in the form of IO stream and synchronizes the data to the backup DataNode in the form of SocketStream stream. Step 6: After the DataNode node finishes writing the data, it returns a message that the file has been written successfully to the MasterNode node and the client.

4. The distributed small file storage system according to claim 3, characterized in that: The client reads the file from the DataNode node, including the following steps: step a, the client sends a request to the MasterNode node to read the file name; step b, the MasterNode node retrieves the location of the file according to the file name; step c, the MasterNode node returns the location of the file to the client according to the network distance; the network distance is the communication distance between the client and the DataNode; step d, the client goes to the DataNode to read the file according to the returned file location.