Distributed storage method and device

文档序号:1627677 发布日期:2020-01-14 浏览:7次 中文

阅读说明:本技术 一种分布式存储方法及装置 (Distributed storage method and device ) 是由 程曙光 林苏琦 于 2018-07-05 设计创作,主要内容包括:本申请公开了一种分布式存储方法及装置,包括:当打开共享磁盘时,控制器记录包括打开版本信息的会话控制信息;控制器将生成的打开版本信息及共享磁盘所在服务器信息返回给客户端;控制器按照预先设置的同步策略,将记录的会话控制信息发送给共享磁盘所在的服务器,以使服务器根据会话控制信息中的打开版本信息实现不同客户端对共享磁盘的同时操作。本申请实现了可靠支持多客户端并发访问。(The application discloses a distributed storage method and a device, comprising the following steps: when the shared disk is opened, the controller records session control information including the opening version information; the controller returns the generated opening version information and the information of the server where the shared disk is located to the client; and the controller sends the recorded session control information to a server where the shared disk is located according to a preset synchronization strategy, so that the server realizes the simultaneous operation of different clients on the shared disk according to the version opening information in the session control information. The method and the device realize reliable support of concurrent access of multiple clients.)

1. A distributed storage method, comprising:

when the shared disk is opened, the controller records session control information including the opening version information;

the controller returns the generated opening version information and the information of the server where the shared disk is located to the client; and the controller sends the recorded session control information to a server where the shared disk is located according to a preset synchronization strategy, so that the server realizes the simultaneous operation of different clients on the shared disk according to the version opening information in the session control information.

2. The distributed storage method of claim 1, further comprising:

the controller receives a creation request for creating a shared disk from a client, creates the disk and marks the created disk as the shared disk;

the controller divides the shared disk into N segments according to preset configuration information, and distributes the N segments to M servers for loading; wherein N, M is an integer greater than or equal to 1 and N is greater than or equal to M.

3. The distributed storage method of claim 1 or 2, wherein the session control information further comprises: and opening the unique identifier of the client of the shared disk and opening the IP address of the client of the shared disk.

4. The distributed storage method according to claim 1 or 2, wherein the open version information is an open version number;

and the controller executes the opening operation on the shared disk once, and the generated opening version number is increased by a preset step length.

5. The distributed storage method of claim 1 or 2, wherein the synchronization policy comprises: and the controller detects that the session control information of the shared disk changes.

6. A distributed storage method, comprising:

the client requests the controller to open the shared disk;

the client receives the opening version information and the server information of the shared disk returned by the controller;

and the client requests input/output operation to the server where the segment of the shared disk needing to be operated is located according to the information of the server where the shared disk is located by using the obtained opening version information.

7. The distributed storage method of claim 6, further comprising, before the method:

the client sends a creation request for creating the shared disk to the controller, so that the controller marks the created disk as the shared disk.

8. The distributed storage method of claim 6 or 7, wherein the client requesting the controller to open the shared disk comprises:

the client sends a creation request to the controller, wherein the creation request carries: the unique identification of the client, the IP address of the client and the identification of the shared disk.

9. The distributed storage method according to claim 6 or 7, wherein the open version information is an open version number;

and the controller executes the opening operation on the shared disk once, and the generated opening version number is increased by a preset step length.

10. The distributed storage method of claim 6 or 7, wherein the server information comprises: and the IP address of each server allocated to the divided segment of the shared disk.

11. A distributed storage method, comprising:

the server receives and stores the session control information including the opening version information;

the server receives an input/output operation request from the client, determines that the opening version information carried in the input/output operation request is stored, and allows the client to perform input/output operation on the shared disk.

12. The distributed storage method according to claim 11, wherein if the server determines that the server does not store the open version information carried in the I/O operation request, the method further comprises:

not allowing the input/output operation of the client.

13. The distributed storage method according to claim 11 or 12, the session control information further comprising: and opening the unique identifier of the client of the shared disk and opening the IP address of the client of the shared disk.

14. The distributed storage method of claim 11 or 12, wherein the input/output operation is a read request; before the executing the read operation, the method further comprises:

calculating a difference value between the current time and lease start time by a segment needing to be operated on the server, judging whether the calculated difference value exceeds a preset lease duration T, if the difference value exceeds the lease duration T, sending write operation by the segment to judge whether the segment is migrated, and returning a result to the client by the read operation when the segment is not migrated;

