CN115964436A - Method and device for managing database cluster - Google Patents

Method and device for managing database cluster Download PDF

Info

Publication number
CN115964436A
CN115964436A CN202211421245.2A CN202211421245A CN115964436A CN 115964436 A CN115964436 A CN 115964436A CN 202211421245 A CN202211421245 A CN 202211421245A CN 115964436 A CN115964436 A CN 115964436A
Authority
CN
China
Prior art keywords
database
response
slave
data
response message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211421245.2A
Other languages
Chinese (zh)
Inventor
高新刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingdong Technology Information Technology Co Ltd
Original Assignee
Jingdong Technology Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jingdong Technology Information Technology Co Ltd filed Critical Jingdong Technology Information Technology Co Ltd
Priority to CN202211421245.2A priority Critical patent/CN115964436A/en
Publication of CN115964436A publication Critical patent/CN115964436A/en
Priority to PCT/CN2023/115359 priority patent/WO2024103898A1/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for managing a database cluster, and relates to the technical field of computers. One embodiment of a method for database cluster management includes: in response to a data write transaction, writing data to be written to a master database in a database cluster and transmitting, by the master database, to a plurality of slave databases in the database cluster; determining response results of all slave database groups in the database cluster according to the response messages received by the master database; the response message is sent by the slave database which is successfully written into the data to be written; and generating a response message corresponding to the data writing transaction according to the response result of each slave database group in the database cluster. The implementation mode can improve the transaction processing efficiency, avoid the influence of network jitter and database node faults on the transaction processing, provide flexible data consistency disaster tolerance service and dynamically adjust the disaster tolerance strategy.

Description

