Disclosure of Invention
In view of this, the present application provides a data writing method, apparatus, distributed cluster system, device and medium, which improves the data writing efficiency of the distributed cluster.
In the first aspect, a data writing method is provided, and the method is applied to a distributed cluster system, wherein the distributed cluster system comprises a cluster shared storage unit and at least one cluster node;
The method comprises the following steps:
When data to be written of a target cluster node is obtained, the data to be written is written into a cache unit of the target cluster node, and the data to be written is synchronized to the cache units of other cluster nodes through the cache unit of the target cluster node;
And writing the cache data stored in the cache unit of the target cluster node into the cluster sharing storage unit.
In a possible implementation manner, when obtaining data to be written of a target cluster node, writing the data to be written into a cache unit of the target cluster node includes:
when the data to be written of the target cluster node is obtained, determining whether a target cache area corresponding to the data to be written is locked by other cluster nodes in a cache unit of the target node;
And if the target cache area corresponding to the data to be written is not locked, writing the data to be written into the target cache area.
In one possible implementation manner, the target cache area is locked through a target cluster node until the data to be written is written into the target cache area.
In one possible implementation manner, the writing the cache data stored in the cache unit of the target cluster node into the cluster shared storage unit includes:
When the new cache data is written in the cache unit of the target cluster node, the new cache data is written in the cluster shared storage unit, or
And writing the cache data in the cache unit of the target cluster node into the cluster shared storage unit in batches according to a specified period.
In a possible implementation manner, when obtaining data to be written of a target cluster node, writing the data to be written into a cache unit of the target cluster node includes:
when the data to be written of the target cluster node is obtained, the priority of the data to be written is obtained;
and when the priority of the data to be written meets the high priority condition, writing the data to be written into a cache unit of the target cluster node.
In one possible implementation, the method further includes:
and when the priority of the data to be written does not meet the high priority condition, directly writing the data to be written into the cluster shared storage unit.
In a second aspect, a data writing device is provided, and the device is applied to a distributed cluster system, wherein the distributed cluster system comprises a cluster shared storage unit and at least one cluster node, each cluster node is provided with a cache unit, and the device comprises:
The cache writing module is used for writing the data to be written into the cache unit of the target cluster node when the data to be written into the target cluster node is obtained, and synchronizing the data to be written into the cache units of other cluster nodes through the cache unit of the target cluster node;
And the cluster synchronous writing module is used for writing the cache data stored in the cache unit of the target cluster node into the cluster shared storage unit.
In a third aspect, a distributed cluster system is provided, where the distributed cluster system includes a cluster shared storage unit and at least one cluster node, and each cluster node is provided with a cache unit;
And each time when the cache unit on any cluster node has data to be written, the cache unit of the cluster node is used for synchronizing the data to be written to the cache units of other cluster nodes and writing the data to be written to the cluster shared storage unit.
In a fourth aspect, a computer device is provided, the computer device comprising a processor and a memory, the memory storing at least one instruction, the at least one instruction being loaded and executed by the processor to implement the data writing method described above.
In a fifth aspect, a computer readable storage medium having stored therein at least one instruction loaded and executed by a processor to implement the data writing method described above is provided.
In a sixth aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions so that the computer device performs the data writing method.
The technical scheme provided by the application can comprise the following beneficial effects:
In the application, a buffer memory unit is arranged on each cluster node in the distributed cluster system, when the target cluster node generates the data to be written in the cluster shared memory unit, the data to be written in is firstly written in the buffer memory unit of the target cluster node, at the moment, the buffer memory unit of the target cluster node synchronizes the data to be written in to the buffer memory units of other cluster nodes, the consistency of the buffer memory data is ensured, and the buffer memory unit of the target cluster node also writes the data to be written in to the cluster shared memory unit, so as to realize the data sharing among the cluster nodes. According to the scheme, the cache units are arranged on the local nodes, the data among the cache units are synchronized, the caches of the nodes in the distributed cluster are always in a synchronous state, the problems of data synchronization delay and conflict in the distributed cluster system are reduced, and the writing speed of writing the data to be written into the cluster shared storage unit through the cache units is higher, so that the overall writing performance of the system is improved.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the description of the embodiments of the present application, the term "corresponding" may indicate that there is a direct correspondence or an indirect correspondence between the two, or may indicate that there is an association between the two, or may indicate a relationship between the two and the indicated, configured, etc.
Fig. 1 is a schematic diagram illustrating a distributed cluster system architecture according to an exemplary embodiment. The distributed cluster system comprises a cluster shared storage unit and at least one cluster node, wherein each cluster node is provided with a cache unit;
And each time when the cache unit on any cluster node has data to be written, the cache unit of the cluster node is used for synchronizing the data to be written to the cache units of other cluster nodes and writing the data to be written to the cluster shared storage unit.
In the distributed cluster system, each cluster node is provided with the cache unit, and the cache unit can rapidly respond to the read-write request at the moment, so that direct access to the cluster shared storage unit is reduced. Alternatively, nvme or SSD disks may be used as the cache unit for each cluster node in the embodiment of the application. In a frequent random write operation scenario, the performance of directly writing to a low-speed device (such as an HDD) is poor because the seek time and write latency of the hard disk are large. By introducing a cache unit into the cache, data may be written to the cache unit (NVMe or SSD) first, and then written to the low-speed device in batches or stepwise by the cache unit. In this way, the cache acceleration module can absorb a large number of random write operations, thereby improving overall performance.
With low latency, high throughput local high speed block storage devices, read and write operations can be significantly accelerated for low speed block devices, thereby alleviating performance bottlenecks of low speed block devices. Particularly when handling frequent random write operations, the cache unit may exhibit a very high efficiency. However, the buffer memory unit alone can only solve the performance problem of local low-speed block storage, but cannot accelerate the performance of the cluster storage device.
Therefore, in the embodiment of the application, the data synchronization and mirroring between different nodes are allowed in the distributed cluster system. When the cache unit of one cluster node updates data, it is necessary to ensure that the changes are synchronized in the cache units of other nodes, thereby ensuring the consistency of the data among different cluster nodes. At the moment, the caches of all cluster nodes can cooperate together to realize real-time sharing and consistency of data. This enables read and write operations of the various nodes to efficiently utilize the respective caches, speeding up access to the shared storage device.
Optionally, in the embodiment of the present application, each cluster node in the distributed cluster may construct a buffer unit on each cluster node as a real-time synchronization block storage device for data between cluster nodes based on DRBD (distributed replication block device, distributed replication block device scheme). The DRBD is a software-based network distributed copy block device scheme, and performs mirror copy on data blocks among a plurality of physical nodes through a multi-node network real-time data synchronization mechanism, so that high availability and data fault tolerance are provided.
In the embodiment of the application, each cluster node can realize the synchronization of the data blocks among the cache units of each cluster node based on DRDB functions. In the embodiment of the application, the data writing mode adopted by the distributed cluster is a multi-node parallel writing operation mode, in the mode, if a certain cluster node writes data into a cache unit, the write exclusive operation on the cache unit can be realized through a lock, namely, when the cluster node writes data into the cache unit, the resources (namely, part of cache areas in the cache unit) which are needed to be occupied by the cluster node in the cache unit are locked, at the moment, only the cluster node can access the part of cache areas, and when the writing operation of the cluster node is completed, the locking is released, and at the moment, other cluster nodes are allowed to access the resources, so that the integrity of the data is ensured.
Fig. 2 is a method flow diagram illustrating a method of writing data according to an example embodiment. The method is performed by a computer device, which may be a cluster node in a distributed cluster system as shown in fig. 1. As shown in fig. 2, the data writing method may include the steps of:
step 201, when the data to be written of the target cluster node is obtained, writing the data to be written into a cache unit of the target cluster node, and synchronizing the data to be written into the cache units of other cluster nodes through the cache unit of the target cluster node.
In the embodiment of the application, when the target cluster node receives the data to be written, the data is written into a local cache unit. And then, the cache unit of the target cluster node synchronizes the data to be written to the cache units of all other cluster nodes (according to the DRBD function), so that the cache units of all the nodes are ensured to obtain the latest data, and the consistency of the data among all the cluster nodes is ensured.
Step 202, writing the cache data stored in the cache unit of the target cluster node into the cluster shared storage unit.
Because the cluster sharing storage unit in the distributed cluster system has each node storage area mapped with each cluster node, namely, the cluster sharing storage unit can be considered to store data of each cluster node, at the moment, the cluster node can acquire the data of any cluster node in the distributed cluster by accessing the cluster sharing storage unit, and the node storage area mapped with each cluster node is arranged in the cluster sharing storage unit to form the cluster sharing file system.
In the distributed cluster architecture shown in fig. 1, in each cluster node, a (node storage area in) cluster shared storage unit is bound with a cache unit, and if a target cluster node needs to write data into the cluster shared storage unit, the target cluster node can write the data into the cache unit first, so as to write the data into the cluster shared storage unit through the cache unit. In the above process, the target cluster node may also synchronize its own cache unit with the cache units of other cluster nodes (for example, by implementing a DRBD function). Therefore, in the scheme, the data to be written is preferentially written into the cache unit, the writing performance is greatly improved, a redundancy protection mechanism is realized in the scheme, the redundancy protection of the cached writing data can be realized, when a single node in the mirrored data is in failure, other nodes can take over seamlessly, the continuity of service is realized, and the effective cross-node HA protection is provided for the writing data.
In summary, in the data writing process of the distributed cluster system, when the target cluster node generates the data to be written into the cluster shared storage unit, the data to be written into the target cluster node is written into the cache unit of the target cluster node, at this time, the cache unit of the target cluster node synchronizes the data to be written into the cache units of other cluster nodes, the consistency of the cache data is ensured, and the cache unit of the target cluster node also writes the data to be written into the cluster shared storage unit, so as to realize data sharing among the cluster nodes. According to the scheme, the cache units are arranged on the local nodes, the data among the cache units are synchronized, the caches of the nodes in the distributed cluster are always in a synchronous state, the problems of data synchronization delay and conflict in the distributed cluster system are reduced, and the writing speed of writing the data to be written into the cluster shared storage unit through the cache units is higher, so that the overall writing performance of the system is improved.
Fig. 3 is a method flow diagram illustrating a method of writing data according to an example embodiment. The method is performed by a computer device, which may be a cluster node in a distributed cluster system as shown in fig. 1. As shown in fig. 3, the data writing method may include the steps of:
Step 301, when the data to be written of the target cluster node is obtained, writing the data to be written into a cache unit of the target cluster node. And synchronizing the data to be written to the cache units of other cluster nodes through the cache units of the target cluster nodes.
Optionally, in the embodiment of the application, when the data to be written of the target cluster node is obtained, the priority of the data to be written is obtained, and when the priority of the data to be written meets the high priority condition, the data to be written is written into the cache unit of the target cluster node.
That is, in the distributed cluster system as shown in fig. 1, even if a buffer unit is provided for acceleration of data writing, not all data needs to be written at an acceleration using the buffer unit. If the data volume generated by the APP or VM in each cluster node is large, the cache unit is used to perform acceleration writing on all the data, which may increase the load of the cache unit or the shared cache unit in the distributed cluster system. Therefore, in the embodiment of the application, the priority of the data to be written can be judged, and only when the priority of the data to be written meets the high priority condition, the data to be written is high in delay requirement and needs to be written into the cluster shared storage unit preferentially, and at the moment, the data to be written with high priority is written into the cache unit of the target cluster node, so that the writing acceleration processing is performed through the cache unit.
Correspondingly, when the priority of the data to be written does not meet the high priority condition, the data to be written is directly written into the cluster shared storage unit. If the priority of the data to be written does not meet the high priority condition, the data to be written is directly written into the cluster shared storage unit through the IO request, so that the load of the cache unit is reduced.
In one possible implementation, the cluster node may determine the priority of the data to be written according to an application that generates the data to be written. At this time, there is a priority level of APP or VM in the cluster node, for example, an application of a communication class, which has very high time efficiency requirement, and at this time, the application (for example, APP) may be set to an APP with a high priority level, and the data to be written corresponding to the APP may be determined to meet the high priority condition.
In another possible implementation manner, the cluster node may determine the priority of the data to be written according to the type identifier of the data to be written. For example, the data to be written is alarm data, system data or other preset data, and at this time, the data to be written representing the type may affect the normal operation of the applications in the cluster, and needs to be preferentially transmitted to the cluster shared storage unit, so that other cluster nodes can quickly acquire important information.
In step 302, when the data to be written of the target cluster node is obtained, in the cache unit of the target node, it is determined whether the target cache area corresponding to the data to be written is locked by other cluster nodes.
Because the buffer units on each cluster node are data synchronous, each cluster node may have the condition of simultaneously writing data into a buffer area, and data competition and writing errors are easy to cause. Therefore, in order to avoid the above situation, after the data to be written of the target cluster node is obtained, it is required to determine that the data to be written needs to be written into the target cache area of the target unit, determine whether the target cache area is locked by other cluster nodes, and if the target cache area is locked by other cluster nodes, indicate that the target cache area is being occupied by other cluster nodes and perform a write operation, and then wait for the write operation of other cluster nodes to finish.
In step 303, if the target cache area corresponding to the data to be written is not locked, the data to be written is written into the target cache area.
Correspondingly, if the target cache area is not locked, it is indicated that no other cluster nodes occupy the target cache area at this time, and the target cluster nodes can directly write the data to be written into the target cache area.
Furthermore, when the target cluster node writes the data to be written into the target cache region, the target cache region needs to be locked through the target cluster node until the data to be written is written into the target cache region, so that the data to be written cannot be interfered by other cluster nodes when the data to be written is written into the target cache region, and the integrity of the data is guaranteed.
And step 304, writing the cache data stored in the cache unit of the target cluster node into the cluster sharing storage unit.
Optionally, when it is detected that the cache unit of the target cluster node writes new cache data, the new cache data is written into the cluster shared storage unit.
Optionally, the cache data in the cache unit of the target cluster node is written into the cluster shared storage unit in batches according to the specified period.
That is, in the embodiment of the present application, the cache unit of the target cluster node may be configured to write new cache data into the cluster shared storage unit whenever new cache data is detected, or may be configured to periodically write the cache data in the cache unit of the target cluster node into the cluster shared storage unit in batches.
In a possible implementation manner, in an embodiment of the present application, a target cluster node specifically writes cache data stored in a cache unit of the target cluster node into a target node storage area mapped with the target cluster node in the cluster shared storage unit.
In the embodiment of the application, a buffer unit of each cluster node can adopt nvme or SSD (solid state disk), and the buffer unit of each cluster node can construct a real-time data synchronization block storage device/dev/DRBD among the cluster nodes based on DRBD (distributed replication block device, distributed replication block device scheme), and ensure strong consistency of multiple copies of data.
Specifically, in order to implement the above steps, in the practical application process, on the cache unit in each cluster node, a synchronization block storage device/dev/drbd is constructed (at this time, the data in the synchronization block storage devices/dev/drbd on each cache unit are synchronous), and the formed synchronization block storage device/dev/drbd and the shared block device of each node are bound to a cache acceleration relationship.
At this time, the cluster sharing file system can be constructed by only caching the accelerated block devices/dev/cachedev of each node of the cluster, so that each function in the steps can be realized.
Specifically, an App or a virtual machine VM of each node of the cluster can normally access the cluster shared file system, the data write IO will be preferentially written into the synchronous block storage device/dev/DRBD constructed based on the DRBD, and then the synchronous block storage device can write the data cached by itself into the cluster shared storage unit, that is, into the cluster shared file system.
Therefore, in the system of the distributed cluster shared storage architecture, a write cache acceleration scheme of the DRBD and the cache acceleration unit is added, so that an App or a virtual machine VM of each node of the cluster can normally and mutually reject reading and writing to access a cluster shared file system, data write IO is preferentially written into the DRBD cache write acceleration layer, the performance is greatly improved, the redundant protection mechanism of the DRBD is utilized, the redundant protection of cache write data can be realized, the effective cross-node HA protection is provided for write data, finally, a local cache acceleration module is configured, a user can reasonably utilize a cache optimization configuration item, custom acceleration is performed on specific IO types in a targeted manner, and the storage performance acceleration requirement of specific scenes is better met.
In summary, in the data writing process of the distributed cluster system, when the target cluster node generates the data to be written into the cluster shared storage unit, the data to be written into the target cluster node is written into the cache unit of the target cluster node, at this time, the cache unit of the target cluster node synchronizes the data to be written into the cache units of other cluster nodes, the consistency of the cache data is ensured, and the cache unit of the target cluster node also writes the data to be written into the cluster shared storage unit, so as to realize data sharing among the cluster nodes. According to the scheme, the cache units are arranged on the local nodes, the data among the cache units are synchronized, the caches of the nodes in the distributed cluster are always in a synchronous state, the problems of data synchronization delay and conflict in the distributed cluster system are reduced, and the writing speed of writing the data to be written into the cluster shared storage unit through the cache units is higher, so that the overall writing performance of the system is improved.
The embodiment of the present application further provides a data writing device, which is used for implementing the foregoing embodiments and preferred embodiments, and is not described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
An embodiment of the present application provides a data writing device, and fig. 4 is a schematic structural diagram of the data writing device provided in the embodiment of the present application, where the device includes:
The cache writing module 401 is configured to, when obtaining data to be written of a target cluster node, write the data to be written into a cache unit of the target cluster node, and synchronize the data to be written to cache units of other cluster nodes through the cache unit of the target cluster node;
And the cluster synchronous writing module 402 is configured to write the cache data stored in the cache unit of the target cluster node into the cluster shared storage unit.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The system upgrade apparatus in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application SPECIFIC INTEGRATED Circuit) Circuit, a processor and a memory that execute one or more software or firmware programs, and/or other devices that can provide the above functions.
The embodiment of the invention also provides computer equipment, which is provided with the data writing device shown in the figure 4.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a computer device according to an alternative embodiment of the present invention, and as shown in fig. 5, the computer device includes one or more processors 10, a memory 20, and interfaces for connecting components, including a high-speed interface and a low-speed interface. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the computer device, including instructions stored in or on memory to display graphical information in a graphical user interface on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple computer devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 10 is illustrated in fig. 5.
The processor 10 may be a central processor, a network processor, or a combination thereof. The processor 10 may further include a hardware chip, among others. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform the methods shown in implementing the above embodiments.
The memory 20 may include a storage program area that may store an operating system, application programs required for at least one function, and a storage data area that may store data created according to the use of the computer device, etc. In addition, the memory 20 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 20 may optionally include memory located remotely from processor 10, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The memory 20 may comprise volatile memory, such as random access memory, or nonvolatile memory, such as flash memory, hard disk or solid state disk, or the memory 20 may comprise a combination of the above types of memory.
The computer device also includes a communication interface 30 for the computer device to communicate with other devices or communication networks.
The embodiments of the present invention also provide a computer readable storage medium, and the method according to the embodiments of the present invention described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium may be a magnetic disk, an optical disk, a read-only memory, a random-access memory, a flash memory, a hard disk, a solid state disk, or the like, and further, the storage medium may further include a combination of the above types of memories. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Portions of the present invention may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or aspects in accordance with the present invention by way of operation of the computer. Those skilled in the art will appreciate that the existence of computer program instructions in a computer-readable medium includes, but is not limited to, source files, executable files, installation package files, and the like, and accordingly, the manner in which computer program instructions are executed by a computer includes, but is not limited to, the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled programs, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed programs. Herein, a computer-readable medium may be any available computer-readable storage medium or communication medium that can be accessed by a computer.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.