High-availability database system based on cluster file system and read-write method

By using odd-numbered nodes and virtual nodes based on a clustered file system, the shortcomings of master-slave and three-node modes are addressed, achieving high availability and cost-effectiveness of data across two servers.

CN121833666APending Publication Date: 2026-04-10BEIJING LOONGSTORE TECH
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-31
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In existing technologies, in the master-slave node mode, the slave node can only access data in read-only mode after the master node fails, while the three-node mode adds additional costs, making it difficult to find a balance between ensuring high data availability and reducing costs.

Method used

A high-availability database system based on a clustered file system is adopted. By utilizing an odd number of nodes and virtual node services, and through the mutex lock mechanism of the clustered file system, high data availability can be guaranteed with only two physical servers, reducing the number of servers to two and saving hardware investment.

Benefits of technology

This ensures high data availability across two physical servers, reduces hardware costs for businesses, and guarantees normal business operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833666A_ABST
    Figure CN121833666A_ABST
Patent Text Reader

Abstract

The invention provides a high-availability database system based on a cluster file system and a read-write method, and the database system comprises a database client which is used for receiving an access request and sending the access request to a database server; the database server is used for processing the access request sent by the database client; the number of nodes included in the database server is an odd number, and the database server comprises real nodes and virtual nodes; and the cluster file system is used for processing the request sent by the database server. According to the invention, two physical servers can be deployed, one database record is stored in each physical server, one database record is stored in the cluster file system, and two data can be available when any physical server fails, so that the normal operation of services is ensured. According to the method, the number of servers required for ensuring high availability of the cluster is reduced from at least three to two, so that the hardware investment of an enterprise is saved, and the cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of high-availability database, and particularly relates to a high-availability database system based on a cluster file system and a read-write method. BACKGROUND

[0002] With the rapid development of computer technology and its wide application in various industries, the informatization of internal data of enterprises and institutions is also rapidly developing, and high-availability access (HA) of data is a necessary requirement. These data are usually divided into structured data and unstructured data. In order to ensure the high availability of data, structured data is usually stored in a distributed database system, and unstructured data is stored in a cluster file system. To meet the high-availability requirement of the database, at least two copies of data need to be saved, and a master-slave node technology (hereinafter referred to as master-slave mode) or an odd number of nodes (the number of nodes is greater than or equal to 3, hereinafter referred to as three-node mode) is usually used. The problem of the master-slave mode is that after the failure of the master node, the slave node can only be read-only accessed. The three-node mode will increase the additional cost. SUMMARY

[0003] The application embodiment provides a high-availability database system based on a cluster file system and a read-write method, which reduces the number of servers required for ensuring cluster high availability from at least 3 to 2, saves the investment of enterprises in hardware, and reduces the cost.

[0004] In a first aspect, the application embodiment provides a high-availability database system based on a cluster file system, comprising: a database client, configured to receive an access request and send the access request to a database server; a database server, configured to process the access request sent by the database client; the number of nodes included in the database server is an odd number, and the database server includes real nodes and virtual nodes; a cluster file system, configured to process the request sent by the database server.

[0005] The database server includes a first physical node and a second physical node, the first physical node runs a first real node service and a first virtual node service, and the second physical node runs a second real node service and a second virtual node service; the first real node service and the second real node service are always effective in the running process of the database system; when the first virtual node service obtains a file lock of the cluster file system, the first virtual node service is effective; when the second virtual node service obtains a file lock of the cluster file system, the second virtual node service is effective.

[0006] The master node is used for processing an access request sent by a database client, reading or writing a database record, and synchronizing the database record to the slave node.

[0007] The cluster file system is used to respond to a lock request of the virtual node service and read and write of database content.

[0008] The database client is used to send a read request to the first real node service, and the first real node service is used to return a read request result. The database client is used to send a write request to the first real node service, and the first real node service is used to write a database record and synchronize the database record to the slave node.

[0009] When the first physical node is down, the first real node service and the first virtual node service are disabled, and when the second virtual node service obtains a file lock of the cluster file system, the second virtual node service is enabled. The database client is used to send a read request to the second real node service, and the second real node service is used to return a read request result. The database client is used to send a write request to the second real node service, and the second real node service is used to write a database record and synchronize the database record to the slave node.

