A High-Availability Database System Based on Cluster File System and Its Read / Write Method

CN121833666BActive Publication Date: 2026-09-01BEIJING LOONGSTORE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202512046123.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-31
Publication Date
2026-09-01
Estimated Expiration
2045-12-31

AI Technical Summary

Technical Problem

主从模式的问题在于主节点故障后,从节点只能只读访问

Benefits of technology

本申请中,可以部署两台物理服务器,每台上各存储一份数据库记录,集群文件系统里存储一份数据库记录,任何一台物理服务器出现故障,都会有两份数据可用,从而保证了业务的正常运行。本申请将保证集群高可用所需服务器的数量由至少3台减少为2台,节省了企业在硬件上的投入,降低了成本。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833666B_ABST
    Figure CN121833666B_ABST
Patent Text Reader

Abstract

This invention provides a high-availability database system and read / write method based on a clustered file system. The database system includes: a database client for receiving access requests and sending them to a database server; a database server for processing the access requests sent by the database client; the database server includes an odd number of nodes, comprising both real and virtual nodes; and a clustered file system for processing the requests sent by the database server. In this invention, two physical servers can be deployed, each storing one copy of the database record, while the clustered file system stores one copy of the database record. If either physical server fails, both copies of the data will be available, ensuring normal business operation. This invention reduces the number of servers required to ensure high availability from at least three to two, saving enterprises on hardware investment and reducing costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of high availability databases, and more specifically, relates to a high availability database system based on a cluster file system and a read / write method thereon. Background Technology

[0002] With the rapid development of computer technology and its widespread application across various industries, the informatization of internal data in enterprises and institutions is also developing rapidly, and high availability (HA) access to data is an essential requirement. This data is typically divided into structured and unstructured data. To ensure high availability, structured data is usually stored in a distributed database system, while unstructured data is stored in a clustered file system. To address the high availability requirements of databases, at least two copies of the data need to be stored, typically using master-slave node technology (hereinafter referred to as master-slave mode) or an odd number of nodes (three or more nodes, hereinafter referred to as three-node mode). The problem with master-slave mode is that if the master node fails, the slave nodes can only access the data read-only. Three-node mode introduces additional costs. Summary of the Invention

[0003] This application provides a high-availability database system and read / write method based on a clustered file system, which reduces the number of servers required to ensure high availability of the cluster from at least 3 to 2, saving enterprises investment in hardware and reducing costs.

[0004] In a first aspect, embodiments of this application provide a highly available database system based on a clustered file system, including: 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, including real nodes and virtual nodes; A clustered file system is used to process requests 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, while 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, and the second virtual node service becomes active when it acquires a file lock in the cluster file system.

[0006] Among them, a master node and a slave node 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 nodes are used to receive data synchronization from the master node and save it.

[0007] The cluster file system is used to respond to lock requests from virtual node services and to read and write database content.

[0008] 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 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 nodes.

[0009] Specifically, when the first physical node fails, the first real 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, with the second real node service being elected as the master node and the second virtual node service as the slave node. The database client is used to send read requests 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.

[0010] 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.

[0011] Secondly, this application 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, including: 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.

[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 Figure 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 Figure 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. Figure 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 may be combined, or integrated into another system, or some features may be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed may be through some interfaces, indirect coupling or communication connection of devices or units, and may 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. 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, while 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, and the second virtual node service becomes active when it acquires a file lock in the cluster file system. Since a file system lock can only be acquired by one virtual node at a time, at most one virtual node will be active at any given time.

2. The high-availability database system based on a clustered file system according to claim 1, 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.

3. The high-availability database system based on a clustered file system according to claim 1 or 2, 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.

4. The high-availability database system based on a clustered file system according to claim 1 or 2, 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.

5. The high-availability database system based on a clustered file system according to claim 4, 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.

6. The high-availability database system based on a clustered file system according to claim 2, 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.

7. 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-6, 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.

8. 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 7.

9. A computer system, characterized in that, Including any one of claims 1-6, 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