and if the difference does not exceed the lease time length T, the client side continues to execute the reading operation.

15. The distributed storage method of claim 14, wherein the determining whether the segment of the shared disk requiring operation is migrated comprises:

if the write request returns success, the read operation returns a result to the client; updating the lease starting time to be the current write starting time by the segment on the server;

and if the write request fails, the server returns that the read request fails.

16. The distributed storage method of claim 14, wherein the write operation is to: a small block of probe data is written and the data index is not updated.

17. A distributed storage device, disposed in a controller, comprising: the device comprises a recording module and a first processing module; wherein the content of the first and second substances,

the recording module is used for recording the session control information comprising the generated opening version information when the shared disk is opened;

the first processing module is used for returning the generated opening version information and the information of the server where the shared disk is located to the client; and sending the recorded session control information to a server where the shared disk is located according to a preset synchronization strategy, so that the server can realize the simultaneous operation of different clients on the shared disk according to the version opening information in the session control information.

18. The distributed storage apparatus of claim 17, the apparatus further comprising:

a first receiving module, configured to receive a creation request for creating a shared disk from the client;

a creation module: creating a disk and marking the created disk as a shared disk; dividing the shared disk into N segments according to preset configuration information, and distributing the N segments to M servers for loading; wherein N, M is an integer greater than or equal to 1 and N is greater than or equal to M.

19. A distributed storage device, provided in a client, comprising: the second receiving module and the second processing module; wherein the content of the first and second substances,

the second receiving module is used for requesting the controller to open the shared disk and receiving the version opening information returned by the controller and the information of the server where the shared disk is located;

and the second processing module is used for requesting input/output operation to the server where the segment of the shared disk needing to be operated is located according to the information of the server where the shared disk is located by utilizing the obtained opening version information.

20. The distributed storage apparatus of claim 19, the second processing module further to: sending a creation request for creating a shared disk to the controller, so that the controller marks the created disk as a shared disk.

21. A distributed storage apparatus, provided in a server, comprising: a third receiving module and a third processing module; wherein the content of the first and second substances,

the third receiving module is used for receiving and storing the session control information including the opening version information from the controller;

and the third processing module is used for receiving an input/output operation request from the client, determining that the opening version information carried in the I/O operation request is stored, and allowing the client to perform input/output operation on the shared disk.

22. The distributed storage apparatus of claim 21, the third processing module further to:

and if the opening version information carried in the input/output operation request is determined not to be stored, the input/output operation of the client is not allowed.

23. The distributed storage apparatus according to claim 21 or 22, wherein when the input/output request initiated by the client is a read operation, before the read operation is performed, the third processing module is further configured to:

calculating the difference between the current time and lease start time, judging whether the calculated difference exceeds a preset lease duration T, if the difference exceeds the lease duration T, sending write operation to the segment needing to be operated to judge whether the segment is transferred, and returning a result to the client by the read operation when the segment is not transferred;

if the difference does not exceed the lease time period T, the read operation continues.

24. The distributed storage apparatus of claim 23, wherein the determining whether the segment of the shared disk requiring operation is migrated comprises:

if the write request returns success, the read operation returns a result to the client; the third processing module updates lease start time to be current write start time;

and if the write request fails, returning a read request failure to the client.

Technical Field

The present application relates to, but not limited to, distributed storage technologies, and more particularly, to a distributed storage method and apparatus.

Background

In a cloud computing environment, a disk may be mounted in a virtual machine (also referred to as a client) purchased by a user, the disk corresponds to a logical disk in a backend distributed storage system, and an input/output (I/O) request in the virtual machine is finally issued to the logical disk in the backend distributed storage system.

In a cloud environment, block storage is a technology which is often used, and it is simply understood that in the cloud environment, a virtual machine object is considered to be unstable, that is, data of a user cannot be stored in a virtual machine, but is stored in an external device, and this way is block storage. Therefore, if the virtual machine crashes, the block storage object can be unloaded from the virtual machine, then a new virtual machine is quickly started through the cloud platform, and the block storage object is directly loaded on the new virtual machine, so that the purpose of data persistence is achieved.

The shared block storage is a data block level storage device supporting concurrent read-write access of multiple clients, and has the characteristics of multiple concurrencies, high performance, high reliability and the like. In order to mount the same disk in multiple virtual machines of a user, a distributed storage system at the back end is required to support a shared disk mode. The shared disk refers to the concurrent read-write operation of a same disk by a plurality of clients.

