Cloud desktop master and standby redis database instance cluster configuration method and system
By creating a master and standby Redis database instance on the cloud management platform and using keepalived and drbd to achieve data synchronization and failover, the database performance bottlenecks and high operating costs in the existing technology are solved, and a high availability and low cost database solution is realized.
Patent Information
- Application Number
- CN202510280919.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-11
- Publication Date
- 2025-06-20
AI Technical Summary
In the prior art, when dealing with web applications with high access volume and large-scale data, there are bottlenecks in relational databases in performance, especially in disk I/O, which is difficult to meet the needs of low latency, high concurrency and large-scale cluster management, and at the same time, the operational cost is high.
Through the cloud management platform, connect to the virtualization platform or independent zone, create primary and secondary Redis database instances, and use keepalived and drbd to achieve disk kernel-level synchronization and data consistency, configure floating IP management and automatic failure switching, and dynamic injection and modification of cluster configuration.
Real-time synchronization of disk data between Redis database instances and automatic failure switching, reducing the risk of data loss and business interruption caused by single point of failure, improving the stability and high availability of database products, and reducing operating costs.
Smart Images

Figure CN120186014A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of cloud computing and databases, and specifically provides a method and system for configuring a primary and standby Redis database instance cluster for a cloud desktop. Background Art
[0002] In the initial stage of the development of Web applications, relational databases received relatively wide attention and application because at that time, the access and concurrency of Web sites were basically low, and the interaction was also less. Later, with the increase in the number of visits, Web sites using relational databases more or less began to encounter some performance bottlenecks, and the source of the bottleneck was generally on disk I / O. With the further development of Internet technology, various types of applications have emerged in an endless stream, which has led to more performance requirements in the current era of popular cloud computing and big data, mainly reflected in the following four aspects:
[0003] Low-latency read and write speeds: The rapid response of applications can greatly improve user satisfaction;
[0004] Support for massive amounts of data and traffic: For large-scale applications such as search, it is necessary to utilize PB-level data and be able to handle millions of traffic;
[0005] Management of large-scale clusters: System administrators hope that distributed applications can be deployed and managed more simply;
[0006] Consideration of huge operating costs: The IT department hopes to significantly reduce hardware costs, software costs, and labor costs. Summary of the Invention
[0007] The purpose of the present invention is to provide a method and system for configuring a primary and standby Redis database instance cluster for a cloud desktop to solve the problems raised in the above background art.
[0008] To achieve the above purpose, the present invention provides the following technical solution: A method for configuring a primary and standby Redis database instance cluster for a cloud desktop, the method comprising the following steps:
[0009] Connect at least two virtualization platforms or independent regions through a cloud management platform to create two Redis database instances;
[0010] Write the cluster configuration information including the host name information and virtual IP of the primary and standby instances into the virtual machine metadata corresponding to the two Redis database instances at the same time;
[0011] Configure the built-in agent programs of the two Redis database instances to start up when the system boots, and set a scheduled task to periodically obtain the metadata of the virtual machines where they are located;
[0012] Update the cluster configuration information in the local configuration directory according to the obtained metadata, and configure the keepalived and drbd cluster services accordingly;
[0013] After both Redis database instance virtual machine nodes are ready, start the keepalived and drbd cluster services to achieve disk kernel-level synchronization and data consistency between the master and standby nodes.
[0014] Preferably, the method further includes the following steps:
[0015] Use drbd to achieve real-time disk data synchronization between the master and standby Redis database instances;
[0016] Manage the floating IP through keepalived to ensure that user requests always access the currently alive Redis database instance node;
[0017] Configure the notify downgrade script of keepalived. When a master node failure is detected, automatically notify the standby node to start the Redis service and take over the floating IP;
[0018] Configure the notify promote master script of keepalived. When the master node recovers, notify the standby node to stop the service and set the master node as the master node again.
[0019] Preferably, the method further includes the steps:
[0020] When the configuration is updated or the cluster status changes, restart the Redis database instance service to make the new configuration take effect;
[0021] Log the entire configuration process and results for easy problem tracking and configuration status monitoring.
[0022] Preferably, the agent program realizes dynamic injection and modification of the Redis database instance cluster configuration by periodically collecting the metadata of the cloud platform desktop instance, improving the flexibility and maintainability of the database cluster configuration.
[0023] Preferably, the method fills the gap in the lack of master-slave Redis database cluster management capabilities in community database management. By realizing real-time synchronization of disk data and automatic fault switching, it improves the stability and high availability of the Redis database product and reduces the risk of data loss and service interruption caused by a single instance failure.
[0024] A cloud desktop master-slave redis database instance cluster configuration system is applied to a cloud desktop master-slave redis database instance cluster configuration method. The system includes:
[0025] A cloud management platform module for connecting to at least two virtualization platforms or independent regions and creating two Redis database instances;
[0026] A metadata management module for writing cluster configuration information including the host names of the primary and standby instances and the virtual IP into the virtual machine metadata corresponding to the two Redis database instances;
[0027] An agent program module configured inside the two Redis database instances, set to start at boot, and including a scheduled task to periodically obtain the metadata of the virtual machine where it is located and update the cluster configuration information in the local configuration directory according to the obtained metadata;
[0028] A cluster service configuration module for configuring keepalived and drbd cluster services according to the cluster configuration information provided by the agent program module to achieve disk kernel-level synchronization and data consistency between the primary and standby nodes;
[0029] A monitoring and logging module for monitoring changes in the cluster status and recording the configuration process and result logs for easy problem tracking and configuration status monitoring.
[0030] Preferably, the cluster service configuration module further includes:
[0031] A drbd synchronization service sub-module for achieving real-time disk data synchronization between the primary and standby Redis database instances;
[0032] An eepalived floating IP management sub-module for managing the floating IP to ensure that user requests always access the currently alive Redis database instance node;
[0033] A keepalived notification script sub-module including a notify downgrade script and a notify upgrade script, which are respectively used to notify the standby node to start the Redis service and take over the floating IP when the primary node fails, and to notify the standby node to stop the service and set the primary node back as the primary node after the primary node recovers.
[0034] Preferably, the agent program module further includes a configuration update sub-module for restarting the Redis database instance service when the cluster configuration information or the cluster status changes to make the new configuration effective.
[0035] Preferably, the agent program module dynamically injects and modifies the cluster configuration of the Redis database instance by periodically collecting the metadata of the cloud platform desktop instance, improving the flexibility and maintainability of the database cluster configuration.
[0036] Preferably, the system fills the gap in the lack of master-slave Redis database cluster management capabilities in community database management. By implementing real-time synchronization of disk data and automatic failure switching, it improves the stability and high availability of Redis database products, reduces the risk of data loss and service interruption caused by a single instance failure. The system uses virtual machine metadata to achieve dynamic management and logging of configurations, enhancing the transparency and traceability of configurations.
[0037] Compared with the prior art, the beneficial effects of the present invention are:
[0038] The method and system for configuring a master-slave redis database instance cluster of a cloud desktop proposed by the present invention are based on the concept of native OpenStack virtual machine metadata. By regularly collecting and obtaining cloud platform desktop instance metadata using database instances, it realizes injecting cluster configurations and dynamically modifying configurations for redis database instances, improving the configuration flexibility and support for modification of the database cluster.
[0039] Realize real-time synchronization of disk data of 2 redis database instances to ensure that user data will not be lost due to a single instance failure; reduce service interruption and downtime when a single redis cluster or region fails, eliminate the risk of data loss due to a single instance single point of failure, and improve the stability and high availability of the database product. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a flowchart of the method of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0041] In order to clearly and completely describe the objectives, technical solutions of the present invention, and make the advantages more clearly understood, the following further details the embodiments of the present invention with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are part of the embodiments of the present invention, rather than all of the embodiments, and are only used to explain the embodiments of the present invention, not to limit the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.
[0042] Embodiment 1, please refer to Figure 1 , the present invention provides a technical solution: a method for configuring a master-slave redis database instance cluster of a cloud desktop, the method comprising the following steps:
[0043] Complete the following tasks through a database management module and an agent built into the database instance:
[0044] 1. Connect to 2 virtualization platforms or 2 independent regions through the cloud management to create 2 database instances.
[0045] 2. At the same time, write the cluster configuration information composed of the primary and standby instances, such as vip and the host names of the primary and standby instances, into the metadata of the two virtual machine instances.
[0046] 3. Configure the built-in agents of the two database instances to start at boot, and use cron jobs to periodically obtain the metadata of the database virtual machines.
[0047] 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.
[0048] 5. After the primary and standby redis virtual machine nodes are each ready, execute the keepalived and drbd cluster configurations.
[0049] 6. Achieve kernel-level disk synchronization between the primary and standby nodes through drbd, ensuring that the data at both ends 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.
[0050] 7. Configure the notify downgrade script through keepalived. When the primary node fails, execute the notify to start the standby node service.
[0051] 8. Configure the notify promote-primary script through keepalived. When the primary node failure is repaired, execute the notify to stop the standby node service and the primary node promote-primary script. Ensure that the primary node is preferentially used when the primary node is available.
[0052] 9. Restart the redis database instance service to make the configuration take effect dynamically.
[0053] 10. Check the configuration and write the results to the log.
[0054] Embodiment 2, based on Embodiment 1, proposes a cloud desktop primary and standby redis database instance cluster configuration system, which is applied to a cloud desktop primary and standby redis database instance cluster configuration method. The system includes:
[0055] A cloud management platform module for docking at least two virtualization platforms or independent regions and creating two Redis database instances;
[0056] A metadata management module for writing the cluster configuration information including the host names of the primary and standby instances and the virtual IP into the virtual machine metadata corresponding to the two Redis database instances;
[0057] The agent program module is configured inside two Redis database instances, set to start up when the system boots, and includes a scheduled task to cyclically obtain the metadata of the virtual machine it resides in, and update the cluster configuration information in the local configuration directory according to the obtained metadata. It also includes a configuration update sub-module, which is used to restart the Redis database instance service when the cluster configuration information or the cluster status changes to make the new configuration effective. The agent program module realizes the dynamic injection and modification of the Redis database instance cluster configuration by regularly collecting the metadata of the cloud platform desktop instances, improving the flexibility and maintainability of the database cluster configuration.
[0058] The cluster service configuration module is used to configure the keepalived and drbd cluster services according to the cluster configuration information provided by the agent program module, realizing disk kernel-level synchronization and data consistency between the primary and standby nodes; it also includes:
[0059] The drbd synchronization service sub-module is used to realize real-time disk data synchronization between the primary and standby Redis database instances;
[0060] The keepalived floating IP management sub-module is used to manage the floating IP to ensure that user requests always access the currently alive Redis database instance node;
[0061] The keepalived notification script sub-module includes a notify downgrade script and a notify upgrade to master script, which are respectively used to notify the standby node to start the Redis service and take over the floating IP when the primary node fails, and to notify the standby node to stop the service and set the primary node back to the primary node when the primary node recovers.
[0062] The monitoring and logging module is used to monitor the changes in the cluster status and record the configuration process and result logs for easy problem tracking and configuration status monitoring.
[0063] The system fills the gap in the management of the primary and standby Redis database clusters that is missing in the community database management. By realizing real-time disk data synchronization and automatic failure switching, it improves the stability and high availability of the Redis database product, reduces the risk of data loss and service interruption caused by a single instance failure. The system uses virtual machine metadata to realize dynamic management and logging of configurations, enhancing the transparency and traceability of configurations.
[0064] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A cloud desktop master and standby redis database instance cluster configuration method, characterized by: The method comprises the following steps: Connect to at least two virtualization platforms or independent regions through the cloud management platform and create two Redis database instances; Write the cluster configuration information including the host name information and virtual IP of the primary and standby instances into the virtual machine metadata corresponding to the two Redis database instances at the same time; Configure the built-in agent programs of the two Redis database instances to start at boot time, and set a scheduled task to cyclically obtain the metadata of the virtual machines where they are located; Update the cluster configuration information in the local configuration directory according to the obtained metadata, and configure the keepalived and drbd cluster services accordingly; After both Redis database instance virtual machine nodes are ready, start the keepalived and drbd cluster services to achieve disk kernel-level synchronization and data consistency between the active and standby nodes.
2. According to claim 1, a cloud desktop active and standby redis database instance cluster configuration method is characterized in that: The method further comprises the following steps: Use DRBD to achieve real-time synchronization of disk data between the primary and standby Redis database instances; Manage floating IP through keepalived to ensure that user requests always access the currently surviving Redis database instance node; Configure the notify downgrade script of keepalived. When a failure of the primary node is detected, the standby node is automatically notified to start the Redis service and take over the floating IP. Configure the notify script of keepalived to upgrade to the master node. When the master node is restored, notify the standby node to stop the service and set the master node back to the master node.
3. According to a cloud desktop active-standby redis database instance cluster configuration method according to claim 1, it is characterized in that: The method further comprises the steps of: When the configuration is updated or the cluster status changes, restart the Redis database instance service to make the new configuration take effect; The entire configuration process and results are logged to facilitate problem tracking and configuration status monitoring.
4. According to a cloud desktop active-standby redis database instance cluster configuration method according to claim 3, it is characterized in that: The agent program periodically collects metadata of cloud platform desktop instances to dynamically inject and modify the Redis database instance cluster configuration, thereby improving the flexibility and maintainability of the database cluster configuration.
5. According to a cloud desktop active and standby redis database instance cluster configuration method according to claim 1, it is characterized in that: The method fills the gap of active-standby Redis database cluster management capability missing in community database management, improves the stability and high availability of Redis database products by realizing real-time synchronization of disk data and automatic failure switching, and reduces the risk of data loss and business interruption caused by single instance failure.
6. A cloud desktop active and standby redis database instance cluster configuration system, applied to a cloud desktop active and standby redis database instance cluster configuration method according to any one of claims 1 to 5, characterized in that: The system comprises: The cloud management platform module is used to connect to at least two virtualization platforms or independent regions and create two Redis database instances; The metadata management module is used to write the cluster configuration information including the host name information and virtual IP of the primary and standby instances into the virtual machine metadata corresponding to the two Redis database instances; The agent program module is configured inside the two Redis database instances, set to start at boot, and contains a scheduled task to cyclically obtain the metadata of the virtual machine where it is located, and update the cluster configuration information in the local configuration directory based on the obtained metadata; The cluster service configuration module is used to configure the keepalived and drbd cluster services according to the cluster configuration information provided by the agent program module, so as to achieve disk kernel-level synchronization and data consistency between the master and standby nodes; The monitoring and logging module is used to monitor cluster status changes and record configuration process and result logs to facilitate problem tracking and configuration status monitoring.
7. A cloud desktop active / standby redis database instance cluster configuration system according to claim 6, characterized in that: The cluster service configuration module also includes: The drbd synchronization service submodule is used to achieve real-time synchronization of disk data between the primary and standby Redis database instances; The eepalived floating IP management submodule is used to manage floating IPs and ensure that user requests always access the currently surviving Redis database instance node; The keepalived notification script submodule includes the notify downgrade script and the notify upgrade script, which are used to notify the standby node to start the Redis service and take over the floating IP when the primary node fails, and to notify the standby node to stop the service and set the primary node back to the primary node after the primary node recovers.
8. A cloud desktop active / standby redis database instance cluster configuration system according to claim 6, characterized in that: The agent program module also includes a configuration update submodule, which is used to restart the Redis database instance service to make the new configuration take effect when the cluster configuration information or cluster status changes.
9. A cloud desktop active / standby redis database instance cluster configuration system according to claim 8, characterized in that: The agent program module periodically collects metadata of cloud platform desktop instances to dynamically inject and modify the Redis database instance cluster configuration, thereby improving the flexibility and maintainability of the database cluster configuration.
10. A cloud desktop active / standby redis database instance cluster configuration system according to claim 6, characterized in that: The system fills the gap in the management capability of active-standby Redis database clusters in community database management. By achieving real-time synchronization of disk data and automatic fault switching, it improves the stability and high availability of Redis database products and reduces the risk of data loss and business interruption due to single instance failure. The system uses virtual machine metadata to achieve dynamic configuration management and log recording, enhancing the transparency and traceability of configuration.