Dynamic balancing method, system and equipment for database instances and storage medium

By confirming health status abnormalities in the cloud database, creating new instances and synchronizing data, uninstalling and mounting dynamic IPs, and combining middleware management request routing, the business interruption caused by dynamic IP migration in the cloud database MySQL load balancing is solved, and the automated management of business continuity and load balancing is achieved.

CN120492142APending Publication Date: 2025-08-15SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510478662.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

In the load balancing scenario of cloud database MySQL, the dynamic IP of the new instance is different from the original instance, resulting in client service interruption when migrating services. The existing technology cannot effectively solve the problem of dynamic IP migration.

Method used

Provide a dynamic balance method for database instances. By confirming the health status abnormality of the current instance, creating a new instance and synchronizing data, turning off disaster recovery monitoring during the switching of dynamic IP, uninstalling and adding dynamic IP to the user network card of the new instance, using network management tools to control the mounting of dynamic IP, and combining middleware to realize the health status management of request routing and instance groups.

Benefits of technology

It realizes automatic management of dynamic IP switching of cloud databases, ensures business continuity in load balancing scenarios, reduces the risk of manual configuration errors, and improves the efficiency and reliability of load balancing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120492142A_ABST
    Figure CN120492142A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of databases, and particularly provides a dynamic balancing method, system and equipment for database instances and a storage medium, and the method comprises the following steps: confirming that the health state of a current instance is abnormal, creating a new instance, and carrying out data synchronization between the current instance and the new instance; closing disaster recovery monitoring on the current instance and the new instance during the dynamic IP switching period; unloading the dynamic IP to be switched from the user network card of the current instance, and synchronously deleting the dynamic IP from the available address pair data of the user network card; and adding the dynamic IP to available address pair data of the user network card of the new instance, and controlling the user network card of the new instance to mount the dynamic IP by using a network management tool. According to the invention, automatic management of the cloud database and switching of the dynamic IP can be realized, the service continuity in a load balancing scene is ensured, and the misoperation risk of manual configuration of the dynamic IP is reduced at the same time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of databases, and in particular relates to a dynamic balancing method, system, device and storage medium for a database instance. Background Art

[0002] As business expands and data volumes increase, the cloud database MySQL instance becomes overloaded, leading to query delays and reduced processing power. To improve service quality, it's necessary to build new instances to offload the pressure from the original instances. These new instances can use different disk types than the original ones.

[0003] However, the new instance has a different dynamic IP address than the original instance, and migrating services would cause client interruption. Therefore, to improve client service continuity, the dynamic IP address of the original instance needs to be migrated to the new instance. However, if the dynamic IP address is currently used by a cloud database MySQL instance, it cannot be selected when creating a new instance.

[0004] Based on this, the present application provides a dynamic balancing method for a database instance to address the problem of user service interruption in an instance load balancing scenario. Summary of the Invention