[0010] The slave node is used to monitor a state of the master node, and after an exception occurs in the master node, the master node is reselected.

[0011] In a second aspect, the application provides a read-write method of a high-availability database system based on a cluster file system, which is applied to any one of the high-availability database systems based on the cluster file system, and includes the following steps. The database client receives an access request and sends the access request to the database server. The database server processes the access request sent by the database client. The number of nodes included in the database server is odd, and the database server includes real nodes and virtual nodes. The cluster file system processes the request sent by the database server.

[0012] Thirdly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.

[0013] Fourthly, this application provides a computer system including any of the above-mentioned high-availability database systems based on a cluster file system.

[0014] The high-availability database system and read / write method based on a clustered file system in this application have the following advantages: In this application, two physical servers can be deployed, each storing one copy of the database record, and another copy is stored in the cluster file system. If either physical server fails, both copies of the data will be available, thus ensuring the normal operation of the business. This application reduces the number of servers required to guarantee high availability of the cluster from at least three to two, saving enterprises on hardware investment and reducing costs. Attached Figure Description

[0015] Figure 1 This is a schematic diagram of a high-availability database system architecture based on a clustered file system, as described in an embodiment of this application. Figure 2 This is a diagram of a high-availability database system architecture based on a clustered file system, as described in an embodiment of this application. Figure 3 This application provides an embodiment of the read record process for a high-availability database system based on a clustered file system. Figure 1 ; Figure 4 This application provides an embodiment of the write record process for a high-availability database system based on a clustered file system. Figure 1 ; Figure 5 This application provides an embodiment of the read record process for a high-availability database system based on a clustered file system. Figure 2 ; Figure 6 This application provides an embodiment of the write record process for a high-availability database system based on a clustered file system. Figure 2 . Detailed Implementation

[0016] The present application will be further described below with reference to the accompanying drawings and embodiments.

[0017] In the following description, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. The following description provides multiple embodiments of the invention, which can be substituted or combined with each other. Therefore, this application can also be considered to include all possible combinations of the same and / or different embodiments described. Thus, if one embodiment includes features A, B, and C, and another embodiment includes features B and D, then this application should also be considered to include embodiments containing one or more other possible combinations of features A, B, C, and D, even if such embodiments are not explicitly described in the following text.

[0018] like Figure 1 As shown, the high-availability database system based on the cluster file system of this application includes: a database client 10, used to receive access requests and send the access requests to a database server; a database server 20, used to process the access requests sent by the database client; the database server includes an odd number of nodes, including real nodes and virtual nodes; and a cluster file system 30, used to process the requests sent by the database server.

[0019] This application utilizes the mutex locks and data sharing features of a clustered file system to provide a highly available database system, such as... Figure 2 As shown, the high-availability database system in this application adopts a client-server model. Theoretically, a minimum high-availability cluster requires 3 nodes to ensure at least two copies of the data are written, guaranteeing data availability. We use two database nodes as normal service nodes, and additionally create virtual service nodes on these two nodes that are bound to the cluster file system, for a total of 3 nodes. This ensures at least two copies of the data are written during data writing.

[0020] like Figure 2 As shown, the database client is responsible for receiving user database access requests and forwarding them to the database server. Taking two physical nodes as an example, each physical node runs one real node service and one virtual node service. The real node service is active throughout the database operation, while the virtual node service only becomes active after acquiring a file lock in the cluster file system. Since file locks are mutually exclusive, only one virtual node service is active at any given time, thus meeting the odd-number node requirement for high availability scenarios.

[0021] Real node services and virtual node services are analogous to processes in an operating system. Only virtual nodes that acquire a file lock in the clustered file system can join the database cluster with the other two real nodes. Virtual nodes that do not acquire a file lock do not participate in the database cluster. Only after a virtual node that has acquired a file lock releases it due to service interruption or the failure of its host physical node will the virtual nodes that are not participating in the database cluster retry acquiring the file lock. The file lock is a service provided by the clustered file system.