Method and device for managing database cluster
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for managing a database cluster.
Background
Different industries have different requirements for data consistency disaster recovery services of databases. The existing data consistency disaster recovery mode commonly used in the field of databases is a master-slave replication mode, and comprises a master database and a plurality of slave databases, wherein the master database is responsible for providing external read-write access service, and the slave databases are used for synchronously replicating an operation log of the master database so as to backup data in the master database in real time.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
network jitter or too much downtime of the slave databases may block the data synchronization process and the response message return process of the slave databases, resulting in low data writing efficiency of the master databases.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for database cluster management, which can improve transaction processing efficiency, avoid the influence of network jitter and database node failure on transaction processing, provide flexible data consistency disaster recovery service, and dynamically adjust a disaster recovery policy.
To achieve the above object, according to an aspect of the embodiments of the present invention, there is provided a method for database cluster management, including:
in response to a data write transaction, writing data to be written to a master database in a database cluster and transmitting, by the master database, to a plurality of slave databases in the database cluster;
determining response results of all slave database groups in the database cluster according to the response messages received by the master database; the response message is sent by the slave database which is successfully written into the data to be written;
and generating a response message corresponding to the data writing transaction according to the response result of each slave database group in the database cluster.
Optionally, determining a response result of each slave database group in the database cluster according to the response message received by the master database includes:
updating the response message quantity of the slave database group sending the response message according to the response message received by the master database; and under the condition that the number of the response messages grouped by any slave database in the database cluster meets a preset grouping response strategy, generating a grouping response message of any slave database grouping so as to obtain a response result of any slave database grouping.
Optionally, the method further comprises:
before determining response results of each slave database grouping in the database cluster, obtaining slave database grouping configuration information of the database cluster, wherein the slave database grouping configuration information comprises: the slave database contained in each slave data group in the database cluster and the group response strategy thereof.
Optionally, the response result is: generating a packet response message or not; generating a response message corresponding to the data writing transaction according to the response result grouped from the database in the database cluster, wherein the response message comprises:
judging whether the number of the grouped response messages in the database cluster meets a preset awakening response strategy or not; if so, generating a wakeup response message corresponding to the data writing transaction to indicate that the data to be written is successfully written into the database cluster; otherwise, generating an abnormal response message corresponding to the data writing transaction to indicate that the data to be written is not successfully written into the database cluster.
Optionally, the method further comprises:
before generating a response message corresponding to the data write transaction, acquiring wake-up response policy configuration information of the database cluster, where the wake-up response policy configuration information includes: a wake response policy for the database cluster.
Optionally, the method further comprises:
before determining the response result of each slave database group in the database cluster, scanning the data replication mode configuration information of the database cluster to confirm that the group response strategy is in an open state;
and under the condition that the grouping response strategy is in a closed state, generating a response message corresponding to the data writing transaction according to a preset response strategy and a response message received by the main database.
According to a second aspect of the embodiments of the present invention, an apparatus for database cluster management is provided, including:
the data writing and transmitting module is used for responding to data writing transactions, writing data to be written into a master database in a database cluster and transmitting the data to be written into a plurality of slave databases in the database cluster from the master database;
the response result determining module is used for determining the response result of each slave database group in the database cluster according to the response message received by the master database; the response message is sent by the slave database which is successfully written into the data to be written;
and the response message generating module is used for generating response messages corresponding to the data writing transactions according to response results grouped from the databases in the database cluster.
Optionally, determining a response result of each slave database group in the database cluster according to the response message received by the master database includes:
updating the response message quantity of the slave database group sending the response message according to the response message received by the master database; and under the condition that the number of the response messages grouped by any slave database in the database cluster meets a preset grouping response strategy, generating a grouping response message of any slave database grouping so as to obtain a response result of any slave database grouping.
Optionally, the apparatus further comprises: a grouping configuration information obtaining module, configured to obtain slave database grouping configuration information of the database cluster before determining a response result of each slave database grouping in the database cluster, where the slave database grouping configuration information includes: the slave database contained in each slave data group in the database cluster and the group response strategy thereof.
Optionally, the response result is: generating a packet response message or not; generating a response message corresponding to the data writing transaction according to the response result grouped from the database in the database cluster, wherein the response message comprises:
judging whether the number of the grouped response messages in the database cluster meets a preset awakening response strategy or not; if so, generating a wakeup response message corresponding to the data writing transaction to indicate that the data to be written is successfully written into the database cluster; otherwise, generating an abnormal response message corresponding to the data writing transaction to indicate that the data to be written is not successfully written into the database cluster.
Optionally, the apparatus further comprises: a wake-up response policy configuration information obtaining module, configured to obtain wake-up response policy configuration information of the database cluster before generating a response message corresponding to the data write transaction, where the wake-up response policy configuration information includes: a wake response policy for the database cluster.
Optionally, the apparatus further comprises: the data replication mode configuration information scanning module is used for scanning the data replication mode configuration information of the database cluster to confirm that a grouping response strategy is in an open state before determining the response result of each slave database grouping in the database cluster;
and under the condition that the grouping response strategy is in a closed state, generating a response message corresponding to the data writing transaction according to a preset response strategy and a response message received by the master database.
According to a third aspect of the embodiments of the present invention, there is provided a database cluster system, including:
a master database, a plurality of slave databases, and means for database cluster management configured on the master database;
the database cluster management apparatus writes data to be written to a master database in a database cluster and transmits the data to be written to a plurality of slave databases in the database cluster from the master database in response to a data write transaction;
the database cluster management device determines the response result of each slave database group in the database cluster according to the response message received by the master database; the response message is sent by the slave database which is successfully written into the data to be written;
and the database cluster management device generates a response message corresponding to the data writing transaction according to the response result of each slave database group in the database cluster.
According to a fourth aspect of embodiments of the present invention, there is provided an electronic apparatus, including:
one or more processors;
a storage device 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 of any of the embodiments described above.
According to a fifth aspect of embodiments of the present invention, there is provided a computer readable medium, on which a computer program is stored, which when executed by a processor implements the method of any of the above embodiments.
One embodiment of the above invention has the following advantages or benefits: by grouping the slave databases and generating response messages according to the grouped response results of the slave databases, the influence of slave database node faults and network jitter on the reception of the response messages by the master database can be avoided, and the processing efficiency of database writing service is improved; configuring the grouping configuration information of the database, and obtaining different slave databases and grouping response strategies so as to meet different data consistency disaster tolerance strategies; the awakening response strategy configuration information of the database cluster is configured, so that the awakening response strategy of the database cluster can be flexibly adjusted, and the transaction processing efficiency of the database cluster is further improved; the latest data replication mode can be obtained and enabled to take effect by scanning the configuration information of the data replication mode of the database cluster, and the data consistency disaster tolerance strategy of the database can be adjusted in real time by modifying the configuration information of the data replication mode without restarting the database cluster service.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic view of a main flow of a method of database cluster management according to an embodiment of the present invention;
FIG. 2 is a schematic flow diagram of database cluster management according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a single-group operating principle of a method of database cluster management according to a referential embodiment of the present invention;
FIG. 4 is a schematic diagram of the grouping of slave databases according to different disaster recovery requirements;
FIG. 5 is a schematic diagram of the overall operation of a method of database cluster management according to another referential embodiment of the present invention;
FIG. 6 is a schematic flow diagram of generalized database cluster management according to the prior art;
FIG. 7 is a schematic diagram of the main modules of an apparatus for database cluster management according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a database cluster system according to an embodiment of the present invention;
FIG. 9 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 10 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that, in the case of no conflict, the features in the embodiments and examples of the present invention may be combined with each other; in the technical scheme of the disclosure, the acquisition, storage, application and the like of the personal information of the related user all accord with the regulations of related laws and regulations, and do not violate the customs of public sequences.
Database related products and technologies are widely applied to various industries such as finance, transportation, medical treatment, education and the like, and become foundation products for digital construction. The database is inevitable to break down, so that the data consistency disaster tolerance capability of the database product is a core problem concerned by users. At present, a disaster recovery mode commonly used by database products is a master-slave replication mode, a master database is responsible for providing services to the outside, a slave database synchronizes the operation of the master database, and data in the master database is backed up in real time; when the master database fails, one slave database is selected as a new master database to continue providing database services.
However, the disaster recovery strategy of the master-slave copy mode is single, and the individual requirements of users in different industries on the data consistency disaster recovery strategy cannot be met; when the disaster tolerance strategy is adjusted, database cluster service needs to be restarted, and the service continuity is influenced; and network jitter and slave database failures can also affect data synchronization of the master database, thereby resulting in low transaction efficiency.
In view of this, according to an aspect of the embodiments of the present invention, a method for managing a database cluster is provided.
Fig. 1 is a schematic diagram of a main flow of a method of database cluster management according to an embodiment of the present invention. As shown in fig. 1, the method for database cluster management according to the embodiment of the present invention mainly includes the following steps S101 to S103.
And step S101, responding to the data writing transaction, writing the data to be written into a master database in the database cluster, and transmitting the data to be written from the master database to a plurality of slave databases in the database cluster.
In embodiments of the present invention, data write transactions typically come from transaction requests issued by various types of applications on the computer, which are received by the database cluster. The database cluster comprises a master database and a plurality of slave databases, wherein the master database of the database cluster is responsible for providing external read-write access service, and the slave databases of the database cluster are responsible for synchronizing operation logs in the master database in real time, so that the slave databases are consistent with data in the master database to serve as backups of the master database. In the data replication process, one master database and a plurality of slave databases are used to obtain sufficient data backup quantity, so that the slave databases with complete data backup are ensured to exist when the master database fails, and meanwhile, preparation is made for providing a plurality of data consistency disaster recovery strategies.
Fig. 2 is a flowchart illustrating database cluster management according to an embodiment of the present invention. As shown in FIG. 2, the database cluster includes a master database 202 and a plurality of slave databases, with slave database 205 being labeled as an example. First, various applications 201 on the computer send data write requests to a master database 202 in the database cluster, and the master database writes corresponding transaction operations into a binary log 203. By monitoring the log parameters of the master database 202, it is possible to identify that the master database 202 is inconsistent with the data of the plurality of slave databases, and then the plurality of slave databases will send communication requests to the master database 202 to read the newly added log information on the master database. Taking the slave database 205 as an example, the slave database 205 saves the received log information into the relay log 204, and then transmits the data to be written from the master database 202 to the slave database 205 according to the log information, and writes the transaction operation of the slave database 205 into the binary log 206.
Step S102, determining the response result of each slave database group in the database cluster according to the response message received by the master database; the response message is issued by the slave database that successfully writes the data to be written.
After the data to be written is successfully written into the slave database, the slave database sends a corresponding response message to the master database to indicate that the slave database has completed the data writing operation. The content of the response message received by the master database includes: a slave database number, a name of a log file on the master database read and a specific read location in the log, a timestamp of receiving the response message, etc.
The slave database grouping is obtained by dividing the slave database in the database cluster according to a preset grouping response strategy, and the grouping response strategy can be determined according to disaster recovery requirements meeting safety regulations or disaster recovery requirements formulated by users. The slave database sending the response message can be determined through the response information received by the master database, and then the slave database group to which the slave database belongs is determined, and the response message is divided into each slave database group, so that the response result of each slave database group in the database cluster is determined. By grouping the slave databases, the unstable slave databases of the network or the slave databases which are easy to be down and the stable slave databases of the network can be divided into a group, and response messages are generated according to response results of the grouping of the slave databases, so that the influence of the node fault of the slave databases and the network jitter on the receiving of the response messages by the master database can be avoided, and the processing efficiency of database writing service is improved.
According to one embodiment of the present invention, determining response results of each slave database group in the database cluster according to the response message received by the master database includes:
updating the response message quantity of the slave database grouping which sends the response message according to the response message received by the master database; and under the condition that the number of response messages grouped by any slave database in the database cluster meets the grouping response strategy, generating a grouping response message of the any slave database group, thereby obtaining a response result of the any slave database group.
According to the content of the received response message, the slave database sending the response message can be determined, the slave database group where the slave database is located can be determined according to the slave database, and then the slave database group to which the response message belongs is determined. By recording the number of response messages grouped from the database, the completion of data write transactions from the database within each slave database group can be known. Each slave database packet has a corresponding packet response policy, and whether the packet response policy is satisfied is determined from the response messages of the slave database packets. In the case where the slave database satisfies its corresponding group response policy, a group response message grouped by the slave database is generated. By grouping the databases and grouping the response strategies, the problems that response messages are returned from the databases in unstable networks after long-time waiting and response results are difficult to determine due to the fact that the response messages cannot be returned from database faults can be avoided, and therefore the transaction processing efficiency of the database cluster is improved.
As shown in fig. 2, after the response message sent from the database is received by the master database, the slave database group to which the response message belongs is determined according to the slave database, for example, the slave database 205 belongs to the slave database group 1, and then the number of response messages of the slave database group 1 should be increased according to the response message sent from the slave database 205 to the master database; the grouping response policy may be to set a threshold value of the number of response messages, and obtain the response result of the slave database grouping when the number of response messages grouped from the database satisfies the grouping response policy, that is, the number of response messages grouped from the database reaches the threshold value of the number of response messages.
Fig. 3 is a schematic diagram of a single-group operation principle of a method for database cluster management according to a referential embodiment of the present invention. As shown in fig. 3, it is a status change process of a slave database packet whose packet response policy is: when the response message grouped from the database is 2, a group response message grouped from the database is generated. The slave database group has two states, in the slave database group state 301, the master database receives the response message sent by the group member 1 of the slave database group, and the number of the response messages of the slave database group is 1, and the group response policy of the slave database group is not satisfied, so that the group response message of the slave database group cannot be generated; after waiting for the response message for a while, the master database receives the response message from the group member 2 of the slave database group, so the slave database group state 301 changes to the slave database group state 302, and in the slave database group state 302, the number of response messages of the slave database group is 2, so the group response policy of the slave database group is satisfied, that is, the number of response messages reaches the threshold number of response messages, so the slave database group generates the group response message of the slave database group, and further obtains the response result of the slave database group.
According to another embodiment of the present invention, before determining the response result of each slave database group in the database cluster, slave database group configuration information of the database cluster may be obtained, the slave database group configuration information including: the slave database contained in each slave data group in the database cluster and the group response strategy thereof.
The database cluster has slave database grouping configuration information, the slave database grouping configuration information is obtained according to disaster tolerance requirements of users, and the slave database grouping configuration information comprises the following steps: each slave database in the database cluster comprises slave databases contained in each slave data group and a group response strategy thereof. When the slave databases in the database cluster are grouped, the slave databases can be grouped according to data security regulations of different industries, and can also be grouped according to personalized disaster tolerance requirements of users. By grouping the configuration information from the database, the latest slave database grouping and grouping response strategy can be obtained to meet the latest disaster tolerance requirement, and the situation that the new slave database grouping and grouping response strategy are not effective in time is avoided. And by configuring the slave database grouping configuration information, the slave databases can be flexibly grouped, and different grouping response strategies can be realized for different slave database groups, so that the disaster tolerance requirements of different users are met, and the transaction processing efficiency of the database cluster can also be improved.
Fig. 4 is a schematic diagram of grouping slave databases according to different disaster tolerance requirements. As shown in fig. 4, the slave databases in three rooms (i.e., two places and three centers) of two cities are grouped, and corresponding slave database grouping configuration information is obtained according to different disaster tolerance requirements, so that different slave database groups can be obtained. For example, in the slave database group 401, each computer room has one slave database, and the disaster tolerance requirement is that data replication of at least one slave database is consistent, all the slave databases may be grouped into one group, and when the master database receives a response message, it indicates that the disaster tolerance requirement of the slave database group 401 can be satisfied after the data replication of at least one slave database is successfully completed; in the slave database grouping 402, each machine room is provided with a slave database, the disaster tolerance requirement is that the data of any remote machine room is copied consistently, the remote machine rooms refer to other machine rooms except the machine room where the master database is located, namely machine room B and machine room C, the slave databases in the machine rooms B and C can be divided into one group according to the grouping strategy, the machine room A where the master database is located is independently divided into one group, and when the master database receives the grouping response message from the slave databases where the machine rooms B and C are located, the slave database of any remote machine room successfully completes the data copying, namely, the disaster tolerance requirement of the slave database grouping 402 is met; in the slave database group 403, if the disaster tolerance requirement is that the data replication in different places is consistent, the slave databases not in the machine room C of one city with the master database may be grouped into one group, and when the master database receives the group response message of the slave database group of another city, it indicates that the data replication in the different places is successfully completed by the slave database, that is, the disaster tolerance requirement of the slave database group 403 is satisfied; in the slave database group 404, if the disaster tolerance requirement is that the data replication of the three machine rooms is consistent, the slave databases of different machine rooms may be respectively divided into a group, and when the master database receives the grouping response messages of different slave database groups, it indicates that the slave databases in different machine rooms all successfully complete data replication, that is, the disaster tolerance requirement of the slave database group 404 is satisfied.
As can be seen from fig. 4, according to the slave database grouping configuration information of the database cluster, which slave databases each slave database group contains and a preset grouping response policy can be obtained; and according to the disaster tolerance requirement of the user, the configuration information of the slave database grouping is adjusted, so that different slave database groupings and different grouping response strategies are obtained. The grouping mode of the slave databases is flexible, the conditions of a plurality of machine rooms in a plurality of regions can be fully considered, the number of the slave databases can be one or more, and the number of the slave databases in the slave database groups can be one or more.
Step S103, generating a response message corresponding to the data writing transaction according to the response result grouped from each database in the database cluster.
Each slave database group has a response result, and different response messages corresponding to the data write transactions can be generated according to different response results. Fig. 5 is a schematic diagram illustrating an overall operation principle of a method for database cluster management according to another exemplary embodiment of the present invention. As shown in fig. 5, each slave database packet generates a packet response message to indicate a response result, and the packet response messages of the respective slave database packets can be grouped together for analysis and processing. And generating a response message corresponding to the data writing transaction according to the response result indicated by the grouping response message. And generating a response message according to the response result, flexibly setting a response strategy, meeting various disaster tolerance requirements and improving the transaction processing efficiency of the database cluster.
According to a reference embodiment of the present invention, the response result is: generating a packet response message or not; generating a response message corresponding to the data writing transaction according to the response result grouped from each database in the database cluster, wherein the response message comprises:
judging whether the number of the grouped response messages in the database cluster meets a preset awakening response strategy or not; if so, generating a wakeup response message corresponding to the data writing transaction to indicate that the data to be written is successfully written into the database cluster; otherwise, generating an abnormal response message corresponding to the data writing transaction to indicate that the data to be written is not successfully written into the database cluster.
The response result may be divided into a generation of a packet response message and a non-generation of a packet response message. Under the condition that the number of response messages grouped from the database does not meet the grouping response strategy, the slave database group sends out a response result without generating grouping response messages; in the case that the number of response messages of the slave database packet satisfies the packet response policy, the slave database packet may send out a response result generating a packet response message. The database cluster is preset with an awakening response strategy, as shown in fig. 5, the grouped response messages are aggregated through the grouped response message set, whether the number of the grouped response messages meets the preset awakening response strategy is judged, if the grouped response messages meet the awakening response strategy, an awakening response message is sent out, and if the grouped response messages do not meet the awakening response strategy, an abnormal response message is sent out. By the response result, the response condition of each group can be clearly known, the awakening response strategy is set, different disaster tolerance requirements can be met, different response messages are set, the data writing condition of the data to be written can be known, corresponding processing can be carried out according to the abnormal response message even if the awakening response strategy is not met, and therefore the transaction processing efficiency of the database cluster is further improved.
According to another embodiment of the present invention, before generating a response message corresponding to a data write transaction, wake-up response policy configuration information of a database cluster is obtained, where the wake-up response policy configuration information includes: wake response policy for the database cluster.
The database cluster has wake response policy configuration information including a wake response policy of the database cluster. In particular, the wake-up response policy may be related to the reply message. Exemplarily, a response message quantity threshold is set in the wake-up response policy, and when the quantity of the response messages reaches the response message quantity threshold, the wake-up response policy is determined to be satisfied; otherwise, under the condition that the number of the response messages reaches the threshold value of the number of the response messages, judging that the awakening response strategy is not met. By acquiring the configuration information of the wake-up response strategy, the latest wake-up response strategy can be acquired so as to meet the latest disaster tolerance requirement and avoid that the new wake-up response strategy is not effective in time.
Figure 6 is a schematic flow diagram of generalized database cluster management according to the prior art. As shown in fig. 6, when the slave databases complete the data writing transaction and return response messages, each slave database returns its response message to the master database, the database cluster sets a threshold value of the number of response messages, which is usually greater than half of the number of slave databases, and the wake-up response message is generated only when the number of response messages received by the master database and returned from the slave databases reaches the threshold value of the number of response messages. Illustratively, there are 10 slave databases in the database cluster, and according to the response strategy of the prior art, the master database needs to receive at least 6 response messages sent by the slave databases to send out the wake-up response message; according to the technical scheme of the embodiment of the invention, 10 slave databases can be divided into two slave database groups according to the slave database grouping configuration information, each slave database group has 5 slave databases, and the grouping response strategy is set to generate the grouping response message of the slave database group under the condition that the number of the response messages of the slave database group is 1; because there are two slave database groups, the wakening response strategy configuration information is set, and the wakening response strategy is set to generate a wakening response message corresponding to the data writing transaction under the condition of obtaining two group response messages, otherwise, an abnormal response message is generated. Under the packet response strategy, the master database can generate two packet response messages only by waiting for the response messages of the two slave databases, so as to obtain the wake-up response message corresponding to the data writing transaction. Compared with the prior art, the number of the response messages waiting in the technical scheme of the embodiment of the invention is far smaller than that of the response messages waiting in the prior art, so that the transaction processing efficiency can be greatly improved under the condition of meeting the disaster tolerance requirement.
Further, for example, in a database cluster architecture with multiple regions and multiple computer rooms, the response messages waiting for the slave database using the prior art are often affected by network jitter, and the response efficiency of the slave database not located in the same region as the master database is very low. According to the technical scheme of the embodiment of the invention, the slave database in the same region (namely local region) as the master database and the slave databases in other different regions (namely different regions) can be classified into one slave database group, and the group response strategy of the slave database group is set as follows: the grouped response messages of the slave database are generated under the condition that the number of the response messages grouped from the slave database is a value X, wherein the value X is a value not larger than the number of the local slave databases. Therefore, the grouping response message and the awakening response message can be generated under the condition that the response message is returned from the database locally, the grouping response message grouped from the database in a different place is prevented from being waited for a long time, the influence of network jitter or the fault of the slave database on the grouping response message and the awakening response message can be avoided, and the transaction processing efficiency of the database cluster is improved.
According to yet another referenceable embodiment of the present invention, before determining the response result of each slave database grouping in the database cluster, scanning the data replication pattern configuration information of the database cluster to confirm that the grouping response policy is in an on state;
and under the condition that the grouping response strategy is in a closed state, generating a response message corresponding to the data writing transaction according to a preset response strategy and a response message received by the master database.
The database cluster is provided with data replication mode configuration information, the data replication mode of the slave database can be configured according to the data replication mode configuration information, and the data replication mode set in the data replication mode configuration information is used under the condition that the grouping response strategy is in an open state; in the case where the packet reply policy is in the off state, a default data copy mode is used. Specifically, a system table may be set in the master database, and data replication mode configuration information may be stored in the system table, where the data replication mode configuration information may include: the number of the packet response strategy, namely a plurality of packet response strategies can be stored in a system table; the name of the packet reply policy; the specific grouping response strategy can be a character string, and different grouping response strategies are matched according to different character strings obtained from a system table by setting a character string matching mode; a default packet reply policy; creator, modifier, and corresponding timestamp of the respective packet reply policy, and so on.
Through the configuration information of the data copy mode, a default data copy mode can be set, and the consistency of data copy can still be ensured under the condition that a packet response strategy is not started. And the latest data replication mode can be acquired by scanning the data replication mode configuration information of the database cluster, including: how the slave database is grouped, the grouping response policy for each group, and the wake response policy. By modifying the specific content in the system table, the data consistency disaster tolerance strategy of the database can be adjusted in real time without restarting the database cluster service.
According to a second aspect of the embodiments of the present invention, an apparatus for managing a database cluster is provided.
Fig. 7 is a schematic block diagram of an apparatus for database cluster management according to an embodiment of the present invention, and as shown in fig. 7, the apparatus 700 for database cluster management mainly includes:
a data writing and transmitting module 701, configured to write data to be written into a master database in a database cluster and transmit the data from the master database to a plurality of slave databases in the database cluster in response to a data writing transaction;
a response result determining module 702, configured to determine, according to the response message received by the master database, a response result of each slave database group in the database cluster; the response message is sent by the slave database which successfully writes the data to be written;
a response message generating module 703, configured to generate a response message corresponding to the data writing transaction according to a response result grouped by each slave database in the database cluster.
According to one exemplary embodiment of the present disclosure, determining response results of each slave database group in the database cluster according to the response message received by the master database includes:
updating the response message quantity of the slave database group sending the response message according to the response message received by the master database; and under the condition that the number of the response messages of any slave database grouping in the database cluster meets a preset grouping response strategy, generating a grouping response message of any slave database grouping so as to obtain a response result of any slave database grouping.
According to a reference embodiment of the present invention, the apparatus 700 for database cluster management further comprises: a grouping configuration information obtaining module, configured to obtain slave database grouping configuration information of the database cluster before determining a response result of each slave database grouping in the database cluster, where the slave database grouping configuration information includes: each slave database in the database cluster comprises slave databases contained in each slave data group and a group response strategy thereof.
According to another embodiment of the invention, the response results are: generating a packet response message or not; generating a response message corresponding to the data writing transaction according to the response result grouped from each database in the database cluster, wherein the response message comprises:
judging whether the number of the grouped response messages in the database cluster meets a preset awakening response strategy or not; if so, generating a wakeup response message corresponding to the data writing transaction to indicate that the data to be written is successfully written into the database cluster; otherwise, generating an abnormal response message corresponding to the data writing transaction to indicate that the data to be written is not successfully written into the database cluster.
According to yet another embodiment of the present invention, the apparatus 700 for database cluster management further comprises: a wake-up response policy configuration information obtaining module, configured to obtain wake-up response policy configuration information of the database cluster before generating a response message corresponding to the data write transaction, where the wake-up response policy configuration information includes: wake response policy for the database cluster.
According to another embodiment of the present invention, the apparatus 700 for database cluster management further comprises: the data replication mode configuration information scanning module is used for scanning the data replication mode configuration information of the database cluster to confirm that the grouping response strategy is in an open state before determining the response result of each slave database grouping in the database cluster;
and under the condition that the grouping response strategy is in a closed state, generating a response message corresponding to the data writing transaction according to a preset response strategy and a response message received by the main database.
It should be noted that, the detailed implementation of the apparatus for database cluster management according to the embodiment of the present invention is already described in detail in the above method for database cluster management, and therefore, the repeated contents are not described herein again.
According to a third aspect of the embodiments of the present invention, a database cluster system is provided.
FIG. 8 is a schematic diagram of a database cluster system according to an embodiment of the present invention. As shown in fig. 8, the database cluster system 800 mainly includes: a master database 801, a plurality of slave databases, and a database cluster management apparatus 802 configured on the master database 801, wherein the plurality of slave databases may be distributed in different machine rooms of different cities, and the database cluster management apparatus 802 may manage the slave databases in the database cluster system 800 across machine rooms and across regions;
the means 802 for database cluster management configured on the master database 801 writes data to be written to the master database 801 in the database cluster and transmits from the master database 801 to a plurality of slave databases in the database cluster in response to the data write transaction;
the database cluster management device 802 configured on the master database 801 determines the response result of each slave database grouping in the database cluster according to the response message received by the master database 801; the response message is sent by the slave database which is successfully written into the data to be written;
the database cluster management means 802 arranged on the master database 801 generates a response message corresponding to the data write transaction from the response result of each slave database group in the database cluster.
It should be noted that, the detailed implementation contents of the database cluster system 800 according to the embodiment of the present invention have been described in detail in the above database cluster management method and database cluster management apparatus, and therefore, the repeated contents are not described herein again. For the related contents of the apparatus 802 for database cluster management configured on the master database 801, refer to the description of the second aspect of the embodiment of the present invention, and are not described herein again.
According to the technical scheme of the embodiment of the invention, the slave databases are grouped, and the response message is generated according to the grouped response result of the slave databases, so that the influence of the node fault of the slave databases and the network jitter on the receiving of the response message by the master database can be avoided, and the processing efficiency of database writing service is improved; configuring grouping configuration information of the database, and obtaining different slave databases and grouping response strategies so as to meet different data consistency disaster tolerance strategies; the awakening response strategy configuration information of the database cluster is configured, so that the awakening response strategy of the database cluster can be flexibly adjusted, and the transaction processing efficiency of the database cluster is further improved; the latest data replication mode can be acquired and enabled to take effect by scanning the configuration information of the data replication mode of the database cluster, and the data consistency disaster tolerance strategy of the database can be adjusted in real time by modifying the configuration information of the data replication mode without restarting the database cluster service.
According to a fourth aspect of the embodiments of the present invention, there is provided an electronic device for database cluster management, including: one or more processors; a storage device, configured to store one or more programs, where when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided by the first aspect of the embodiment of the present invention.
According to a fifth aspect of embodiments of the present invention, there is provided a computer-readable medium, on which a computer program is stored, which when executed by a processor, performs the method provided by the first aspect of embodiments of the present invention.
Fig. 9 shows an exemplary system architecture 900 of a method of database cluster management or an apparatus of database cluster management to which embodiments of the invention may be applied.
As shown in fig. 9, the system architecture 900 may include end devices 901, 902, 903, a network 904, and a server 905. Network 904 is the medium used to provide communication links between terminal devices 901, 902, 903 and server 905. The network 904 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may use the terminal devices 901, 902, 903 to interact with a server 905 over a network 904 to receive or send messages and the like. Various messaging client applications, such as a database cluster management application, a database cluster status presentation application, a search application, an instant messaging tool, a mailbox client, social platform software, etc. (just examples) may be installed on the terminal devices 901, 902, 903.
The terminal devices 901, 902, 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 905 may be a server that provides various services, such as a background management server (for example only) that supports data write requests sent by the upstream utilization terminal devices 901, 902, 903. The background management server can respond to data writing transactions, and data to be written is written into a master database in a database cluster and transmitted to a plurality of slave databases in the database cluster by the master database; determining response results of all slave database groups in the database cluster according to the response messages received by the master database; the response message is sent by the slave database which is successfully written into the data to be written; generating a response message corresponding to the data writing transaction according to the response result of each slave database group in the database cluster; and feeds back a result of the reply of the data write transaction (for example only) to the terminal device.
It should be noted that, the method for bill charging management provided by the embodiment of the present invention is generally executed by the server 905, and accordingly, the apparatus for database cluster management is generally disposed in the server 905. The method for database cluster management provided by the embodiment of the present invention may also be executed by the terminal devices 901, 902, 903, and accordingly, the apparatus for database cluster management may be disposed in the terminal devices 901, 902, 903.
It should be understood that the number of terminal devices, networks, and servers in fig. 9 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for an implementation.
Referring now to FIG. 10, a block diagram of a computer system 1000 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 10 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 10, the computer system 1000 includes a Central Processing Unit (CPU) 1001 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. In the RAM1003, various programs and data necessary for the operation of the system 1000 are also stored. The CPU 1001, ROM1002, and RAM1003 are connected to each other via a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
The following components are connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output portion 1007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 1008 including a hard disk and the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1010 as necessary, so that a computer program read out therefrom is mounted into the storage section 1008 as necessary.
In particular, according to embodiments of the present disclosure, the processes described above with reference to the flow diagrams may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program comprising a computer program embodied on a computer-readable medium, the computer program comprising program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication part 1009 and/or installed from the removable medium 1011. The above-described functions defined in the system of the embodiment of the present invention are executed when the computer program is executed by a Central Processing Unit (CPU) 1001.
It should be noted that the computer readable medium shown in the embodiment of the present invention may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In yet another embodiment of the present invention, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer programs according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a data writing and transmitting module, a response result determining module, and a response message generating module, wherein names of these modules do not constitute a limitation to the module itself in some cases, for example, the response result determining module may also be described as a "module that determines a response result from a response message returned from a database".
As another aspect, an embodiment of the present invention further provides a computer-readable medium, where the computer-readable medium may be included in the apparatus described in the foregoing embodiment; or may be separate and not assembled into the device. The computer readable medium carries one or more programs which, when executed by a device, implement the method of: in response to a data write transaction, writing data to be written to a master database in a database cluster and transmitting, by the master database, to a plurality of slave databases in the database cluster; determining response results of all slave database groups in the database cluster according to the response messages received by the master database; the response message is sent by the slave database which successfully writes the data to be written; and generating a response message corresponding to the data writing transaction according to the response result of each slave database group in the database cluster.
According to the technical scheme of the embodiment of the invention, the slave databases are grouped, and the response message is generated according to the grouped response result of the slave databases, so that the influence of the node fault of the slave databases and the network jitter on the receiving of the response message by the master database can be avoided, and the processing efficiency of database writing service is improved; configuring the grouping configuration information of the database, and obtaining different slave databases and grouping response strategies so as to meet different data consistency disaster tolerance strategies; the awakening response strategy configuration information of the database cluster is configured, so that the awakening response strategy of the database cluster can be flexibly adjusted, and the transaction processing efficiency of the database cluster is further improved; the latest data replication mode can be acquired and enabled to take effect by scanning the configuration information of the data replication mode of the database cluster, and the data consistency disaster tolerance strategy of the database can be adjusted in real time by modifying the configuration information of the data replication mode without restarting the database cluster service.
The above detailed description does not limit the scope of the embodiments of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the embodiments of the present invention should be included in the scope of the embodiments of the present invention.