[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a method, system, device and storage medium for dynamic balancing of database instances to solve the above-mentioned technical problems.

[0006] In a first aspect, the present invention provides a method for dynamically balancing a database instance, comprising: Confirm that the health status of the current instance is abnormal, create a new instance, and synchronize data between the current instance and the new instance; Disable disaster recovery monitoring for the current and new instances during the dynamic IP switch period; Uninstall the dynamic IP to be switched from the user network card of the current instance, and simultaneously delete the dynamic IP from the available address pair data of the user network card; The dynamic IP is added to the available address pair data of the user network card of the new instance, and the network management tool is used to control the user network card of the new instance to mount the dynamic IP.

[0007] In an optional embodiment, uninstalling the dynamic IP to be switched from the user network card of the current instance and simultaneously deleting the dynamic IP from the available address pair data of the user network card includes: Use the network management tool to uninstall the dynamic IP to be switched from the user network card of the current instance; Call the OpenStack port command to delete the dynamic IP address of the existing available address data on the user network card of the current instance.

[0008] In an optional embodiment, the method further comprises: If it is confirmed that the current instance has only one dynamic IP, the initial dynamic IP of the new instance is switched to the current instance, where the initial dynamic IP is the dynamic IP allocated when the new instance is created.

[0009] In an optional embodiment, the method further comprises: Add middleware between the cloud database and the client; Synchronously store the health status and dynamic IP of each instance in the cloud database to the middleware; Configuring an instance group in a cloud database, the instance group includes a write instance and multiple read-only instances, and performing data synchronization between the multiple read-only instances and the write instance; Allocate a virtual IP address for the instance group in the cloud database, establish a mapping relationship between the virtual IP address and the dynamic IP address of each instance in the instance group, and synchronously store the mapping relationship in the middleware; The middleware receives a request from a client and routes the request to the instance with the best health status and type matching in the corresponding instance group according to the request type, target virtual IP and the mapping relationship; the request type includes write request and read request.

[0010] In an optional embodiment, the method further comprises: Get the health status of the write instance and the read instance of the instance group; Calculate the average health status of the read instance based on the health status of multiple read instances; If the health status of the write instance exceeds the set status threshold, a new instance is created and some dynamic IP addresses of the write instance are switched to the new instance. If it is confirmed that the average health status of the read instance exceeds a set status threshold, a new read instance is constructed and added to the instance group.

[0011] In an optional embodiment, the method further comprises: The middleware identifies the fault instance according to the health status and deletes the dynamic IP of the fault instance from the mapping relationship.

[0012] In an optional embodiment, before adding the dynamic IP to the available address pair data of the user network card of the new instance, the method further includes: Verify whether the dynamic IP matches the network segment of the user network card of the new instance. If the two match, perform the addition operation. If the two do not match, roll back to the initial state.

[0013] In a second aspect, the present invention provides a dynamic balancing system for database instances, comprising: The instance building module is used to confirm the health status of the current instance is abnormal, create a new instance, and synchronize data between the current instance and the new instance; Disaster recovery configuration module, used to disable disaster recovery monitoring of the current instance and the new instance during the dynamic IP switch; A deletion module is used to uninstall the dynamic IP to be switched from the user network card of the current instance and simultaneously delete the dynamic IP from the available address pair data of the user network card; The adding module is used to add the dynamic IP to the available address pair data of the user network card of the new instance, and use the network management tool to control the user network card of the new instance to mount the dynamic IP.

[0014] According to a third aspect, a device is provided, comprising: A memory for storing a dynamic balancing program of a database instance; The processor is configured to implement the steps of the method for dynamic balancing of database instances provided in the first aspect when executing the dynamic balancing program of the database instance.

[0015] In a fourth aspect, a computer-readable storage medium is provided, on which a dynamic balancing program for a database instance is stored. When the dynamic balancing program for the database instance is executed by a processor, the steps of the dynamic balancing method for the database instance provided in the first aspect are implemented.

[0016] The beneficial effects of the present invention lie in the fact that the method, system, device, and storage medium for dynamically balancing database instances provided herein are achieved by pausing and starting disaster recovery monitoring, uninstalling and mounting dynamic IP addresses, modifying available address pairs of user network cards, and modifying management data in resource orchestration. The present invention enables automatic management and switching of dynamic IP addresses in cloud databases, ensuring business continuity in load balancing scenarios while reducing the risk of errors associated with manually configuring dynamic IP addresses.

[0017] In addition, the present invention has a reliable design principle, a simple structure and a very broad application prospect. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0019] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention.

[0020] Figure 2 is another schematic flow chart of a method according to an embodiment of the present invention.

[0021] Figure 3 FIG. 4 is a schematic block diagram of a system according to an embodiment of the present invention.

[0022] Figure 4 A schematic structural diagram of a device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0023] In order to enable those skilled in the art to better understand the technical solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.

[0025] The key terms appearing in the present invention are explained below.

[0026] MySQL is an open-source relational database management system (RDBMS) based on Structured Query Language (SQL) for storing, managing, and retrieving data. It organizes data in tabular form, supports multi-user and multi-threaded operations, and is suitable for applications of all sizes.

[0027] An instance is a virtualized database service provided by a cloud service provider. It's built on the cloud platform's computing resources (such as CPU, memory, and storage) and runs the MySQL database management system. An instance provides users with a complete database environment, including the database engine, storage, and network configuration. Within this environment, users can create and manage databases, execute SQL queries, and perform other database operations.

[0028] The dynamic balancing method for database instances provided by the embodiment of the present invention is executed by a computer device. Accordingly, the dynamic balancing system for database instances runs in the computer device.

[0029] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention. Figure 1The execution subject may be a dynamic balancing system of a database instance. According to different requirements, the order of the steps in the flowchart may be changed, and some steps may be omitted.