[0022] In some embodiments, such as Figure 2 As shown, the database server 20 includes a first physical node 21 and a second physical node 22. The first physical node 21 runs a first real node service 211 and a first virtual node service 212, while the second physical node 22 runs a second real node service 221 and a second virtual node service 222. The first real node service 211 and the second real node service 221 remain active throughout the database system's operation. The first virtual node service 212 becomes active when it acquires a file lock from the cluster file system; similarly, the second virtual node service 222 becomes active when it acquires a file lock from the cluster file system. A master node and slave nodes are selected from the first real node service 211, the second real node service 221, and the active virtual node services. The master node handles access requests from database clients, reads or writes database records, and synchronizes database records to slave nodes. Slave nodes receive and store data from the master node. The cluster file system is used to respond to lock requests from the virtual node services and to read and write database content.

[0023] Real and virtual nodes are responsible for handling the leader election process; only one leader node will be elected at any given time. The leader node handles CRUD (Create, Read, Update, Delete) requests from clients, reads or writes database records, and synchronizes these records to the slave nodes. Slave nodes receive and store data from the leader node, monitor its status, and restart the leader election process if the leader node encounters an error.

[0024] During the leader election process, a node undergoes three role changes, whether it is a real node or a virtual node: Followers: Completely passive, they cannot send any requests, they only accept and respond to messages from leaders and candidates. The initial state of each node after startup must be that of a follower.

[0025] Candidate: Used to run for a new leader.

[0026] Leader: Handles all requests from clients and replicates node data to all followers. Elected by candidates using a consensus algorithm.

[0027] All nodes start as followers. The candidate node is an intermediary; after the election, if it fails, it reverts to a follower; if it succeeds, it becomes the leader. Virtual nodes can only participate in the election after acquiring the cluster file system lock. The node that wins the leader role becomes the master node, and the nodes that win the follower role become slave nodes.

[0028] like Figures 3-4 As shown, the process of reading and writing records is described using two physical nodes N1 and N2. N1 runs real node service R1 and virtual node service V1, while N2 runs real node service R2 and virtual node service V2. R1 is selected as the master node. Physical node N1 is the first physical node, and physical node N2 is the second physical node. Real node service R1 is the first real node service, and virtual node service V1 is the first virtual node service. Real node service R2 is the second real node service, and virtual node service V2 is the second virtual node service.

[0029] like Figures 3-4 As shown, the database server includes a first real node service, a second real node service, and a first virtual node service. The first real node service is the master node, and the second real node service and the first virtual node service are slave nodes. The database client is used to send read requests to the first real node service, and the first real node service is used to return the read request results. The database client is used to send write requests to the first real node service, and the first real node service is used to write database records and synchronize the database records to the slave nodes.

[0030] If node N1 fails, services R1 and V1 will become unavailable. The real node service R2 and the virtual node service V2 on node N2 will then re-elect a leader. The following example assumes that real node R2 is elected as the leader. Figures 5-6 As shown, when the first physical node fails, both the first physical node service and the first virtual node service become ineffective. When the second virtual node service acquires a file lock in the cluster file system, the second virtual node service becomes active. The second physical node service and the second virtual node service on the second physical node then re-elect a master node; the second physical node service is elected as the master node, and the second virtual node service is elected as the slave node. The database client sends read requests to the second physical node service, which returns the read request results. The database client also sends write requests to the second physical node service, which writes database records and synchronizes them to the slave node. The slave node monitors the master node's status and restarts the master node election process after the master node experiences an anomaly.

[0031] In cloud storage systems of medium and large enterprises, a highly available database is typically needed to store a large number of departments and users, as well as their file access permissions. Simultaneously, a clustered file system is required to store user files. This scenario can be achieved using the aforementioned highly available database. Two physical servers are deployed, each storing one copy of the database records, while the clustered file system stores the remaining records. If either physical server fails, both copies of the data remain available, ensuring normal business operations. This application reduces the number of servers required for high availability from at least three to two, saving enterprises on hardware investment and lowering costs.

[0032] This application also provides a method for reading and writing a highly available database system based on a clustered file system, applicable to any of the aforementioned highly available database systems based on a clustered file system, comprising: a database client receiving an access request and sending the access request to a database server; the database server processing the access request sent by the database client; the database server comprising an odd number of nodes, including real nodes and virtual nodes; and the clustered file system processing the request sent by the database server.