Claims (10)

1. A method for database cluster management, comprising:
in response to a data write transaction, writing data to be written to a master database in a database cluster and transmitting, by the master database, to a plurality of slave databases in the database cluster;
determining response results of all slave database groups in the database cluster according to the response messages received by the master database; the response message is sent by the slave database which is successfully written into the data to be written;
and generating a response message corresponding to the data writing transaction according to the response result of each slave database group in the database cluster.
2. The method of claim 1, wherein determining the response results for each slave database grouping in the database cluster based on the response messages received by the master database comprises:
updating the response message quantity of the slave database group sending the response message according to the response message received by the master database; and under the condition that the number of response messages grouped by any slave database in the database cluster meets a preset grouping response strategy, generating a grouping response message grouped by any slave database so as to obtain a response result grouped by any slave database.
3. The method of claim 2, further comprising:
before determining a response result of each slave database grouping in the database cluster, obtaining slave database grouping configuration information of the database cluster, wherein the slave database grouping configuration information comprises: the slave database contained in each slave data group in the database cluster and the group response strategy thereof.
4. The method of claim 1, wherein the response results in: generating a packet response message or not; generating a response message corresponding to the data writing transaction according to the response result grouped from the database in the database cluster, wherein the response message comprises:
judging whether the number of the grouped response messages in the database cluster meets a preset awakening response strategy or not; if so, generating a wakeup response message corresponding to the data writing transaction to indicate that the data to be written is successfully written into the database cluster; otherwise, generating an abnormal response message corresponding to the data writing transaction to indicate that the data to be written is not successfully written into the database cluster.
5. The method of claim 4, further comprising:
before generating a response message corresponding to the data write transaction, acquiring wake-up response policy configuration information of the database cluster, where the wake-up response policy configuration information includes: a wake response policy for the database cluster.
6. The method of claim 1, further comprising:
scanning data replication mode configuration information of the database cluster to confirm that a packet reply policy is in an open state before determining a response result of each slave database packet in the database cluster;
and under the condition that the grouping response strategy is in a closed state, generating a response message corresponding to the data writing transaction according to a preset response strategy and a response message received by the master database.
7. An apparatus for database cluster management, comprising:
the data writing and transmitting module is used for responding to data writing transactions, writing data to be written into a master database in a database cluster and transmitting the data to be written into a plurality of slave databases in the database cluster from the master database;
the response result determining module is used for determining the response result of each slave database group in the database cluster according to the response message received by the master database; the response message is sent by the slave database which is successfully written into the data to be written;
and the response message generating module is used for generating a response message corresponding to the data writing transaction according to the response result of each slave database group in the database cluster.
8. A database clustering system, comprising:
a master database, a plurality of slave databases, and means for database cluster management configured on the master database;
the database cluster management apparatus writes data to be written to a master database in a database cluster and transmits the data to be written to a plurality of slave databases in the database cluster from the master database in response to a data write transaction;
the database cluster management device determines the response result of each slave database group in the database cluster according to the response message received by the master database; the response message is sent by the slave database which successfully writes the data to be written;
and the database cluster management device generates a response message corresponding to the data writing transaction according to the response result of each slave database group in the database cluster.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
the one or more processors, when the one or more programs are executed by the one or more processors, implement the method of any of claims 1-6.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202211421245.2A 2022-11-14 2022-11-14 Method and device for managing database cluster Pending CN115964436A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202211421245.2A CN115964436A (en) 2022-11-14 2022-11-14 Method and device for managing database cluster
PCT/CN2023/115359 WO2024103898A1 (en) 2022-11-14 2023-08-29 Database cluster management method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211421245.2A CN115964436A (en) 2022-11-14 2022-11-14 Method and device for managing database cluster