Disclosure of Invention

In order to solve the above technical problem, the present invention provides a distributed storage method and apparatus, which can reliably support concurrent access by multiple clients.

In order to achieve the object of the present invention, the present invention provides a distributed storage method, including:

when the shared disk is opened, the controller records session control information including the opening version information;

the controller returns the generated opening version information and the information of the server where the shared disk is located to the client; and the controller sends the recorded session control information to a server where the shared disk is located according to a preset synchronization strategy, so that the server realizes the simultaneous operation of different clients on the shared disk according to the version opening information in the session control information.

Optionally, the method further comprises:

the controller receives a creation request for creating a shared disk from a client, creates the disk and marks the created disk as the shared disk;

the controller divides the shared disk into N segments according to preset configuration information, and distributes the N segments to M servers for loading; wherein N, M is an integer greater than or equal to 1 and N is greater than or equal to M.

Optionally, the session control information further includes: and opening the unique identifier of the client of the shared disk and opening the IP address of the client of the shared disk.

Optionally, the open version information is an open version number;

and the controller executes the opening operation on the shared disk once, and the generated opening version number is increased by a preset step length.

Optionally, the synchronization policy includes: and the controller detects that the session control information of the shared disk changes.

The application also provides a distributed storage method, which comprises the following steps:

the client requests the controller to open the shared disk;

the client receives the opening version information and the server information of the shared disk returned by the controller;

and the client requests input/output operation to the server where the segment of the shared disk needing to be operated is located according to the information of the server where the shared disk is located by using the obtained opening version information.

Optionally, the method further comprises:

the client sends a creation request for creating the shared disk to the controller, so that the controller marks the created disk as the shared disk.

Optionally, the requesting, by the client, the shared disk from the controller includes:

the client sends a creation request to the controller, wherein the creation request carries: the unique identification of the client, the IP address of the client and the identification of the shared disk.

Optionally, the open version information is an open version number;

and the controller executes the opening operation on the shared disk once, and the generated opening version number is increased by a preset step length.

Optionally, the server information includes: and the IP address of each server allocated to the divided segment of the shared disk.

The application further provides a distributed storage method, including:

the server receives and stores the session control information including the opening version information;

the server receives an input/output operation request from the client, determines that the opening version information carried in the input/output operation request is stored, and allows the client to perform input/output operation on the shared disk.

Optionally, if the server determines that the server does not store the open version information carried in the I/O operation request, the method further includes:

not allowing the input/output operation of the client.

Optionally, the session control information further includes: and opening the unique identifier of the client of the shared disk and opening the IP address of the client of the shared disk.

Optionally, the input/output operation is a read request; before the executing the read operation, the method further comprises:

calculating a difference value between the current time and lease start time by a segment needing to be operated on the server, judging whether the calculated difference value exceeds a preset lease duration T, if the difference value exceeds the lease duration T, sending write operation by the segment to judge whether the segment is migrated, and returning a result to the client by the read operation when the segment is not migrated;

and if the difference does not exceed the lease time length T, the client side continues to execute the reading operation.

Optionally, the determining whether the segment needing to be operated in the shared disk is migrated includes:

if the write request returns success, the read operation returns a result to the client; updating the lease starting time to be the current write starting time by the segment on the server;

and if the write request fails, the server returns that the read request fails.

Optionally, the write operation is: a small block of probe data is written and the data index is not updated.

The present application further provides a distributed storage device, disposed in a controller, including: the device comprises a recording module and a first processing module; wherein the content of the first and second substances,

the recording module is used for recording the session control information comprising the generated opening version information when the shared disk is opened;

the first processing module is used for returning the generated opening version information and the information of the server where the shared disk is located to the client; and sending the recorded session control information to a server where the shared disk is located according to a preset synchronization strategy, so that the server can realize the simultaneous operation of different clients on the shared disk according to the version opening information in the session control information.

Optionally, the apparatus further comprises:

a first receiving module, configured to receive a creation request for creating a shared disk from the client;

a creation module: creating a disk and marking the created disk as a shared disk; dividing the shared disk into N segments according to preset configuration information, and distributing the N segments to M servers for loading; wherein N, M is an integer greater than or equal to 1 and N is greater than or equal to M.