[0033] In this application, the implementation of the high-availability database system read / write method based on the clustered file system is basically similar to the implementation of the high-availability database system based on the clustered file system. For relevant details, please refer to the description of the implementation of the high-availability database system based on the clustered file system.

[0034] This application also provides a computer system, including any of the above-mentioned high-availability database systems based on a clustered file system.

[0035] This application also provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, this program implements the steps of the above-described high-availability database system read / write method based on a clustered file system. The computer-readable storage medium may include, but is not limited to, any type of disk, including floppy disks, optical disks, DVDs, CD-ROMs, microdrives, as well as magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic cards or optical cards, nanosystems (including molecular memory ICs), or any type of medium or device suitable for storing instructions and / or data.

[0036] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, and can be electrical, mechanical, or other forms.

[0037] In the various embodiments of the present invention, all functional units can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0038] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A highly available database system based on a clustered file system, characterized in that, include: A database client is used to receive access requests and send the access requests to the database server. A database server is used to process access requests sent by the database client. The database server includes an odd number of nodes, and the database server includes real nodes and virtual nodes; A clustered file system is used to process requests sent by the database server.

2. The high-availability database system based on a clustered file system according to claim 1, characterized in that, The database server includes a first physical node and a second physical node. The first physical node runs a first real node service and a first virtual node service, and the second physical node runs a second real node service and a second virtual node service. The first real node service and the second real node service are always active during the operation of the database system. The first virtual node service becomes active when it acquires a file lock in the cluster file system; the second virtual node service becomes active when it acquires a file lock in the cluster file system.

3. The high-availability database system based on a clustered file system according to claim 2, characterized in that, A master node and slave nodes are selected from the first real node service, the second real node service, and the effective virtual node service; the master node is used to process access requests sent by the database client, read or write database records, and synchronize database records to the slave nodes; The slave node is used to receive and store data from the master node.

4. The high-availability database system based on a clustered file system according to claim 2 or 3, characterized in that, The cluster file system is used to respond to lock requests from virtual node services and to read and write database content.

5. The high-availability database system based on a clustered file system according to claim 2 or 3, characterized in that, The database server includes a first real node service, a second real node service, and a first virtual node service, wherein the first real node service is the master node, and the second real node service and the first virtual node service are slave nodes. The database client is used to send a read request to the first real node service, and the first real node service is used to return the read request result. The database client is used to send write requests to the first real node service, and the first real node service is used to write database records and synchronize the database records to the slave node.

6. The high-availability database system based on a clustered file system according to claim 5, characterized in that, When the first physical node fails, the first physical node service and the first virtual node service become ineffective. When the second virtual node service acquires a file lock in the cluster file system, the second virtual node service becomes effective. The second real node service and the second virtual node service on the second physical node re-elect a master node. The second real node service is elected as the master node, and the second virtual node service is elected as the slave node. The database client is used to send a read request to the second real node service, and the second real node service is used to return the read request result. The database client is used to send write requests to the second real node service, and the second real node service is used to write database records and synchronize the database records to the slave node.

7. The high-availability database system based on a clustered file system according to claim 3, characterized in that, The slave node is used to monitor the status of the master node and restart the master election process after the master node encounters an anomaly.

8. A method for reading and writing a highly available database system based on a clustered file system, characterized in that, Applied to any one of the high-availability database systems based on a clustered file system as described in claims 1-7, comprising: The database client receives the access request and sends the access request to the database server; The database server processes the access requests sent by the database client; the database server includes an odd number of nodes, and includes real nodes and virtual nodes; The cluster file system processes the requests sent by the database server.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method of claim 8.

10. A computer system, characterized in that, Including any one of claims 1-7, a high-availability database system based on a clustered file system.

Citation Information

Patent Citations

  • Distributed lock method for supporting distributed database and distributed database system

    CN104239418A

  • Cluster file system access method and device, equipment and readable storage medium

    CN113704191A

  • Database high availability method, system and device and storage medium

    CN117093425A

  • Database cluster service providing method, program product and readable storage medium

    CN119025591A

  • Server side API for fencing cluster hosts via export access rights

    US7516285B1