Cluster file distributed management method and system
By deploying a master-slave metadata server cluster and a consistent hash algorithm, files are divided into objects and stored in multiple storage nodes, which solves the metadata performance bottleneck and load balancing problems in cluster file distributed management, and achieves efficient file management. Storage and access.
Patent Information
- Application Number
- CN202410895874.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-07-05
AI Technical Summary
Existing cluster file distributed management technology has problems such as metadata management performance bottlenecks, high data replication overhead, data block granularity not adaptable to different file characteristics, and high load balancing difficulty, making it difficult to meet the needs of massive data storage and high concurrent access.
Deploy a master-slave metadata server cluster, use a consistent hash algorithm to divide files into objects of preset sizes and store them on multiple storage nodes, implement file request forwarding and load balancing through proxy services, and dynamically adjust object storage nodes to achieve metadata High data reliability and load balancing.
It improves metadata management performance, reduces data replication overhead, adapts to different file characteristics, achieves horizontal scalability and load balancing of file storage, and ensures high availability and flexibility of the system.
Smart Images

Figure CN118426713B
Abstract
Description
Technical Field
[0001] The present invention relates to file management technology, and in particular to a cluster file distributed management method and system. Background Art
[0002] With the rapid development of information technology and the sharp increase in data volume, traditional centralized file storage and management methods can no longer meet the storage and access needs of massive data. Centralized file systems face problems such as poor scalability, single point failures, and performance bottlenecks, making it difficult to cope with the continuous growth of data scale and high concurrent access to services.
[0003] Cluster file distributed management technology came into being. By dispersing and storing file data on multiple server nodes, distributed processing of file storage and access is achieved, effectively solving the limitations of traditional centralized file systems.
[0004] Although the existing cluster file distributed management technology has solved the problem of massive data storage and access to a certain extent, it still has some shortcomings:
[0005] Performance bottleneck of metadata management: When the number of files and access concurrency are high, a single metadata server may not be able to efficiently process all requests, becoming a performance bottleneck of the system.
[0006] Data replication overhead: In order to ensure data reliability, each data block needs to be replicated in multiple copies, which takes up a lot of storage space and network bandwidth, and increases the system's storage and management overhead.
[0007] The granularity problem of data blocks: Data blocks of fixed size may not be able to adapt to the characteristics of different types of files, resulting in waste of storage space and degradation of read and write performance.
[0008] Difficulty of load balancing: Dynamically adjusting the distribution and access strategy of data blocks requires consideration of many factors, such as the storage capacity of the node, access popularity, network topology, etc., and the implementation complexity is relatively high.
[0009] Therefore, how to further optimize cluster file distributed management technology, improve the performance of metadata management, reduce the overhead of data replication, adapt to the characteristics of different files, and achieve efficient load balancing has become a key issue that needs to be solved urgently. Summary of the invention
[0010] The embodiments of the present invention provide a cluster file distributed management method and system, which can at least solve some problems in the prior art.
[0011] According to a first aspect of the embodiments of the present invention,
[0012] A cluster file distributed management method is provided, comprising:
[0013] Deploy a metadata server cluster, the metadata server cluster includes a master metadata server and at least one slave metadata server, the master metadata server is used to manage the file system namespace and maintain the directory tree structure and file metadata, and the slave metadata server is a backup of the master metadata server;
[0014] Divide the file into objects of preset sizes, and store the multiple objects on multiple storage nodes in the file system based on a consistent hashing algorithm, wherein an object storage service is run on each storage node, and the object storage service is used for persistent storage and access of the objects;
[0015] In response to the primary metadata server receiving a file request sent by a client, the file request is implemented on the corresponding storage node based on a proxy service between the client and the storage node, wherein the file request includes any one or more of a file creation request, a file write request, and a file read request. In the event that the primary metadata server fails, the primary metadata server switches to the secondary metadata server to receive the file request sent by the client.
[0016] In an optional embodiment,
[0017] Based on the consistent hashing algorithm, multiple objects are stored on multiple storage nodes in the file system, including:
[0018] Based on a hash function, the object name of the object is mapped to an integer hash value in a hash value space of a fixed size, and the hash value space is divided into a plurality of sub-intervals corresponding to storage nodes respectively, and the object corresponding to the integer hash value in the sub-interval is stored in the storage node corresponding to the sub-interval;
[0019] The method also includes:
[0020] Collecting load indicator data of each storage node at preset time intervals, the load indicator data including any one or more of the quality of read and write requests processed by the object storage service on the storage node per unit time, the response time of the object storage service on the storage node, the CPU usage rate occupied by the object storage service process on the storage node, and the proportion of memory resources occupied by the object storage service process on the storage node;
[0021] The preset load indicator data is sent to the main metadata server, so that the main metadata server generates a global load view based on the load indicator data on each storage node and determines the load status of each storage node, and selects to migrate objects on the storage node based on the load status of each storage node.
[0022] In an optional embodiment,
[0023] The metadata server generates a global load view based on the load indicator data on each storage node and determines the load status of each storage node. Based on the load status of each storage node, the metadata server selects objects on the storage node for migration, including:
[0024] A warning threshold and a critical threshold are set for each load indicator data, wherein the warning threshold is smaller than the critical threshold;
[0025] In response to any load indicator data on the storage node being greater than a warning threshold and less than a critical threshold within a preset time period, lowering the critical threshold according to a preset ratio;
[0026] In response to any load indicator data on the storage node being not less than the critical threshold, the storage node is determined to be a high-load node, and a target node is selected from other storage nodes based on the global load view to receive the object on the high-load node, wherein the target node satisfies: each load indicator data of the target node is less than the critical threshold, the storage space and input / output bandwidth of the target node meet preset conditions, and the network distance between the target node and the high-load node is less than a preset threshold;
[0027] Based on the data access mode of the high-load node, determine the objects in the high-load node whose access frequency is greater than a preset threshold as objects to be migrated, and generate a migration task list based on the distribution of the objects to be migrated in the high-load node and the location of the target node;
[0028] The metadata server sends the migration task list to the high-load node, so that the high-load node sends the objects to be migrated to the target node by streaming transmission or object-based transmission. During the transmission process, the high-load node suspends the modification operation of the objects to be migrated.
[0029] After receiving the objects to be migrated, the target node synchronizes confirmation messages to the high-load node and the metadata server, so that the high-load node deletes the local data to be migrated based on the confirmation message, and the metadata server updates the global load information based on the confirmation message.
[0030] In an optional embodiment,
[0031] In response to the primary metadata server receiving a file request sent by a client, implementing the file request on a corresponding storage node based on a proxy service between the client and the storage node, including:
[0032] In response to the primary metadata server receiving a file request sent by a client, determining metadata information of the file according to a file path in the file request, the metadata information including an object list and an object identifier of the file, and using a proxy service to calculate an object range corresponding to the file request according to the metadata information, an offset and a length of the file request, so as to convert the file request into an object request, the object request being used to access an object on a storage node;
[0033] Searching for the object to be accessed in the cache of the proxy service based on the object request, returning the object to be accessed to the client in response to the object to be accessed being hit in the cache of the proxy service, wherein the cache of the proxy service stores objects accessed by the client within a preset time period;
[0034] In response to the object to be accessed not being hit in the cache of the proxy service, a storage node is selected based on the data distribution strategy, the load indicator data of the storage node and the network topology, and the object request is sent to the storage node to return the object to be accessed based on the object request, wherein the data distribution strategy is implemented based on a consistent hashing algorithm.
[0035] In an optional embodiment,
[0036] The method also includes:
[0037] When the free space in the cache of the proxy service reaches a preset threshold, the historical access records of the client are analyzed to determine the data access mode of the client, and in response to the data access mode of the client being a sequential access mode, subsequent files of the file are read sequentially into the cache of the proxy service when the client accesses the file, and in response to the data access mode of the client being a random access mode, files with a frequency higher than a threshold within a preset time period are read into the cache of the proxy service based on the frequency of the client accessing the file;
[0038] When a file is read from the cache of the proxy service, the timestamp of the file is recorded. When there is an object request, the timestamp of the corresponding object to be accessed in the cache of the proxy service is compared with the timestamp of the corresponding object to be accessed in the storage node. In response to the timestamp of the corresponding object to be accessed in the cache of the proxy service being less than the timestamp of the corresponding object to be accessed in the storage node, the object to be accessed corresponding to the object request is read from the storage node.
[0039] In an optional embodiment,
[0040] Deploy a metadata server cluster, including:
[0041] Determine an odd number of server nodes in the metadata server cluster, wherein the same metadata service program runs on each server node, and determine configuration information of each server node in the metadata server cluster by static configuration or dynamic discovery, wherein the configuration information includes a network address and a port number, and connect the server nodes to each other through a network based on the configuration information;
[0042] Each server node is used as a follower node. In response to each follower node not receiving a heartbeat message sent by the leader node within a preset election duration, the follower node is changed from a follower node to a candidate node and a new round of election is initiated, wherein the election is used to determine a new leader node from each candidate node;
[0043] In a new round of elections, each candidate node updates its term number and sends a voting request to other candidate nodes. If other candidate nodes have not voted in the new round of elections and the term number included in the voting request is greater than its own term number, it votes for the candidate node that sent the voting request and updates its own term number.
[0044] The candidate node that receives the most votes is used as the new leader node and the other candidate nodes are used as new follower nodes. The leader node is the master metadata server in the metadata server cluster, and the follower nodes are slave metadata servers in the metadata server cluster.
[0045] In an optional embodiment,
[0046] In the event that the master metadata server fails, stopping sending heartbeat messages to other slave metadata servers, the method further includes:
[0047] The primary metadata server encapsulates the client's file request into a log entry and adds the log entry to the log of the primary metadata server, wherein the log entry includes an index identifier and a current term number on the primary metadata server;
[0048] The master metadata server sends a log adding request to each slave metadata server, wherein the log adding request includes the log entry;
[0049] In response to receiving the add log request, each slave metadata server rejects the add log request when the term number in the add log request is less than the current term number of the slave metadata server, or a log entry with the same index identifier but a different current term number already exists on the slave metadata server;
[0050] Otherwise, receiving the log adding request and adding the log entry to the log of the slave metadata server, and returning a log adding response message to the master metadata server;
[0051] When the primary metadata server receives a predetermined number of response add log messages, the log entry is marked as committed so that all metadata servers apply the log entry.
[0052] In the second aspect of the embodiments of the present application,
[0053] A cluster file distributed management system is provided, comprising:
[0054] The first unit is used to deploy a metadata server cluster, wherein the metadata server cluster includes a master metadata server and at least one slave metadata server, wherein the master metadata server is used to manage the file system namespace and maintain the directory tree structure and metadata of the files, and the slave metadata server is a backup of the master metadata server;
[0055] The second unit is used to divide the file into objects of preset sizes, and store the multiple objects on multiple storage nodes in the file system based on a consistent hashing algorithm, wherein an object storage service is respectively run on each storage node, and the object storage service is used for persistent storage and access of the objects;
[0056] The third unit is used to implement the file request on the corresponding storage node based on the proxy service between the client and the storage node in response to the main metadata server receiving the file request sent by the client, wherein the file request includes any one or more of a file creation request, a file write request, and a file read request, wherein in the event of failure of the main metadata server, the main metadata server switches to the slave metadata server to receive the file request sent by the client.
[0057] According to a third aspect of the embodiments of the present invention,
[0058] An electronic device is provided, comprising:
[0059] processor;
[0060] a memory for storing processor-executable instructions;
[0061] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0062] A fourth aspect of the embodiments of the present invention is:
[0063] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.
[0064] This application achieves high reliability of metadata management by deploying a master-slave metadata server cluster. The master metadata server is responsible for managing the file system namespace, maintaining the directory tree structure and file metadata, and the slave metadata server serves as a backup for the master metadata server, automatically taking over its functions when the master metadata server fails, ensuring the continuous availability of metadata services.
[0065] By dividing files into objects of preset sizes and using a consistent hashing algorithm to distribute and store objects on multiple storage nodes, load balancing of file storage and access is achieved. Each storage node runs an independent object storage service, and the persistent storage and access of objects are completed on the local node, avoiding the overhead of network transmission and improving the performance of file reading and writing.
[0066] By introducing a proxy service between the client and the storage node, the client's file request is forwarded to the corresponding storage node for processing, realizing distributed concurrency of file access. Multiple clients can initiate file requests to different storage nodes at the same time, and each storage node processes the requests in parallel, significantly improving the concurrency and throughput of file access.
[0067] The object storage service and consistent hashing algorithm are used to achieve horizontal scalability of file storage. When the storage capacity is insufficient, new storage nodes can be easily added. The consistent hashing algorithm will automatically adjust the distribution of objects between nodes without the need for data migration, which improves the scalability and flexibility of the system. The proxy service shields the interaction details between the client and the storage node. The client does not need to care about which node the file is stored on, nor does it need to understand the increase or decrease of storage nodes, thus achieving transparency in file access. The client only needs to interact with the proxy service, which automatically routes the file request to the corresponding storage node for processing based on the type and parameters of the request. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 A schematic diagram of a process flow of a cluster file distributed management method according to an embodiment of the present invention;
[0069] Figure 2 The diagram is a schematic diagram of the structure of a cluster file distributed management system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0070] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0071] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0072] Figure 1 FIG. 1 is a flow chart of a cluster file distributed management method according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0073] S101 deploys a metadata server cluster, the metadata server cluster includes a master metadata server and at least one slave metadata server, the master metadata server is used to manage the file system namespace and maintain the directory tree structure and file metadata, the slave metadata server is a backup of the master metadata server;
[0074] In an optional embodiment,
[0075] Deploy a metadata server cluster, including:
[0076] Determine an odd number of server nodes in the metadata server cluster, wherein the same metadata service program runs on each server node, and determine configuration information of each server node in the metadata server cluster by static configuration or dynamic discovery, wherein the configuration information includes a network address and a port number, and connect the server nodes to each other through a network based on the configuration information;
[0077] Each server node is used as a follower node. In response to each follower node not receiving a heartbeat message sent by the leader node within a preset election duration, the follower node is changed from a follower node to a candidate node and a new round of election is initiated, wherein the election is used to determine a new leader node from each candidate node;
[0078] In a new round of elections, each candidate node updates its term number and sends a voting request to other candidate nodes. If other candidate nodes have not voted in the new round of elections and the term number included in the voting request is greater than its own term number, it votes for the candidate node that sent the voting request and updates its own term number.
[0079] The candidate node that receives the most votes is used as the new leader node and the other candidate nodes are used as new follower nodes. The leader node is the master metadata server in the metadata server cluster, and the follower nodes are slave metadata servers in the metadata server cluster.
[0080] Exemplarily, deploying a master metadata server includes:
[0081] Select a server node with high performance and good stability in the cluster file system as the primary metadata server. The primary metadata server needs to be configured with sufficient memory and disk space to store and manage the metadata information of the file system. Deploy metadata management software on the primary metadata server, such as NameNode of Apache HDFS or MDS (Metadata Server) of Ceph.
[0082] The main responsibilities of the master metadata server include:
[0083] Manage the file system namespace, maintain the directory tree structure and file metadata, such as file name, file size, permissions, etc. Process client file metadata requests, such as file creation, deletion, renaming, query, etc. Manage storage node status information, such as storage capacity, heartbeat, etc., and allocate storage nodes to clients according to load balancing strategies. Record the mapping relationship between file data blocks and storage nodes for file reading, writing, and recovery.
[0084] Deployment of the secondary metadata server includes:
[0085] In order to improve the reliability and availability of metadata services, one or more slave metadata servers are deployed in the cluster file system as backups of the master metadata server. The slave metadata server has the same hardware configuration and software environment as the master metadata server.
[0086] The main responsibilities of the metadata server include:
[0087] Keep in real-time synchronization with the main metadata server and regularly obtain the latest metadata information from the main metadata server, including directory tree structure, file metadata, storage node status, etc. Automatically take over the work of the main metadata server when it fails, continue to provide metadata services to clients, and ensure service continuity. Assist the main metadata server to share the load of metadata management and improve the performance and throughput of metadata services.
[0088] Further:
[0089] Identify the server nodes in the metadata server cluster:
[0090] When building a metadata server cluster, select an odd number of server nodes, usually 3, 5, or 7 nodes. An odd number of nodes can avoid the situation where the number of votes is the same during the election process, ensuring that the election can proceed smoothly. Each server node needs to be configured with the same hardware resources and software environment to ensure the consistency and reliability of metadata services.
[0091] The same metadata service program runs on each server node, such as NameNode of Apache HDFS or MDS of Ceph. The metadata service program is responsible for managing the metadata information of the file system, such as the directory tree structure, file attributes, etc., and provides metadata access services to clients.
[0092] Configure the connection information of each server node in the metadata server cluster:
[0093] In order to enable the server nodes in the metadata server cluster to communicate and collaborate with each other, it is necessary to configure the connection information between them. The connection information includes the network address (such as IP address) and communication port number of each server node.
[0094] There are two ways to configure connection information:
[0095] Static configuration: Manually configure the network addresses and port numbers of other nodes on each server node in advance. Static configuration is suitable for situations where the number of nodes is small and the network environment is relatively stable.
[0096] Dynamic discovery: Use distributed coordination services, such as ZooKeeper or etcd, to achieve dynamic discovery and connection between server nodes. Each server node registers its own connection information with the coordination service when it starts, and obtains the connection information of other nodes from the coordination service. Dynamic discovery is suitable for situations where there are a large number of nodes and the network environment changes dynamically.
[0097] Based on the configured connection information, each server node in the metadata server cluster establishes connections with each other through the network to form a fully connected network topology.
[0098] Initialize the node roles in the metadata server cluster:
[0099] The metadata server cluster uses the Raft protocol to achieve distributed consistency and fault tolerance. The Raft protocol defines three node roles: leader, follower, and candidate. Initially, all server nodes are set to follower roles. Follower nodes passively receive heartbeat messages and log replication requests from leader nodes and participate in voting during the election process.
[0100] Implement the election mechanism for the leader node:
[0101] The Raft protocol selects a leader node from the follower nodes through an election mechanism. The leader node is responsible for coordinating and managing the entire metadata server cluster.
[0102] The election process is as follows:
[0103] When a follower node does not receive a heartbeat message from the leader node within the preset election duration, it considers the current leader node to be invalid, changes its role to a candidate node, and initiates a new round of elections. The candidate node first increases its term number (Term), which is used to identify the round of elections. Then, the candidate node sends a voting request (RequestVote) to all other nodes, requesting other nodes to vote for it.
[0104] When other nodes receive a voting request from a candidate node, if the term number contained in the request is greater than their own term number and they have not voted in the current term, they vote for the candidate node and update their own term number. The candidate node collects voting responses from other nodes, and if it receives votes from more than half of the nodes, it becomes the new leader node. The leader node sends a heartbeat message to other nodes to notify them of its election, and begins to receive and process client requests. After receiving the heartbeat message from the new leader node, the un-elected candidate node changes its role to a follower node and begins to receive log replication and heartbeat messages from the leader node.
[0105] Through the above election mechanism, the metadata server cluster can dynamically elect a leader node, namely the primary metadata server, and other nodes as follower nodes, namely slave metadata servers.
[0106] In order to ensure the consistency of metadata information of each node in the metadata server cluster, the leader node needs to synchronize the metadata update operation to all follower nodes. The synchronization process is as follows:
[0107] When the leader node receives a write request from the client, it converts the request into a log entry (LogEntry) and adds it to its own log (Log). The leader node sends a log replication request (AppendEntries) to all follower nodes, and the request contains the new log entry.
[0108] After receiving the log replication request, the follower node checks the term number and log index in the request. If they match its own term number and log index, it accepts the new log entry and appends it to its own log. After the follower node completes log replication, it sends a confirmation response (AppendEntriesResponse) to the leader node, indicating that the log replication is successful.
[0109] The leader node collects confirmation responses from follower nodes. When the number of confirmation responses reaches the majority (more than half), it considers that the log entry has been safely copied to most nodes, applies the log entry to the metadata state machine, and returns the response of the write request to the client. The follower node asynchronously applies the copied log entry to its own metadata state machine to maintain metadata consistency with the leader node.
[0110] Through the above synchronization mechanism, real-time synchronization of metadata information can be achieved between the leader node and the follower nodes, ensuring the consistency and reliability of the metadata service.
[0111] In order to improve the performance and throughput of the metadata server cluster, the following optimization measures can be taken: Batch replication optimization: The leader node can merge multiple write requests into a batch log replication request to reduce the number of network communications and latency. Pipeline replication optimization: The leader node can send log replication requests to multiple follower nodes in parallel to improve the efficiency of log replication. Snapshot optimization: The leader node can periodically snapshot the metadata state machine and send the snapshot to the follower node to reduce the amount of data replicated and the recovery time.
[0112] In an optional embodiment,
[0113] In the event that the master metadata server fails, stopping sending heartbeat messages to other slave metadata servers, the method further includes:
[0114] The primary metadata server encapsulates the client's file request into a log entry and adds the log entry to the log of the primary metadata server, wherein the log entry includes an index identifier and a current term number on the primary metadata server;
[0115] The master metadata server sends a log adding request to each slave metadata server, wherein the log adding request includes the log entry;
[0116] In response to receiving the add log request, each slave metadata server rejects the add log request when the term number in the add log request is less than the current term number of the slave metadata server, or a log entry with the same index identifier but a different current term number already exists on the slave metadata server;
[0117] Otherwise, receiving the log adding request and adding the log entry to the log of the slave metadata server, and returning a log adding response message to the master metadata server;
[0118] When the primary metadata server receives a predetermined number of response add log messages, the log entry is marked as committed so that all metadata servers apply the log entry.
[0119] Exemplarily, when the primary metadata server receives a file request from a client, it encapsulates the request into a log entry. The log entry contains the following information:
[0120] Index: used to identify the position of a log entry in the log, usually an increasing integer. Term: indicates the term of the current primary metadata server, used to distinguish log entries between different primary metadata servers. Request data: contains the specific content of the client request, such as file path, operation type (create, write, read, etc.), data content, etc.
[0121] The primary metadata server adds the generated log entries to its own log (Log), which is an ordered, persistent data structure used to record the status changes of the metadata server.
[0122] The master metadata server synchronizes the newly added log entries to all slave metadata servers to ensure metadata consistency. The specific steps are as follows:
[0123] The master metadata server sends a log add request (AppendEntries) to each slave metadata server in parallel. The log add request contains the new log entry, as well as the master metadata server's current term number and log index information.
[0124] After each slave metadata server receives a log add request from the master metadata server, it performs the following processing:
[0125] Check whether the term number (Term) in the request is smaller than its own current term number. If the term number in the request is smaller, it means that the term of the master metadata server has expired, and the slave metadata server rejects the request. Check whether the index identifier (Index) of the log entry in the request already exists in the log of the slave metadata server. If there is already a log entry with the same index but a different term number, it means that the log conflict occurs, and the slave metadata server rejects the request.
[0126] If all the above checks are passed, the slave metadata server accepts the request to add logs and appends the log entries to its own logs to keep them consistent with the logs of the master metadata server. The slave metadata server returns a response message (AppendEntriesResponse) to the master metadata server to indicate that the logs were added successfully.
[0127] Primary metadata server commit log entry:
[0128] The master metadata server collects responses to add log messages from slave metadata servers and counts the number of slave metadata servers that have successfully added logs. If the number of slave metadata servers that have successfully added logs reaches a predetermined number (usually more than half), the master metadata server believes that the log entry has been safely copied to most nodes. The master metadata server marks the log entry as committed, indicating that the entry has been persisted and taken effect. The master metadata server applies the committed log entry to its own metadata state machine and updates the status of the metadata. The master metadata server sends a notification commit message to the slave metadata server, notifying the slave metadata server to mark all log entries before the specified index as committed and apply them to the metadata state machine of the slave metadata server.
[0129] After receiving the notification submission message from the primary metadata server, the slave metadata server performs the following operations:
[0130] Mark all log entries before the specified index in the notification message as committed. Apply the committed log entries to the metadata state machine of the slave metadata server in order, and keep them consistent with the metadata state of the master metadata server. After the slave metadata server completes the log application, it sends an ApplyConfirmation message to the master metadata server, indicating that the log entry has been successfully applied.
[0131] Processing of failure of the primary metadata server:
[0132] In the event that the master metadata server fails, it is necessary to stop sending heartbeat messages to the slave metadata server to trigger a new round of leader election. The specific process is as follows:
[0133] The master metadata server stops sending heartbeat messages to the slave metadata server, indicating that the master metadata server has failed. If the slave metadata server does not receive the heartbeat message from the master metadata server within a certain period of time, it considers that the master metadata server has failed and starts a new round of leader election.
[0134] The election process refers to the previous leader election scheme, and a new primary metadata server is elected from metadata servers through the Raft protocol. The newly elected primary metadata server begins to receive client requests and restarts the log replication and synchronization process.
[0135] Through the above detailed technical solution, log replication and synchronization between the master metadata server and the slave metadata server are realized, ensuring the consistency and reliability of metadata. At the same time, through the leader election mechanism of the Raft protocol, the fault switching problem when the master metadata server fails is solved, and the high availability of the metadata service is improved.
[0136] S102. Divide the file into objects of a preset size, and store the multiple objects on multiple storage nodes in the file system based on a consistent hashing algorithm, wherein an object storage service is respectively run on each storage node, and the object storage service is used for persistent storage and access of the objects;
[0137] In an optional embodiment,
[0138] Based on the consistent hashing algorithm, multiple objects are stored on multiple storage nodes in the file system, including:
[0139] Based on a hash function, the object name of the object is mapped to an integer hash value in a hash value space of a fixed size, and the hash value space is divided into a plurality of sub-intervals corresponding to storage nodes respectively, and the object corresponding to the integer hash value in the sub-interval is stored in the storage node corresponding to the sub-interval;
[0140] The method also includes:
[0141] Collecting load indicator data of each storage node at preset time intervals, the load indicator data including any one or more of the quality of read and write requests processed by the object storage service on the storage node per unit time, the response time of the object storage service on the storage node, the CPU usage rate occupied by the object storage service process on the storage node, and the proportion of memory resources occupied by the object storage service process on the storage node;
[0142] The preset load indicator data is sent to the main metadata server, so that the main metadata server generates a global load view based on the load indicator data on each storage node and determines the load status of each storage node, and selects to migrate objects on the storage node based on the load status of each storage node.
[0143] For example,
[0144] Define a hash function: Choose an appropriate hash function, such as SHA-256 or MD5, to map the object name of the object to a fixed-size hash value. The hash function should have the characteristics of uniform distribution and low collision. Define a fixed-size hash value space, usually represented by an integer range, such as 0 to 2^32-1. The hash value space represents the set of all possible hash values.
[0145] Map the storage nodes in the file system to different locations in the hash value space. You can use the unique identifier of the storage node (such as the IP address or node ID) as input and calculate the location of the storage node in the hash value space through a hash function. Divide the hash value space into multiple sub-intervals, each of which corresponds to a storage node. You can use simple interval partitioning methods, such as average partitioning or partitioning by node weight. Each sub-interval represents the range of hash values that the storage node is responsible for storing.
[0146] When you need to store an object, perform the following steps:
[0147] Apply the hash function to the object name to calculate the hash value of the object. According to the hash value of the object, determine the subinterval to which it belongs, that is, determine the storage node responsible for storing the object. Store the object on the corresponding storage node.
[0148] Through the above steps, object storage based on consistent hashing algorithm is realized, and objects are distributed and stored on multiple storage nodes.
[0149] Determine the load indicator data that needs to be collected, which may include the following indicators:
[0150] The number of read and write requests processed by the object storage service on the storage node per unit time; the response time of the object storage service on the storage node; the CPU usage occupied by the object storage service process on the storage node; the proportion of memory resources occupied by the object storage service process on the storage node.
[0151] Determine the time interval for collecting load indicator data, such as collecting once every 5 minutes. The time interval should be adjusted according to the actual needs and performance requirements of the system. Deploy the load collection component on each storage node to regularly collect the load indicator data of the storage node. The collection component can be implemented using system monitoring tools or custom scripts. Send the collected load indicator data to the primary metadata server. You can use message queues, RPC, or other communication mechanisms to transmit data to the primary metadata server.
[0152] The main metadata server receives the load indicator data from each storage node, summarizes and processes it. The main metadata server generates a global load view based on the received load indicator data. The global load view reflects the load status of each storage node in the entire file system.
[0153] The primary metadata server analyzes the global load view and determines the load status of each storage node. You can set a load threshold. When the load index of a storage node exceeds the threshold, the node is considered to be in a high-load state. The primary metadata server selects objects to be migrated based on the load status of the storage node. Usually, some objects on high-load nodes are selected for migration to achieve load balancing. The primary metadata server determines the target storage node for the migration object based on the consistent hashing algorithm. You can select nodes with lower load as migration targets to achieve load balancing.
[0154] The primary metadata server sends migration instructions to the source storage node and the target storage node to coordinate the object migration process. The source storage node transfers the object data to the target storage node and updates the object's metadata information. After the object migration is completed, the primary metadata server updates the object's metadata information and records the object's new storage location. At the same time, it notifies the relevant storage nodes and clients to make them aware of the object migration.
[0155] Through the above detailed technical solutions, object storage based on consistent hashing algorithm is realized, and load balancing mechanism is introduced. By collecting the load index data of storage nodes, generating a global load view, judging the load status of nodes, selecting objects to be migrated, and performing object migration, load balancing between storage nodes is achieved, and the performance and scalability of the file system are improved.
[0156] In an optional embodiment,
[0157] The metadata server generates a global load view based on the load indicator data on each storage node and determines the load status of each storage node. Based on the load status of each storage node, the metadata server selects objects on the storage node for migration, including:
[0158] A warning threshold and a critical threshold are set for each load indicator data, wherein the warning threshold is smaller than the critical threshold;
[0159] In response to any load indicator data on the storage node being greater than a warning threshold and less than a critical threshold within a preset time period, lowering the critical threshold according to a preset ratio;
[0160] In response to any load indicator data on the storage node being not less than the critical threshold, the storage node is determined to be a high-load node, and a target node is selected from other storage nodes based on the global load view to receive the object on the high-load node, wherein the target node satisfies: each load indicator data of the target node is less than the critical threshold, the storage space and input / output bandwidth of the target node meet preset conditions, and the network distance between the target node and the high-load node is less than a preset threshold;
[0161] Based on the data access mode of the high-load node, determine the objects in the high-load node whose access frequency is greater than a preset threshold as objects to be migrated, and generate a migration task list based on the distribution of the objects to be migrated in the high-load node and the location of the target node;
[0162] The metadata server sends the migration task list to the high-load node, so that the high-load node sends the objects to be migrated to the target node by streaming transmission or object-based transmission. During the transmission process, the high-load node suspends the modification operation of the objects to be migrated.
[0163] After receiving the objects to be migrated, the target node synchronizes confirmation messages to the high-load node and the metadata server, so that the high-load node deletes the local data to be migrated based on the confirmation message, and the metadata server updates the global load information based on the confirmation message.
[0164] For example, in order to further improve the load balancing of the system, a dynamic load balancing strategy can be introduced. Specifically, the system monitors the load of each OSD (Object Storage Device, OSD) in real time, including indicators such as I / O throughput, response time, CPU and memory usage. When the load of an OSD exceeds the preset threshold, the system triggers a data redistribution operation to migrate part of the data from the high-load OSD to the low-load OSD to achieve load balancing.
[0165] In order to further improve the load balancing of the distributed storage system, this application proposes a dynamic data redistribution strategy based on real-time load monitoring. This strategy monitors the load status of each OSD in real time, dynamically adjusts the distribution of data between OSDs, and transfers the load from high-load nodes to low-load nodes, thereby achieving overall system load balancing. The key technologies and implementation steps of this strategy will be described in detail below.
[0166] First, in order to comprehensively evaluate the load status of the OSD node, it is necessary to select appropriate load monitoring indicators. This application selects the following key indicators:
[0167] I / O throughput: indicates the number of read and write requests processed by OSD per unit time, reflecting the I / O load of OSD. It includes two indicators: IOPS (I / O operations per second) and throughput (MB / s).
[0168] Response time: indicates the average time it takes for an OSD to process an I / O request, reflecting the OSD's service quality. Specifically, it includes two indicators: average response time and tail response time (such as 99th percentile response time).
[0169] CPU usage: Indicates the proportion of CPU resources occupied by the OSD process, reflecting the computing load of the OSD.
[0170] Memory usage: indicates the proportion of memory resources occupied by the OSD process, reflecting the memory load of the OSD. These indicators describe the load status of the OSD node from different angles, taking into account various factors such as I / O, computing, and memory.
[0171] In order to collect these load indicators, the system deploys a lightweight monitoring module on each OSD node. This module periodically collects various indicator data at fixed time intervals (such as 1 second) and sends the data to the central load manager. The load manager summarizes the load data of all OSD nodes to form a global load view, providing a basis for subsequent data redistribution decisions. At the same time, the load manager will continuously update the load data to ensure the real-time nature of the data.
[0172] After obtaining the load data of each OSD node, the system needs to determine which nodes are in a high load state and need to redistribute data. To this end, this application introduces the concept of load threshold.
[0173] For each load monitoring indicator, the system sets two thresholds: warning threshold and critical threshold. When the load indicator of an OSD node exceeds the warning threshold, the system considers that the node is in a potential high-load state; when the load indicator further exceeds the critical threshold, the system confirms that the node is a high-load node and needs to trigger data redistribution.
[0174] The setting of thresholds needs to comprehensively consider the system's performance requirements, hardware configuration and other factors. Generally speaking, the warning threshold can be set to 70%~80% of the node's maximum load capacity, and the critical threshold can be set to 90%~95% of the maximum load capacity. This can not only detect high-load nodes in a timely manner, but also avoid frequent data migration operations. In addition, the threshold can be dynamically adjusted according to the actual operation of the system. For example, if the load of an OSD node is continuously higher than the warning threshold but lower than the critical threshold, and this state lasts for a long time (such as 30 minutes), the system can appropriately lower the threshold of the node to trigger data redistribution earlier. On the contrary, if the load of an OSD node frequently exceeds the critical threshold, but the load quickly returns to normal levels after data redistribution, the system can appropriately increase the threshold of the node to reduce unnecessary data migration.
[0175] When the load manager detects that the load of an OSD node exceeds the critical threshold, the data redistribution process is triggered. The specific steps are as follows:
[0176] Target node selection: The load manager first needs to select a suitable target node from the global load view to receive data from the high-load node. Candidate target nodes should meet the following conditions: the load level is lower than the warning threshold; have sufficient storage space and I / O bandwidth; and be as close to the high-load node as possible to reduce the overhead of data migration. The load manager will comprehensively consider these factors and select one or more optimal target nodes.
[0177] Migration data selection: After determining the target node, the load manager needs to decide which data to migrate from the high-load node. Ideally, the hot data with high load should be migrated first. To do this, the system analyzes the data access pattern of the high-load node and identifies the data objects or data areas with high access frequency. At the same time, in order to avoid data inconsistency during the migration process, the system will give priority to independent data blocks that are less related to other data.
[0178] Migration task generation: The load manager generates a detailed list of migration tasks based on the distribution of migration data and the location of the target node. Each migration task contains information such as the source OSD node, the target OSD node, the starting location and size of the migration data, etc. These tasks will be sent to the corresponding OSD nodes, which will be responsible for specific data transmission and synchronization.
[0179] Data transmission and synchronization: The OSD nodes involved in data migration perform actual data transmission operations according to the migration tasks issued by the load manager. Data transmission is completed through the network connection between OSD nodes, and can be transmitted in a streaming or object-based manner. In order to ensure data consistency, during the transmission process, the source OSD node will suspend the modification of the migrated data until the target OSD node completes data synchronization. At the same time, the metadata server will update the location information of the data object to ensure that subsequent I / O requests can be correctly routed to the new location.
[0180] Migration completion confirmation: When the target OSD node completes data synchronization, it will send a confirmation message to the source OSD node. After the source OSD node receives the confirmation, it can safely delete the local migration data to free up storage space. At the same time, the source OSD node and the target OSD node will report the completion of the migration task to the load manager, and the load manager will update the global load information and data distribution status accordingly.
[0181] S103. In response to the primary metadata server receiving a file request sent by a client, the file request is implemented on a corresponding storage node based on a proxy service between the client and the storage node, wherein the file request includes any one or more of a file creation request, a file write request, and a file read request, wherein in the event that the primary metadata server fails, the primary metadata server switches to the secondary metadata server to receive the file request sent by the client.
[0182] In an optional embodiment,
[0183] In response to the primary metadata server receiving a file request sent by a client, implementing the file request on a corresponding storage node based on a proxy service between the client and the storage node, including:
[0184] In response to the primary metadata server receiving a file request sent by a client, determining metadata information of the file according to a file path in the file request, the metadata information including an object list and an object identifier of the file, and using a proxy service to calculate an object range corresponding to the file request according to the metadata information, an offset and a length of the file request, so as to convert the file request into an object request, the object request being used to access an object on a storage node;
[0185] Searching for the object to be accessed in the cache of the proxy service based on the object request, returning the object to be accessed to the client in response to the object to be accessed being hit in the cache of the proxy service, wherein the cache of the proxy service stores objects accessed by the client within a preset time period;
[0186] In response to the object to be accessed not being hit in the cache of the proxy service, a storage node is selected based on the data distribution strategy, the load indicator data of the storage node and the network topology, and the object request is sent to the storage node to return the object to be accessed based on the object request, wherein the data distribution strategy is implemented based on a consistent hashing algorithm.
[0187] For example, in order to improve the data access efficiency and user experience of the distributed storage system, a design scheme of a proxy service module is introduced between the client and the object storage device (OSD). As an intermediate layer between the client and the OSD, the proxy service effectively reduces the client's access delay and improves the overall performance of the system through key technologies such as request conversion, request routing, data caching and prefetching. The design and implementation steps of the proxy service module will be described in detail below.
[0188] The primary task of the proxy service is to convert the client's file request into an object request. In a traditional file system, the client accesses data through the file path and offset. In an object storage system, data is organized into independent objects, each with a unique object ID (OID). In order to unify the two access methods, the proxy service needs to maintain the mapping relationship between files and objects.
[0189] Specifically, after receiving the file request from the client, the proxy service first queries the file's metadata information based on the file path. The metadata records the file's attributes and the list of objects contained in the file and their OIDs. After the proxy service extracts the object list corresponding to the requested file from the metadata, it calculates the object range involved in the request based on the offset and length of the request.
[0190] For example, the client initiates a request to read the file / foo / bar.txt, with an offset of 1000 and a length of 2000. The proxy service queries the metadata and finds that the file contains three objects: obj1 (0-1023), obj2 (1024-2047), and obj3 (2048-3071). Based on the offset and length, the proxy service determines that the request involves two objects, obj2 and obj3, and that the offset of obj2 is 1000-1024=976, and the offset of obj3 is 0, and the lengths are 1024 and 976 respectively.
[0191] After the above calculation, the proxy service converts the original file request into two object requests: read bytes 976 to 2047 of obj2 and bytes 0 to 975 of obj3. In this way, the file request is mapped to an object request in the object storage system, and the data object on the OSD can be directly accessed.
[0192] After converting the request, the proxy service needs to route the request to the appropriate OSD node for execution. In large-scale distributed storage systems, data objects are usually distributed on different OSD nodes in multiple copies to provide high availability and load balancing. Therefore, the proxy service needs to select the optimal target OSD to process the request based on the data distribution strategy and OSD status.
[0193] A common data distribution strategy is a data placement algorithm based on consistent hashing. This algorithm maps object IDs and OSD nodes to the same hash space, and each object is assigned to the nearest OSD node in the hash space based on its ID hash value. This method can achieve a balanced distribution of objects among OSD nodes and minimize the cost of data migration when OSD nodes are added or reduced. The proxy service can use the consistent hashing algorithm to determine the target OSD node for each object request.
[0194] In addition to the data distribution strategy, the proxy service also needs to consider the real-time status and load of the OSD node when requesting routing. The proxy service will regularly obtain status information from the OSD node, including storage capacity, I / O load, response delay and other indicators. When routing requests, the proxy service gives priority to OSD nodes with lower load and faster response to achieve load balancing. At the same time, the proxy service can also consider the network topology and try to send the request to the OSD node closest to the client to reduce the overhead of network transmission.
[0195] By comprehensively considering factors such as data distribution, OSD status and network topology, the proxy service can reasonably route requests to the optimal OSD node, improving the efficiency and performance of data access.
[0196] To further reduce the client's access latency, the proxy service can implement a data cache mechanism internally. Since the proxy service is located between the client and the OSD, it can act as an intermediate cache layer to store recently accessed hot data. When the data requested by the client hits the proxy service's cache, the data can be returned directly from the cache, avoiding remote communication with the OSD and greatly reducing the request response time.
[0197] The proxy service cache can adopt a multi-level cache architecture, including two levels: memory cache and disk cache. The memory cache has a small capacity but a fast speed, and is used to store the most frequently accessed data. The disk cache has a large capacity but a slow speed, and is used to store secondary hot data. When the requested data does not hit in the memory cache, the proxy service will search in the disk cache; if it does not hit in the disk cache, it will obtain the data from the OSD node. The obtained data will be cached in the proxy service for subsequent requests.
[0198] The cache management strategy has an important impact on the performance of the proxy service. The proxy service can use various cache replacement algorithms, such as LRU (Least Recently Used) and LFU (Least Frequently Used), to dynamically adjust the cache content according to the access frequency and time of the data. When the cache space is insufficient, the replacement algorithm will choose to eliminate the data that has not been used for the longest time or has the lowest access frequency to ensure the effectiveness of the cache. In addition, the proxy service can also implement a cache expiration mechanism to regularly clean up expired cache data to avoid data inconsistency problems.
[0199] In an optional embodiment,
[0200] The method also includes:
[0201] When the free space in the cache of the proxy service reaches a preset threshold, the historical access records of the client are analyzed to determine the data access mode of the client, and in response to the data access mode of the client being a sequential access mode, subsequent files of the file are read sequentially into the cache of the proxy service when the client accesses the file, and in response to the data access mode of the client being a random access mode, files with a frequency higher than a threshold within a preset time period are read into the cache of the proxy service based on the frequency of the client accessing the file;
[0202] When a file is read from the cache of the proxy service, the timestamp of the file is recorded. When there is an object request, the timestamp of the corresponding object to be accessed in the cache of the proxy service is compared with the timestamp of the corresponding object to be accessed in the storage node. In response to the timestamp of the corresponding object to be accessed in the cache of the proxy service being less than the timestamp of the corresponding object to be accessed in the storage node, the object to be accessed corresponding to the object request is read from the storage node.
[0203] Exemplarily, the proxy service periodically checks the free space in its cache to determine whether it needs to pre-read data. The free space in the cache is compared with a preset threshold. The preset threshold represents the size of the free space that triggers the pre-read operation and can be set according to the actual situation of the system.
[0204] The proxy service records the client's historical access records, including the files accessed by the client, access time, access order, etc. By analyzing the client's historical access records, the client's access data mode is determined. Common access modes include sequential access mode and random access mode.
[0205] If the client's access mode is sequential access mode, that is, the client accesses files in order, then when the client accesses a file, the proxy service reads the subsequent files of the file into the cache in order, which can improve the access efficiency of subsequent files.
[0206] If the client's access mode is random access mode, that is, the client randomly accesses different files, the proxy service pre-reads files based on the frequency of the client's access to the files. Files with access frequencies higher than the threshold within a preset time period are read into the cache to improve the access efficiency of these files.
[0207] When the proxy service cache reads a file, it records the timestamp of the file. The timestamp indicates the time when the file was read into the cache. If the file already exists in the cache, its timestamp is updated to the latest read time.
[0208] When the proxy service receives an object request, it first searches the cache for the corresponding object to be accessed. If the corresponding object to be accessed exists in the cache, the timestamp of the object in the cache is compared with the timestamp of the corresponding object in the storage node. If the timestamp of the object in the cache is less than the timestamp of the corresponding object in the storage node, it means that the object in the cache has expired and the latest object data needs to be re-read from the storage node.
[0209] If the object in the cache has expired, the proxy service sends an object request to the storage node, requesting to read the latest object data. After receiving the object request, the storage node reads the requested object data from the local storage and returns it to the proxy service. After receiving the object data returned by the storage node, the proxy service updates it to the cache and updates the timestamp of the corresponding object.
[0210] Through the above detailed technical solution, the intelligent caching mechanism of the proxy service is realized. When the cache space reaches the preset threshold, the proxy service analyzes the client's historical access records, determines the client's access data pattern, and pre-reads according to the access pattern, and reads the files that may be frequently accessed into the cache in advance. At the same time, the proxy service records the timestamp of the file when reading the file from the cache, and compares the timestamp of the object in the cache with the timestamp of the object in the storage node when processing the object request, ensuring that the object in the cache is always the latest data. If the object in the cache has expired, the latest object data is re-read from the storage node and the cache is updated. This intelligent caching mechanism can improve the efficiency of data access, reduce the number of visits to the storage node, and ensure the consistency and real-time performance of the data.
[0211] Figure 2 FIG. 1 is a schematic diagram of the structure of a cluster file distributed management system according to an embodiment of the present invention. Figure 2 As shown, the system comprises:
[0212] The first unit is used to deploy a metadata server cluster, wherein the metadata server cluster includes a master metadata server and at least one slave metadata server, wherein the master metadata server is used to manage the file system namespace and maintain the directory tree structure and metadata of the files, and the slave metadata server is a backup of the master metadata server;
[0213] The second unit is used to divide the file into objects of preset sizes, and store the multiple objects on multiple storage nodes in the file system based on a consistent hashing algorithm, wherein an object storage service is respectively run on each storage node, and the object storage service is used for persistent storage and access of the objects;
[0214] The third unit is used to implement the file request on the corresponding storage node based on the proxy service between the client and the storage node in response to the main metadata server receiving the file request sent by the client, wherein the file request includes any one or more of a file creation request, a file write request, and a file read request, wherein in the event of failure of the main metadata server, the main metadata server switches to the slave metadata server to receive the file request sent by the client.
[0215] According to a third aspect of the embodiments of the present invention,
[0216] An electronic device is provided, comprising:
[0217] processor;
[0218] a memory for storing processor-executable instructions;
[0219] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0220] A fourth aspect of the embodiments of the present invention is:
[0221] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.
[0222] The present invention may be a method, an apparatus, a system and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present invention.
[0223] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A cluster file distributed management method, characterized in that: include: Deploy a metadata server cluster, the metadata server cluster includes a master metadata server and at least one slave metadata server, the master metadata server is used to manage the file system namespace and maintain the directory tree structure and file metadata, and the slave metadata server is a backup of the master metadata server; Divide the file into objects of preset sizes, and store the multiple objects on multiple storage nodes in the file system based on a consistent hashing algorithm, wherein an object storage service is run on each storage node, and the object storage service is used for persistent storage and access of the objects; In response to the primary metadata server receiving a file request sent by a client, the primary metadata server implements the file request on a corresponding storage node based on a proxy service between the client and the storage node, wherein the file request includes any one or more of a file creation request, a file write request, and a file read request, wherein in the event of failure of the primary metadata server, the primary metadata server switches to the secondary metadata server to receive the file request sent by the client; Deploy a metadata server cluster, including: Determine an odd number of server nodes in the metadata server cluster, wherein the same metadata service program runs on each server node, and determine configuration information of each server node in the metadata server cluster by static configuration or dynamic discovery, wherein the configuration information includes a network address and a port number, and connect the server nodes to each other through a network based on the configuration information; Each server node is used as a follower node. In response to each follower node not receiving a heartbeat message sent by the leader node within a preset election duration, the follower node is changed from a follower node to a candidate node and a new round of election is initiated, wherein the election is used to determine a new leader node from each candidate node; In a new round of elections, each candidate node updates its term number and sends a voting request to other candidate nodes. If other candidate nodes have not voted in the new round of elections and the term number included in the voting request is greater than its own term number, it votes for the candidate node that sent the voting request and updates its own term number. The candidate node that receives the most votes is used as the new leader node and the other candidate nodes are used as new follower nodes, wherein the leader node is the master metadata server in the metadata server cluster and the follower nodes are the slave metadata servers in the metadata server cluster; In the event that the master metadata server fails, stopping sending heartbeat messages to other slave metadata servers, the method further includes: The primary metadata server encapsulates the client's file request into a log entry and adds the log entry to the log of the primary metadata server, wherein the log entry includes an index identifier and a current term number on the primary metadata server; The master metadata server sends a log adding request to each slave metadata server, wherein the log adding request includes the log entry; In response to receiving the add log request, each slave metadata server rejects the add log request when the term number in the add log request is less than the current term number of the slave metadata server, or a log entry with the same index identifier but a different current term number already exists on the slave metadata server; Otherwise, receiving the log adding request and adding the log entry to the log of the slave metadata server, and returning a log adding response message to the master metadata server; When the primary metadata server receives a predetermined number of response add log messages, the log entry is marked as committed so that all metadata servers apply the log entry.
2. The method according to claim 1, characterized in that Based on the consistent hashing algorithm, multiple objects are stored on multiple storage nodes in the file system, including: Based on a hash function, the object name of the object is mapped to an integer hash value in a hash value space of a fixed size, and the hash value space is divided into a plurality of sub-intervals corresponding to storage nodes respectively, and the object corresponding to the integer hash value in the sub-interval is stored in the storage node corresponding to the sub-interval; The method also includes: Collecting load indicator data of each storage node at preset time intervals, the load indicator data including any one or more of the quality of read and write requests processed by the object storage service on the storage node per unit time, the response time of the object storage service on the storage node, the CPU usage rate occupied by the object storage service process on the storage node, and the proportion of memory resources occupied by the object storage service process on the storage node; The preset load indicator data is sent to the main metadata server, so that the main metadata server generates a global load view based on the load indicator data on each storage node and determines the load status of each storage node, and selects to migrate objects on the storage node based on the load status of each storage node.
3. The method according to claim 2, characterized in that The metadata server generates a global load view based on the load indicator data on each storage node and determines the load status of each storage node. Based on the load status of each storage node, the metadata server selects objects on the storage node for migration, including: A warning threshold and a critical threshold are set for each load indicator data, wherein the warning threshold is smaller than the critical threshold; In response to any load indicator data on the storage node being greater than a warning threshold and less than a critical threshold within a preset time period, lowering the critical threshold according to a preset ratio; In response to any load indicator data on the storage node being not less than the critical threshold, the storage node is determined to be a high-load node, and a target node is selected from other storage nodes based on the global load view to receive the object on the high-load node, wherein the target node satisfies: each load indicator data of the target node is less than the critical threshold, the storage space and input / output bandwidth of the target node meet preset conditions, and the network distance between the target node and the high-load node is less than a preset threshold; Based on the data access mode of the high-load node, determine the objects in the high-load node whose access frequency is greater than a preset threshold as objects to be migrated, and generate a migration task list based on the distribution of the objects to be migrated in the high-load node and the location of the target node; The metadata server sends the migration task list to the high-load node, so that the high-load node sends the objects to be migrated to the target node by streaming transmission or object-based transmission. During the transmission process, the high-load node suspends the modification operation of the objects to be migrated. After receiving the objects to be migrated, the target node synchronizes confirmation messages to the high-load node and the metadata server, so that the high-load node deletes the local data to be migrated based on the confirmation message, and the metadata server updates the global load information based on the confirmation message.
4. The method according to claim 1, characterized in that: In response to the primary metadata server receiving a file request sent by a client, implementing the file request on a corresponding storage node based on a proxy service between the client and the storage node, including: In response to the primary metadata server receiving a file request sent by a client, determining metadata information of the file according to a file path in the file request, the metadata information including an object list and an object identifier of the file, and using a proxy service to calculate an object range corresponding to the file request according to the metadata information, an offset and a length of the file request, so as to convert the file request into an object request, the object request being used to access an object on a storage node; Searching for the object to be accessed in the cache of the proxy service based on the object request, returning the object to be accessed to the client in response to the object to be accessed being hit in the cache of the proxy service, wherein the cache of the proxy service stores objects accessed by the client within a preset time period; In response to the object to be accessed not being hit in the cache of the proxy service, a storage node is selected based on the data distribution strategy, the load indicator data of the storage node and the network topology, and the object request is sent to the storage node to return the object to be accessed based on the object request, wherein the data distribution strategy is implemented based on a consistent hashing algorithm.
5. The method according to claim 4, characterized in that The method also includes: When the free space in the cache of the proxy service reaches a preset threshold, the historical access records of the client are analyzed to determine the data access mode of the client, and in response to the data access mode of the client being a sequential access mode, subsequent files of the file are read sequentially into the cache of the proxy service when the client accesses the file, and in response to the data access mode of the client being a random access mode, files with a frequency higher than a threshold within a preset time period are read into the cache of the proxy service based on the frequency of the client accessing the file; When a file is read from the cache of the proxy service, the timestamp of the file is recorded. When there is an object request, the timestamp of the corresponding object to be accessed in the cache of the proxy service is compared with the timestamp of the corresponding object to be accessed in the storage node. In response to the timestamp of the corresponding object to be accessed in the cache of the proxy service being less than the timestamp of the corresponding object to be accessed in the storage node, the object to be accessed corresponding to the object request is read from the storage node.
6. A cluster file distributed management system, used to implement the method according to any one of claims 1 to 5, characterized in that: include: The first unit is used to deploy a metadata server cluster, wherein the metadata server cluster includes a master metadata server and at least one slave metadata server, wherein the master metadata server is used to manage the file system namespace and maintain the directory tree structure and metadata of the files, and the slave metadata server is a backup of the master metadata server; The second unit is used to divide the file into objects of preset sizes, and store the multiple objects on multiple storage nodes in the file system based on a consistent hashing algorithm, wherein an object storage service is respectively run on each storage node, and the object storage service is used for persistent storage and access of the objects; The third unit is used to implement the file request on the corresponding storage node based on the proxy service between the client and the storage node in response to the main metadata server receiving the file request sent by the client, wherein the file request includes any one or more of a file creation request, a file write request, and a file read request, wherein in the event of failure of the main metadata server, the main metadata server switches to the slave metadata server to receive the file request sent by the client.
7. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method described in any one of claims 1 to 5.
8. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 5 is implemented.
