A method and system for implementing a primary and standby highly available database instance cluster in a cloud desktop
The implementation of a high-availability database instance cluster using OpenStack metadata and internal agents addresses the lack of failover capabilities in traditional database products, ensuring minimal service disruption and data loss through automatic failover and synchronization.
Patent Information
- Application Number
- CN202311014233.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-11
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2043-08-11
AI Technical Summary
Traditional database products lack high availability features, leading to potential long service interruptions and data loss when a site instance fails, which is unacceptable for cloud desktop users, and existing solutions do not adequately support database instance failover capabilities.
Implement a cloud desktop high-availability database instance cluster using OpenStack virtual machine metadata, with internal agent software for periodic data collection, configuration management, and automatic failover, ensuring synchronous disk replication and dynamic IP management between primary and standby instances.
This approach reduces service disruptions and data loss during instance failures, enhancing database stability and availability by enabling seamless failover and real-time data synchronization.
Smart Images

Figure CN117149740B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of cloud computing and databases, and specifically to a method and system for implementing a master-slave highly available database instance cluster for a cloud desktop. Background Art
[0002] At present, most traditional virtualization vendors use the open-source OpenStack, and the community does not provide the management ability for commercial and reliable database products. For cloud desktop users, there is often a similar need to use commercial database products provided by public cloud vendors to relieve the technical burden of small and medium-sized enterprises in creating, configuring, managing, and maintaining databases. However, for traditional database products, it is difficult to ensure the high availability of database instances. When a site instance fails, long-term service interruption and data loss are unacceptable to customers, and manufacturers are required to provide a highly available database cluster. For ordinary database instances, manufacturers often do not have or do not open the ability of the master-slave cluster of database instances. Summary of the Invention
[0003] The technical task of the present invention is to address the above deficiencies and provide a method and system for implementing a master-slave highly available database instance cluster for a cloud desktop, which realizes the master-slave high availability of database instances, reduces access interruption and data loss caused by the failure of a single database instance, and improves the stability and high availability of database products.
[0004] The technical solution adopted by the present invention to solve its technical problems is as follows:
[0005] A method for implementing a master-slave highly available database instance cluster for a cloud desktop, based on the concept of native OpenStack virtual machine metadata, uses database instances to regularly collect and obtain cloud platform desktop instance metadata, and uses OpenStack to manage database instances to achieve the injection and dynamic modification of configurations for database instances;
[0006] Some database cluster configuration information is pre-agreed. When the internal agent software of the database instance detects the cluster configuration, it realizes the configuration of database cluster components. The master-slave database instance disk synchronization, floating IP mounting, service failure notification, and failure switching operations are completed through the database agent.
[0007] The internal agent software of the database instance itself realizes the disk synchronization of the database instance, floating IP access, and controls the automatic conversion of the instance failure to the standby node to provide services, realizing the master-slave high availability of the database instance; reducing access interruption and data loss caused by the failure of a single database instance, and improving the stability and high availability of database products.
[0008] Preferably, an agent is built into the database instance, and the virtual machine metadata is cyclically obtained in the form of a periodic task.
[0009] Preferably, back up the original instance configuration, compare the latest configuration with the old configuration, and execute the configuration update after the configuration changes. Configure the drbd and keepalive high-availability components with the agreed cluster configuration fields.
[0010] Preferably, execute the start and stop processes of drbd and the database service through the notify mechanism of keepalive.
[0011] Preferably, judge the success of the result and output the execution log by executing the check after restarting the database instance.
[0012] Preferably, the implementation process of this method is as follows:
[0013] 1) Connect to two virtualization platforms or two independent regions through the cloud management to create two primary and standby database instances.
[0014] 2) Write the cluster configuration information composed of the two primary and standby instances into the metadata of the two virtual machine instances at the same time.
[0015] 3) The agent configurations of the two database instances are configured to start at boot, and the database virtual machine metadata is cyclically obtained using a scheduled task.
[0016] 4) Back up the latest configuration to the configuration directory, and fill in the keepalived and drbd cluster information according to the primary and standby node information of the cluster.
[0017] 5) Wait for the primary and standby nodes to be ready respectively, and then execute the keepalived and drbd cluster configurations.
[0018] 6) Achieve kernel-level disk synchronization of the primary and standby nodes through drbd, and the data at both ends of the primary and standby is consistent; manage the floating ip through keepalived to enable user requests to be accessed on the surviving node, and the database software data is saved on the drbd synchronized disk.
[0019] 7) Configure the notify downgrade script through keepalived. When the primary node fails, execute the notify standby node to start the service.
[0020] 8) Configure the notify promote primary script through keepalived. When the primary node failure is repaired, execute the notify standby node to stop the service and the primary node promote primary script; to ensure that the primary node is preferentially used when the primary node is available.
[0021] 9) Restart the database instance service to make the configuration take effect dynamically.
[0022] 10) Check the configuration and write the results to the log.
[0023] Preferably, the cluster configuration information composed of the primary and standby 2 instances includes vip and the host names of the primary and standby instances.
[0024] The present invention also claims to protect a cloud desktop primary and standby highly available database instance cluster implementation system, including a database management module and a database instance built-in agent.
[0025] Based on the concept of native OpenStack virtual machine metadata, the database management module uses the database instance to regularly collect and obtain the cloud platform desktop instance metadata, and uses OpenStack to manage the database instance, realizing the injection and dynamic modification of the configuration of the database instance.
[0026] Some database cluster configuration information is agreed in advance. When the internal agent software of the database instance detects the cluster configuration, it realizes the configuration of the database cluster components, completes the disk synchronization of the primary and standby database instances through the database agent, as well as the floating ip mounting, service failure notification and failover operations.
[0027] Preferably, the process of the system to realize the primary and standby highly available database instance cluster is as follows:
[0028] 1) Connect to 2 virtualization platforms or 2 independent regions through the cloud management to create 2 primary and standby database instances.
[0029] 2) Write the cluster configuration information composed of the primary and standby 2 instances to the metadata of 2 virtual machine instances at the same time.
[0030] 3) The built-in agent of the 2 database instances is configured to start at boot, and the database virtual machine metadata is obtained in a loop using a scheduled task.
[0031] 4) Back up the latest configuration to the configuration directory, and fill in the keepalived and drbd cluster information according to the primary and standby node information of the cluster.
[0032] 5) After the primary and standby nodes are ready respectively, execute the keepalived and drbd cluster configurations.
[0033] 6) Realize the kernel-level synchronization of the disks of the primary and standby nodes through drbd, and the data at both ends of the primary and standby is consistent; manage the floating ip through keepalived to ensure that user requests are accessed on the surviving node, and the database software data is saved on the drbd synchronized disk.
[0034] 7), Configure the notify downgrade script through keepalived. When the primary node fails, execute notify to start the service on the standby node;
[0035] 8), Configure the notify promote-to-primary script through keepalived. After the primary node failure is repaired, execute notify to stop the service on the standby node and the primary node promote-to-primary script; to ensure that when the primary node is available, the primary node is preferentially used;
[0036] 9), Restart the database instance service to make the configuration take effect dynamically;
[0037] 10), Check the configuration and write the results to the log.
[0038] The present invention also claims to protect a cloud desktop primary and standby highly available database instance cluster implementation device, including: at least one memory and at least one processor;
[0039] The at least one memory is used to store machine-readable programs;
[0040] The at least one processor is used to call the machine-readable program to implement the above-mentioned cloud desktop primary and standby highly available database instance cluster implementation method.
[0041] Compared with the prior art, the cloud desktop primary and standby highly available database instance cluster implementation method and system of the present invention have the following beneficial effects:
[0042] This method is based on the concept of native OpenStack virtual machine metadata, uses the database instance to regularly collect and obtain the cloud platform desktop instance metadata, realizes injecting the cluster configuration into the database instance and dynamically modifying the configuration, and improves the configuration flexibility and support for modification of the database cluster;
[0043] This method fills the shortcoming of the lack of primary and standby database cluster management capabilities in community database management; realizes real-time synchronization of disk data of two database instances to ensure that user data will not be lost due to the failure of a single instance; reduces business interruption and downtime when a single cluster or region fails, eliminates the risk of data loss due to a single instance single point of failure, and improves the stability and high availability of the database product;
[0044] This method records the log of whether the database instance configuration process is successful, and realizes perceiving the configuration process. Description of the Drawings
[0045] Figure 1 It is a process diagram of the cloud desktop primary and standby highly available database instance cluster implementation method provided by the embodiment of the present invention. Detailed Embodiments
[0046] The present invention will be further described below in conjunction with specific embodiments.
[0047] An embodiment of the present invention provides a method for implementing a cloud desktop primary and standby highly available database instance cluster. Based on the concept of native OpenStack virtual machine metadata, the method uses database instances to regularly collect and obtain cloud platform desktop instance metadata, and uses OpenStack to manage the database instances, so as to implement the injection and dynamic modification of configurations for the database instances.
[0048] Some database cluster configuration information is pre-agreed. When the internal agent software of the database instance detects the cluster configuration, it implements the configuration of the database cluster components. The primary and standby database instance disk synchronization, as well as floating IP mounting, service failure notification, and failure switching operations, are completed through the database agent.
[0049] The internal agent software of the database instance itself realizes the disk synchronization of the database instance, floating IP access, and controls the automatic conversion of the instance failure to the standby node to provide services, achieving the primary and standby high availability of the database instance; reducing the access interruption and data loss caused by the failure of a single database instance, and improving the stability and high availability of the database product.
[0050] The database instance is built-in with an agent, which cyclically obtains virtual machine metadata in the form of periodic tasks.
[0051] Back up the original instance configuration, compare the latest configuration with the old configuration, and execute the configuration update after the configuration changes. Configure the drbd and keepalive high-availability components according to the agreed cluster configuration fields.
[0052] Through the notify mechanism of keepalive, execute the start and stop processes of drbd and the database service.
[0053] The result judgment is achieved by executing the check after restarting the database instance, and the execution log is output.
[0054] As Figure 1 shown, the implementation process of this method is as follows:
[0055] 1) Connect to 2 virtualization platforms or 2 independent regions through the cloud management to create 2 primary and standby database instances.
[0056] 2) Write the cluster configuration information composed of the 2 primary and standby instances, such as vip and the host names of the primary and standby instances, into the metadata of the 2 virtual machine instances at the same time.
[0057] 3) The agent configured in the 2 database instances is set to start at boot, and uses a scheduled task to cyclically obtain the metadata of the database virtual machine.
[0058] 4) Back up the latest configuration to the configuration directory, and fill in the keepalived and drbd cluster information according to the primary and standby node information of the cluster;
[0059] 5) After waiting for the primary and standby nodes to be ready respectively, execute the keepalived and drbd cluster configurations;
[0060] 6) Implement kernel-level disk synchronization between the primary and standby nodes through drbd, so that the data at both ends is consistent; manage the floating IP through keepalived to ensure that user requests are accessed on the surviving node, and the database software data is stored on the drbd synchronized disk;
[0061] 7) Configure the notify downgrade script through keepalived. When the primary node fails, execute the notify to start the service on the standby node;
[0062] 8) Configure the notify promote primary script through keepalived. After the primary node failure is repaired, execute the notify to stop the service on the standby node and the primary node promote primary script; to ensure that the primary node is preferentially used when the primary node is available;
[0063] 9) Restart the database instance service to make the configuration take effect dynamically;
[0064] 10) Check the configuration and write the results to the log.
[0065] The embodiment of the present invention also provides a cloud desktop primary and standby high-availability database instance cluster implementation system, including a database management module and a database instance built-in agent,
[0066] The database management module is based on the concept of native OpenStack virtual machine metadata, regularly collects and obtains cloud platform desktop instance metadata by using the database instance, and uses OpenStack to manage the database instance, so as to realize injecting configuration and dynamically modifying configuration for the database instance;
[0067] Agree on some database cluster configuration information in advance. When the internal agent software of the database instance detects the cluster configuration, implement the configuration of the database cluster components, complete the disk synchronization of the primary and standby database instances through the database agent, as well as floating IP mounting, service failure notification and failure switching operations.
[0068] The database instance built-in agent obtains the virtual machine metadata in a cyclic manner in the form of a periodic task.
[0069] Back up the original instance configuration, compare the latest configuration with the old configuration, and execute the configuration update after the configuration changes. Configure the drbd and keepalive high-availability components according to the agreed cluster configuration fields.
[0070] Through the notify mechanism of keepalive, execute the startup and stop processes of drbd and the database service.
[0071] Judge the success of the result and output the execution log by executing the check after restarting the database instance.
[0072] The process of implementing the master-slave high-availability database instance cluster by this system is as follows:
[0073] 1) Connect to 2 virtualization platforms or 2 independent regions through the cloud management to create 2 master-slave database instances;
[0074] 2) Write the cluster configuration information composed of the 2 master-slave instances into the metadata of the 2 virtual machine instances at the same time;
[0075] 3) The built-in agent of the 2 database instances is configured to start at boot, and the metadata of the database virtual machine is obtained in a loop using a scheduled task;
[0076] 4) Back up the latest configuration to the configuration directory, and fill in the keepalived and drbd cluster information according to the master-slave node information of the cluster;
[0077] 5) After the master and slave nodes are both ready, execute the keepalived and drbd cluster configurations;
[0078] 6) Implement kernel-level disk synchronization between the master and slave nodes through drbd, so that the data at both ends of the master and slave is consistent; manage the floating IP through keepalived to enable user requests to be accessed on the surviving node, and the database software data is stored on the drbd synchronized disk;
[0079] 7) Configure the notify downgrade script through keepalived. When the master node fails, execute notify to start the service on the slave node;
[0080] 8) Configure the notify promote master script through keepalived. When the master node failure is repaired, execute notify to stop the service on the slave node and the master node promote master script; to ensure that the master node is preferentially used when the master node is available;
[0081] 9) Restart the database instance service to make the configuration take effect dynamically;
[0082] 10) Check the configuration and write the results to the log.
[0083] An embodiment of the present invention further provides a device for implementing a cloud desktop primary / standby highly available database instance cluster, including: at least one memory and at least one processor;
[0084] The at least one memory is used for storing machine-readable programs;
[0085] The at least one processor is used for calling the machine-readable programs to implement the method for implementing a cloud desktop primary / standby highly available database instance cluster described in the above embodiment.
[0086] Through the above specific implementation manners, those skilled in the art of the present invention can easily implement the present invention. However, it should be understood that the present invention is not limited to the above specific implementation manners. Based on the disclosed implementation manners, those skilled in the art can arbitrarily combine different technical features to implement different technical solutions.
[0087] Except for the technical features described in the specification, the rest are well-known technologies to those skilled in the art.
Claims
1. A method for implementing a primary and standby highly available database instance cluster for cloud desktops, characterized in that, Based on the concept of native OpenStack virtual machine metadata, the database instance regularly collects and obtains cloud platform desktop instance metadata, and uses OpenStack to manage the database instance to achieve injecting configuration and dynamically modifying the configuration of the database instance; Some database cluster configuration information is agreed in advance. When the internal agent software of the database instance detects the cluster configuration, it realizes the configuration of the database cluster components. Through the database agent, disk synchronization of the primary and standby database instances, as well as floating IP mounting, service failure notification, and failure switching operations are completed; The implementation process of this method is as follows: 1). Connect to 2 virtualization platforms or 2 independent regions through the cloud management to create 2 primary and standby database instances; 2). Write the cluster configuration information composed of the 2 primary and standby instances into the metadata of the 2 virtual machine instances at the same time; 3). The built-in agent configuration of the 2 database instances starts at boot, and uses a scheduled task to loop and obtain the metadata of the database virtual machine; 4). Back up the latest configuration to the configuration directory, and fill in the keepalived and drbd cluster information according to the primary and standby node information of the cluster; 5). Wait for the primary and standby nodes to be ready respectively, and execute the keepalived and drbd cluster configurations; 6). Implement kernel-level disk synchronization of the primary and standby nodes through drbd, and the data at both ends of the primary and standby is consistent; manage the floating IP through keepalived to enable user requests to be accessed on the surviving node, and the database software data is stored on the drbd synchronized disk; 7). Configure the notify downgrade script through keepalived. When the primary node fails, execute notify to start the service on the standby node; 8). Configure the notify promote primary script through keepalived. When the primary node failure is repaired, execute notify to stop the service on the standby node and the primary node promote primary script; to ensure that the primary node is preferentially used when the primary node is available; 9). Restart the database instance service to make the configuration take effect dynamically; 10). Check the configuration and write the results to the log.
2. A method for implementing a primary and standby highly available database instance cluster for cloud desktops according to claim 1, characterized in that, Back up the original instance configuration, compare the latest configuration with the old configuration, and execute the updated configuration when the configuration changes. Configure the drbd and keepalive highly available components according to the agreed cluster configuration fields.
3. A method for implementing a primary and standby highly available database instance cluster for cloud desktops according to claim 1, characterized in that, The result is judged to be successful and the execution log is output by performing a check after restarting the database instance.
4. A method for implementing a primary and standby highly available database instance cluster for cloud desktops according to claim 1, characterized in that, The cluster configuration information composed of the 2 primary and standby instances includes vip and the host names of the primary and standby instances.
5. A system for implementing a primary and standby highly available database instance cluster for cloud desktops, characterized in that, It includes a database management module and a built-in agent for the database instance. Based on the concept of native OpenStack virtual machine metadata, the database management module uses the database instance to periodically collect and obtain the metadata of cloud platform desktop instances, and uses OpenStack to manage the database instance, realizing the injection configuration and dynamic modification of the configuration of the database instance. Some database cluster configuration information is pre-agreed. When the internal agent software of the database instance detects the cluster configuration, it realizes the configuration of the database cluster components. Through the database agent, it completes the disk synchronization of the primary and standby database instances, as well as the floating IP mounting, service failure notification, and failover operations. The process of the system to implement a primary and standby highly available database instance cluster is as follows: 1). Connect to 2 virtualization platforms or 2 independent regions through the cloud management to create 2 primary and standby database instances. 2). Write the cluster configuration information composed of the 2 primary and standby instances into the metadata of the 2 virtual machine instances simultaneously. 3). The built-in agents of the 2 database instances are configured to start at boot, and use scheduled tasks to loop and obtain the metadata of the database virtual machines. 4). Back up the latest configuration to the configuration directory, and fill in the keepalived and drbd cluster information according to the primary and standby node information of the cluster. 5). After the primary and standby nodes are each ready, execute the keepalived and drbd cluster configurations. 6). Realize the kernel-level synchronization of the disks of the primary and standby nodes through drbd, and the data at both ends of the primary and standby is consistent; manage the floating IP through keepalived to enable user requests to access the surviving node, and the database software data is stored on the drbd-synchronized disk. 7). Configure the notify downgrade script through keepalived. When the primary node fails, execute the notify to start the service on the standby node. 8). Configure the notify promote primary script through keepalived. When the primary node failure is repaired, execute the notify to stop the service on the standby node and the promote primary script on the primary node; to ensure that the primary node is preferentially used when the primary node is available. 9). Restart the database instance service to make the configuration take effect dynamically. 10). Check the configuration and write the results to the log.
6. A device for implementing a primary and standby highly available database instance cluster for a cloud desktop, characterized in that it includes: at least one memory and at least one processor; the at least one memory is used for storing machine-readable programs; the at least one processor is used for calling the machine-readable programs to implement the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Data synchronization method for metadata service cluster of cloud storage system
CN104104739A
Cloud desktop hot standby management method, device and system
CN115499296A
Instance creation method and device, electronic equipment and readable storage medium
CN115878587A