[0030] like Figure 1 As shown, the method includes: S1. Confirm that the health status of the current instance is abnormal, create a new instance, and synchronize data between the current instance and the new instance.

[0031] S101. Confirm that the health status of the current instance is abnormal: Monitoring metrics collection: Use the monitoring tools provided by the cloud platform to continuously collect key metrics for MySQL instances, such as CPU usage, memory usage, disk I / O read / write speeds, number of connections, and number of slow queries. Set reasonable thresholds so that when these metrics exceed the thresholds, health status anomaly alerts are triggered.

[0032] Check the database status: Use MySQL's built-in commands, such as SHOWENGINEINNODBSTATUS, to check the status of the InnoDB storage engine and see if there are any issues with error logs or transaction backlogs. Also, use SHOWPROCESSLIST to view the currently executing SQL statements and determine if there are any long-running or blocked queries.

[0033] Connection test: Try to connect to the MySQL instance from the application side and database management tools (such as Navicat, HeidiSQL, etc.) to check whether the connection is successful and whether the connection response time is within an acceptable range.

[0034] S102. Create a new instance: Select a cloud platform service: Log in to the corresponding cloud platform console.

[0035] Configure instance parameters: Based on business needs, set the specifications of the new instance, including the number of CPU cores, memory size, storage capacity, etc. Select an appropriate MySQL version (such as version 8.0) and set the database character set, storage engine, and other parameters.

[0036] Set up networking and security groups: Configure the appropriate network environment for the new instance, select the same VPC (virtual private cloud) as the current instance, and set security group rules to ensure that the new instance can communicate normally with applications and other related components.

[0037] Create an instance: Click the Create button and wait for the cloud platform to complete the creation of the new instance. This process may take several minutes to dozens of minutes, depending on the instance specifications and the resource status of the cloud platform.

[0038] S103. Synchronize data between the current instance and the new instance: Enable binary logging: Ensure that binary logging is enabled for both the current and new instances. Set log_bin = ON in the MySQL configuration file (such as my.cnf or my.ini) and specify the path and name of the log file.

[0039] Get the binary log position of the current instance: Execute the SHOW MASTER STATUS command on the current instance and record the values of File and Position. These two values will be used as the starting position for the new instance to copy data from the current instance.

[0040] Configure the new instance as a slave: Execute a series of commands on the new instance to configure replication, such as CHANGE MASTER TO MASTER_HOST='IP address of the current instance', MASTER_USER='replication user', MASTER_PASSWORD='replication password', MASTER_LOG_FILE='obtained File value', MASTER_LOG_POS=obtained Position value;, and then execute START SLAVE; to start replication.

[0041] Check the replication status: Run the SHOW SLAVE STATUS\G command on the new instance to check whether Slave_IO_Running and Slave_SQL_Running are both Yes and whether the value of Seconds_Behind_Master is 0 or within the acceptable range to ensure that data synchronization is normal.

[0042] S2. Disable disaster recovery monitoring for the current instance and the new instance during the dynamic IP switch.

[0043] Determine the disaster recovery monitoring system: Identify the disaster recovery monitoring tool currently in use. This may be the cloud platform's built-in disaster recovery monitoring service (such as AWS's Elastic Disaster Recovery) or a third-party monitoring solution (such as Datadog).

[0044] To disable monitoring rules: For cloud platform built-in monitoring services: Log in to the cloud platform console, find the settings page for disaster recovery monitoring, find the monitoring rules for the current instance and the new instance, and pause or disable them. For example, in Alibaba Cloud's Cloud Monitoring, find the corresponding rules on the monitoring alarm rule management page and click the Pause button.

[0045] For third-party monitoring solutions: Log in to the third-party monitoring tool's management interface, find the monitoring tasks associated with the current and new instances, and stop them. For example, in Datadog, find the corresponding tasks in the monitoring task list and click the Stop button.

[0046] Record the operation time: When shutting down disaster recovery monitoring, record the time of the operation so that you can resume monitoring in time after the subsequent operation is completed, and check whether any abnormal situation occurs during the period when monitoring is shut down.

[0047] S3. Uninstall the dynamic IP to be switched from the user network card of the current instance, and simultaneously delete the dynamic IP from the available address pair data of the user network card.

[0048] S301. Log in to the current instance: Use SSH or other remote connection tools (such as PuTTY) to log in to the server where the current MySQL instance is located.

[0049] Uninstall dynamic IP: For Linux systems: Depending on the network configuration tool (such as ifconfig or the ip command), run the corresponding command to uninstall the dynamic IP address. For example, use the ipaddrdel <dynamic IP address> / <subnet mask> dev <network card name> command (where <dynamic IP address> is the IP address to be uninstalled, <subnet mask> is the corresponding subnet mask, and <network card name> is the name of the user network card, such as eth0 or ens33).

[0050] For Windows systems: Open the network connection settings, find the corresponding user network card, right-click it and select Properties. In the Internet Protocol Version 4 (TCP / IPv4) properties, manually delete the dynamic IP address to be uninstalled.

[0051] S302. Update the available address pair data of the user network card: If you use a cloud platform's network management service: Log in to the cloud platform's network management console, find the configuration page for your network interface card, and delete the uninstalled dynamic IP address from the list of available address pairs. For example, in the Tencent Cloud VPC console, find the corresponding network interface card on the network interface card management page and delete the IP address from its IP configuration.

[0052] If it is a local network environment: According to the specific implementation of the local network management system, find the database or configuration file that stores the data of the available address pairs of the user network card, and manually delete the corresponding dynamic IP records.

[0053] S4. Add the dynamic IP to the available address pair data of the user network card of the new instance, and use a network management tool to control the user network card of the new instance to mount the dynamic IP.

[0054] Preferably, the dynamic IP is checked to see if it matches the network segment of the user network card of the new instance. If they match, the add operation is performed; if they do not match, the system rolls back to the initial state.

[0055] S401. Log in to the new instance: Use SSH or other remote connection tools to log in to the server where the new MySQL instance is located.

[0056] Add dynamic IP to the available address pair data of the user network card: If you are using a cloud platform's network management service: Log in to the cloud platform's network management console, find the configuration page for the new instance's user network adapter, and add the dynamic IP address you want to switch to in the list of available address pairs. For example, in Alibaba Cloud's VPC console, you can add the new IP address in the IP configuration page for the network adapter.

[0057] If it is a local network environment: According to the specific implementation of the local network management system, find the database or configuration file that stores the available address pair data of the user network card, and manually add the corresponding dynamic IP record.

[0058] S402. Mount the dynamic IP to the user's network card: For Linux systems: Use the ipaddradd <dynamic IP address> / <subnet mask>dev <network card name> command (where <dynamic IP address> is the IP address to be mounted, <subnet mask> is the corresponding subnet mask, and <network card name> is the name of the user network card, such as eth0 or ens33) to mount the dynamic IP.

[0059] For Windows systems: Open the network connection settings, find the user network card of the new instance, right-click it and select Properties. In the Internet Protocol Version 4 (TCP / IPv4) properties, manually add the dynamic IP address to be mounted.

[0060] Verify that the IP address is successfully attached: Run the ping command on the new instance or use a network testing tool (such as traceroute or tracert) to check whether the new instance can communicate normally with other related components through the newly attached dynamic IP address.

[0061] If the current instance only has one dynamic IP, the new instance's initial dynamic IP address needs to be switched to the current instance. The initial dynamic IP address is the dynamic IP address assigned when the new instance was created. This means that the current instance and the new instance need to switch their dynamic IP addresses.

[0062] Please refer to Figure 2 The steps for dynamic IP switching between MySQL database instances are as follows: (1) Call the cloud database disaster recovery system to suspend the disaster recovery monitoring API, and suspend the disaster recovery monitoring of the two cloud database instances A and B that are about to switch dynamic IP addresses.

[0063] (2) Use the network management tool to uninstall the dynamic IP from the eth0 network card of cloud database instance A and instance B respectively, "ifconfig eth0:1 down".

[0064] (3) Call the OpenStack port command to delete the existing available address data on the user network cards of cloud database instance A and instance B respectively, "OpenStack port unset $port_id --allowed-address ip-address= $VIP,mac-address = '$mac-address'". Where $port_id refers to the user network card ID, $VIP refers to the dynamic IP address, and $mac-address is the MAC address of the dynamic IP address.

[0065] (4) Call the OpenStack port command again, and add the dynamic IP addresses of the original instance B and the original instance A to the available address pairs on the user network cards of the cloud database instance A and instance B respectively, "OpenStack port set $port_id --allowed-address ip-address = $VIP, mac-address = '$mac-address'". Among them, $port_id refers to the user network card ID, $VIP refers to the dynamic IP, and $mac-address is the MAC address of the dynamic IP.

[0066] (5) Use the network management tool to mount dynamic IP B and dynamic IP A to cloud database instance A and instance B respectively, "ifconfig eth0:1 $VIP / network segment", where $VIP refers to the dynamic IP and the network segment is consistent with the eth0 IP.

[0067] (6) Call the resource orchestration data update API to update the dynamic IP and MAC address information of database instance A in the resource orchestration module to dynamic IP B and MAC of dynamic IP B respectively; similarly, update the dynamic IP and MAC address information of database instance B to dynamic IP A and MAC of dynamic IP A respectively.

[0068] (7) Call the cloud database disaster recovery system to suspend the disaster recovery monitoring API, and start the disaster recovery monitoring of the two cloud database instances A and B whose dynamic IPs have been switched.

[0069] This method and system utilizes the Ansible tool and script encapsulation to encapsulate the unmounting and mounting of dynamic IP addresses and the modification of available address pairs on network cards within the Ansible script. This enables automatic dynamic IP switching between two cloud database instances. Compared to manual offline operations for dynamic IP switching between two cloud database instances, this improves efficiency and reduces the risk of misoperation.

[0070] The prerequisites for implementing this method include: the database instance deployed in the public cloud environment can operate normally; the cluster status of the database instance is normal; for the database instance deployed in the public cloud environment, with the help of the Ansible automated operation and maintenance management tool, an automated operation and maintenance script for automatic dynamic IP switching between two cloud database instances is written, which automatically manages the uninstallation and mounting of dynamic IPs and the modification of available address pairs on the network card, thereby realizing the automatic dynamic IP switching function between two cloud database instances.

[0071] On the basis of the above embodiments, in order to further improve the business continuity in the load balancing scenario and realize the client-unaware load balancing, a feasible way is to build a dynamic load balancing solution to perform load balancing in the background without the client being aware of it.

[0072] 1. Solution Architecture Design Core components: Middleware: Serves as a unified entry point between the client and the database cluster, responsible for request routing, health checks, and dynamic IP management.

[0073] Instance group: Contains one write instance (master database) and N read-only instances (slave databases). Data consistency is maintained between the master and slave databases through asynchronous / semi-synchronous replication.

[0074] Virtual IP (VIP): A unique externally exposed IP address that is mapped to a dynamic set of IP addresses for currently healthy write and read-only instances.

[0075] Data flow path: client, VIP (middleware), routing based on request type, write instance / read-only instance.

[0076] 2. Health Check and Status Assessment Health check indicators include: CPU, load 1min (1 minute average load); memory pressure, Mem Usage ;Disk IO latency, IO Wait ; Number of database connections.

[0077] Health status scoring function: Define the instance health score H (range 0 to 1, 1 is the best):

[0078] w1, w2, w3 are weight coefficients, the sum of which is 1; α, β are load threshold adjustment parameters.

[0079] Average health status calculation: For read-only instance groups, calculate the average health status H avg :

[0080] N represents the total number of read-only instances, H i Indicates the health score of the i-th read-only instance.

[0081] 3. Dynamic IP Management and Mapping Virtual IP and dynamic IP mapping table: The middleware maintains the global mapping relationship M: M={VIP→{Write_IP,Read_IP1,Read_IP2,...}} The write instance is associated with only one dynamic IP (master database), and the read-only instance can be dynamically expanded.

[0082] The mapping relationship is persistently stored in a distributed key-value database (such as etcd or ZooKeeper).

[0083] IP address allocation rules: Write instance IP: Fixed binding to the write port of VIP (such as VIP:4306).

[0084] Read-only instance IP: Dynamically assigned to different ports (such as VIP:4307, VIP:4308) based on load.

[0085] 4. Request Routing Strategy Write request routing: Rule: Routes only to the currently healthy write instance IP.

[0086] Failover: If the write instance health score is H <H threshold , the middleware triggers capacity expansion and elects a new master database.

[0087] Read request routing: Weighted round-robin algorithm: Based on the health score H of the read-only instance i Dynamically assign weights:

[0088] Probabilistic selection: The probability that a client request is assigned to the i-th instance is .

[0089] 5. Instance Scaling Logic Expansion trigger conditions: Write instance expansion: If H write <H write_threshold , create a new instance and synchronize data.

[0090] Read-only instance expansion: If H avg <H read_threshold , create a new instance and join it to the cluster.

[0091] Dynamic IP switching process: Create a new instance: Start a pre-configured template instance through the cloud API.

[0092] Data synchronization: master-slave replication or physical backup and recovery (such as MySQL GTID replication).

[0093] IP remapping: Release the original instance dynamic IP: VIP:4307 → Old_Instance_IP; Assign a new instance dynamic IP: VIP:4308 → New_Instance_IP.

[0094] Update the mapping table: The middleware synchronously updates M and notifies the client.

[0095] 6. Fault Detection and Recovery Fault instance determination: Three consecutive health check failures (e.g., CPU load > 90% for 5 minutes).

[0096] The middleware marks the failed instance as unavailable and removes its IP from M.

[0097] VII. Mathematical Model Verification Health score convergence: An exponential decay model is used to ensure that the score quickly reflects the real-time status: H t =λ⋅H t−1 +(1−λ)⋅H current λ is the attenuation coefficient (range 0.8~0.95).

[0098] Load balancing efficiency: Assume that the number of read-only instances is N and the average response time is T avg It can be approximated as:

[0099] When H i When it approaches 1, the system throughput is maximized.

[0100] The client initiates a request through VIP, and the middleware dynamically routes it. Even if there is dynamic IP switching of instances in the instance group, the client is completely unaware of it, which greatly improves business continuity.

[0101] In some embodiments, the dynamic balancing system of the database instance may include multiple functional modules composed of computer program segments. The computer program of each program segment in the dynamic balancing system of the database instance may be stored in the memory of a computer device and executed by at least one processor to perform (see Figure 1 Dynamic balancing of database instances.

[0102] In this embodiment, the dynamic balancing system of the database instance can be divided into multiple functional modules according to the functions it performs, such as Figure 3 As shown. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0103] The instance building module is used to confirm the health status of the current instance is abnormal, create a new instance, and synchronize data between the current instance and the new instance; Disaster recovery configuration module, used to disable disaster recovery monitoring of the current instance and the new instance during the dynamic IP switch; A deletion module is used to uninstall the dynamic IP to be switched from the user network card of the current instance and simultaneously delete the dynamic IP from the available address pair data of the user network card; The adding module is used to add the dynamic IP to the available address pair data of the user network card of the new instance, and use the network management tool to control the user network card of the new instance to mount the dynamic IP.

[0104] Figure 4 The dynamic balancing method of the database instance provided for the embodiment of the present application can be applied to a device. It will be understood by those skilled in the art that the device structure involved in the embodiment of the present invention does not constitute a limitation on the device, and the device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiment of the present invention, the device includes but is not limited to a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present application described and / or required herein.

[0105] The device 400 may include a processor 410, a memory 420, and a communication unit 430. These components communicate via one or more buses. Those skilled in the art will appreciate that the server structure shown in the figure does not limit the present invention. The server structure may be a bus structure or a star structure, and may include more or fewer components than shown, or combine certain components, or arrange the components differently.

[0106] Memory 420 can be used to store execution instructions of processor 410. Memory 420 can be implemented by any type of volatile or non-volatile memory device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk. When the execution instructions in memory 420 are executed by processor 410, device 400 can perform some or all of the steps in the following method embodiments.

[0107] The processor 410 is the control center of the storage device, which uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs and / or modules stored in the memory 420, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 410 can only include a central processing unit (CPU). In an embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.

[0108] The communication unit 430 is configured to establish a communication channel so that the storage device can communicate with other devices, receive user data sent by other devices, or send user data to other devices.

[0109] The present invention also provides a computer storage medium, wherein the computer storage medium may store a program that, when executed, may include some or all of the steps of each embodiment provided by the present invention. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0110] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software and a necessary general-purpose hardware platform. Based on this understanding, the technical solutions in the embodiments of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, among other media capable of storing program code, and includes instructions for causing a computer device (which can be a personal computer, a server, or a second device, a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention.

[0111] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.

[0112] In the several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or modules, and can be electrical, mechanical or other forms.

[0113] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules may be selected to achieve the purpose of the present embodiment according to actual needs.

[0114] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0115] Although the present invention has been described in detail with reference to the accompanying drawings and in conjunction with preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, persons of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and such modifications or substitutions shall be within the scope of the present invention. Any changes or substitutions that can be easily conceived by persons skilled in the art within the technical scope disclosed in the present invention shall be within the scope of protection of the present invention.

Claims

1. [1] A method for dynamic balancing of database instances, characterized in that: include: Confirm that the health status of the current instance is abnormal, create a new instance, and synchronize data between the current instance and the new instance; Disable disaster recovery monitoring for the current and new instances during the dynamic IP switch period; Uninstall the dynamic IP to be switched from the user network card of the current instance, and simultaneously delete the dynamic IP from the available address pair data of the user network card; The dynamic IP is added to the available address pair data of the user network card of the new instance, and the network management tool is used to control the user network card of the new instance to mount the dynamic IP.

2. The method according to claim 1, characterized in that Uninstall the dynamic IP to be switched from the user network card of the current instance and simultaneously delete the dynamic IP from the available address pair data of the user network card, including: Use the network management tool to uninstall the dynamic IP to be switched from the user network card of the current instance; Call the OpenStack port command to delete the dynamic IP address of the existing available address data on the user network card of the current instance.

3. The method according to claim 1, characterized in that The method further comprises: If it is confirmed that the current instance has only one dynamic IP, the initial dynamic IP of the new instance is switched to the current instance, where the initial dynamic IP is the dynamic IP allocated when the new instance is created. 4.[2] The method according to claim 1, characterized in that The method further comprises: Add middleware between the cloud database and the client; Synchronously store the health status and dynamic IP of each instance in the cloud database to the middleware; Configuring an instance group in a cloud database, the instance group includes a write instance and multiple read-only instances, and performing data synchronization between the multiple read-only instances and the write instance; Allocate a virtual IP address for the instance group in the cloud database, establish a mapping relationship between the virtual IP address and the dynamic IP address of each instance in the instance group, and synchronously store the mapping relationship in the middleware; The middleware receives a request from a client and routes the request to the instance with the best health status and type matching in the corresponding instance group according to the request type, target virtual IP and the mapping relationship; the request type includes write request and read request.

5. The method according to claim 4, characterized in that The method further comprises: Get the health status of the write instance and the read instance of the instance group; Calculate the average health status of the read instance based on the health status of multiple read instances; If the health status of the write instance exceeds the set status threshold, a new instance is created and some dynamic IP addresses of the write instance are switched to the new instance. If it is confirmed that the average health status of the read instance exceeds a set status threshold, a new read instance is constructed and added to the instance group.

6. The method according to claim 5, characterized in that The method further comprises: The middleware identifies the fault instance according to the health status and deletes the dynamic IP of the fault instance from the mapping relationship.

7. The method according to claim 1, characterized in that Before adding the dynamic IP address to the available address pair data of the user network card of the new instance, the method further includes: Verify whether the dynamic IP matches the network segment of the user network card of the new instance. If the two match, perform the addition operation. If the two do not match, roll back to the initial state.

8. A dynamic balancing system for database instances, characterized in that: include: The instance building module is used to confirm the health status of the current instance is abnormal, create a new instance, and synchronize data between the current instance and the new instance; Disaster recovery configuration module, used to disable disaster recovery monitoring of the current instance and the new instance during the dynamic IP switch; A deletion module is used to uninstall the dynamic IP to be switched from the user network card of the current instance and simultaneously delete the dynamic IP from the available address pair data of the user network card; The adding module is used to add the dynamic IP to the available address pair data of the user network card of the new instance, and use the network management tool to control the user network card of the new instance to mount the dynamic IP.

9. A device, characterized in that include: A memory for storing a dynamic balancing program of a database instance; A processor, configured to implement the steps of the method for dynamic balancing of a database instance as claimed in any one of claims 1 to 7 when executing the dynamic balancing program of the database instance.

10. A computer-readable storage medium storing a computer program, characterized in that: The readable storage medium stores a dynamic balancing program for a database instance. When the dynamic balancing program for the database instance is executed by a processor, the steps of the dynamic balancing method for a database instance according to any one of claims 1 to 7 are implemented.