The application further provides a distributed storage device, which is arranged in a client and comprises: the second receiving module and the second processing module; wherein the content of the first and second substances,

and the second receiving module is used for requesting the controller to open the shared disk and receiving the opening version information returned by the controller and the server information of the shared disk.

And the second processing module is used for requesting input/output operation to the server where the segment of the shared disk needing to be operated is located according to the information of the server where the shared disk is located by utilizing the obtained opening version information.

Optionally, the second processing module is further configured to: sending a creation request for creating a shared disk to the controller, so that the controller marks the created disk as a shared disk.

The present application further provides a distributed storage apparatus, which is disposed in a server, and includes: a third receiving module and a third processing module; wherein the content of the first and second substances,

the third receiving module is used for receiving and storing the session control information including the opening version information from the controller;

and the third processing module is used for receiving an input/output operation request from the client, determining that the opening version information carried in the I/O operation request is stored, and allowing the client to perform input/output operation on the shared disk.

Optionally, the third processing module is further configured to:

and if the opening version information carried in the input/output operation request is determined not to be stored, the input/output operation of the client is not allowed.

Optionally, when the input/output request initiated by the client is a read operation, before the read operation is executed, the third processing module is further configured to:

calculating the difference between the current time and lease start time, judging whether the calculated difference exceeds a preset lease duration T, if the difference exceeds the lease duration T, sending write operation to the segment needing to be operated to judge whether the segment is transferred, and returning a result to the client by the read operation when the segment is not transferred;

if the difference does not exceed the lease time period T, the read operation continues.

Optionally, the determining whether the segment needing to be operated in the shared disk is migrated includes:

if the write request returns success, the read operation returns a result to the client; the third processing module updates lease start time to be current write start time;

and if the write request fails, returning a read request failure to the client.

The technical scheme of the application includes: when the shared disk is opened, the controller records session control information including the opening version information; the controller returns the generated opening version information and the information of the server where the shared disk is located to the client; and the controller sends the recorded session control information to a server where the shared disk is located according to a preset synchronization strategy, so that the server realizes the simultaneous operation of different clients on the shared disk according to the version opening information in the session control information. The method and the device realize reliable support of concurrent access of multiple clients.

Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.

Drawings

The accompanying drawings are included to provide a further understanding of the claimed subject matter and are incorporated in and constitute a part of this specification, illustrate embodiments of the subject matter and together with the description serve to explain the principles of the subject matter and not to limit the subject matter.

FIG. 1 is a schematic flow chart diagram illustrating a first embodiment of a distributed storage method according to the present application;

FIG. 2 is a schematic diagram of an embodiment of creating a shared disk according to the present application;

FIG. 3 is a schematic flow chart of a distributed storage method according to a second embodiment of the present application;

FIG. 4 is a schematic flow chart diagram illustrating a third embodiment of a distributed storage method according to the present application;

FIG. 5 is a diagram illustrating a scenario of a multi-client data inconsistency problem;

FIG. 6 is a schematic diagram illustrating a structure of a distributed storage apparatus according to a first embodiment of the present application;

FIG. 7 is a schematic structural diagram illustrating a second embodiment of a distributed storage apparatus according to the present application;

fig. 8 is a schematic structural diagram of a distributed storage apparatus according to a third embodiment of the present application.

Detailed Description

To make the objects, technical solutions and advantages of the present application more apparent, embodiments of the present application will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.

In one exemplary configuration of the present application, a computing device includes one or more processors (CPUs), input/output interfaces, a network interface, and memory.

The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.

Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory computer readable media (transient media), such as modulated data signals and carrier waves.

The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.

Fig. 1 is a schematic flowchart of a first embodiment of a distributed storage method according to the present application, as shown in fig. 1, including:

step 100: when the shared disk is opened, the controller records session control information including open version information.

The Session control (Session) information further includes: the unique identification of the Client (Client) opening the shared disk and the IP address of the Client opening the shared disk.

Alternatively, the open version information may be an open version number. When the controller (Master) performs an opening operation on the shared disk once, the generated opening version number is incremented by a preset step length, for example: 1.

the method also comprises the following steps:

receiving a creation request for creating a shared disk from a client, a controller creates a disk and marks the created disk as the shared disk, for example, a tag is set to indicate that the created disk is the shared disk; then, the controller divides the shared disk into N segments (segments) according to the preset configuration information, and distributes the segments to M servers (servers) for loading; wherein N, M is an integer greater than or equal to 1 and N is greater than or equal to M.