Publications (1)

Publication Number Publication Date
CN115964436A true CN115964436A (en) 2023-04-14

Family

ID=87358711

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211421245.2A Pending CN115964436A (en) 2022-11-14 2022-11-14 Method and device for managing database cluster

Country Status (2)

Country Link
CN (1) CN115964436A (en)
WO (1) WO2024103898A1 (en)

Also Published As

Publication number Publication date
WO2024103898A1 (en) 2024-05-23

Similar Documents

Publication Publication Date Title
US10061828B2 (en) Cross-ontology multi-master replication
CN112069265B (en) Synchronization method of configuration data, business data system, computer system and medium
CN109951331B (en) Method, device and computing cluster for sending information
EP2948875B1 (en) Method and system for using a recursive event listener on a node in hierarchical data structure
US10331625B2 (en) Managing sequential data store
US10726042B2 (en) Replication control using eventually consistent meta-data
CN111143382B (en) Data processing method, system and computer readable storage medium
CN109245908B (en) Method and device for switching master cluster and slave cluster
CN112597249A (en) Synchronous distribution and storage method and system for service data
CN112860343A (en) Configuration changing method, system, device, electronic equipment and storage medium
CN113193947A (en) Method, apparatus, medium, and program product for implementing distributed global ordering
CN115757616A (en) Data consistency checking method, device and medium based on binary log
CN116303789A (en) Parallel synchronization method and device for multi-fragment multi-copy database and readable medium
CN115964436A (en) Method and device for managing database cluster
CN115629909A (en) Service data processing method and device, electronic equipment and storage medium
CN115640280A (en) Data migration method and device
CN113297327A (en) System and method for generating distributed ID
CN112463887A (en) Data processing method, device, equipment and storage medium
CN114490128A (en) Data storage method and device under remote multi-active architecture
CN115168440A (en) Data read-write method, distributed storage system, device, equipment and storage medium
CN114741450A (en) Method, device, equipment and computer readable medium for switching nodes in cluster
CN117950850A (en) Data transmission method, device, electronic equipment and computer readable medium
CN116567000A (en) Data synchronization method, receiving end, transmitting end, medium and computing device
CN113486116A (en) Data synchronization method and device, electronic equipment and computer readable medium
CN113886500A (en) Data processing method, device, server and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination