Database cluster management method, device, equipment, medium and program product
By monitoring the data synchronization between the host and the synchronous standby machine in the database cluster, and timely detecting and downgrading the data synchronization mode of the synchronous standby machine, the service unavailability problem caused by sudden failures is solved and business processing efficiency is improved.
Patent Information
- Application Number
- CN202411275756.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-09-12
AI Technical Summary
In database clusters, regular detection of synchronous standby machines is difficult to deal with sudden failures, resulting in unavailability of services and low service processing efficiency.
By monitoring data synchronization between the host and the synchronous standby machine, if the host does not receive the heartbeat information feedback from the synchronous standby machine, the configuration information of the synchronous standby machine will be matched with the preset downgrade list, allowing the data synchronization mode to be changed to asynchronous after downgrade model.
It effectively reduces business waiting time, improves business processing efficiency, and avoids unavailability of services caused by synchronous standby downtime.
Smart Images

Figure CN118796923B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing, and more specifically, to a database cluster management method, device, equipment, medium and program product. Background Art
[0002] In a database cluster, to ensure the availability of services, a master-slave deployment method is usually adopted. When a business is triggered, the master node needs to wait for the log synchronization of the synchronous standby node before the business execution is considered completed. However, if the synchronous standby node goes down, it will cause service unavailability or high latency. In related technologies, the synchronous standby is regularly tested to reduce the occurrence of failures.
[0003] In the process of realizing the concept of the present invention, the inventors found that there are at least the following problems in the related technology: regular detection of synchronous standby machines is difficult to cope with sudden failures. In the face of sudden downtime, waiting for the repair of the synchronous standby will cause the service to be unavailable, resulting in low business processing efficiency. Summary of the invention
[0004] In view of this, the present invention provides a database cluster management method, apparatus, device, medium and program product.
[0005] One aspect of the present invention provides a database cluster management method, including: in response to a received business processing request, using a host in a database cluster to provide a service corresponding to the above business processing request; synchronizing the log data generated by the above host when providing the above service to a synchronous standby in the above database cluster; in a case where the above host does not receive the heartbeat information fed back by the above synchronous standby for more than a preset time period, matching the configuration information of the above synchronous standby with a preset downgrade list to obtain a matching result, wherein the above heartbeat information is used to indicate that the above synchronous standby has received the above log data; in a case where the above matching result indicates that the above synchronous standby is allowed to be downgraded, changing the data synchronization mode of the above synchronous standby to an asynchronous mode.
[0006] According to an embodiment of the present invention, when the host fails to receive the heartbeat information fed back by the synchronous standby machine for more than a preset time period, the configuration information of the synchronous standby machine is matched with a preset downgrade list to obtain a matching result, including: when the synchronous standby machine receives the log data, the heartbeat information is sent to the keep-alive module corresponding to the host machine using the keep-alive module corresponding to the synchronous standby machine; when the keep-alive module of the host fails to receive the heartbeat information for more than a preset time period, the configuration information of the synchronous standby machine is sent to the downgrade determination component for processing to obtain the matching result, wherein the preset downgrade list is configured in the downgrade determination component.
[0007] According to an embodiment of the present invention, after changing the data synchronization mode of the above-mentioned synchronous standby machine to the asynchronous mode, it also includes: continuously synchronizing the log data generated by the above-mentioned host to the synchronous standby machine whose data synchronization mode is the above-mentioned asynchronous mode; when the above-mentioned host receives the heartbeat information fed back by the above-mentioned synchronous standby machine, determining the time difference between the moment when the above-mentioned host sends the log data to the above-mentioned synchronous standby machine and the moment when the above-mentioned host receives the above-mentioned heartbeat information; when the above-mentioned time difference is less than the above-mentioned preset time period, restoring the data synchronization mode of the above-mentioned synchronous standby machine to the synchronous mode.
[0008] According to an embodiment of the present invention, the above-mentioned database cluster includes multiple synchronous standby machines and multiple asynchronous standby machines, and the above-mentioned method also includes: when it is determined that the above-mentioned host has an abnormality, determining the standby machine information of each synchronous standby machine in the above-mentioned database cluster, wherein the above-mentioned standby machine information includes the data synchronization mode and the historical change information of the data synchronization mode; based on the above-mentioned standby machine information, filtering the multiple above-mentioned synchronous standby machines to obtain multiple candidate standby machines, wherein the above-mentioned candidate standby machines are synchronous standby machines whose data synchronization mode is the synchronous mode; based on the configuration information of each of the above-mentioned candidate standby machines and the above-mentioned asynchronous standby machines, determining the target standby machine from the multiple above-mentioned candidate standby machines and the multiple above-mentioned asynchronous standby machines; using the master-slave switching component to switch the above-mentioned target standby machine to a new host.
[0009] According to an embodiment of the present invention, based on the above-mentioned standby machine information, the multiple above-mentioned synchronous standby machines are filtered to obtain multiple candidate standby machines, including: according to the data synchronization mode of each of the above-mentioned synchronous standby machines, a plurality of preferred standby machines are screened out from the multiple above-mentioned synchronous standby machines, wherein the above-mentioned preferred standby machine is a synchronous standby machine whose data synchronization mode is the synchronous mode; based on the historical change information of each of the above-mentioned preferred standby machines, a plurality of the above-mentioned candidate standby machines are determined from the multiple above-mentioned preferred standby machines, wherein the above-mentioned candidate standby machines are synchronous standby machines whose data synchronization mode has not been changed in history.
[0010] According to an embodiment of the present invention, the above method also includes: when it is determined that the above new host is an asynchronous standby host, determining the asynchronous log sequence number recorded when the above new host historical synchronization log data, and the host log sequence number recorded when the abnormal host historical synchronization log data occurs; when it is determined that the above host log sequence number is greater than the above asynchronous log sequence number, the log lost data lost during the master-slave switching is recovered to the above new host.
[0011] According to an embodiment of the present invention, the above-mentioned recovering the log loss data lost during the master-slave switching to the above-mentioned new host includes determining the log bifurcation point based on the above-mentioned host log sequence number and the above-mentioned asynchronous log sequence number; based on the above-mentioned log bifurcation point, determining multiple log loss data in the above-mentioned host where the abnormality occurred; utilizing the logical decoding function, generating a log retrieval statement corresponding to the above-mentioned log loss data; in response to the received log retrieval command, triggering the log retrieval component to execute the above-mentioned log retrieval statement to recover the above-mentioned log loss data to the above-mentioned new host.
[0012] Another aspect of the present invention provides a database cluster management device, including: a service provision module, which is used to respond to a received business processing request and use a host in a database cluster to provide a service corresponding to the above business processing request; a data synchronization module, which is used to synchronize the log data generated when the above host provides the above service to the synchronous standby in the above database cluster; an information matching module, which is used to match the configuration information of the above synchronous standby with a preset downgrade list to obtain a matching result when the above host does not receive the heartbeat information fed back by the above synchronous standby for more than a preset time period, wherein the heartbeat information is used to indicate that the above synchronous standby has received the above log data; and a mode change module, which is used to change the data synchronization mode of the above synchronous standby to an asynchronous mode when the above matching result indicates that the above synchronous standby is allowed to be downgraded.
[0013] Another aspect of the present invention provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above method.
[0014] Another aspect of the present invention provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above method when executed.
[0015] Another aspect of the present invention provides a computer program product, the computer program product comprising computer executable instructions, and the instructions are used to implement the above method when executed.
[0016] According to an embodiment of the present invention, during the operation phase of the database cluster, the data synchronization between the host and the synchronous standby is continuously monitored. If the host does not receive the heartbeat information fed back by the synchronous standby for more than a preset time period, it means that the synchronous standby may be down, or there is a problem in the network between the master and the standby. Therefore, the configuration information is matched with the preset downgrade list, and when the matching result indicates that the downgrade of the synchronous standby is allowed, the data synchronization mode of the synchronous standby is changed to asynchronous mode. By changing the data synchronization mode of the synchronous standby, the business no longer needs to wait for the response of the synchronous standby during operation, which effectively reduces the waiting time of the business and improves the processing efficiency of the business. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0018] Figure 1 An exemplary system architecture to which the database cluster management method and apparatus of the present invention can be applied is shown.
[0019] Figure 2 A flow chart of a database cluster management method according to an embodiment of the present invention is shown.
[0020] Figure 3 A schematic diagram of active / standby information feedback in a database cluster management method according to an embodiment of the present invention is shown.
[0021] Figure 4 A schematic diagram of synchronous standby machine degradation in a database cluster management method according to an embodiment of the present invention is shown.
[0022] Figure 5 A schematic diagram of active / standby switching in a database cluster management method according to an embodiment of the present invention is shown.
[0023] Figure 6 A log retrieval schematic diagram of a database cluster management method according to an embodiment of the present invention is shown.
[0024] Figure 7 A block diagram of a database cluster management device according to an embodiment of the present invention is shown.
[0025] Figure 8 A block diagram of an electronic device suitable for implementing a database cluster management method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0026] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.
[0027] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0028] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0029] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0030] In the embodiments of the present invention, the collection, updating, analysis, processing, use, transmission, provision, invention, storage and other aspects of the data involved (for example, including but not limited to user personal information) are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. In particular, necessary measures are taken for user personal information to prevent unauthorized access to user personal information data and maintain the security of user personal information and network security.
[0031] In the embodiment of the present invention, before obtaining or collecting the user's personal information, the user's authorization or consent is obtained.
[0032] In a database cluster, in order to ensure high availability of services, a master-slave deployment method is generally adopted. When the master node fails, one of the slave nodes will be selected to provide services as the new master node. In order to ensure that data is not lost after the switchover, it is necessary to ensure that the data of the selected slave node is completely consistent with that of the master node. This type of slave node is called a synchronous slave node. When a business is triggered, the master node needs to wait for the log synchronization of the synchronous slave node before it can consider the business execution completed. Correspondingly, the slave node that does not need to wait for the log synchronization to be completed is called an asynchronous slave node. However, if the synchronous slave node goes down, or there is a problem with the network between the master and the slave, such as jitter. The user's business will be stuck, resulting in unavailability or high latency of the service, which will bring a relatively poor experience to the user.
[0033] The embodiments of the present invention provide a database cluster management method, apparatus, device, medium and program product. The method includes: in response to a received business processing request, using a host in a database cluster to provide a service corresponding to the business processing request; synchronizing the log data generated when the host provides the service to a synchronous standby in the database cluster; in the case where the host does not receive the heartbeat information fed back by the synchronous standby for more than a preset time period, matching the configuration information of the synchronous standby with a preset downgrade list to obtain a matching result, wherein the heartbeat information is used to indicate that the synchronous standby receives the log data; in the case where the matching result indicates that the synchronous standby is allowed to be downgraded, changing the data synchronization mode of the synchronous standby to an asynchronous mode.
[0034] Figure 1 The following is an exemplary system architecture to which the database cluster management method and apparatus of the present invention can be applied. It should be noted that: Figure 1 The examples shown are merely examples of system architectures to which the embodiments of the present invention may be applied, to help those skilled in the art understand the technical content of the present invention, but do not mean that the embodiments of the present invention may not be used in other devices, systems, environments or scenarios.
[0035] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0036] The user may use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (only for example).
[0037] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0038] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0039] It should be noted that the database cluster management method provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the database cluster management device provided in the embodiment of the present invention can generally be set in the server 105. The database cluster management method provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Correspondingly, the database cluster management device provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Alternatively, the database cluster management method provided in the embodiment of the present invention can also be executed by the terminal device 101, 102, or 103, or can also be executed by other terminal devices different from the terminal device 101, 102, or 103. Correspondingly, the database cluster management device provided in the embodiment of the present invention may also be arranged in the terminal device 101 , 102 , or 103 , or in other terminal devices different from the terminal device 101 , 102 , or 103 .
[0040] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only . According to the implementation requirements, there can be any number of terminal devices, networks and servers.
[0041] Figure 2 A flowchart of a database cluster management method according to an embodiment of the present invention is shown.
[0042] like Figure 2 As shown, the method includes operations S210 to S240.
[0043] In operation S210 , in response to the received business processing request, a host in the database cluster is used to provide a service corresponding to the business processing request.
[0044] In operation S220, log data generated when the host provides services is synchronized to a synchronous standby machine in the database cluster.
[0045] In operation S230, when the host does not receive the heartbeat information fed back by the synchronous standby machine for more than a preset time period, the configuration information of the synchronous standby machine is matched with the preset downgrade list to obtain a matching result, wherein the heartbeat information is used to indicate that the synchronous standby machine has received log data.
[0046] In operation S240 , when the matching result indicates that the synchronous standby machine can be downgraded, the data synchronization mode of the synchronous standby machine is changed to an asynchronous mode.
[0047] According to an embodiment of the present invention, in response to a business processing request sent by a client, the database cluster provides corresponding services to the client. Specifically, in the process of providing services to the client, the host needs to synchronize log data with the synchronous standby and asynchronous standby in the database cluster. Among them, for the synchronous standby, the host needs to wait for the synchronization of the log data of the synchronous standby to be completed before the business execution is considered completed. The sign of the completion of the synchronization of the log data by the synchronous standby is to return the heartbeat information to the host. Among them, the heartbeat information is the feedback information generated by the synchronous standby after receiving the log data.
[0048] According to an embodiment of the present invention, during the operation phase of the database cluster, the control system for controlling the database cluster will be used to continuously monitor the connection information between the master and the synchronous standby. If it is found that the master does not receive the heartbeat information fed back by the synchronous standby for more than a preset time period, it means that the synchronous standby may be down, or there is a problem with the network between the master and the standby, so it is necessary to adjust the data synchronization between the master and the standby so that the business can proceed normally.
[0049] According to an embodiment of the present invention, the configuration information of the synchronous standby is matched with a preset downgrade list to determine whether the synchronous standby is allowed to be downgraded based on the configuration information. The preset downgrade list includes configuration information of multiple synchronous standby machines that are allowed to be downgraded. If the preset downgrade list includes the configuration information of the synchronous standby, it means that the data synchronization mode of the synchronous standby is allowed to be changed. Using a control system that controls the database cluster, the data synchronization mode of the synchronous standby is changed to an asynchronous mode, so that in the process of synchronizing log data, the business does not need to wait for the response of the synchronous standby and can continue to execute normally.
[0050] According to an embodiment of the present invention, during the operation phase of the database cluster, the data synchronization between the host and the synchronous standby is continuously monitored. If the host does not receive the heartbeat information fed back by the synchronous standby for more than a preset time period, it means that the synchronous standby may be down, or there is a problem in the network between the master and the standby. Therefore, the configuration information is matched with the preset downgrade list, and when the matching result indicates that the downgrade of the synchronous standby is allowed, the data synchronization mode of the synchronous standby is changed to the asynchronous mode. By changing the data synchronization mode of the synchronous standby, the business no longer needs to wait for the response of the synchronous standby during operation, which effectively reduces the waiting time of the business and improves the processing efficiency of the business.
[0051] Figure 3 A schematic diagram of active / standby information feedback in a database cluster management method according to an embodiment of the present invention is shown.
[0052] According to an embodiment of the present invention, when the host does not receive the heartbeat information fed back by the synchronous standby machine for more than a preset time period, the configuration information of the synchronous standby machine is matched with the preset downgrade list to obtain a matching result, including: when the synchronous standby machine receives log data, the heartbeat information is sent to the keep-alive module corresponding to the host machine by using the keep-alive module corresponding to the synchronous standby machine; when the keep-alive module of the host machine does not receive the heartbeat information for more than a preset time period, the configuration information of the synchronous standby machine is sent to the standby downgrade determination component for processing to obtain a matching result, wherein the standby downgrade determination component is configured with a preset downgrade list.
[0053] like Figure 3 As shown, the host 310 synchronizes the log data to the synchronous standby 320 and the synchronous standby 330 respectively. When receiving the log data, the synchronous standby 320 and the synchronous standby 330 respectively send heartbeat information to the keep-alive module 311 of the host 310. Specifically, the synchronous standby 320 uses the keep-alive module 321 corresponding thereto to send the heartbeat information to the keep-alive module 311. The synchronous standby 330 uses the keep-alive module 331 corresponding thereto to send the heartbeat information to the keep-alive module 311.
[0054] According to an embodiment of the present invention, if the keep-alive module 311 of the host 310 does not receive the heartbeat information sent by the keep-alive module 321 of the synchronous standby 320 for more than a preset time period, the configuration information of the synchronous standby 320 is sent to the standby downgrade determination component 340 for processing. Among them, the standby downgrade determination component 340 has a preset downgrade list configured by the standby downgrade configuration module 350.
[0055] According to an embodiment of the present invention, if the preset downgrade list includes the configuration information of the synchronous standby machine 320, it means that the data synchronization mode of the synchronous standby machine 320 is allowed to be changed. Therefore, the standby downgrade determination component 340 can output a matching result indicating that the synchronous standby machine 320 is allowed to be downgraded. By using the keep-alive module to monitor the connection information between the master and the standby, the operating status of the synchronous standby machine can be known in a timely manner.
[0056] Figure 4 A schematic diagram of synchronous standby machine degradation in a database cluster management method according to an embodiment of the present invention is shown.
[0057] like Figure 4 As shown, after determining that the synchronous standby machine 320 is allowed to be downgraded, the downgrade determination module 410 sends the matching result to the downgrade execution module 420, so that the downgrade execution module 420 sends a downgrade command to the downgrade execution module 430 of the host 310 based on the matching information, thereby completing the downgrade processing of the synchronous standby machine 320.
[0058] According to the embodiment of the present invention, by downgrading the synchronous standby machine, the service no longer needs to wait for the response of the synchronous standby machine during operation, which effectively reduces the waiting time of the service and improves the processing efficiency of the service.
[0059] According to an embodiment of the present invention, after changing the data synchronization mode of the synchronous standby machine to the asynchronous mode, it also includes: continuously synchronizing the log data generated by the host to the synchronous standby machine whose data synchronization mode is the asynchronous mode; when the host receives the heartbeat information fed back by the synchronous standby machine, determining the time difference between the moment when the host sends the log data to the synchronous standby machine and the moment when the host receives the heartbeat information; when the time difference is less than a preset time period, restoring the data synchronization mode of the synchronous standby machine to the synchronous mode.
[0060] According to an embodiment of the present invention, after the data synchronization mode of the synchronous standby is changed, it is only necessary to inform the host that it no longer needs to wait for the heartbeat information fed back by the synchronous standby, but the synchronous standby itself is not changed. Therefore, after the synchronous standby solves the downtime or network connection problem, it will still send heartbeat information to the host.
[0061] According to an embodiment of the present invention, when the host continues to synchronize log data with the synchronous standby machine, if a heartbeat message sent by the downgraded synchronous standby machine is received, the time when the host sends log data to the synchronous standby machine and the time when the host receives the heartbeat message are determined, and the time difference between the two is determined. It is determined whether the time difference is less than the preset time period. If it is less than, it means that the synchronous standby machine can normally feedback information. Therefore, the data synchronization mode of the flannel standby machine is restored to the synchronous mode.
[0062] According to an embodiment of the present invention, if the time difference is still greater than the preset time period, it means that the synchronous standby has not recovered, because the host still does not need to wait to receive the heartbeat information fed back by the synchronous standby. By timely upgrading the restored synchronous standby, the database cluster runs more stably.
[0063] Figure 5 A schematic diagram of active / standby switching in a database cluster management method according to an embodiment of the present invention is shown.
[0064] According to an embodiment of the present invention, a database cluster includes multiple synchronous standby machines and multiple asynchronous standby machines, and the method also includes: when it is determined that an abnormality occurs in a host, determining the standby information of each synchronous standby machine in the database cluster, wherein the standby information includes a data synchronization mode and historical change information of the data synchronization mode; based on the standby information, filtering the multiple synchronous standby machines to obtain multiple candidate standby machines, wherein the candidate standby machines are synchronous standby machines whose data synchronization mode is a synchronous mode; based on the configuration information of each candidate standby machine and the asynchronous standby machine, determining a target standby machine from the multiple candidate standby machines and the multiple asynchronous standby machines; and using a master-slave switching component to switch the target standby machine to a new host.
[0065] According to an embodiment of the present invention, if an abnormality occurs in a host in a database cluster, a master-slave switchover needs to be triggered. The standby information of each synchronous standby in the database cluster is determined, and multiple synchronous standbys are filtered based on the standby information. Among them, a synchronous standby whose data synchronization mode has been changed cannot be switched to the master, because the synchronous standby whose data synchronization mode has been switched may still have a downtime problem.
[0066] like Figure 5 As shown, the standby downgrade determination module 410 sends the standby information of each synchronous standby machine to the switching determination component 520, so that the switching determination component 520 filters the synchronous standby machines and determines the target standby machine 530 from multiple candidate standby machines and multiple asynchronous standby machines.
[0067] According to the embodiment of the present invention, the switching determination component 520 sends a command of switching from the master to the standby to the switching execution component 541 of the master 540, and sends a command of switching from the standby to the master to the switching execution component 531 of the target standby 530, thereby completing the switching of the master to the standby. By switching the master to the standby in a timely manner, the operation of the business can be continued, and the business will not be unable to be carried out due to the abnormality of the master.
[0068] According to an embodiment of the present invention, based on the standby machine information, multiple synchronous standby machines are filtered to obtain multiple candidate standby machines, including: according to the data synchronization mode of each synchronous standby machine, multiple preferred standby machines are screened out from the multiple synchronous standby machines, wherein the preferred standby machine is a synchronous standby machine whose data synchronization mode is a synchronous mode; based on the historical change information of each preferred standby machine, multiple candidate standby machines are determined from the multiple preferred standby machines, wherein the candidate standby machines are synchronous standby machines whose data synchronization mode has not been changed in history.
[0069] According to an embodiment of the present invention, when filtering multiple synchronous standby machines, synchronous standby machines whose data synchronization modes have been changed are first eliminated to obtain multiple preferred standby machines. The preferred standby machines are further screened to eliminate synchronous standby machines whose data synchronization modes have been changed in the past. Since synchronous standby machines whose data synchronization modes have been changed have the hidden danger of instability, in order to reduce the switching frequency of the host, it is necessary to select a relatively stable standby machine.
[0070] According to an embodiment of the present invention, the database cluster management method also includes: when it is determined that the new host is an asynchronous standby host, determining the asynchronous log sequence number recorded when the new host historical synchronization log data is stored, and the host log sequence number recorded when the abnormal host historical synchronization log data is stored; when it is determined that the host log sequence number is greater than the asynchronous log sequence number, the lost log data lost during the master-slave switching is retrieved to the new host.
[0071] According to an embodiment of the present invention, when it is determined that the new host is an asynchronous standby, after the asynchronous standby becomes the master, the log data of the host where the abnormality occurs will be forked, and users with high data requirements will require to retrieve the lost data. Specifically, in the process of recording log data, the database will record a sequence number, called lsn (log sequence number). When a log data is written, the sequence number increases.
[0072] According to an embodiment of the present invention, if the host log sequence number of the host has reached 6, but the asynchronous log sequence number of the asynchronous standby has only been synchronized to 3. There is a probability that after the host is abnormally unavailable, the asynchronous standby is upgraded to the host, and the log data 4-6 does not exist on the new host. The business continues to write log data on the new host, and the asynchronous log sequence number continues to increase from 3, but the log data of the host log sequence number 4-6 is not the same as the log data of the host where the abnormality occurred, so a fork occurs. It is necessary to retrieve the business operations corresponding to the 4-6 log data of the host where the abnormality occurred.
[0073] According to the embodiment of the present invention, by automatically retrieving the log data lost by the user during the active / standby switching, the maximum availability of the database is guaranteed, and the data consistency after the database switching can be guaranteed, which greatly improves the user experience of the database.
[0074] Figure 6 A log retrieval schematic diagram of a database cluster management method according to an embodiment of the present invention is shown.
[0075] According to an embodiment of the present invention, the log loss data lost during the master-slave switching is recovered to the new host, including: determining the log bifurcation point based on the host log sequence number and the asynchronous log sequence number; based on the log bifurcation point, determining multiple log loss data in the host where the abnormality occurs; utilizing the logical decoding function to generate a log retrieval statement corresponding to the log loss data; in response to the received log retrieval command, triggering the log retrieval component to execute the log retrieval statement to recover the log loss data to the new host.
[0076] like Figure 6 As shown, the log retrieval component 610 determines that the asynchronous log sequence number is 3 according to the log module 621 of the new host 620. The log retrieval component 610 determines that the asynchronous log sequence number is 6 according to the log module 631 of the host 630 where the abnormality occurs. Therefore, the log bifurcation point determined based on the host log sequence number and the asynchronous log sequence number is 4. However, the host log sequence number of the host where the abnormality occurs has reached 6, so it is necessary to determine the log loss data of 4-6 in the host where the abnormality occurs.
[0077] According to an embodiment of the present invention, through the logic decoding function, the log loss data is converted into a log retrieval statement, which can be a SQL statement (Structured Query Language). The log retrieval component 610 sends a log retrieval command to the log module 631 of the host 630 where the exception occurs, thereby triggering the log retrieval component 610 to execute the log retrieval statement to retrieve the log loss data to the new host 620. By automatically retrieving the log loss data, the data consistency after the database switch is guaranteed, and the use experience of the database is greatly improved.
[0078] Figure 7A block diagram of a database cluster management device according to an embodiment of the present invention is shown.
[0079] like Figure 7 As shown, the database cluster management device 700 includes a service providing module 710 , a data synchronization module 720 , an information matching module 730 , and a schema changing module 740 .
[0080] The service providing module 710 is used to respond to the received business processing request and provide the service corresponding to the business processing request by using the host in the database cluster.
[0081] The data synchronization module 720 is used to synchronize the log data generated when the host provides services to the synchronization standby machine in the database cluster.
[0082] The information matching module 730 is used to match the configuration information of the synchronous standby with the preset downgrade list to obtain a matching result when the host does not receive the heartbeat information fed back by the synchronous standby for more than a preset time period, wherein the heartbeat information is used to indicate that the synchronous standby has received log data.
[0083] The mode changing module 740 is used to change the data synchronization mode of the synchronous standby machine to the asynchronous mode when the matching result indicates that the synchronous standby machine can be downgraded.
[0084] According to an embodiment of the present invention, the information matching module 730 includes a heartbeat sending submodule and a degradation processing submodule.
[0085] The heartbeat sending submodule is used to send the heartbeat information to the keep-alive module corresponding to the host by using the keep-alive module corresponding to the synchronous standby machine when the synchronous standby machine receives the log data.
[0086] The downgrade processing submodule is used to send the configuration information of the synchronous standby machine to the standby downgrade determination component for processing to obtain a matching result when the host's keep-alive module does not receive heartbeat information for more than a preset time period, wherein the standby downgrade determination component is configured with a preset downgrade list.
[0087] According to an embodiment of the present invention, the database cluster management device 700 further includes a continuous synchronization module, a difference determination module and a mode recovery module.
[0088] The continuous synchronization module is used to continuously synchronize the log data generated by the host to the synchronous standby machine whose data synchronization mode is asynchronous mode.
[0089] The difference determination module is used to determine the time difference between the time when the host sends log data to the synchronous standby machine and the time when the host receives the heartbeat information fed back by the synchronous standby machine.
[0090] The mode recovery module is used to restore the data synchronization mode of the synchronous standby machine to the synchronous mode when the time difference is less than a preset time period.
[0091] According to an embodiment of the present invention, the database cluster management device 700 further includes an information determination module, a standby machine filtering module, a target determination module and an active / standby switching module.
[0092] The information determination module is used to determine the standby information of each synchronous standby in the database cluster when it is determined that an abnormality occurs in the host, wherein the standby information includes the data synchronization mode and the historical change information of the data synchronization mode.
[0093] The standby machine filtering module is used to filter multiple synchronous standby machines based on the standby machine information to obtain multiple candidate standby machines, wherein the candidate standby machines are synchronous standby machines whose data synchronization mode is the synchronous mode.
[0094] The target determination module is used to determine a target standby machine from a plurality of candidate standby machines and a plurality of asynchronous standby machines based on configuration information of each candidate standby machine and asynchronous standby machine.
[0095] The master-slave switching module is used to switch the target standby machine to the new master machine by using the master-slave switching component.
[0096] According to an embodiment of the present invention, the standby machine filtering module includes a standby machine screening submodule and a standby machine determining submodule.
[0097] The standby machine screening submodule is used to screen out multiple preferred standby machines from multiple synchronous standby machines according to the data synchronization mode of each synchronous standby machine, wherein the preferred standby machine is a synchronous standby machine whose data synchronization mode is the synchronous mode.
[0098] The standby machine determination submodule is used to determine multiple candidate standby machines from multiple preferred standby machines based on historical change information of each preferred standby machine, wherein the candidate standby machines are synchronous standby machines whose data synchronization mode has not been changed in the past.
[0099] According to an embodiment of the present invention, the database cluster management device 700 further includes a sequence determination module and a data retrieval module.
[0100] The sequence determination module is used to determine the asynchronous log sequence number recorded when the new host is determined to be an asynchronous standby host, and the host log sequence number recorded when the host has abnormal historical synchronization log data.
[0101] The data retrieval module is used to retrieve the lost log data lost during the master-slave switch to the new host when determining that the host log sequence number is greater than the asynchronous log sequence number.
[0102] According to an embodiment of the present invention, the data retrieval module includes a fork determination submodule, a loss determination submodule, a statement generation submodule and a data retrieval submodule.
[0103] The fork determination submodule is used to determine the log fork point based on the host log sequence number and the asynchronous log sequence number.
[0104] The loss determination submodule is used to determine multiple log loss data in the host where the abnormality occurs based on the log bifurcation point.
[0105] The statement generation submodule is used to generate a log retrieval statement corresponding to the lost log data by using the logic decoding function.
[0106] The data retrieval submodule is used to trigger the log retrieval component to execute the log retrieval statement in response to the received log retrieval command, so as to retrieve the lost log data to the new host.
[0107] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware, and firmware, or by a proper combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be executed.
[0108] For example, any of the service providing module 710, the data synchronization module 720, the information matching module 730, and the mode changing module 740 can be combined in one module / unit / sub-unit for implementation, or any of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more of these modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units and implemented in one module / unit / sub-unit. According to an embodiment of the present invention, at least one of the service providing module 710, the data synchronization module 720, the information matching module 730, and the mode changing module 740 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware or in a suitable combination of any of them. Alternatively, at least one of the service providing module 710 , the data synchronization module 720 , the information matching module 730 , and the mode changing module 740 may be at least partially implemented as a computer program module, and when the computer program module is executed, a corresponding function may be performed.
[0109] It should be noted that the database cluster management device part in the embodiment of the present invention corresponds to the database cluster management method part in the embodiment of the present invention. The description of the database cluster management device part specifically refers to the database cluster management method part, which will not be repeated here.
[0110] Figure 8 A block diagram of an electronic device suitable for implementing a database cluster management method according to an embodiment of the present invention is shown. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0111] like Figure 8As shown, the electronic device 800 according to an embodiment of the present invention includes a processor 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 to a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include an onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0112] In RAM 803, various programs and data required for the operation of electronic device 800 are stored. Processor 801, ROM 802 and RAM 803 are connected to each other via bus 804. Processor 801 performs various operations of the method flow according to the embodiment of the present invention by executing the programs in ROM 802 and / or RAM 803. It should be noted that the program can also be stored in one or more memories other than ROM 802 and RAM 803. Processor 801 can also perform various operations of the method flow according to the embodiment of the present invention by executing the programs stored in the one or more memories.
[0113] According to an embodiment of the present invention, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to the bus 804. The electronic device 800 may further include one or more of the following components connected to the I / O interface 805: an input portion 806 including a keyboard, a mouse, etc.; an output portion 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 808 including a hard disk, etc.; and a communication portion 809 including a network interface card such as a LAN card, a modem, etc. The communication portion 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that the computer program read therefrom is installed into the storage portion 808 as needed.
[0114] According to an embodiment of the present invention, the method flow according to an embodiment of the present invention can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the processor 801, the above-mentioned functions defined in the system of the embodiment of the present invention are executed. According to an embodiment of the present invention, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0115] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.
[0116] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device.
[0117] For example, according to an embodiment of the present invention, the computer-readable storage medium may include the ROM 802 and / or the RAM 803 described above and / or one or more memories other than the ROM 802 and the RAM 803 .
[0118] An embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method provided by the embodiment of the present invention. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the database cluster management method provided by the embodiment of the present invention.
[0119] When the computer program is executed by the processor 801, the above functions defined in the system / device of the embodiment of the present invention are executed. According to the embodiment of the present invention, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0120] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 809, and / or installed from a removable medium 811. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0121] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0122] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments and / or claims of the present invention can be combined and / or combined in various ways, even if such a combination or combination is not explicitly recorded in the present invention. In particular, without departing from the spirit and teaching of the present invention, the features described in the various embodiments and / or claims of the present invention may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present invention.
[0123] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination. The scope of the present invention is defined by the attached claims and their equivalents. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.
Claims
1. A database cluster management method, characterized in that: include: In response to the received business processing request, using a host in the database cluster to provide a service corresponding to the business processing request; Synchronizing the log data generated by the host when providing the service to the synchronous standby machine in the database cluster; When the host fails to receive the heartbeat information fed back by the synchronous standby machine for more than a preset time period, matching the configuration information of the synchronous standby machine with a preset downgrade list to obtain a matching result, wherein the heartbeat information is used to indicate that the synchronous standby machine has received the log data; If the matching result indicates that the synchronous standby machine can be downgraded, changing the data synchronization mode of the synchronous standby machine to an asynchronous mode; The database cluster includes multiple synchronous standby machines and multiple asynchronous standby machines, and the method further includes: In the case where it is determined that the host is abnormal, determining the standby information of each synchronous standby in the database cluster, wherein the standby information includes a data synchronization mode and historical change information of the data synchronization mode; Based on the standby machine information, the plurality of synchronous standby machines are filtered to obtain a plurality of candidate standby machines, wherein the candidate standby machines are synchronous standby machines whose data synchronization mode is a synchronous mode and whose data synchronization mode has not been changed in history; Determine a target standby machine from the plurality of candidate standby machines and the plurality of asynchronous standby machines based on the configuration information of each of the candidate standby machines and the asynchronous standby machines; The target standby machine is switched to a new master machine by using the master-slave switching component.
2. The method according to claim 1, characterized in that When the host fails to receive the heartbeat information fed back by the synchronous standby machine for more than a preset time period, matching the configuration information of the synchronous standby machine with a preset downgrade list to obtain a matching result includes: When the synchronous standby receives the log data, the heartbeat information is sent to the keep-alive module corresponding to the host by using the keep-alive module corresponding to the synchronous standby; When the keep-alive module of the host fails to receive the heartbeat information for more than a preset time period, the configuration information of the synchronous standby is sent to the standby downgrade determination component for processing to obtain the matching result, wherein the preset downgrade list is configured in the standby downgrade determination component.
3. The method according to claim 1, characterized in that After changing the data synchronization mode of the synchronous standby machine to an asynchronous mode, the method further includes: Continuously synchronizing the log data generated by the host to the synchronous standby machine whose data synchronization mode is the asynchronous mode; In the case where the host receives the heartbeat information fed back by the synchronous standby machine, determining the time difference between the time when the host sends the log data to the synchronous standby machine and the time when the host receives the heartbeat information; When the time difference is less than the preset time period, the data synchronization mode of the synchronous standby machine is restored to the synchronization mode.
4. The method according to claim 1, characterized in that: The filtering of the plurality of synchronous standby machines based on the standby machine information to obtain a plurality of candidate standby machines includes: According to the data synchronization mode of each synchronous standby machine, a plurality of preferred standby machines are selected from the plurality of synchronous standby machines, wherein the preferred standby machine is a synchronous standby machine whose data synchronization mode is a synchronous mode; Based on the historical change information of each of the preferred standby machines, a plurality of candidate standby machines are determined from the plurality of preferred standby machines.
5. The method according to claim 1, characterized in that Also includes: In the case where it is determined that the new host is an asynchronous standby host, determining the asynchronous log sequence number recorded when the new host historical synchronization log data is recorded, and the host log sequence number recorded when the abnormal host historical synchronization log data occurs; When it is determined that the host log sequence number is greater than the asynchronous log sequence number, the log loss data lost during the master-slave switch is retrieved to the new host.
6. The method according to claim 5, characterized in that The method of recovering the lost log data when the master-slave switch is performed to the new host includes: Determine a log bifurcation point based on the host log sequence number and the asynchronous log sequence number; Based on the log bifurcation point, determining a plurality of log loss data in the host where the abnormality occurs; Using the logic decoding function, a log retrieval statement corresponding to the lost log data is generated; In response to the received log retrieval command, the log retrieval component is triggered to execute the log retrieval statement to retrieve the lost log data to the new host.
7. A database cluster management device, characterized in that: include: A service providing module, configured to respond to a received business processing request and provide a service corresponding to the business processing request using a host in the database cluster; A data synchronization module, used to synchronize log data generated when the host provides the service to a synchronization standby machine in the database cluster; an information matching module, configured to match the configuration information of the synchronous standby machine with a preset downgrade list to obtain a matching result when the host fails to receive the heartbeat information fed back by the synchronous standby machine for more than a preset time period, wherein the heartbeat information is used to indicate that the synchronous standby machine has received the log data; and A mode changing module, configured to change the data synchronization mode of the synchronous standby machine to an asynchronous mode when the matching result indicates that the synchronous standby machine can be downgraded; Wherein, the database cluster management device also includes: An information determination module, configured to determine the standby information of each synchronous standby in the database cluster when it is determined that the host is abnormal, wherein the standby information includes a data synchronization mode and historical change information of the data synchronization mode; A standby machine filtering module, used for filtering the plurality of synchronous standby machines based on the standby machine information to obtain a plurality of candidate standby machines, wherein the candidate standby machines are synchronous standby machines whose data synchronization mode is the synchronous mode and whose data synchronization mode has not been changed in history; A target determination module, configured to determine a target standby machine from a plurality of the candidate standby machines and a plurality of the asynchronous standby machines based on configuration information of each of the candidate standby machines and the asynchronous standby machines; The active-standby switching module is used to switch the target standby machine to a new active machine by using the active-standby switching component.
8. An electronic device, characterized in that: include: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: Executable instructions are stored thereon, and when the instructions are executed by a processor, the processor implements the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data management method, system and equipment and storage medium
CN113326251A