The preset configuration information includes but is not limited to: the value of M, the value of N, how many segments are allocated in each server, etc. Such as: let N be 10 and M be 2, and there are two servers (servers), i.e., Server1 and Server2, 6 segments are allocated in Server1 and 4 segments are allocated in Server 2. Thus, for a 1000G shared disk, 10 segments may be split, with 6 segments allocated to Server1 and 4 segments allocated to Server 2. It should be noted that the skilled person is easy to understand how to segment and distribute the disk to the server, and the skilled person knows the preset configuration information controller and the client. It is emphasized that when a create request received by the controller is for a shared disk, then the created disk is identified as a shared disk.

For example, fig. 2 is a schematic diagram of an embodiment of creating a shared disk according to the present application, and as shown in fig. 2, a Client 1(Client1) initiates a creation request for creating a shared disk to a Master, the Master marks the shared disk as a shared disk, and then, according to preset configuration information, the shared disk is divided into N segments and then allocated to M (two in fig. 2) servers for loading.

Step 101: the controller returns the generated opening version information and the information of the server where the shared disk is located to the client; and the controller sends all recorded session control information to a server where the shared disk is located according to a preset synchronization strategy, so that the server realizes the simultaneous operation of different clients on the shared disk according to the version opening information in the session control information.

Optionally, the synchronization policy may include: the controller detects that the session control information of the shared disk changes. Such as: when the controller receives the opening/closing operation of the shared disk, the session control information changes, and the change triggers the synchronous operation of the controller.

In the application, the session control information including the opening version information of all the client opening operations is recorded in the controller, and the recorded session control information including the opening version information is updated to the server, so that the server knows the legal client information, and only a disk on the client operation server opened in the controller is legal, thereby realizing that a plurality of clients simultaneously operate the same shared disk, and avoiding illegal I/O operation requests.

The present application also provides a computer-readable storage medium storing computer-executable instructions for performing any of the distributed storage methods described above with reference to fig. 1.

The present application also provides an apparatus for implementing distributed shared storage, including a memory and a processor, where the memory stores therein any one of the instructions described above in fig. 1 that can be executed by the processor.

Fig. 3 is a schematic flowchart of a second embodiment of the distributed storage method of the present application, as shown in fig. 3, including:

step 300: the client requests the controller to open the shared disk.

Optionally, the requesting, by the client, the shared disk from the controller includes:

the client sends a creation request to the controller, wherein the creation request carries: unique identification of the client, IP address of the client and identification of the shared disk.

The method also comprises the following steps:

the client sends a create request to the controller for creating a shared disk, so that the controller marks the created disk as a shared disk.

Step 301: and the client receives the opening version information and the server information of the shared disk returned by the controller.

Alternatively, the open version information may be an open version number. Each time the controller executes an opening operation on the shared disk, the generated opening version number is incremented by a preset step length, such as: 1.

optionally, the server information includes an IP address of each server to which the divided segment of the shared disk is allocated.

Step 302: and the client requests the server where the segment of the shared disk needing to be operated is located for I/O operation according to the information of the server where the shared disk is located by using the obtained opening version information.

It should be noted that, for the client, since the configuration information for creating the shared disk is known, the client knows the correspondence between each segment of the shared disk and the server.

In this step, when initiating an I/O operation to the server, the client sends the opening version information obtained when opening the shared disk to the server at the same time, so that the server realizes the simultaneous operation of different clients on the shared disk according to the opening version information.

In the application, the session control information including the opening version information of all the client opening operations is recorded in the controller, and the recorded session control information including the opening version information is updated to the server, the I/O operation request of the client can be carried out based on the opening version information, and the server can check the legality of the client according to the version information, so that a plurality of clients can simultaneously operate the same shared disk, and illegal I/O operation requests are avoided.

The present application also provides a computer-readable storage medium storing computer-executable instructions for performing any of the distributed storage methods described above with reference to fig. 3.

The present application also provides an apparatus for implementing distributed shared storage, including a memory and a processor, where the memory stores therein any one of the instructions described above in fig. 3 that can be executed by the processor.

Fig. 4 is a schematic flowchart of a third embodiment of the distributed storage method of the present application, as shown in fig. 4, including:

step 400: the server receives and saves the session control information including the open version information.

The session control information further includes: the unique identification of the client side for opening the shared disk and the IP address of the client side for opening the shared disk.

Step 401: and the server receives the I/O operation request from the client, determines that the opening version information carried in the I/O operation request is stored, and allows the I/O operation of the client.

Optionally, if the server determines that the server does not store the open version information carried in the I/O operation request, the I/O operation request is considered to be illegal, an error may be returned, and the I/O operation of the client is not allowed.

In the application, the session control information including the opening version information of all the client opening operations is recorded in the controller, and the recorded session control information including the opening version information is updated to the server, so that the server knows the legal client information, and only a disk on the client operation server opened in the controller is legal, thereby realizing that a plurality of clients simultaneously operate the same shared disk, and avoiding illegal I/O operation requests.

By adopting the method for realizing distributed shared storage provided by the application, after the virtual machine supports the shared disk, some high-availability architectures can realize the characteristics of multiple concurrency, high performance, high reliability and the like based on the disk of the sharing mode, such as: the implementation of the Oracle RAC database high-availability architecture commonly used by government, enterprise and financial industry customers.

When a network error occurs, a problem that different clients read the same disk to obtain different data, that is, a problem of data inconsistency of multiple clients, is caused, as shown in fig. 5, based on the shared storage implementation provided by the present application, it is assumed that two clients are as shown in fig. 5, and a segment is opened on the Server1 by the Client1 and the Client2 at the same time. If the network is in error, which causes the Client2 to disconnect, the network partition needs to be performed again, at this time, the Client1 and the Server1 are divided into the same area, and it is assumed that the Master schedule schedules the Segment from the Server1 to the Server2 for loading. After the Client2 reconnects, it will re-initiate an open request to the controller, so as to re-obtain the open version information and the Server information where the shared disk is located, that is, the Client2 obtains the Server information after the network partition at this time, and thus it is sensed that the Segment is migrated to the Server 2.

In this case, since the Client1 does not reinitiate the open request, the read/write operation of the Client1 will be performed with respect to the Server1, and the read/write operation of the Client2 will naturally be performed with respect to the Server 2. Since all the Server sides cache the index of the data in the memory, assuming that the original data block a has data a, the Client2 can normally perform read-write operation on the data block migrated to the Server2, taking the example that the Client2 writes data b into the data block a and updates the index, because the Client1 still reads the old data a or the old data a according to the old index in the memory at this time in the Server 1. As can be seen, two clients perform read operations on the same data block, but obtain different data, which results in the problem that different clients read the same disk to obtain different data.

Optionally, in order to ensure consistency of data obtained by reading the same disk by different clients, when a client initiates a read operation and before the read operation is performed, the method shown in fig. 4 in this application further includes:

calculating a difference value between the current time and lease start time by a Segment (Segment) needing to be operated on the server, judging whether the calculated difference value exceeds a preset lease duration T, if the difference value exceeds the lease duration T, sending a false write operation to the Segment along with a false write operation of the Segment to judge whether the Segment needing to be operated in the shared disk is migrated, and returning a result to the client by the read operation when the Segment is not migrated;

and if the difference does not exceed the lease time length T, the client side continues to execute the reading operation.

Optionally, the lease start time is a write down time for each successful write operation of the Segment (including normal write operations and lease-triggered dummy write operations).

Optionally, the determining whether the segment needing to be operated in the shared disk is migrated includes:

if the false write request returns success, the Segment needing to be operated is not migrated, and the read operation returns a result to the client; and the update lease start time is the current write start time;

if the false write request fails, the Segment which needs to be operated is preempted, the read operation is ended, and the server returns that the read request fails.

Alternatively, the dummy write operation may be to write a small block of probe data without updating the data index.

It should be noted that, in addition to the false write operation, the normal write operation sent by the client may also achieve the purpose of continuation. The lease start time is also updated after a normal write operation is successful. This has the advantage that if the user has both read and write requests, there is no need to use additional dummy write operations to complete the continuation.

The inventors have found that after Segment is migrated, read requests to read the old file are allowed, but when write requests are performed on the old file, the previously written file has been made unwritable. The inventor of the application skillfully utilizes the point, and judges whether Segment needing operation is migrated or not through a false write request. Meanwhile, the false write request is executed when the difference value between the current time for initiating the read request and the lease start time exceeds the preset lease duration T, so that the effectiveness of the scheme for avoiding the problem that different clients read the same disk to obtain different data is ensured.

It should be noted that, after the lease expires, the read operation and the false write operation are issued simultaneously, that is, are parallel, but the result returned by the read operation to the client needs to be returned after the result of the false write operation is returned.

When the migrated Segment is loaded on the new device, after the old file is set as unwritable, the service can be provided after waiting for the lease duration T. Thus, this waiting for the lease duration T ensures that old data is not read, thereby allowing a false write operation to be performed only 1 time at most within the lease duration T.

The present application also provides a computer-readable storage medium storing computer-executable instructions for performing any of the distributed storage methods described above with reference to fig. 4.

The present application further provides an apparatus for implementing distributed shared storage, including a memory and a processor, where the memory stores therein any one of the instructions described above in fig. 4 that can be executed by the processor.

Fig. 6 is a schematic structural diagram of a first embodiment of an apparatus for implementing distributed shared storage according to the present application, and as shown in fig. 6, the apparatus may be disposed in a controller, and includes: the device comprises a recording module and a first processing module; wherein the content of the first and second substances,

the recording module is used for recording the session control information comprising the generated opening version information when the shared disk is opened;

the first processing module is used for returning the generated opening version information and the information of the server where the shared disk is located to the client; and sending the recorded session control information to a server where the shared disk is located according to a preset synchronization strategy, so that the server can realize the simultaneous operation of different clients on the shared disk according to the version opening information in the session control information.

Optionally, the apparatus shown in fig. 6 further comprises:

the first receiving module is used for receiving a creating request for creating the shared disk from the client;

a creation module: creating a disk and marking the created disk as a shared disk; dividing the shared disk into N segments according to preset configuration information, and distributing the N segments to M servers for loading; wherein N, M is an integer greater than or equal to 1 and N is greater than or equal to M.

Fig. 7 is a schematic structural diagram of a second embodiment of an apparatus for implementing distributed shared storage according to the present application, and as shown in fig. 7, the apparatus may be disposed in a client, and includes: the second receiving module and the second processing module; wherein the content of the first and second substances,

and the second receiving module is used for requesting the controller to open the shared disk and receiving the opening version information returned by the controller and the server information of the shared disk.

And the second processing module is used for requesting I/O operation to the server where the segment of the shared disk needing to be operated is located according to the information of the server where the shared disk is located by utilizing the obtained opening version information.

Optionally, the second processing module is further configured to: a create request to create the shared disk is sent to the controller to cause the controller to mark the created disk as a shared disk.

Fig. 8 is a schematic structural diagram of a third embodiment of an apparatus for implementing distributed shared storage according to the present application, and as shown in fig. 8, the apparatus may be disposed in a server, and includes: a third receiving module and a third processing module; wherein the content of the first and second substances,

the third receiving module is used for receiving and storing the session control information including the opening version information from the controller;

and the third processing module is used for receiving the I/O operation request from the client, determining that the opening version information carried in the I/O operation request is stored, and allowing the I/O operation of the client.

Optionally, the third processing module is further configured to: and determining that the opening version information carried in the I/O operation request is not stored, and then considering that the I/O operation request is illegal, returning an error and not allowing the I/O operation of the client.

Optionally, in order to ensure consistency of data obtained by reading the same disk by different clients, when the client initiates a read operation, before the server performs the read operation, the third processing module is further configured to:

calculating the difference between the current time and lease start time, judging whether the calculated difference exceeds a preset lease duration T, if the difference exceeds the lease duration T, sending a false write operation to the Segment needing to be operated to judge whether the Segment is migrated, and returning a result to the client only by the read operation when the Segment is not migrated;

if the difference does not exceed the lease time period T, the read operation continues.

Optionally, the determining whether the segment needing to be operated in the shared disk is migrated includes:

if the false write request returns success, the Segment needing to be operated is not migrated, and the read operation returns a result to the client; and the update lease start time is the current write start time;

if the false write request fails, the Segment which needs to be operated is preempted, the read operation is ended, and the read request failure is returned to the client.

Although the embodiments disclosed in the present application are described above, the descriptions are only for the convenience of understanding the present application, and are not intended to limit the present application. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the disclosure as defined by the appended claims.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于区块链技术的数据存储方法及系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类