Data sharing method and device, equipment, storage medium and program product
By obtaining and processing metadata read requests in the main cluster server of the distributed file storage system, the problem of poor flexibility in traditional data sharing technology is solved and efficient and flexible data sharing is achieved.
Patent Information
- Application Number
- CN202411420972.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-01-24
AI Technical Summary
There is a problem of poor flexibility in traditional data sharing technology, which is difficult to meet the efficient and flexible data sharing needs in large-scale distributed file storage systems.
By obtaining metadata reading requests in the client in the first server of the main set cluster, using metadata indexing to quickly obtain metadata, and send it to the client. The client determines the target data according to metadata. , To achieve efficient data sharing.
It improves the flexibility and efficiency of data sharing, avoids the problem that the client needs to send metadata read requests to the main cluster and the slave cluster respectively, and simplifies the data acquisition process.
Smart Images

Figure CN119363766A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data sharing, and in particular to a data sharing method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] With the development of the Internet, the data level generated in user systems is PB, EB or even higher, which requires a large-scale distributed file storage system to store massive data and provide high-availability, low-latency, and high-scalability storage services. In actual applications, distributed file systems will store files according to user needs. For example, according to the frequency of data access, data stored in a high-cost regional storage system (primary cluster) will be migrated to a low-cost regional storage system (slave cluster).
[0003] For data migrated to the slave cluster, the shared directory in the slave cluster is usually mounted in the master cluster through a file sharing protocol to achieve data sharing between the master and slave clusters.
[0004] However, traditional technologies suffer from poor flexibility in data sharing. Summary of the invention
[0005] Based on this, it is necessary to provide a data sharing method, apparatus, computer device, computer-readable storage medium and computer program product that can improve the flexibility of data sharing in response to the above technical problems.
[0006] In a first aspect, the present application provides a data sharing method for a first server in a main cluster. The method comprises:
[0007] Obtaining a metadata read request corresponding to the client, wherein the metadata read request includes a first metadata index;
[0008] According to the first metadata index, obtaining, from the first server, first metadata corresponding to the first metadata index;
[0009] The first metadata is sent to the client, where the first metadata is used by the client to obtain target data from the first server or from a second server in the cluster according to the first metadata.
[0010] In one embodiment, the method further comprises:
[0011] receiving a first data read request sent by the client, where the first data read request is sent by the client after determining a target cluster storing the target data according to the first metadata;
[0012] According to the first data read request, the target data is acquired, and the target data is returned to the client.
[0013] In one embodiment, the first data read request includes an identifier of a target data segment, and acquiring the target data according to the first data read request includes:
[0014] If the target cluster is the main cluster, the target data is obtained from the first server according to the identifier of the target data segment.
[0015] In one embodiment, acquiring the target data according to the first data read request further includes:
[0016] If the target cluster is the slave cluster, generating a second data read request according to the identifier of the target data segment and the first metadata index, and sending the second data read request to the second server;
[0017] The target data sent by the second server in response to the second data read request is received.
[0018] In one embodiment, the method further comprises:
[0019] receiving a data migration request, wherein the data migration request includes a second metadata index corresponding to the data to be migrated;
[0020] According to the second metadata index, obtaining, from the first server, second metadata corresponding to the second metadata index, and obtaining a plurality of segment data corresponding to the second metadata;
[0021] During the process of migrating each of the segment data to the second server, a flag bit corresponding to the segment data that has been migrated to the second server in each of the segment data is updated from a first value to a second value, and the flag bit is used by the client to determine a target cluster for storing the target data.
[0022] In one embodiment, the method further comprises:
[0023] generating a segment migration request corresponding to each segment data, and sending each segment migration request to the second server, wherein the segment migration request includes the segment data, a data segment identifier of the segment data, and a third metadata index, where the third metadata index is obtained from the second metadata;
[0024] A response message sent by the second server in response to each of the segment migration requests is received, and segment data among each of the segment data that has been migrated to the second server is determined according to the response message.
[0025] In one embodiment, the method further comprises:
[0026] Receive a file creation request sent by the client, create a first target file in the first server according to the file creation request, and save a first parent directory metadata index corresponding to the first target file;
[0027] Determine, according to the first parent directory metadata index, a second parent directory metadata index in the second server corresponding to the first parent directory metadata index;
[0028] A first data synchronization request is sent to the second server according to the second parent directory metadata index, wherein the first data synchronization request is used to instruct the second server to create a second target file according to the second parent directory metadata index, and both the first target file and the second target file correspond to the first metadata.
[0029] In one embodiment, the method further comprises:
[0030] receiving an update request for the first metadata sent by the second server, and updating the first metadata according to the update request;
[0031] Determining, according to the first updated metadata index corresponding to the updated first metadata, a second updated metadata index corresponding to the updated first metadata in the second server;
[0032] A second data synchronization request is sent to the second server according to the second updated metadata index, where the second data synchronization request is used to instruct the second server to update second metadata according to the second updated metadata index, where the second metadata is the same as the first metadata.
[0033] In one embodiment, obtaining a metadata reading request corresponding to a client includes:
[0034] The metadata reading request sent by the management server in the main cluster is received, where the management server transfers the metadata reading request in the third server to the first server when detecting that a third server in the main cluster has a fault.
[0035] In a second aspect, the present application further provides a data sharing method for a second server in a cluster. The method comprises:
[0036] Receiving a second data read request sent by a first server or a client in the main cluster, wherein the second data read request includes a first metadata index;
[0037] According to the first metadata index, acquiring target data corresponding to the second data read request from the second server;
[0038] The second data read request is responded to based on the target data.
[0039] In one embodiment, the second data read request further includes an identifier of a target data segment, and acquiring the target data corresponding to the second data read request from the second server according to the first metadata index includes:
[0040] Determine, according to the first metadata index, first metadata corresponding to the first metadata index;
[0041] determining a target storage location according to the first metadata and the identifier of the target data segment;
[0042] The target data is read from the target storage location.
[0043] In one embodiment, the method further comprises:
[0044] receiving a plurality of segment migration requests sent by the first server, the segment migration requests including segment data, each of the segment migration requests being generated by the first server in response to a data migration request;
[0045] Writing each of the segments of data into the second server;
[0046] A response message is sent to the first server, so that the first server determines the segment data among the segment data that have been migrated to the second server according to the response message.
[0047] In one embodiment, the segment migration request further includes a data segment identifier corresponding to the segment data and a second metadata index, and writing each segment data to the second server includes:
[0048] According to the data segment identifier, writing the segment data into the target data segment corresponding to the data segment identifier;
[0049] According to the second metadata index, obtaining second metadata corresponding to the second metadata index;
[0050] The flag bit corresponding to each of the target data segments in the second metadata is updated from the first value to the second value.
[0051] In one embodiment, the method further comprises:
[0052] Receive a first data synchronization request sent by the first server, wherein the first data synchronization request includes a second parent directory metadata index corresponding to the first parent directory metadata index, wherein the first parent directory metadata index is a parent directory metadata index corresponding to a first target file created by the first server;
[0053] A second target file is created according to the second parent directory metadata index, and both the first target file and the second target file correspond to the first metadata.
[0054] In one embodiment, the method further comprises:
[0055] Sending an update request for the first metadata to the first server;
[0056] receiving a second data synchronization request sent by the first server, wherein the second data synchronization request includes a second updated metadata index corresponding to the first updated metadata index, wherein the first updated metadata index corresponds to the updated first metadata in the first server, and the updated first metadata is obtained after the first server updates the first metadata in response to the update request;
[0057] The second metadata is updated according to the second updated metadata index, where the second metadata is the same as the first metadata.
[0058] In a third aspect, the present application also provides a data sharing method for a client. The method comprises:
[0059] Sending a metadata read request to a first server in the main cluster, wherein the metadata read request includes a first metadata index;
[0060] receiving first metadata corresponding to the first metadata index sent by the first server in response to the metadata read request;
[0061] According to the first metadata, target data is obtained from the first server or from a second server in the cluster.
[0062] In one embodiment, the metadata read request further includes an identifier of a target data segment, and obtaining the target data from the first server or from a second server in the cluster according to the first metadata includes:
[0063] Generate a first data read request according to the first metadata and the identifier of the target data segment;
[0064] Sending the first data read request to the first server, where the first data read request is used to instruct the first server to obtain the target data from the first server or to send the first data read request to the second server;
[0065] The target data sent by the first server or the second server is received.
[0066] In one embodiment, generating a first data read request according to the first metadata and the identifier of the target data segment includes:
[0067] According to the identifier of the target data segment, acquiring a storage location corresponding to the flag bit of the target data segment from the first metadata;
[0068] Acquire the flag bit from a storage space corresponding to the storage location;
[0069] Determine a target cluster for storing the target data according to the flag bit;
[0070] The first data read request is generated according to the identifiers of the target cluster and the target data segment.
[0071] In one of the embodiments, if the target cluster is the primary cluster, the first data read request is used to instruct the first server to obtain the target data from the first server;
[0072] If the target cluster is the slave cluster, the first data read request is used to instruct the first server to generate a second data read request according to the first data read request, and send the second data read request to the second server to obtain the target data from the second server.
[0073] In a fourth aspect, the present application also provides a data sharing device. The device comprises:
[0074] A first receiving module, configured to receive a data reading request sent by a client, wherein the reading request includes a metadata index corresponding to the data to be read;
[0075] A first acquisition module, configured to read metadata according to the metadata index;
[0076] The second acquisition module is used to acquire the data to be read according to the metadata.
[0077] In a fifth aspect, the present application also provides a data sharing device. The device comprises:
[0078] A seventh receiving module, configured to receive a data reading request sent by a first server or a client in the main cluster, wherein the data reading request includes a first metadata index;
[0079] a fifth acquisition module, configured to acquire, from the second server, target data corresponding to the data read request according to the first metadata index;
[0080] A response module is used to respond to the data read request based on the target data.
[0081] In a sixth aspect, the present application also provides a data sharing device. The device comprises:
[0082] A sixth sending module, configured to send a metadata read request to a first server in the main cluster, wherein the metadata read request includes a first metadata index;
[0083] an eleventh receiving module, configured to receive first metadata corresponding to the first metadata index sent by the first server in response to the metadata read request;
[0084] A sixth acquisition module is used to acquire target data from the first server or from a second server in the cluster according to the first metadata.
[0085] In a seventh aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method described in the first aspect, the second aspect and the third aspect are implemented.
[0086] In an eighth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method described in the first aspect, the second aspect, and the third aspect are implemented.
[0087] In a ninth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the method described in the first aspect, the second aspect and the third aspect are implemented.
[0088] In the above-mentioned data sharing method, apparatus, computer device, computer-readable storage medium and computer program product, the first server first obtains a metadata reading request corresponding to the client, the metadata reading request includes a first metadata index, then obtains the first metadata corresponding to the first metadata index from the first server according to the first metadata index, and then sends the first metadata to the client. Since in the data sharing method, after receiving the metadata reading request, the first server can quickly determine the first metadata according to the first metadata index and send it to the client, and the target data corresponding to the first metadata is stored in the main cluster or in the slave cluster, the client can quickly and accurately determine that the target data is stored in the first server in the main cluster or the second server in the slave cluster according to the first metadata, avoiding the problem that the client needs to send metadata reading requests to both the first server and the second server respectively to obtain the target data, thereby improving the efficiency and convenience of the client obtaining the target data using the data sharing method, and further improving the flexibility of data sharing. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0090] FIG1 is an application environment diagram of a data sharing method in one embodiment;
[0091] FIG2 is a schematic diagram of a flow chart of a data sharing method in one embodiment;
[0092] FIG3 is a schematic diagram of a flow chart of a data sharing method in another embodiment;
[0093] FIG4 is a schematic diagram of a flow chart of step 302 in another embodiment;
[0094] FIG5 is a schematic flow chart of a data sharing method in another embodiment;
[0095] FIG6 is a schematic flow chart of a data sharing method in another embodiment;
[0096] FIG7 is a schematic flow chart of a data sharing method in another embodiment;
[0097] FIG8 is a schematic flow chart of a data sharing method in another embodiment;
[0098] FIG9 is a schematic flow chart of a data sharing method in another embodiment;
[0099] FIG10 is a flow chart of step 902 in another embodiment;
[0100] FIG11 is a schematic flow chart of a data sharing method in another embodiment;
[0101] FIG12 is a schematic diagram of a flow chart of step 1102 in another embodiment;
[0102] FIG13 is a schematic flow chart of a data sharing method in another embodiment;
[0103] FIG14 is a schematic flow chart of a data sharing method in another embodiment;
[0104] FIG15 is a schematic flow chart of a data sharing method in another embodiment;
[0105] FIG16 is a flow chart of step 1503 in another embodiment;
[0106] FIG17 is a schematic diagram of a flow chart of step 1601 in another embodiment;
[0107] FIG18 is a schematic flow chart of a data sharing method in another embodiment;
[0108] FIG19 is a schematic diagram of a flow chart of a file creation method in another embodiment;
[0109] FIG20 is a schematic flow chart of a metadata synchronization update method in another embodiment;
[0110] FIG21 is a schematic diagram of a flow chart of a metadata migration method in another embodiment;
[0111] FIG22 is a structural block diagram of a data sharing device in one embodiment;
[0112] FIG23 is a structural block diagram of a data sharing device in another embodiment;
[0113] FIG24 is a structural block diagram of a data sharing device in another embodiment;
[0114] FIG. 25 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0115] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0116] In the scenario where the master cluster and the slave cluster share data, the master cluster and the slave cluster can be implemented through the file sharing protocol (Network File System, NFS) for distributed file systems. When the client accesses data, the master cluster can access the file directory of the slave cluster through NFS, thereby accessing the shared resources in the slave cluster. In the scenario where data in the master cluster is migrated to the slave cluster, the data migration module in the master cluster reads the file data to be migrated by accessing the distributed file system, and then the data migration module sends the file data to the slave cluster. After receiving the data, the slave cluster writes the data to the local distributed file system. However, the server that provides NFS services for the master cluster and the slave cluster is a separately deployed server. If the server fails, the NFS service cannot be provided, resulting in the inability to share and migrate data between the master cluster and the slave cluster. Therefore, the NFS service needs to be combined with other methods to solve the single point of failure, and the read and write performance of NFS is limited under high concurrency. Therefore, there is a problem of poor flexibility in data sharing in traditional technologies.
[0117] In view of this, the data sharing method provided by the present application, the first server obtains a metadata reading request corresponding to the client, the metadata reading request includes a first metadata index, then, according to the first metadata index, obtains the first metadata corresponding to the first metadata index from the first server, and then sends the first metadata to the client. Since in the data sharing method, after receiving the metadata reading request, the first server can quickly determine the first metadata according to the first metadata index and send it to the client, and the target data corresponding to the first metadata is stored in the main cluster or in the slave cluster, so that the client can quickly and accurately determine that the target data is stored in the first server in the main cluster or the second server in the slave cluster according to the first metadata, avoiding the problem that the client needs to send metadata reading requests to both the first server and the second server respectively to obtain the target data, thereby improving the efficiency and convenience of the client in obtaining the target data using the data sharing method, thereby improving the flexibility of data sharing.
[0118] The data sharing method provided in the embodiment of the present application can be applied to the implementation environment shown in FIG. 1, wherein the first server 102 communicates with the second server 104 through a network, the first server 102 also communicates with the client 106 through a network, and the second server 104 also communicates with the client 106 through a network. The first data storage system can store data that the first server 102 needs to process, and the second data storage system can store data that the second server 104 needs to process. The first data storage system can be integrated on the first server 102, or placed on a cloud or other network server, and the second data storage system can be integrated on the second server 104, or placed on a cloud or other network server. The first server 102 can obtain a metadata read request corresponding to the client 106, and the metadata read request includes a first metadata index, and then, according to the first metadata index, obtains the first metadata corresponding to the first metadata index from the first server, and then sends the first metadata to the client, and the first metadata is used by the client to obtain the target data from the first server or from the second server in the cluster according to the first metadata. The first server 102 can be implemented with an independent server or a server cluster consisting of multiple servers. The second server 104 can be implemented by an independent server or a server cluster composed of multiple servers, and the client 106 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, etc. The portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc.
[0119] In an exemplary embodiment, as shown in FIG. 2 , a data sharing method is provided, which is described by taking the method applied to the first server in FIG. 1 as an example, and includes the following steps 201 to 203:
[0120] Step 201: Obtain a metadata read request corresponding to a client, where the metadata read request includes a first metadata index.
[0121] It should be noted that in the embodiment of the present application, the master cluster can be a storage system with a higher cost, and the slave cluster can be a storage system with a lower cost. Both the master cluster and the slave cluster are distributed systems. Both the master cluster and the slave cluster include multiple servers, wherein the servers may include communication servers, management servers, storage servers, etc. The master cluster and the slave cluster can communicate through the communication servers in their respective clusters, and store data in the storage server. In the embodiment of the present application, metadata synchronization can be achieved between the master cluster and the slave cluster, and the data corresponding to the metadata can be stored only in the master cluster or only in the slave cluster.
[0122] In the data sharing method provided in the present application, both the master cluster and the slave cluster realize data sharing through a distributed system. Since the distributed system includes multiple nodes, if a node fails, data sharing can be realized through other nodes. Therefore, compared with realizing data sharing through NFS service, the data sharing method provided in the present application does not have the problem of single point failure.
[0123] It can be understood that the data in a distributed system can be divided into two parts: data and metadata. Data refers to the content of a file, and metadata is data that describes data information. In a distributed system, file data is segmented and stored on different disks of different storage nodes in the distributed system. Each segmented data unit is called a data segment, and each data segment corresponds to a fixed size. The file layout in the metadata is used to describe the specific location of the file segment in the storage system, storage node, and storage disk. Therefore, when the distributed system reads and writes the data of a file, it first reads the metadata, then determines the segment corresponding to the data according to the index in the metadata, and then reads the data in the segment, or writes data to the segment. In this embodiment, before the master cluster and the slave cluster share data, the metadata can be synchronized through the master-slave cluster so that both the master and slave clusters can locally access the metadata of the same file, and the layout corresponding to the metadata shared by the master and slave clusters points to the same segment, thereby realizing data sharing and data migration.
[0124] Among them, the client refers to a network application, software or hardware device that provides local services to users outside the main cluster and the slave cluster. The client can send requests to the server and receive responses from the server. For example, the client can send a data read request to the server, or the client can also send a metadata read request to the server. It should be noted that the client can send a metadata read request to the main cluster, or it can also send a metadata read request to the slave cluster. The embodiment of the present application takes the example of the client sending a metadata read request to the first server in the main cluster to describe the process of data sharing.
[0125] First, the master cluster and the slave cluster can establish a cluster binding relationship through the first server in the master cluster and the second server in the slave cluster. Optionally, the master cluster can be bound to one slave cluster, or the master cluster can be bound to multiple slave clusters. Furthermore, the master cluster and the slave cluster that have established the cluster binding relationship can also establish a shared directory binding relationship. The shared directory binding relationship is one-to-one, and multiple shared directory binding relationships can be established between the master cluster and the slave cluster.
[0126] When the client reads data from the main cluster, it can first read metadata from the main cluster, and then read data according to the metadata. Therefore, the client can send a metadata read request to the first server, wherein the metadata read request is used to instruct the first server to read the metadata and return it to the client. The metadata read request can include a first metadata index, and the first server can quickly determine the location of the metadata storage from the storage space of the main cluster through the first metadata index.
[0127] In this embodiment, the first server may receive a metadata reading request sent by the client through a network, and then parse the first metadata reading request to obtain a first metadata index.
[0128] Step 202: According to the first metadata index, first metadata corresponding to the first metadata index is obtained from the first server.
[0129] The first metadata refers to the metadata corresponding to the first metadata index, and the first metadata may include information such as the storage location of the data, historical data, and file records.
[0130] In this embodiment, the first server may determine a storage location for storing the first metadata in the storage space of the main cluster according to the first metadata index, and then obtain the first metadata.
[0131] Step 203: Send the first metadata to the client, where the first metadata is used by the client to obtain target data from the first server or from the second server in the cluster according to the first metadata.
[0132] It is understandable that in the data sharing method provided in the embodiment of the present application, on the basis of realizing metadata synchronization between the master cluster and the slave cluster, a copy of the data corresponding to the metadata can be saved in the storage space of the master cluster or the storage space of the slave cluster, so the client can first obtain the metadata, and then determine whether the stored data is the master cluster or the slave cluster according to the metadata, and further obtain the data from the master cluster or the slave cluster. Among them, the target data refers to the data corresponding to the first metadata.
[0133] In this embodiment, after acquiring the first metadata, the first server can send the first metadata to the client through the network, so that after receiving the first metadata, the client can determine the cluster storing the target data based on the first metadata, thereby acquiring the target data from the main cluster or the slave cluster.
[0134] In the above data sharing method, the first server first obtains a metadata read request corresponding to the client, the metadata read request includes a first metadata index, then obtains the first metadata corresponding to the first metadata index from the first server according to the first metadata index, and then sends the first metadata to the client. Since in the data sharing method, after receiving the metadata read request, the first server can quickly determine the first metadata according to the first metadata index and send it to the client, and the target data corresponding to the first metadata is stored in the main cluster or in the slave cluster, the client can quickly and accurately determine that the target data is stored in the first server in the main cluster or the second server in the slave cluster according to the first metadata, avoiding the problem that the client needs to send metadata read requests to both the first server and the second server respectively to obtain the target data, thereby improving the efficiency and convenience of the client obtaining the target data using the data sharing method, thereby improving the flexibility of data sharing.
[0135] In addition, the client can determine, based on the first metadata, whether the server storing the target data is the first server or the second server in the slave cluster, thereby obtaining the target data from the first server or the second server, thereby avoiding the need for the client to send metadata read requests to the first server and the second server respectively, resulting in waste of resources and a long period for obtaining the target data, and improving the efficiency of the client in reading the target data from the main cluster and the slave cluster.
[0136] In one embodiment, based on the embodiment shown in Figure 2, referring to Figure 3, this embodiment relates to a process of how the first server returns target data to the client. As shown in Figure 3, the first server can perform steps 301 and 302 to implement the process.
[0137] Step 301 : receiving a first data read request sent by a client, where the first data read request is sent by the client after determining a target cluster storing target data according to first metadata.
[0138] The first data read request refers to a request by the client to obtain target data from the first server. It is understandable that after receiving the first metadata, the client can determine whether the target data is stored in the master cluster or the slave cluster based on the first metadata, and determine it as the target cluster, and then generate a data read request based on the target cluster and send the data read request to the first server.
[0139] In this embodiment, the first server may receive the first data reading request sent by the client through the network.
[0140] Step 302: Acquire target data according to the first data read request, and return the target data to the client.
[0141] In this embodiment, the first server may parse the received first data read request, determine a target storage location for storing the target data according to the parsing result, then find the target data from the target storage location, and return the target data to the client through the network.
[0142] It is understandable that when the target cluster is different, the process of the first server acquiring the target data is also different. The following describes the process of the first server acquiring the target data when the target cluster is a master cluster or when the target cluster is a slave cluster.
[0143] In a possible implementation, the first data read request includes an identifier of a target data segment, and the above step 302 may include: if the target cluster is a primary cluster, obtaining the target data from the first server according to the identifier of the target data segment.
[0144] The target data segment refers to a data segment for storing target data, namely the above-mentioned segment. The identifier of the target data segment refers to a unique identifier corresponding to the target data segment. Optionally, the identifier may be in the form of an array, a symbol, etc. For example, the identifier of the target data segment may be 100.
[0145] In this embodiment, after the first server parses the first data read request, if the parsing result indicates that the target cluster is the main cluster, that is, the cluster where the first server is located, the first server can search for the data segment corresponding to the identifier of the target data segment from the local storage space, and then obtain the target data from the data segment.
[0146] In this implementation, since the target data is stored in the main cluster, the first server can quickly obtain the target data from the main cluster in a local access manner, thereby improving the efficiency of obtaining the target data.
[0147] In another possible implementation, as shown in FIG4 :
[0148] Step 401: If the target cluster is a slave cluster, a second data read request is generated according to the identifier of the target data segment and the first metadata index, and the second data read request is sent to the second server.
[0149] Among them, the first metadata index refers to the information included in the metadata read request. It can be understood that if the target cluster is a slave cluster, the first server needs to obtain the target data from the slave cluster. Therefore, the first server can send the metadata index corresponding to the target data in the second server to the second server, so that the second server can determine the data segment storing the target data according to the metadata index, and thus obtain the target data according to the data segment; further, since metadata synchronization is achieved in the main cluster and the slave cluster, the first server can obtain the corresponding metadata index in the second server from the first metadata information, thereby sending the corresponding metadata index in the second server to the second server.
[0150] In this embodiment, after the first server parses the first data read request, if the parsing result indicates that the target cluster is a slave cluster, that is, the cluster where the second server is located, the first server can obtain the first metadata based on the first metadata index, and then obtain the corresponding metadata index in the second server from the information of the first metadata, and then generate a second data read request based on the identifier of the target data segment and the corresponding metadata index in the second server, and then send the second data read request to the second server.
[0151] Step 402: Receive target data sent by the second server in response to a second data read request.
[0152] It can be understood that after receiving the second data read request, the second server can obtain metadata based on the metadata index in the second data read request, and then determine the storage location of the target data based on the metadata information, and then, based on the identifier of the target data segment, find the corresponding target data segment in the storage location and obtain data from the target data segment.
[0153] In this embodiment, when the second server responds to the second data reading request, the second server can obtain the target data, and thus the first server can receive the target data sent by the second server.
[0154] In this embodiment, the first server can obtain target data according to the first data read request and return the target data to the client by receiving the first data read request sent by the client. Since the first data read request is sent by the client after determining the target cluster storing the target data according to the first metadata, the first server can determine whether the target cluster is a master cluster or a slave cluster according to the first data read request, and thus can quickly obtain the target data from the first server of the master cluster or the second server of the slave cluster, thereby improving the efficiency and accuracy of obtaining the target data.
[0155] In one embodiment, based on the above embodiment, referring to Figure 5, this embodiment relates to a process of how a first server migrates data to a second server. As shown in Figure 5, the first server can perform steps 501 to 503 to implement the process.
[0156] Step 501: Receive a data migration request, where the data migration request includes a second metadata index corresponding to the data to be migrated.
[0157] Among them, the data migration request is used to instruct the first server to migrate the data in the main cluster to the slave cluster. It should be noted that in an embodiment of the present application, a distributed system with a relatively high storage cost can be used as a main cluster to store hot data with high frequency of access, and a distributed system with a relatively low storage cost can be used as a slave cluster to store cold data with low frequency of access. Therefore, after the hot data is converted into cold data, the data that has become cold data needs to be migrated from the first server to the second server. Among them, the second metadata index refers to the index information of the metadata corresponding to the data to be migrated.
[0158] In this embodiment, the first server may receive a data migration request sent by the client through a network, and parse the data migration request to obtain a second source data index corresponding to the data to be migrated from the parsing result.
[0159] Step 502: According to the second metadata index, obtain second metadata corresponding to the second metadata index from the first server, and obtain multiple segment data corresponding to the second metadata.
[0160] The segment data refers to dividing the second metadata into multiple data segments according to a fixed size, and determining all the divided data segments as multiple segment data corresponding to the second metadata.
[0161] In this embodiment, the first server can determine the storage location of the second metadata based on the second metadata index, then obtain the second metadata from the storage location, determine the multiple segment data corresponding to the second metadata based on the second metadata, and thus obtain the multiple segment data corresponding to the second metadata.
[0162] Step 503, during the process of migrating each segment of data to the second server, the flag corresponding to the segment of data that has been migrated to the second server is updated from the first value to the second value, and the flag is used by the client to determine the target cluster for storing the target data.
[0163] The flag is used to indicate whether the segment data is stored in the first server or the second server. It is understandable that after the first server migrates the data to the second server, it is necessary to modify the content of the metadata in the first server, that is, modify the flag corresponding to the segment data stored in the metadata, so that the modified flag indicates that the migrated segment data is stored in the second server.
[0164] In this embodiment, the first server can obtain metadata corresponding to the segment data that has been migrated to the second server in real time during the process of migrating each segment data to the second server, and modify the flag bit stored in the metadata to update the flag bit from the first value to the second value. For example, if the first value is 1 and the second value is 0, the flag bit can be modified from 1 to 0.
[0165] Exemplarily, if the flag of the segment data to be migrated to the second server is seg-idx0.is remote=0, then after migrating the segment data to the second server, the first server can modify the flag to seg-idx0.isremote=1, indicating that the segment data is stored in the second server.
[0166] In this embodiment, the first server receives a data migration request, which includes a second metadata index corresponding to the data to be migrated; based on the second metadata index, the second metadata corresponding to the second metadata index is obtained from the first server, and multiple segment data corresponding to the second metadata are obtained; in the process of migrating each segment data to the second server, the flag corresponding to the segment data that has been migrated to the second server in each segment data is updated from the first value to the second value, and the flag is used by the client to determine the target cluster for storing the target data.
[0167] In one embodiment, based on the above embodiment, referring to Figure 6, this embodiment relates to a process of how a first server sends a segment migration request to a second server to perform segment data migration. As shown in Figure 6, the first server can perform steps 601 and 602 to implement the process.
[0168] Step 601, generate a segment migration request corresponding to each segment data, and send each segment migration request to the second server, the segment migration request includes the segment data, the data segment identifier of the segment data and the third metadata index, the third metadata index is obtained from the second metadata.
[0169] The segment migration request is an instruction generated by the first server according to the segment data to be migrated, and is used to instruct the second server to receive the data to be migrated in response to the segment migration request. The segment data refers to the data to be stored in the second server, the data segment identifier refers to the unique identifier corresponding to each segment data, and the third metadata index refers to the index information of the metadata corresponding to the second metadata in the second server. It can be understood that in the first server and the second server, the metadata index corresponding to the same metadata can store the corresponding metadata index in the opposite end.
[0170] In this embodiment, the first server can generate a segment migration request according to each segment data, the data segment identifier of the segment data and the third metadata index, thereby obtaining multiple segment migration requests, and send the multiple segment migration requests to the second server in sequence.
[0171] Step 602: Receive a response message sent by the second server in response to each segment migration request, and determine, according to the response message, the segment data among each segment data that has been migrated to the second server.
[0172] The response message refers to the response message generated by the second server after responding to the segment migration request and storing the segment data. It is understandable that the second server can carry the data segment identifier of the segment data that has completed data migration in the response message, so that the first server can determine the segment data that has completed data migration and the segment data that has not completed data migration.
[0173] In this embodiment, after sending a segment migration request, the first server can receive a response message sent by the second server for each segment migration request, parse the response message, and then, the first server can determine the segment data in the second server that has completed data migration based on the analysis result.
[0174] In this embodiment, the first server generates a segment migration request corresponding to each segment data, and sends each segment migration request to the second server. Since the segment migration request includes the segment data, the data segment identifier of the segment data, and the third metadata index, the second server can accurately store each segment data in the storage location corresponding to the third metadata index according to the segment migration request. Then, the second server can receive a response message sent by the second server for each segment migration request, and determine the segment data in each segment data that has been migrated to the second server based on the response message, thereby ensuring the accuracy and reliability of the segment data migration.
[0175] In one embodiment, based on the above embodiment, referring to Figure 7, this embodiment relates to a process of how the first server and the second server synchronously create a file. As shown in Figure 7, the first server can perform steps 701-703 to implement the process.
[0176] Step 701: Receive a file creation request sent by a client, create a first target file in a first server according to the file creation request, and save a first parent directory metadata index corresponding to the first target file.
[0177] The file creation request is an instruction for creating a new file in the first server. In this embodiment, the new file to be created is determined as the first target file. It should be noted that when creating a new file, the first server can create the new file in any parent directory, or create the new file in the parent directory specified in the file creation request. In this embodiment, the parent directory corresponding to the first target file in the first server is determined as the first parent directory, and the source data index of the first parent directory is determined as the first parent directory metadata index.
[0178] In this embodiment, the first server can receive a file creation request sent by the client through the network, and parse the file creation request. Then, based on the parsing result, it creates the first target file under the selected first parent directory, and then obtains and saves the first parent directory source data index corresponding to the metadata of the first parent directory.
[0179] Exemplarily, the file creation request may carry information such as a first target file creation instruction, a parent directory corresponding to the first target file, a name of the first target file, and a memory size occupied by data corresponding to the first target file.
[0180] Step 702: Determine, based on the first parent directory metadata index, a second parent directory metadata index in the second server that corresponds to the first parent directory metadata index.
[0181] It should be noted that there are multiple levels of directories in the file management systems of the first server and the second server. To ensure metadata synchronization, when creating the first target file, it is necessary to ensure that the parent directory of the first target file in the first server and the second server is also the same.
[0182] The second parent directory metadata index refers to the metadata index of the directory in the second server that corresponds to the first parent directory. In this embodiment, the first server can determine the first parent directory metadata based on the first parent directory metadata index, and then obtain the metadata index information of the corresponding parent directory in the second server from the first parent directory metadata, and then determine the second parent directory metadata index.
[0183] Step 703: Send a first data synchronization request to the second server according to the second parent directory metadata index. The first data synchronization request is used to instruct the second server to create a second target file according to the second parent directory metadata index. Both the first target file and the second target file correspond to the first metadata.
[0184] The first data synchronization request is an instruction to instruct the second server to create a file corresponding to the first target file in the corresponding parent directory, that is, to create a second target file. It can be understood that both the first target file and the second target file correspond to the first metadata, and by creating the first target file in the first parent directory and the second target file in the corresponding second parent directory, the first target file and the second target file correspond to the same metadata, thereby achieving metadata synchronization.
[0185] In this embodiment, the first server can generate a first data synchronization request based on the second parent directory metadata index, the first parent directory metadata index, the operation type of the first target file, and the operation data, and then send the first data synchronization request to the second server, so that the second server creates a second target file corresponding to the first target file under the second parent directory according to the second parent directory metadata index.
[0186] In this embodiment, the first server first receives a file creation request sent by the client, and creates a first target file in the first server according to the file creation request, and saves the first parent directory metadata index corresponding to the first target file. Then, based on the first parent directory metadata index, the second parent directory metadata index corresponding to the first parent directory metadata index in the second server is determined, and then, based on the second parent directory metadata index, a first data synchronization request is sent to the second server. Since the first data synchronization request is used to instruct the second server to create a second target file according to the second parent directory metadata index, the second server can create a second target file including the first metadata in the second server, so that files corresponding to the first metadata exist in both the first server and the second server, thereby realizing metadata synchronization.
[0187] In one embodiment, based on the above embodiment, referring to Fig. 8, this embodiment involves a process of the first server. As shown in Fig. 8, the first server can execute steps 801 to 803 to implement the process.
[0188] Step 801: receiving an update request for first metadata sent by a second server, and updating the first metadata according to the update request.
[0189] The update request refers to an instruction to update the first metadata. It is understandable that when a user accesses the second server through a client, if an operation is performed on a file, the metadata corresponding to the file will be modified. In order to maintain real-time synchronization of the metadata in the first server and the second server, the second server can send an update request to the first server so that the first server can modify the metadata.
[0190] In this embodiment, the first server can receive the update request sent by the second server and parse the update request. Then, based on the parsing result, the first metadata index corresponding to the first metadata that needs to be updated and the new metadata are determined. Then, the first metadata is searched and obtained based on the first metadata index, and the content of the original first metadata is updated to the new metadata, thereby updating the first metadata.
[0191] Step 802: Determine a second updated metadata index corresponding to the updated first metadata in the second server according to the first updated metadata index corresponding to the updated first metadata.
[0192] The first updated metadata index refers to the index of the first metadata after the first metadata is updated, and the second updated metadata index refers to the corresponding metadata index in the second server stored in the first metadata.
[0193] In this embodiment, the first server may determine the corresponding metadata according to the first updated metadata index, and then obtain the corresponding second updated metadata index in the second server from the metadata.
[0194] Step 803: Send a second data synchronization request to the second server according to the second updated metadata index, where the second data synchronization request is used to instruct the second server to update second metadata according to the second updated metadata index, where the second metadata is the same as the first metadata.
[0195] The second data synchronization request is an instruction to instruct the second server to update the second metadata in the corresponding second updated metadata index, wherein the second metadata is metadata stored in the second server and is the same metadata as the first metadata in the first server.
[0196] In this embodiment, the first server can generate a second data synchronization request based on the second updated metadata index, the operation type and operation data for updating the first metadata, and then send the second data synchronization request to the second server so that the second server updates the second metadata corresponding to the second updated metadata index.
[0197] In this embodiment, the first server first receives an update request for the first metadata sent by the second server, updates the first metadata according to the update request, and then determines the second updated metadata index corresponding to the updated first metadata in the second server according to the first updated metadata index, and then sends a second data synchronization request to the second server according to the second updated metadata index. Since the second data synchronization request is used to instruct the second server to update the second metadata according to the second updated metadata index, the second metadata and the first metadata are the same metadata, so that the second server can accurately update the second metadata according to the second data synchronization request, thereby achieving synchronization between the updated first metadata and the updated second metadata, thereby improving the accuracy of metadata synchronization.
[0198] In one embodiment, based on the embodiment shown in Figure 2, this embodiment involves a process of how the first server obtains a metadata reading request corresponding to the client. The server implements the process through the following steps.
[0199] A metadata read request is received from a management server in the main cluster, where the management server transfers the metadata read request from the third server to the first server when detecting that a third server in the main cluster has a fault.
[0200] It should be noted that in the data sharing method provided in the embodiment of the present application, both the master cluster and the slave cluster are distributed systems, the master cluster includes multiple servers, and the slave cluster includes multiple servers. Taking the master cluster as an example, the server may include multiple application servers and management servers, and the management server may monitor the running status of each application server, so that when a certain application server fails, the metadata reading request received by the application server is transferred to other non-faulty application servers to avoid single point failure and improve the reliability of data sharing.
[0201] The third server refers to an application server with a fault in the main cluster, and the management server refers to a server that detects the operating status of each server in the main cluster and manages requests received by each server.
[0202] In this embodiment, when the management server monitors that the third server has a fault, the first server may receive a metadata reading request from the third server sent by the management server, thereby responding to the received metadata reading request.
[0203] In this embodiment, the first server receives a metadata read request sent by the management server in the main cluster. Since the metadata read request is transferred from the third server to the first server when the management server detects that there is a fault in the third server in the main cluster, the problem of the metadata read request being unable to be responded to due to a fault in the third server can be avoided, thereby improving the reliability of the request being responded to, and further improving the reliability of data sharing.
[0204] In one embodiment, based on the above embodiment, referring to FIG. 9 , this embodiment provides a data sharing method, which can be used for the second server shown in FIG. 1 , including steps 901 to 903 shown in FIG. 9 :
[0205] Step 901: receiving a second data read request sent by a first server or a client in a main cluster, where the second data read request includes a first metadata index.
[0206] The second data read request refers to the request generated by the client after determining the cluster corresponding to the data to be acquired, and the first metadata can be queried according to the first metadata index, so as to determine the corresponding metadata index storing the first metadata in the second server from the first metadata. It should be noted that if the data is stored in the second server of the cluster, after the client generates the second data read request, the client can send the second data read request to the first server so that the first server sends the second data read request to the second server, or the client can also send the second data read request to the second server.
[0207] In this embodiment, the second server may receive the second data read request sent by the client or the first server through the network, and may obtain the first metadata index included in the second data read request by responding to the second data read request.
[0208] Step 902: Obtain target data corresponding to a second data read request from a second server according to the first metadata index.
[0209] The target data refers to the data that the client is going to obtain.
[0210] In this embodiment, the second server can determine the storage location of the metadata storing the target data based on the first metadata index, and then obtain the first metadata stored in the second server, and then determine the storage location of the target data based on the first metadata, and then obtain the target data.
[0211] Step 903: respond to a second data read request based on the target data.
[0212] In this embodiment, after acquiring the target data, the second server may respond to the second data read request and send the target data to the client, or send the target data to the first server so that the first server sends the target data to the client.
[0213] In this embodiment, the second server receives a second data read request sent by the first server or the client in the main cluster. The second data read request includes a first metadata index. The second server can obtain target data corresponding to the second data read request from the second server according to the first metadata index, thereby being able to respond to the second data read request based on the target data. Since metadata synchronization is achieved between the first server and the second server, the second server can accurately and quickly obtain the target data according to the first metadata index, thereby improving the efficiency of responding to the second data read request.
[0214] In one embodiment, the second data read request also includes an identifier of the target data segment. Based on the embodiment shown in FIG. 9 above, referring to FIG. 10, this embodiment involves a process of how the second server obtains the target data corresponding to the second data read request from the second server according to the first metadata index. As shown in FIG. 10, step 902 may include steps 1001 to 1003 shown in FIG. 10 to implement the process.
[0215] Step 1001: Determine first metadata corresponding to the first metadata index according to the first metadata index.
[0216] The first metadata refers to the metadata corresponding to the first metadata index.
[0217] In this embodiment, after obtaining the first metadata according to the data reading request, the second server can find the first metadata from the storage space of the second server according to the first metadata index, thereby obtaining the first metadata from the storage space.
[0218] Step 1002: determine a target storage location according to the first metadata and an identifier of the target data segment.
[0219] The identifier of the target data segment refers to a unique identifier of the data segment where the target data is located, and the target storage location refers to a storage location used to store the target data.
[0220] In this embodiment, the second server can obtain multiple storage locations for storing each data segment from the first metadata, and then determine the target data segment from each data segment based on the identifier of the target data segment, and then determine the target storage location from the multiple storage locations.
[0221] Step 1003, read target data from the target storage location.
[0222] In this embodiment, the second server may send a data acquisition instruction to the target storage location to read the target data from the target storage location.
[0223] In this embodiment, the second server first determines the first metadata corresponding to the first metadata index based on the first metadata index, then determines the target storage location based on the first metadata and the identifier of the target data segment, and then reads the target data from the target storage location, so that the target data can be quickly and accurately obtained according to the first metadata index.
[0224] In one embodiment, based on the above embodiment, referring to Figure 11, this embodiment relates to a process of how the second server responds to a segment migration request. As shown in Figure 11, the second server can execute steps 1101 to 1103 to implement the process.
[0225] Step 1101: Receive multiple segment migration requests sent by a first server, where the segment migration requests include segment data, and each segment migration request is generated by the first server in response to a data migration request.
[0226] It should be noted that, after receiving the data migration request, the first server may generate multiple segment migration requests according to each data segment corresponding to the data to be migrated.
[0227] In this embodiment, the second server may receive multiple segment migration requests sent by the first server through the network, and then obtain the segment data in each segment request according to each segment migration request.
[0228] Step 1102, write each segment of data into the second server.
[0229] In this embodiment, the second server may write each segment data into a storage location corresponding to the second server.
[0230] Step 1103: Send a response message to the first server, so that the first server determines the segment data among the segments of data that have been migrated to the second server according to the response message.
[0231] The response message may carry a data segment identifier of the segment data for which data migration has been completed, so that the first server can determine the segment data for which data migration has been completed and the segment data for which data migration has not been completed.
[0232] In this embodiment, after the second server writes the segment data into the second server, in order for the first server to determine whether the segment data is written successfully, a response message may be sent to the first server.
[0233] In this embodiment, the second server receives multiple segment migration requests sent by the first server, and the segment migration requests include segment data, so that each segment data can be written to the second server, and a response message is sent to the first server, so that the first server can determine the segment data in each segment data that has been migrated to the second server based on the response message, thereby avoiding the problem of data migration failure caused by a certain segment data not being migrated to the second server, thereby improving the reliability of data migration.
[0234] In one embodiment, the segment migration request also includes a data segment identifier and a second metadata index corresponding to the segment data, referring to Figure 12. This embodiment relates to a process in which the second server writes each segment data into the second server. As shown in Figure 12, step 1102 may include steps 1201-1203 shown in Figure 12 to implement the process.
[0235] Step 1201, according to the data segment identifier, write the segment data into the target data segment corresponding to the data segment identifier.
[0236] The data segment identifier refers to a unique identifier of each data segment, and the target data segment refers to a data segment for storing segment data migrated to the second server. In this embodiment, the second server can determine the storage location corresponding to each data segment according to the data segment identifier, and write the segment data corresponding to the data segment identifier into the corresponding storage location, that is, write the segment data into the target data segment corresponding to the data segment identifier.
[0237] Step 1202: Acquire second metadata corresponding to the second metadata index according to the second metadata index.
[0238] The second metadata index is an index corresponding to all segment data migrated to the second server. In this embodiment, the second server can determine the storage location for storing the second metadata according to the second metadata index, and thus obtain the second metadata from the storage location.
[0239] Step 1203: Update the flag bit corresponding to each target data segment in the second metadata from the first value to the second value.
[0240] The flag bit is used to indicate whether the data is stored in the first server or in the second server. For example, a first value may indicate that the data is stored in the first server, and a second value may indicate that the data is stored in the second server.
[0241] In this embodiment, after the second server writes the segment data into the target data segment, the segment data is migrated from the first server to the second server. Therefore, it is necessary to modify the flag bit of the segment data, and update the first value representing the data stored in the first server to the second value representing the data stored in the second server to indicate that the segment data is stored in the second server.
[0242] In this embodiment, the second server writes the segment data into the target data segment corresponding to the data segment identifier based on the data segment identifier, then obtains the second metadata corresponding to the second metadata index based on the second metadata index, and then updates the flag corresponding to each target data segment in the second metadata from the first value to the second value. The flag of the segment data that has been migrated to the second server can be modified in time, thereby avoiding the problem of being unable to obtain data due to failure to modify the flag in time, and further improving the reliability of data sharing.
[0243] In one embodiment, based on the above embodiment, referring to Figure 13, this embodiment relates to a process of how the second server creates a file synchronously with the first server. As shown in Figure 13, the second server can perform steps 1301 and 1302 to implement the process.
[0244] Step 1301, receiving a first data synchronization request sent by a first server, wherein the first data synchronization request includes a second parent directory metadata index corresponding to a first parent directory metadata index, and the first parent directory metadata index is a parent directory metadata index corresponding to a first target file created by the first server.
[0245] It should be noted that after the first server creates the first target file under the first parent directory, it can obtain the corresponding second parent directory metadata index in the second server from the first parent directory metadata, thereby generating a first data synchronization request including the second parent directory metadata index, so that the second server can create a file corresponding to the first target file under the second parent directory according to the second parent directory metadata index.
[0246] In this embodiment, the second server may receive the first data synchronization request through the network, and then obtain the second parent directory metadata index by parsing the first data synchronization request.
[0247] Step 1302: Create a second target file according to the metadata index of the second parent directory, and both the first target file and the second target file correspond to the first metadata.
[0248] The second target file refers to a file in the second server corresponding to the first target file. In this embodiment, the second server can determine the second parent directory metadata according to the second parent directory metadata index, then determine the second parent directory, and create the second target file in the second parent directory.
[0249] In this embodiment, the second server receives the first data synchronization request sent by the first server, and the first data synchronization request includes a second parent directory metadata index corresponding to the first parent directory metadata index. Then, the second server can create a second target file based on the second parent directory metadata index. Since the first parent directory metadata index is the parent directory metadata index corresponding to the first target file created by the first server, the second server can determine the second parent directory corresponding to the first server based on the second parent directory metadata index, and thus create a second target file under the second parent directory, so that files corresponding to the first metadata exist in both the first server and the second server, thereby realizing metadata synchronization.
[0250] In one embodiment, based on the above embodiment, referring to Figure 14, this embodiment relates to a process of how the second server implements metadata synchronization update with the first server. As shown in Figure 14, the second server can perform steps 1401 to 1403 to implement the process.
[0251] Step 1401: Send an update request for first metadata to a first server.
[0252] It should be noted that, when the data of the file in the shared directory of the second server is updated, the corresponding metadata in the first server and the second server need to be updated. The first metadata refers to the metadata corresponding to the updated data.
[0253] In this embodiment, when the data of the file in the second server is updated, the second server may generate an update request according to the first metadata corresponding to the data, and send the update request to the first server.
[0254] Step 1402, receiving a second data synchronization request sent by the first server, the second data synchronization request including a second updated metadata index corresponding to the first updated metadata index, the first updated metadata index corresponding to the updated first metadata in the first server, the updated first metadata being obtained after the first server updates the first metadata in response to the update request.
[0255] The second data synchronization request is sent from the first server to the second server so that the second server performs a synchronous metadata update operation. It can be understood that the second data synchronization request is sent to the second server after the update process is completed in the first server.
[0256] In this embodiment, the second server can receive the second data synchronization request sent by the first server through the network, and parse the second data synchronization request to obtain the second updated metadata index included in the second data synchronization request from the parsing result, so as to determine the metadata that needs to be updated according to the second updated metadata index.
[0257] Step 1403: update the second metadata according to the second updated metadata index, where the second metadata is the same as the first metadata.
[0258] As an optional implementation, the second data synchronization request may also include data to be updated and an operation type.
[0259] The second metadata is metadata stored in the second server before the data is updated.
[0260] In this embodiment, the second server can determine the storage location for storing the second updated metadata according to the second updated metadata index, and update the data to be updated to the storage location according to the operation type to update the second metadata originally stored in the storage location.
[0261] In this embodiment, the second server sends an update request for the first metadata to the first server, and then can receive a second data synchronization request sent by the first server, where the second data synchronization request includes a second updated metadata index corresponding to the first updated metadata index, where the first updated metadata index corresponds to the updated first metadata in the first server, and the updated first metadata is obtained after the first server updates the first metadata in response to the update request, so that the second server can quickly and accurately update the second metadata according to the second updated metadata index, so that the updated second metadata is synchronized with the updated first metadata, thereby improving the reliability of data sharing.
[0262] In an exemplary embodiment, as shown in FIG. 15 , a data sharing method is provided, which is described by taking the method applied to the client in FIG. 1 as an example, and includes the following steps 1501 to 1503:
[0263] Step 1501: Send a metadata read request to a first server in a main cluster, where the metadata read request includes a first metadata index.
[0264] It should be noted that when data needs to be obtained from the main cluster or the slave cluster, the user can send a data read request to the first server in the main cluster through the client. In the embodiment of the present application, only one copy of the data is stored in the main cluster and the slave cluster, and both store the same metadata. Therefore, the client can first obtain the metadata from the main cluster, and then further obtain data based on the metadata.
[0265] The metadata read request is used to obtain metadata, and the first metadata index refers to the index of the corresponding metadata to be obtained.
[0266] In this embodiment, the client may generate a metadata read request according to the first metadata index, and then send the metadata read request to the first server in the main cluster through the network.
[0267] Step 1502: Receive first metadata corresponding to a first metadata index sent by a first server in response to a metadata read request.
[0268] It is understandable that after receiving the metadata read request, the first server can determine the storage location of the first metadata according to the first metadata index, then obtain the first metadata from the storage location, and return the first metadata to the client in response to the metadata read request.
[0269] In this embodiment, the client may receive the first metadata sent by the first server through the network.
[0270] Step 1503: Obtain target data from the first server or from the second server in the cluster according to the first metadata.
[0271] The target data refers to the data to be acquired. It should be noted that the first metadata may store relevant information of the target data, such as the storage location of the target data, the memory size occupied by the target data, the data structure and other information. The target data may be stored in the master cluster, or the target data may be stored in the slave cluster. The flag bit may be used to indicate the cluster where the target data is stored. For example, if the flag bit is the first value, it may indicate that the target data is stored in the master cluster, and if the flag bit is the second value, it may indicate that the target data is stored in the slave cluster.
[0272] In this embodiment, the client can obtain the flag information corresponding to the target data from the first metadata, and then determine whether the target data is stored in the main cluster or in the slave cluster according to the value of the flag. If the target data is stored in the main cluster, the target data is obtained from the first server; if the target data is stored in the slave cluster, the target data is obtained from the second server.
[0273] In this embodiment, the client sends a metadata read request to the first server in the main cluster, and the metadata read request includes a first metadata index, so that the first server can obtain the first metadata according to the first metadata index. Then, the first metadata corresponding to the first metadata index sent by the first server in response to the metadata read request is received, and then, according to the first metadata, the target data is obtained from the first server or the second server in the cluster. Since metadata synchronization is achieved in the main cluster and the slave cluster, it can be quickly and accurately determined whether the target data is stored in the main cluster or the slave cluster according to the first metadata, so that the target data can be quickly and accurately obtained from the first server or the second server.
[0274] In one embodiment, the metadata read request also includes an identifier of the target data segment, see Figure 16, this embodiment involves a process. As shown in Figure 16, step 1503 may include steps 1601-1603 shown in Figure 16 to implement the process.
[0275] Step 1601: Generate a first data read request according to first metadata and an identifier of a target data segment.
[0276] It should be noted that when storing data, the data can be divided into multiple segments according to a fixed size, and each segment corresponds to a unique identification code, i.e., an identification. In this embodiment, the data segment storing the target data is determined as the target data segment, and the unique identification code of the target data segment is determined as the identification of the target data segment. Among them, the first data read request refers to an instruction to obtain the target data, which is used to instruct the first server or the second server to obtain the target data and return it to the client.
[0277] In this embodiment, the client may carry the first metadata and the identifier of the target data segment in the data read request, thereby generating a first data read request for instructing the first server or the second server to obtain the target data and return it to the client.
[0278] Step 1602: Send a first data read request to the first server, where the first data read request is used to instruct the first server to obtain target data from the first server or to send the first data read request to the second server.
[0279] It can be understood that if the target data is stored in the first server, the target data can be obtained from the first server; if the target data is stored in the second server, the target data can be obtained from the second server. Therefore, the operation of the first server after receiving the first data read request may be to obtain the target data from itself, or it may be to send the first data read request to the second server so that the second server obtains the target data from itself.
[0280] As a possible implementation manner, if the target cluster is the main cluster, the first data read request is used to instruct the first server to obtain the target data from the first server.
[0281] As another possible implementation, if the target cluster is a slave cluster, the first data read request is used to instruct the first server to send the first data read request to the second server to obtain the target data from the second server.
[0282] Step 1603: Receive target data sent by the first server or the second server.
[0283] In this embodiment, the client may receive the target data sent by the first server through the network, or the client may also receive the target data sent by the second server through the network.
[0284] In this embodiment, the client generates a first data read request based on the first metadata and the identifier of the target data segment, and then sends the first data read request to the first server. Thereafter, the target data sent by the first server or the second server can be received. Since the first data read request can be used to instruct the first server to obtain the target data from the first server or to send the first data read request to the second server, the reliability of obtaining the target data can be guaranteed.
[0285] In one embodiment, referring to Fig. 17, this embodiment relates to a process of a client determining a target cluster. As shown in Fig. 17, step 1601 may include steps 1701 to 1704 shown in Fig. 17 to implement the process.
[0286] Step 1701: According to the identifier of the target data segment, obtain the storage location corresponding to the flag bit of the target data segment from the first metadata.
[0287] It should be noted that, in the first metadata, the storage position corresponding to the flag bit of each data segment corresponding to the data can be stored through the layout.
[0288] In this embodiment, after obtaining the first metadata, the client can determine the index corresponding to the target data segment from the indexes of multiple data segments stored in the first metadata based on the identifier of the target data segment corresponding to the target data, and then determine the storage location corresponding to the flag bit of the target data segment based on the index of the target data segment.
[0289] Step 1702, obtaining a flag bit from the storage space corresponding to the storage location.
[0290] In this embodiment, the client may obtain a flag bit corresponding to the target data segment from the storage space corresponding to the storage location.
[0291] Step 1703: determine the target cluster for storing the target data according to the flag bit.
[0292] The target cluster refers to the cluster storing the target data. The target cluster may be a master cluster, or a slave cluster. The target cluster may be represented by different values of the flag bit. For example, if the flag bit is the first value, it may represent that the target cluster is the master cluster, and if the flag bit is the second value, it may represent that the target cluster is the slave cluster.
[0293] In this embodiment, after obtaining the flag bit, the client may determine the target cluster storing the target data according to the value of the flag bit.
[0294] Step 1704: Generate a first data read request according to the identifiers of the target cluster and the target data segment.
[0295] In this embodiment, the client can carry the identifiers of the target cluster and the target data segment in the data read request, thereby generating a first data read request, so that the first server can obtain the target data from itself according to the first data read request, or send the first data read request to the second server, so that the second server obtains the target data from itself.
[0296] In this embodiment, the client can obtain the storage location corresponding to the flag bit of the target data segment from the first metadata based on the identifier of the target data segment, and then obtain the flag bit from the storage space corresponding to the storage location. Then, the target cluster for storing the target data can be determined based on the flag bit, and then, a first data read request is generated based on the identifier of the target cluster and the target data segment. Since the identifiers of the target cluster and the target data segment in the first data read request are determined based on the first metadata, and the metadata between the first server and the second server are synchronized, the first server and the second server can both obtain the target data based on the first data read request, and different data read requests cannot be sent to the first server and the second server respectively, thereby improving the efficiency of obtaining the target data.
[0297] In one embodiment, as shown in FIG18 , a data sharing method is provided, and the method is described by taking the data sharing method used for a client, a first server in a master cluster, and a second server in a slave cluster as an example. The method includes:
[0298] Step 1801: The client sends a metadata read request to the first server in the main cluster.
[0299] Step 1802: The first server obtains a metadata read request corresponding to the client, where the metadata read request includes a first metadata index.
[0300] Step 1803: The first server obtains first metadata corresponding to the first metadata index from the first server according to the first metadata index.
[0301] Step 1804: The first server sends the first metadata to the client.
[0302] Step 1805: The client receives first metadata corresponding to the first metadata index sent by the first server.
[0303] Step 1806: The client determines a target cluster for storing target data according to the first metadata.
[0304] Step 1807: The client obtains the storage location corresponding to the flag bit of the target data segment from the first metadata according to the identifier of the target data segment.
[0305] Step 1808: The client obtains the flag bit from the storage space corresponding to the storage location.
[0306] Step 1809: The client determines the target cluster for storing the target data according to the flag bit.
[0307] Step 1810: The client generates a first data read request according to the identifiers of the target cluster and the target data segment.
[0308] Step 1811 , the client determines whether the target cluster is the primary cluster.
[0309] Step 1812: If the target cluster is the primary cluster, the client sends a first data read request to the first server, where the first data read request includes an identifier of the target data segment.
[0310] Step 1813: The first server receives the first data read request, obtains the target data according to the identifier of the target data segment, and sends the target data to the client.
[0311] Step 1814: If the target cluster is a slave cluster, the client sends a first data read request to the first server.
[0312] Step 1815: The first server generates a second data read request according to the first data read request, and sends the second data read request to the second server, where the second data read request includes the first metadata index.
[0313] Step 1816: The second server receives the second data read request, and determines the first metadata corresponding to the first metadata index according to the first metadata index.
[0314] Step 1817: The second server determines the target storage location according to the first metadata and the identifier of the target data segment.
[0315] Step 1818: The second server reads the target data from the target storage location and sends the target data to the client.
[0316] In one embodiment, as shown in FIG. 19 , a file creation method is provided, and the method is described by taking the file creation method used for a client, a first server in a master cluster, and a second server in a slave cluster as an example. The method includes:
[0317] Step 1901: The first server receives a file creation request sent by a client.
[0318] Step 1902: The first server creates a first target file in the first server according to the file creation request, and saves a first parent directory metadata index corresponding to the first target file.
[0319] Step 1903: The first server determines, based on the first parent directory metadata index, a second parent directory metadata index in the second server that corresponds to the first parent directory metadata index.
[0320] Step 1904: The first server sends a first data synchronization request to the second server according to the second parent directory metadata index.
[0321] Step 1905: The second server receives the first data synchronization request sent by the first server.
[0322] Step 1906: The second server creates a second target file according to the second parent directory metadata index.
[0323] In one embodiment, as shown in FIG20 , a metadata synchronization update method is provided, and the method is described by taking the metadata synchronization update method used for a first server in a master cluster and a second server in a slave cluster as an example. The method includes:
[0324] Step 2001: The second server sends an update request for first metadata to the first server.
[0325] Step 2002: The first server receives an update request for first metadata sent by the second server.
[0326] Step 2003: The first server updates the first metadata according to the update request.
[0327] Step 2004: The first server determines a second updated metadata index corresponding to the updated first metadata in the second server according to the first updated metadata index corresponding to the updated first metadata.
[0328] Step 2005: The first server sends a second data synchronization request to the second server according to the second updated metadata index.
[0329] Step 2006: The second server receives a second data synchronization request sent by the first server.
[0330] Step 2007: The second server updates the second metadata according to the second updated metadata index.
[0331] In one embodiment, as shown in FIG21 , a data migration method is provided, and the method is described by taking the data migration method used for a first server in a master cluster and a second server in a slave cluster as an example. The method includes:
[0332] Step 2101: The first server receives a data migration request.
[0333] Step 2102: The first server obtains second metadata corresponding to the second metadata index from the first server according to the second metadata index, and obtains multiple segment data corresponding to the second metadata.
[0334] Step 2103: The first server generates a segment migration request corresponding to each segment data, and sends each segment migration request to the second server. The segment migration request also includes a data segment identifier corresponding to the segment data and a second metadata index.
[0335] Step 2104: The second server writes the segment data into the target data segment corresponding to the data segment identifier according to the data segment identifier.
[0336] Step 2105: The second server obtains second metadata corresponding to the second metadata index according to the second metadata index.
[0337] Step 2106: The second server updates the flag bit corresponding to each target data segment in the second metadata from the first value to the second value.
[0338] Step 2107: The first server receives a response message sent by the second server in response to each segment migration request, and determines, based on the response message, the segment data among each segment data that has been migrated to the second server.
[0339] Step 2108: The first service updates the flag corresponding to the segment data that has been migrated to the second server from the first value to the second value.
[0340] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0341] Based on the same inventive concept, the embodiment of the present application also provides a data sharing device for implementing the data sharing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more data sharing device embodiments provided below can refer to the limitations on the data sharing method above, and will not be repeated here.
[0342] In an exemplary embodiment, as shown in FIG22 , a data sharing device is provided, which is used for a first server in a main cluster, and includes:
[0343] The first receiving module 2201 is used to receive a data reading request sent by a client, where the reading request includes a metadata index corresponding to the data to be read.
[0344] The first acquisition module 2202 is used to read metadata according to the metadata index.
[0345] The second acquisition module 2203 is used to acquire the data to be read according to the metadata.
[0346] In one embodiment, the above device further comprises:
[0347] The second receiving module is configured to receive a first data reading request sent by a client, where the first data reading request is sent by the client after determining a target cluster storing target data according to the first metadata.
[0348] The third acquisition module is used to acquire target data according to the first data reading request and return the target data to the client.
[0349] In one embodiment, the third acquisition module includes:
[0350] The first acquisition unit is configured to acquire target data from the first server according to an identifier of the target data segment if the target cluster is the main cluster.
[0351] In one embodiment, the third acquisition module includes:
[0352] The first sending unit is configured to generate a second data read request according to an identifier of the target data segment and the first metadata index if the target cluster is a slave cluster, and send the second data read request to the second server.
[0353] The second acquiring unit is configured to receive target data sent by the second server in response to the second data reading request.
[0354] In one embodiment, the above device further comprises:
[0355] The third receiving module is used to receive a data migration request, where the data migration request includes a second metadata index corresponding to the data to be migrated.
[0356] The fourth acquisition module is used to acquire, according to the second metadata index, the second metadata corresponding to the second metadata index from the first server, and acquire a plurality of segment data corresponding to the second metadata.
[0357] The update module is used to update the flag corresponding to the segment data migrated to the second server from the first value to the second value during the process of migrating each segment data to the second server. The flag is used by the client to determine the target cluster for storing the target data.
[0358] In one embodiment, the above device further comprises:
[0359] The first sending module is used to generate a segment migration request corresponding to each segment data, and send each segment migration request to the second server, the segment migration request includes the segment data, the data segment identifier of the segment data and the third metadata index, and the third metadata index is obtained from the second metadata.
[0360] The fourth receiving module is used to receive a response message sent by the second server in response to each segment migration request, and determine the segment data in each segment data that has been migrated to the second server according to the response message.
[0361] In one embodiment, the above device further comprises:
[0362] The fifth receiving module is used to receive a file creation request sent by the client, create a first target file in the first server according to the file creation request, and save a first parent directory metadata index corresponding to the first target file.
[0363] The first determining module is used to determine, according to the first parent directory metadata index, a second parent directory metadata index in the second server corresponding to the first parent directory metadata index.
[0364] The second sending module is used to send a first data synchronization request to the second server according to the second parent directory metadata index. The first data synchronization request is used to instruct the second server to create a second target file according to the second parent directory metadata index. The first target file and the second target file both contain corresponding first metadata.
[0365] In one embodiment, the above device further comprises:
[0366] The sixth receiving module is configured to receive an update request for the first metadata sent by the second server, and update the first metadata according to the update request.
[0367] The second determining module is used to determine a second updated metadata index corresponding to the updated first metadata in the second server according to the first updated metadata index corresponding to the updated first metadata.
[0368] The third sending module is used to send a second data synchronization request to the second server according to the second updated metadata index, where the second data synchronization request is used to instruct the second server to update second metadata according to the second updated metadata index, and the second metadata is the same as the first metadata.
[0369] Based on the same inventive concept, the embodiment of the present application also provides a data sharing device for implementing the data sharing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more data sharing device embodiments provided below can refer to the limitations on the data sharing method above, and will not be repeated here.
[0370] In an exemplary embodiment, as shown in FIG. 23 , a data sharing device is also provided, for use from a second server in a cluster, comprising:
[0371] The seventh receiving module 2301 is configured to receive a data reading request sent by a first server or client in the main cluster, where the data reading request includes a first metadata index.
[0372] The fifth acquisition module 2302 is used to acquire target data corresponding to the data read request from the second server according to the first metadata index.
[0373] The response module 2303 is used to respond to the data read request based on the target data.
[0374] In one embodiment, the second data read request further includes an identifier of the target data segment, and the fifth acquisition module includes:
[0375] The first determining unit is configured to determine first metadata corresponding to the first metadata index according to the first metadata index.
[0376] The second determining unit is used to determine the target storage location according to the first metadata and the identifier of the target data segment.
[0377] The second acquiring unit is used to read target data from a target storage location.
[0378] In one embodiment, the above device further comprises:
[0379] An eighth receiving module is used to receive multiple segment migration requests sent by the first server, where the segment migration requests include segment data, and each segment migration request is generated by the first server in response to a data migration request.
[0380] The writing module is used to write each segment of data into the second server.
[0381] The fourth sending module is used to send a response message to the first server, so that the first server determines the segment data that has been migrated to the second server among the segments of data according to the response message.
[0382] In one embodiment, the segment migration request also includes a data segment identifier corresponding to the segment data and a second metadata index, and the writing module includes:
[0383] The writing unit is used to write the segment data into the target data segment corresponding to the data segment identifier according to the data segment identifier.
[0384] The third acquisition unit is used to acquire second metadata corresponding to the second metadata index according to the second metadata index.
[0385] An updating unit is used to update the flag bit corresponding to each target data segment in the second metadata from a first value to a second value.
[0386] In one embodiment, the above device further comprises:
[0387] A ninth receiving module is used to receive a first data synchronization request sent by the first server, wherein the first data synchronization request includes a second parent directory metadata index corresponding to the first parent directory metadata index, and the first parent directory metadata index is a parent directory metadata index corresponding to the first target file created by the first server.
[0388] The creation module is used to create a second target file according to the metadata index of the second parent directory, and the first target file and the second target file both correspond to the first metadata.
[0389] In one embodiment, the above device further comprises:
[0390] The fifth sending module is used to send an update request for the first metadata to the first server.
[0391] The tenth receiving module is used to receive a second data synchronization request sent by the first server, wherein the second data synchronization request includes a second updated metadata index corresponding to the first updated metadata index, the first updated metadata index corresponds to the updated first metadata in the first server, and the updated first metadata is obtained after the first server updates the first metadata in response to the update request.
[0392] The updating module is used to update the second metadata according to the second updated metadata index, where the second metadata is the same as the first metadata.
[0393] Based on the same inventive concept, the embodiment of the present application also provides a data sharing device for implementing the data sharing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more data sharing device embodiments provided below can refer to the limitations on the data sharing method above, and will not be repeated here.
[0394] In an exemplary embodiment, as shown in FIG24 , a data sharing device is also provided, for use in a client, comprising:
[0395] The sixth sending module 2401 is configured to send a metadata read request to a first server in the main cluster, where the metadata read request includes a first metadata index.
[0396] The eleventh receiving module 2402 is configured to receive first metadata corresponding to a first metadata index sent by the first server in response to a metadata read request.
[0397] The sixth acquisition module 2403 is used to acquire target data from the first server or from the second server in the cluster according to the first metadata.
[0398] Optionally, if the target cluster is a main cluster, the first data read request is used to instruct the first server to obtain target data from the first server.
[0399] If the target cluster is a slave cluster, the first data read request is used to instruct the first server to generate a second data read request according to the first data read request, and send the second data read request to the second server to obtain target data from the second server.
[0400] In one embodiment, the metadata read request also includes an identifier of the target data segment, and the sixth acquisition module includes:
[0401] A generating unit is used to generate a first data read request according to the first metadata and the identifier of the target data segment.
[0402] The second sending unit is used to send a first data reading request to the first server, where the first data reading request is used to instruct the first server to obtain target data from the first server or to send the first data reading request to the second server.
[0403] The receiving unit is used to receive target data sent by the first server or the second server.
[0404] In one of the embodiments, the generating unit is specifically used to obtain a storage location corresponding to a flag bit of the target data segment from the first metadata according to an identifier of the target data segment.
[0405] Get the flag bit from the storage space corresponding to the storage location.
[0406] The target cluster for storing the target data is determined according to the flag bit.
[0407] A first data read request is generated according to the identifiers of the target cluster and the target data segment.
[0408] Each module in the above device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of the processor in the server in the form of hardware, or can be stored in the memory in the server in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0409] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG25. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store metadata and data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data sharing method is implemented.
[0410] Those skilled in the art will understand that the structure shown in FIG. 25 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0411] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0412] Obtaining a metadata read request corresponding to the client, where the metadata read request includes a first metadata index;
[0413] According to the first metadata index, obtaining first metadata corresponding to the first metadata index from the first server;
[0414] The first metadata is sent to the client, where the first metadata is used by the client to obtain target data from the first server or from the second server in the cluster according to the first metadata.
[0415] In one embodiment, the processor implements the following steps when executing the computer program:
[0416] receiving a first data read request sent by a client, where the first data read request is sent by the client after determining a target cluster storing target data according to the first metadata;
[0417] According to the first data read request, target data is acquired and returned to the client.
[0418] In one embodiment, the processor implements the following steps when executing the computer program:
[0419] If the target cluster is the main cluster, the target data is obtained from the first server according to the identifier of the target data segment.
[0420] In one embodiment, the processor implements the following steps when executing the computer program:
[0421] If the target cluster is a slave cluster, generating a second data read request according to the identifier of the target data segment and the first metadata index, and sending the second data read request to the second server;
[0422] Receive target data sent by the second server in response to the second data read request.
[0423] In one embodiment, the processor implements the following steps when executing the computer program:
[0424] receiving a data migration request, wherein the data migration request includes a second metadata index corresponding to the data to be migrated;
[0425] According to the second metadata index, obtain, from the first server, second metadata corresponding to the second metadata index, and obtain multiple segment data corresponding to the second metadata;
[0426] During the process of migrating each segment of data to the second server, the flag corresponding to the segment of data that has been migrated to the second server is updated from the first value to the second value, and the flag is used by the client to determine the target cluster for storing the target data.
[0427] In one embodiment, the processor implements the following steps when executing the computer program:
[0428] receiving a data migration request, wherein the data migration request includes a second metadata index corresponding to the data to be migrated;
[0429] According to the second metadata index, obtain, from the first server, second metadata corresponding to the second metadata index, and obtain multiple segment data corresponding to the second metadata;
[0430] During the process of migrating each segment of data to the second server, the flag corresponding to the segment of data that has been migrated to the second server is updated from the first value to the second value, and the flag is used by the client to determine the target cluster for storing the target data.
[0431] In one embodiment, the processor implements the following steps when executing the computer program:
[0432] Generate a segment migration request corresponding to each segment data, and send each segment migration request to the second server, where the segment migration request includes the segment data, a data segment identifier of the segment data, and a third metadata index, where the third metadata index is obtained from the second metadata;
[0433] A response message sent by the second server in response to each segment migration request is received, and segment data among each segment data that has been migrated to the second server is determined according to the response message.
[0434] In one embodiment, the processor implements the following steps when executing the computer program:
[0435] Receive a file creation request sent by a client, create a first target file in a first server according to the file creation request, and save a first parent directory metadata index corresponding to the first target file;
[0436] Determine, according to the first parent directory metadata index, a second parent directory metadata index in the second server corresponding to the first parent directory metadata index;
[0437] A first data synchronization request is sent to the second server according to the second parent directory metadata index. The first data synchronization request is used to instruct the second server to create a second target file according to the second parent directory metadata index. Both the first target file and the second target file correspond to the first metadata.
[0438] In one embodiment, the processor implements the following steps when executing the computer program:
[0439] receiving an update request for the first metadata sent by the second server, and updating the first metadata according to the update request;
[0440] Determining, according to the first updated metadata index corresponding to the updated first metadata, a second updated metadata index corresponding to the updated first metadata in the second server;
[0441] A second data synchronization request is sent to the second server according to the second updated metadata index, where the second data synchronization request is used to instruct the second server to update second metadata according to the second updated metadata index, where the second metadata is the same as the first metadata.
[0442] In one embodiment, the processor implements the following steps when executing the computer program:
[0443] A metadata read request is received from a management server in the main cluster, where the management server transfers the metadata read request from the third server to the first server when detecting that a third server in the main cluster has a fault.
[0444] In an exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0445] receiving a second data read request sent by a first server or a client in the main cluster, where the second data read request includes the first metadata index;
[0446] According to the first metadata index, obtaining target data corresponding to the second data read request from the second server;
[0447] A second data read request is responded to based on the target data.
[0448] In one embodiment, the processor implements the following steps when executing the computer program:
[0449] Determine, according to the first metadata index, first metadata corresponding to the first metadata index;
[0450] determining a target storage location according to the first metadata and an identifier of the target data segment;
[0451] Read the target data from the target storage location.
[0452] In one embodiment, the processor implements the following steps when executing the computer program:
[0453] receiving a plurality of segment migration requests sent by the first server, the segment migration requests including segment data, each segment migration request being generated by the first server in response to the data migration request;
[0454] Writing each segment of data into the second server;
[0455] A response message is sent to the first server, so that the first server determines the segment data among the segments of data that have been migrated to the second server according to the response message.
[0456] In one embodiment, the processor implements the following steps when executing the computer program:
[0457] According to the data segment identifier, write the segment data into the target data segment corresponding to the data segment identifier;
[0458] According to the second metadata index, obtaining second metadata corresponding to the second metadata index;
[0459] The flag bit corresponding to each target data segment in the second metadata is updated from the first value to the second value.
[0460] In one embodiment, the processor implements the following steps when executing the computer program:
[0461] Receive a first data synchronization request sent by a first server, the first data synchronization request including a second parent directory metadata index corresponding to the first parent directory metadata index, the first parent directory metadata index being a parent directory metadata index corresponding to a first target file created by the first server;
[0462] A second target file is created according to the second parent directory metadata index, and both the first target file and the second target file correspond to the first metadata.
[0463] In one embodiment, the processor implements the following steps when executing the computer program:
[0464] Sending an update request for the first metadata to the first server;
[0465] receiving a second data synchronization request sent by the first server, wherein the second data synchronization request includes a second updated metadata index corresponding to the first updated metadata index, wherein the first updated metadata index corresponds to the updated first metadata in the first server, and the updated first metadata is obtained after the first server updates the first metadata in response to the update request;
[0466] The second metadata is updated according to the second updated metadata index, and the second metadata is the same as the first metadata.
[0467] In an exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0468] Sending a metadata read request to a first server in the main cluster, where the metadata read request includes a first metadata index;
[0469] Receiving first metadata corresponding to a first metadata index sent by the first server in response to a metadata read request;
[0470] According to the first metadata, target data is obtained from the first server or from a second server in the cluster.
[0471] Optionally, if the target cluster is a primary cluster, the first data read request is used to instruct the first server to obtain target data from the first server;
[0472] If the target cluster is a slave cluster, the first data read request is used to instruct the first server to generate a second data read request according to the first data read request, and send the second data read request to the second server to obtain target data from the second server.
[0473] In one embodiment, the processor implements the following steps when executing the computer program:
[0474] Generate a first data read request according to the first metadata and an identifier of the target data segment;
[0475] Sending a first data read request to the first server, where the first data read request is used to instruct the first server to obtain target data from the first server or to send the first data read request to the second server;
[0476] Receive target data sent by the first server or the second server.
[0477] In one embodiment, the processor implements the following steps when executing the computer program:
[0478] According to the identifier of the target data segment, obtaining a storage location corresponding to the flag bit of the target data segment from the first metadata;
[0479] Get the flag bit from the storage space corresponding to the storage location;
[0480] Determine the target cluster for storing target data according to the flag bit;
[0481] A first data read request is generated according to the identifiers of the target cluster and the target data segment.
[0482] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0483] Obtaining a metadata read request corresponding to the client, where the metadata read request includes a first metadata index;
[0484] According to the first metadata index, obtaining first metadata corresponding to the first metadata index from the first server;
[0485] The first metadata is sent to the client, where the first metadata is used by the client to obtain target data from the first server or from the second server in the cluster according to the first metadata.
[0486] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0487] receiving a first data read request sent by a client, where the first data read request is sent by the client after determining a target cluster storing target data according to the first metadata;
[0488] According to the first data read request, target data is acquired and returned to the client.
[0489] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0490] If the target cluster is the main cluster, the target data is obtained from the first server according to the identifier of the target data segment.
[0491] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0492] If the target cluster is a slave cluster, generating a second data read request according to the identifier of the target data segment and the first metadata index, and sending the second data read request to the second server;
[0493] Receive target data sent by the second server in response to the second data read request.
[0494] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0495] Generate a segment migration request corresponding to each segment data, and send each segment migration request to the second server, where the segment migration request includes the segment data, a data segment identifier of the segment data, and a third metadata index, where the third metadata index is obtained from the second metadata;
[0496] A response message sent by the second server in response to each segment migration request is received, and segment data among each segment data that has been migrated to the second server is determined according to the response message.
[0497] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0498] Receive a file creation request sent by a client, create a first target file in a first server according to the file creation request, and save a first parent directory metadata index corresponding to the first target file;
[0499] Determine, according to the first parent directory metadata index, a second parent directory metadata index in the second server corresponding to the first parent directory metadata index;
[0500] A first data synchronization request is sent to the second server according to the second parent directory metadata index. The first data synchronization request is used to instruct the second server to create a second target file according to the second parent directory metadata index. Both the first target file and the second target file correspond to the first metadata.
[0501] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0502] receiving an update request for the first metadata sent by the second server, and updating the first metadata according to the update request;
[0503] Determining, according to the first updated metadata index corresponding to the updated first metadata, a second updated metadata index corresponding to the updated first metadata in the second server;
[0504] A second data synchronization request is sent to the second server according to the second updated metadata index, where the second data synchronization request is used to instruct the second server to update second metadata according to the second updated metadata index, where the second metadata is the same as the first metadata.
[0505] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0506] A metadata read request is received from a management server in the main cluster, where the management server transfers the metadata read request from the third server to the first server when detecting that a third server in the main cluster has a fault.
[0507] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0508] receiving a second data read request sent by a first server or a client in the main cluster, where the second data read request includes the first metadata index;
[0509] According to the first metadata index, obtaining target data corresponding to the second data read request from the second server;
[0510] A second data read request is responded to based on the target data.
[0511] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0512] Determine, according to the first metadata index, first metadata corresponding to the first metadata index;
[0513] determining a target storage location according to the first metadata and an identifier of the target data segment;
[0514] Read the target data from the target storage location.
[0515] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0516] receiving a plurality of segment migration requests sent by the first server, the segment migration requests including segment data, each segment migration request being generated by the first server in response to the data migration request;
[0517] Writing each segment of data into the second server;
[0518] A response message is sent to the first server, so that the first server determines the segment data among the segments of data that have been migrated to the second server according to the response message.
[0519] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0520] According to the data segment identifier, write the segment data into the target data segment corresponding to the data segment identifier;
[0521] According to the second metadata index, obtaining second metadata corresponding to the second metadata index;
[0522] The flag bit corresponding to each target data segment in the second metadata is updated from the first value to the second value.
[0523] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0524] Receive a first data synchronization request sent by a first server, the first data synchronization request including a second parent directory metadata index corresponding to the first parent directory metadata index, the first parent directory metadata index being a parent directory metadata index corresponding to a first target file created by the first server;
[0525] A second target file is created according to the second parent directory metadata index, and both the first target file and the second target file correspond to the first metadata.
[0526] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0527] Sending an update request for the first metadata to the first server;
[0528] receiving a second data synchronization request sent by the first server, wherein the second data synchronization request includes a second updated metadata index corresponding to the first updated metadata index, wherein the first updated metadata index corresponds to the updated first metadata in the first server, and the updated first metadata is obtained after the first server updates the first metadata in response to the update request;
[0529] The second metadata is updated according to the second updated metadata index, and the second metadata is the same as the first metadata.
[0530] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0531] Sending a metadata read request to a first server in the main cluster, where the metadata read request includes a first metadata index;
[0532] Receiving first metadata corresponding to a first metadata index sent by the first server in response to a metadata read request;
[0533] According to the first metadata, target data is obtained from the first server or from a second server in the cluster.
[0534] Optionally, if the target cluster is a primary cluster, the first data read request is used to instruct the first server to obtain target data from the first server;
[0535] If the target cluster is a slave cluster, the first data read request is used to instruct the first server to generate a second data read request according to the first data read request, and send the second data read request to the second server to obtain target data from the second server.
[0536] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0537] Generate a first data read request according to the first metadata and an identifier of the target data segment;
[0538] Sending a first data read request to the first server, where the first data read request is used to instruct the first server to obtain target data from the first server or to send the first data read request to the second server;
[0539] Receive target data sent by the first server or the second server.
[0540] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0541] According to the identifier of the target data segment, obtaining a storage location corresponding to the flag bit of the target data segment from the first metadata;
[0542] Get the flag bit from the storage space corresponding to the storage location;
[0543] Determine the target cluster for storing target data according to the flag bit;
[0544] A first data read request is generated according to the identifiers of the target cluster and the target data segment.
[0545] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0546] Obtaining a metadata read request corresponding to the client, where the metadata read request includes a first metadata index;
[0547] According to the first metadata index, obtaining first metadata corresponding to the first metadata index from the first server;
[0548] The first metadata is sent to the client, where the first metadata is used by the client to obtain target data from the first server or from the second server in the cluster according to the first metadata.
[0549] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0550] receiving a first data read request sent by a client, where the first data read request is sent by the client after determining a target cluster storing target data according to the first metadata;
[0551] According to the first data read request, target data is acquired and returned to the client.
[0552] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0553] If the target cluster is the main cluster, the target data is obtained from the first server according to the identifier of the target data segment.
[0554] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0555] If the target cluster is a slave cluster, generating a second data read request according to the identifier of the target data segment and the first metadata index, and sending the second data read request to the second server;
[0556] Receive target data sent by the second server in response to the second data read request.
[0557] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0558] receiving a data migration request, wherein the data migration request includes a second metadata index corresponding to the data to be migrated;
[0559] According to the second metadata index, obtain, from the first server, second metadata corresponding to the second metadata index, and obtain multiple segment data corresponding to the second metadata;
[0560] During the process of migrating each segment of data to the second server, the flag corresponding to the segment of data that has been migrated to the second server is updated from the first value to the second value, and the flag is used by the client to determine the target cluster for storing the target data.
[0561] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0562] Generate a segment migration request corresponding to each segment data, and send each segment migration request to the second server, where the segment migration request includes the segment data, a data segment identifier of the segment data, and a third metadata index, where the third metadata index is obtained from the second metadata;
[0563] A response message sent by the second server in response to each segment migration request is received, and segment data among each segment data that has been migrated to the second server is determined according to the response message.
[0564] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0565] Receive a file creation request sent by a client, create a first target file in a first server according to the file creation request, and save a first parent directory metadata index corresponding to the first target file;
[0566] Determine, according to the first parent directory metadata index, a second parent directory metadata index in the second server corresponding to the first parent directory metadata index;
[0567] A first data synchronization request is sent to the second server according to the second parent directory metadata index. The first data synchronization request is used to instruct the second server to create a second target file according to the second parent directory metadata index. Both the first target file and the second target file correspond to the first metadata.
[0568] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0569] receiving an update request for the first metadata sent by the second server, and updating the first metadata according to the update request;
[0570] Determining, according to the first updated metadata index corresponding to the updated first metadata, a second updated metadata index corresponding to the updated first metadata in the second server;
[0571] A second data synchronization request is sent to the second server according to the second updated metadata index, where the second data synchronization request is used to instruct the second server to update second metadata according to the second updated metadata index, where the second metadata is the same as the first metadata.
[0572] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0573] A metadata read request is received from a management server in the main cluster, where the management server transfers the metadata read request from the third server to the first server when detecting that a third server in the main cluster has a fault.
[0574] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0575] receiving a second data read request sent by a first server or a client in the main cluster, where the second data read request includes the first metadata index;
[0576] According to the first metadata index, obtaining target data corresponding to the second data read request from the second server;
[0577] A second data read request is responded to based on the target data.
[0578] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0579] Determine, according to the first metadata index, first metadata corresponding to the first metadata index;
[0580] determining a target storage location according to the first metadata and an identifier of the target data segment;
[0581] Read the target data from the target storage location.
[0582] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0583] receiving a plurality of segment migration requests sent by the first server, the segment migration requests including segment data, each segment migration request being generated by the first server in response to the data migration request;
[0584] Writing each segment of data into the second server;
[0585] A response message is sent to the first server, so that the first server determines the segment data among the segments of data that have been migrated to the second server according to the response message.
[0586] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0587] According to the data segment identifier, write the segment data into the target data segment corresponding to the data segment identifier;
[0588] According to the second metadata index, obtaining second metadata corresponding to the second metadata index;
[0589] The flag bit corresponding to each target data segment in the second metadata is updated from the first value to the second value.
[0590] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0591] Receive a first data synchronization request sent by a first server, the first data synchronization request including a second parent directory metadata index corresponding to the first parent directory metadata index, the first parent directory metadata index being a parent directory metadata index corresponding to a first target file created by the first server;
[0592] A second target file is created according to the second parent directory metadata index, and both the first target file and the second target file correspond to the first metadata.
[0593] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0594] Sending an update request for the first metadata to the first server;
[0595] receiving a second data synchronization request sent by the first server, wherein the second data synchronization request includes a second updated metadata index corresponding to the first updated metadata index, wherein the first updated metadata index corresponds to the updated first metadata in the first server, and the updated first metadata is obtained after the first server updates the first metadata in response to the update request;
[0596] The second metadata is updated according to the second updated metadata index, and the second metadata is the same as the first metadata.
[0597] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0598] Sending a metadata read request to a first server in the main cluster, where the metadata read request includes a first metadata index;
[0599] Receiving first metadata corresponding to a first metadata index sent by the first server in response to a metadata read request;
[0600] According to the first metadata, target data is obtained from the first server or from a second server in the cluster.
[0601] Optionally, if the target cluster is a primary cluster, the first data read request is used to instruct the first server to obtain target data from the first server;
[0602] If the target cluster is a slave cluster, the first data read request is used to instruct the first server to generate a second data read request according to the first data read request, and send the second data read request to the second server to obtain target data from the second server.
[0603] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0604] Generate a first data read request according to the first metadata and the identifier of the target data segment;
[0605] Sending a first data read request to the first server, where the first data read request is used to instruct the first server to obtain target data from the first server or to send the first data read request to the second server;
[0606] Receive target data sent by the first server or the second server.
[0607] In one embodiment, when the computer program is executed by a processor, the following steps are specifically implemented:
[0608] According to the identifier of the target data segment, obtaining a storage location corresponding to the flag bit of the target data segment from the first metadata;
[0609] Get the flag bit from the storage space corresponding to the storage location;
[0610] Determine the target cluster for storing target data according to the flag bit;
[0611] A first data read request is generated according to the identifiers of the target cluster and the target data segment.
[0612] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0613] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0614] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data sharing method, characterized in that: For a first server in a primary cluster, the method comprises: Obtaining a metadata read request corresponding to the client, wherein the metadata read request includes a first metadata index; According to the first metadata index, obtaining, from the first server, first metadata corresponding to the first metadata index; The first metadata is sent to the client, where the first metadata is used by the client to obtain target data from the first server or from a second server in the cluster according to the first metadata.
2. The method according to claim 1, characterized in that The method further comprises: receiving a first data read request sent by the client, where the first data read request is sent by the client after determining a target cluster storing the target data according to the first metadata; According to the first data read request, the target data is acquired, and the target data is returned to the client.
3. The method according to claim 2, characterized in that The first data read request includes an identifier of a target data segment, and acquiring the target data according to the first data read request includes: If the target cluster is the primary cluster, obtaining the target data from the first server according to the identifier of the target data segment; or, If the target cluster is the slave cluster, a second data read request is generated according to the identifier of the target data segment and the first metadata index, and the second data read request is sent to the second server; and the target data sent by the second server in response to the second data read request is received.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: receiving a data migration request, wherein the data migration request includes a second metadata index corresponding to the data to be migrated; According to the second metadata index, obtaining, from the first server, second metadata corresponding to the second metadata index, and obtaining a plurality of segment data corresponding to the second metadata; During the process of migrating each of the segment data to the second server, a flag bit corresponding to the segment data that has been migrated to the second server in each of the segment data is updated from a first value to a second value, and the flag bit is used by the client to determine a target cluster for storing the target data.
5. The method according to claim 1, characterized in that The method further comprises: Receive a file creation request sent by the client, create a first target file in the first server according to the file creation request, and save a first parent directory metadata index corresponding to the first target file; Determine, according to the first parent directory metadata index, a second parent directory metadata index in the second server corresponding to the first parent directory metadata index; A first data synchronization request is sent to the second server according to the second parent directory metadata index, wherein the first data synchronization request is used to instruct the second server to create a second target file according to the second parent directory metadata index, and both the first target file and the second target file correspond to the first metadata.
6. The method according to claim 5, characterized in that The method further comprises: receiving an update request for the first metadata sent by the second server, and updating the first metadata according to the update request; Determining, according to the first updated metadata index corresponding to the updated first metadata, a second updated metadata index corresponding to the updated first metadata in the second server; A second data synchronization request is sent to the second server according to the second updated metadata index, where the second data synchronization request is used to instruct the second server to update second metadata according to the second updated metadata index, where the second metadata is the same as the first metadata.
7. A data sharing method, characterized in that: For a second server in the slave cluster, the method comprises: Receiving a second data read request sent by a first server or a client in the main cluster, wherein the second data read request includes a first metadata index; According to the first metadata index, acquiring target data corresponding to the second data read request from the second server; The second data read request is responded to based on the target data.
8. The method according to claim 7, characterized in that The second data read request also includes an identifier of a target data segment, and acquiring the target data corresponding to the second data read request from the second server according to the first metadata index includes: Determine, according to the first metadata index, first metadata corresponding to the first metadata index; determining a target storage location according to the first metadata and the identifier of the target data segment; The target data is read from the target storage location.
9. The method according to claim 7, characterized in that: The method further comprises: receiving a plurality of segment migration requests sent by the first server, the segment migration requests including segment data, each of the segment migration requests being generated by the first server in response to a data migration request; Writing each of the segments of data into the second server; A response message is sent to the first server, so that the first server determines the segment data among the segment data that have been migrated to the second server according to the response message.
10. The method according to claim 9, characterized in that The segment migration request also includes a data segment identifier corresponding to the segment data and a second metadata index, and the step of writing each segment data to the second server includes: According to the data segment identifier, writing the segment data into the target data segment corresponding to the data segment identifier; According to the second metadata index, obtaining second metadata corresponding to the second metadata index; The flag bit corresponding to each of the target data segments in the second metadata is updated from the first value to the second value.
11. A data sharing method, characterized in that: For a client, the method comprises: Sending a metadata read request to a first server in the main cluster, wherein the metadata read request includes a first metadata index; receiving first metadata corresponding to the first metadata index sent by the first server in response to the metadata read request; According to the first metadata, target data is obtained from the first server or from a second server in the cluster.
12. The method according to claim 11, characterized in that The metadata read request also includes an identifier of a target data segment, and obtaining the target data from the first server or from a second server in the cluster according to the first metadata includes: Generate a first data read request according to the first metadata and the identifier of the target data segment; Sending the first data read request to the first server, where the first data read request is used to instruct the first server to obtain the target data from the first server or to send the first data read request to the second server; The target data sent by the first server or the second server is received.
13. A data sharing device, characterized in that: For a first server in a main cluster, the apparatus comprises: A first receiving module, configured to receive a data reading request sent by a client, wherein the reading request includes a metadata index corresponding to the data to be read; A first acquisition module, configured to read metadata according to the metadata index; The second acquisition module is used to acquire the data to be read according to the metadata.
14. A data sharing device, characterized in that: For a second server in a slave cluster, the apparatus comprises: A seventh receiving module, configured to receive a data reading request sent by a first server or a client in the main cluster, wherein the data reading request includes a first metadata index; a fifth acquisition module, configured to acquire, from the second server, target data corresponding to the data read request according to the first metadata index; A response module is used to respond to the data read request based on the target data.
15. A data sharing device, characterized in that: For a client, the device comprises: A sixth sending module, configured to send a metadata read request to a first server in the main cluster, wherein the metadata read request includes a first metadata index; an eleventh receiving module, configured to receive first metadata corresponding to the first metadata index sent by the first server in response to the metadata read request; A sixth acquisition module is used to acquire target data from the first server or from a second server in the cluster according to the first metadata.
16. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 12 are implemented.
17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.
18. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.