CN116541461A - Data processing method, device, equipment and storage medium applied to database - Google Patents

Data processing method, device, equipment and storage medium applied to database Download PDF

Info

Publication number
CN116541461A
CN116541461A CN202310343657.7A CN202310343657A CN116541461A CN 116541461 A CN116541461 A CN 116541461A CN 202310343657 A CN202310343657 A CN 202310343657A CN 116541461 A CN116541461 A CN 116541461A
Authority
CN
China
Prior art keywords
database
slave
transaction
virtual address
data
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
CN202310343657.7A
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202310343657.7A priority Critical patent/CN116541461A/en
Publication of CN116541461A publication Critical patent/CN116541461A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • 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

Abstract

The disclosure provides a data processing method, a device, equipment and a storage medium applied to a database, which can be applied to the technical field of big data. The data processing method of the database comprises the following steps: in response to receiving an access request from application software, determining a first virtual address according to a domain name of the access request, wherein the access request is used for accessing a main database, and the first virtual address corresponds to the main database; under the condition that the main database is determined to have faults, determining the running states of M slave databases connected with the main database, wherein M is more than or equal to 2; determining a target slave database from M slave databases according to the running state; removing the binding relation between the first virtual address and the domain name, and binding a second virtual address corresponding to the target slave database with the domain name; the access request is sent to the target slave database through the second virtual address so that an operation corresponding to the access request is executed through the target slave database.

Description

Data processing method, device, equipment and storage medium applied to database
Technical Field
The present disclosure relates to the field of big data technologies, and in particular, to a data processing method, apparatus, device, and storage medium applied to a database.
Background
The database in the distributed database adopts a semi-synchronous architecture of a master database and a plurality of slave databases. In the related art, a master database performs a data processing operation and writes an execution result into the database, and the master database returns the execution result after data synchronization is achieved from the database.
In the process of implementing the inventive concept of the present disclosure, the inventor found that at least the following problems exist in the related art: under the condition that the network between the master database and the slave database is abnormal, but the network between the master database and the application software is normal, the data of the application software can be continuously written into the original master database and the new master database after fault processing, so that two master databases capable of writing data exist in one database, and the phenomenon of inconsistent service data is caused.
Disclosure of Invention
In view of the foregoing, the present disclosure provides a data processing method, apparatus, device and storage medium applied to a database.
According to a first aspect of the present disclosure, there is provided a data processing method applied to a database, comprising:
in response to receiving an access request from application software, determining a first virtual address according to a domain name of the access request, wherein the access request is used for accessing a main database, and the first virtual address corresponds to the main database;
Under the condition that the main database is determined to have faults, determining the running states of M slave databases connected with the main database, wherein M is more than or equal to 2;
determining a target slave database from M slave databases according to the running state;
removing the binding relation between the first virtual address and the domain name, and binding a second virtual address corresponding to the target slave database with the domain name; and
the access request is sent to the target slave database through the second virtual address so that an operation corresponding to the access request is executed through the target slave database.
According to an embodiment of the present disclosure, the method further comprises:
after the binding relation between the first virtual address and the domain name is released, the first virtual address is updated to be a preset address, and the preset address represents an inaccessible address.
According to an embodiment of the present disclosure, determining a target slave database from the M slave databases according to an operation state includes:
acquiring a return value of a confirmation character from the slave database, wherein the confirmation character is used for representing that the slave database has completed data synchronization, and the return value represents the number of the slave databases which have completed data synchronization;
determining a standard value of the confirmation character according to the running state;
And randomly determining a slave database from the slave databases for which the data synchronization has been completed as a target slave database in the case that the return value is greater than or equal to the standard value.
According to an embodiment of the present disclosure, wherein determining a standard value of a validation character according to an operation state includes:
under the condition that the operation states of the M slave databases are normal, determining a standard value as M-1;
in the case where it is determined that there is an abnormality in the operation states of the M slave databases, the standard value is updated to 1.
According to an embodiment of the present disclosure, the method further comprises:
the waiting time of the master database is configured to be a preset time so that the master database waits for the M slave databases to return to the running state within the preset time, the preset time is longer than a default processing time, and the default processing time represents a processing time under normal conditions.
According to an embodiment of the present disclosure, the method further comprises:
in response to receiving a detection request from a detection server, determining a transaction execution status of a main database according to an operation type, wherein the transaction execution status comprises a first data volume returned after a preset transaction is executed on original data in the database;
sending the transaction execution status of the main database to a detection server so as to enable the detection server to generate a transaction closing statement according to the first data quantity, wherein the transaction closing statement is used for closing a target transaction of which the first data quantity exceeds a preset threshold;
In response to receiving the transaction closing statement from the detection server, the transaction closing statement is executed to close the target transaction.
According to an embodiment of the present disclosure, wherein the first data amount comprises a number of returned records or bytes, the preset threshold comprises a first preset threshold or a second preset threshold,
the transaction closing statement is used for closing a target transaction with the returned record number exceeding a first preset threshold value; or alternatively, the process may be performed,
the transaction close statement is used to close a target transaction whose number of bytes exceeds a second preset threshold.
According to an embodiment of the present disclosure, in response to receiving a detection request from a detection server, determining a transaction execution status of a master database according to an operation type includes:
determining the data quantity relation before and after executing the preset transaction according to the operation type;
acquiring a second data quantity corresponding to the original data; and
and generating a first data volume according to the data volume change relation and the second data volume.
A second aspect of the present disclosure provides a data processing apparatus applied to a database, comprising:
the first determining module is used for determining a first virtual address according to the domain name of the access request in response to receiving the access request from the application software, wherein the access request is used for accessing the main database, and the first virtual address corresponds to the main database;
The second determining module is used for determining the running states of M slave databases connected with the master database under the condition that the master database is determined to have faults, wherein M is more than or equal to 2;
the third determining module is used for determining a target slave database from M slave databases according to the running state;
the binding module is used for removing the binding relation between the first virtual address and the domain name and binding the second virtual address corresponding to the target slave database with the domain name; and
and the sending module is used for sending the access request to the target slave database through the second virtual address so as to execute the operation corresponding to the access request through the target slave database.
A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the data processing method applied to the database as described above.
A fourth aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the above-described data processing method applied to a database.
A fifth aspect of the present disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the data processing method as described above applied to a database.
In the embodiment of the disclosure, a first virtual address is determined according to a domain name of an access request by responding to the access request from application software, and the first virtual address corresponds to a main database; under the condition that the main database is determined to have faults, determining the running states of M slave databases connected with the main database; determining a target slave database from M slave databases according to the running state; removing the binding relation between the first virtual address and the domain name, and binding a second virtual address corresponding to the target slave database with the domain name; and sending the access request to the target slave database through the second virtual address so as to execute the operation corresponding to the access request through the target slave database, thereby realizing that the database switching is not perceived by the application.
Because the domain name and the virtual address are bound, and the binding relation between the domain name and the virtual address is updated under the condition that the main database fails, only one target slave database can be accessed through the access request, so that the situation that the database switching does not feel the application is realized, the phenomenon that the two databases can write in data is avoided, the influence of the database switching on the service is reduced, and the emergency time is shortened.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be more apparent from the following description of embodiments of the disclosure with reference to the accompanying drawings, in which:
fig. 1 schematically illustrates an application scenario of a data processing method applied to a database according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow chart of a data processing method applied to a database according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow chart of a method of determining a target slave database in accordance with an embodiment of the disclosure;
FIG. 4 schematically illustrates an application scenario of a data processing flow within a database according to an embodiment of the present disclosure;
FIG. 5 schematically illustrates a flow diagram of a method of closing a target transaction, in accordance with an embodiment of the present disclosure;
FIG. 6 schematically illustrates an application scenario of a close target transaction according to an embodiment of the disclosure;
FIG. 7 schematically illustrates a block diagram of a data processing apparatus applied to a database according to an embodiment of the present disclosure; and
fig. 8 schematically illustrates a block diagram of an electronic device adapted for application to a data processing method of a database according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is only exemplary and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the present disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. In addition, in the following description, descriptions of well-known structures and techniques are omitted so as not to unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and/or the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It should be noted that the terms used herein should be construed to have meanings consistent with the context of the present specification and should not be construed in an idealized or overly formal manner.
Where expressions like at least one of "A, B and C, etc. are used, the expressions should generally be interpreted in accordance with the meaning as commonly understood by those skilled in the art (e.g.," a system having at least one of A, B and C "shall include, but not be limited to, a system having a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
In the technical scheme of the disclosure, the related data (such as including but not limited to personal information of a user) are collected, stored, used, processed, transmitted, provided, disclosed, applied and the like, all conform to the regulations of related laws and regulations, necessary security measures are adopted, and the public welcome is not violated.
For the semi-synchronous replication mode, application software submits a new transaction to a database server, the database server executes the transaction by the main database after receiving the new transaction, and the execution result is written into the main database. After writing the execution result into the master database, the master database does not directly return the execution result to the application software, but waits for the plurality of slave databases to complete data synchronization before returning the execution result to the application software.
When the network between the master database and the slave database is abnormal, but the network between the master database and the application software is normal, the database server can promote one slave database to be the master database because the network between the master database and the slave database is abnormal; however, the network between the master database and the application software is normal and the application can continue to write data to the database. In the above case, there may be two main databases in which data can be written in one database, resulting in a phenomenon of brain fracture in which data in the databases are inconsistent.
The embodiment of the disclosure provides a data processing method applied to a database, comprising the following steps: in response to receiving an access request from application software, determining a first virtual address according to a domain name of the access request, wherein the access request is used for accessing a main database, and the first virtual address corresponds to the main database; under the condition that the main database is determined to have faults, determining the running states of M slave databases connected with the main database, wherein M is more than or equal to 2; determining a target slave database from M slave databases according to the running state; removing the binding relation between the first virtual address and the domain name, and binding a second virtual address corresponding to the target slave database with the domain name; and sending the access request to the target slave database through the second virtual address so as to execute the operation corresponding to the access request through the target slave database.
Fig. 1 schematically illustrates an application scenario of a data processing method applied to a database according to an embodiment of the present disclosure.
As shown in fig. 1, an application scenario 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 a medium used to provide 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, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 through the network 104 using at least one of the first terminal device 101, the second terminal device 102, the third terminal device 103, to receive or send messages, etc. Various communication client applications, such as a shopping class application, a web browser application, a search class application, an instant messaging tool, a mailbox client, social platform software, etc. (by way of example only) may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103.
The first terminal device 101, the second terminal device 102, the third terminal device 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 105 may be a server providing various services, such as a database server providing support for a user with client application functions of the first terminal device 101, the second terminal device 102, the third terminal device 103. The database server may analyze and process the received data such as the user request, and return the execution result to the terminal device after implementing data synchronization.
The data processing method applied to the database provided by the embodiments of the present disclosure may be generally performed by the server 105. Accordingly, the data processing apparatus of the database provided in the embodiments of the present disclosure may be generally disposed in the server 105. The data processing method of the database provided by the embodiments of the present disclosure may also be performed by a server or a server cluster that is different from the server 105 and is capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and/or the server 105. Accordingly, the data processing apparatus of the database provided by the embodiments of the present disclosure may also be provided in a server or a server cluster that is different from the server 105 and is capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and/or the server 105.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The data processing method of the database of the disclosed embodiment will be described in detail below with reference to fig. 2 to 6 based on the scenario described in fig. 1.
Fig. 2 schematically illustrates a flow chart of a data processing method applied to a database according to an embodiment of the present disclosure.
As shown in fig. 2, the method 200 includes operations S210-S250.
In response to receiving an access request from the application software, a first virtual address is determined from a domain name of the access request in operation S210.
According to an embodiment of the present disclosure, a master database and a plurality of slave databases are included in a database server. The access request of the application software is used for accessing the master database, and in the case of failure of the master database, the access request is used for accessing the slave database of the master database.
According to embodiments of the present disclosure, the database server may be a database shard in a distributed database for storing and executing data of a predetermined traffic scenario or a predetermined traffic type. The distributed database may be a redis cluster and the master and slave databases may be MySQL databases.
According to an embodiment of the present disclosure, the application software and database server are connected through a domain name system (Domain Name System, DNS) service. In particular, the domain name system service may map domain names and internet protocol (Internet Protocol, IP) addresses to each other so that application software accesses a database within a database server through DNS.
According to an embodiment of the present disclosure, the master database and the slave databases include physical IP addresses used by their own operating systems, and further include virtual IP addresses corresponding to each database. The virtual IP address corresponding to the master database is a first virtual address, and the virtual IP address corresponding to the slave database is a second virtual address.
In operation S220, in case it is determined that the master database fails, the operation states of M slave databases connected to the master database are determined, M being equal to or greater than 2.
According to an embodiment of the present disclosure, in case of a failure of the master database, in order to guarantee a normal response of an access request of the application software, the database server will process the above access request through the slave database associated with the master database.
According to an embodiment of the present disclosure, in the distributed server, one master database may have M slave databases, and thus, a target slave database for processing an access request is determined from the M slave databases by determining an operation state of the M slave databases.
According to an embodiment of the present disclosure, the operational status is used to characterize whether a slave database is faulty.
According to the embodiment of the disclosure, whether the main database has a fault or not can be determined according to the operation state of the main database. Wherein, the fault types of the main database include: the network between the master database and the slave database fails or breaks, but the master database may normally receive an access request of the application software.
In operation S230, a target slave database is determined from the M slave databases according to the operation state.
According to the embodiment of the disclosure, after determining the operation states of the M slave databases, one slave database which is normal in operation may be determined from the M slave databases based on the operation states of the M slave databases, and the slave database which is normal in operation may be determined as the target slave database.
In operation S240, the binding relationship between the first virtual address and the domain name is released, and the second virtual address corresponding to the target slave database is bound to the domain name.
According to an embodiment of the present disclosure, the application software accesses a database within a database server through a domain name. And under the condition that the main database does not have faults, the domain name of the access request is bound with the first virtual address.
According to the embodiment of the disclosure, since only the master database is mounted on the first virtual address, in the case that a network between the master database and the slave database fails, in order to avoid an access request accessing the master database, a domain name of the access request is in contact binding relation with the first virtual address, and the domain name is bound with the second virtual address. Thus, the access request may access the secondary database corresponding to the second virtual address through the secondary database corresponding to the second virtual address.
According to the embodiment of the disclosure, since the binding relation between the first virtual address and the domain name is released, the situation that the master database and the slave database corresponding to the second virtual address can both write data does not occur in the database server.
In operation S250, the access request is transmitted to the target slave database through the second virtual address so that an operation corresponding to the access request is performed through the target slave database.
According to the embodiment of the disclosure, after binding the domain name with the second virtual address, the data server may determine the target slave database to be accessed according to the domain name of the access request, that is, may send the access request to the target slave database through the second virtual address, so as to execute an operation corresponding to the access request through the target slave database.
For example, the first virtual address may be VIP1 and the second virtual address may be VIP2. The physical address of the master database is TIP1, and the physical address of the target slave database is TIP2. The master database is mounted on the first virtual address, and the target slave database is mounted on the second virtual address. I.e. the mapping relationship between virtual address and physical address is VIP1-TIP1, VIP2-TIP2.
In the case that the primary database fails, since the first virtual address VIP1 used by the primary database is configured in the domain name system service DNS, the application software may determine the first virtual address VIP1 through the DNS and access the primary database through a physical address associated with the first virtual address VIP1, such as TIP1. The data access relationship is DNS-VIP1-TIP1.
When the master database fails, the first virtual address VIP1 of the master database is unbound with the DNS, and the second virtual address VIP2 of the target slave database is bound with the DNS, so that the data server normally accesses the application access request. At this time, the application software may determine the second virtual address VIP2 through DNS and access the target slave database through a physical address, such as TIP2, associated with the second virtual address VIP2. The data access relationship is DNS-VIP2-TIP2.
According to the embodiment of the disclosure, since only the master database is mounted on the first virtual address, in the case that a network between the master database and the slave database fails, the access request can access the master database through the first virtual address, but the master database cannot receive a response from the slave database. At this time, the database server automatically promotes one slave database to the master database to complete data processing and returns an execution result to the application software. However, in this case, the semi-synchronous replication may be degraded to asynchronous replication, and the integrity of the data from the database may not be guaranteed.
In the embodiment of the disclosure, a first virtual address is determined according to a domain name of an access request by responding to the access request from application software, and the first virtual address corresponds to a main database; under the condition that the main database is determined to have faults, determining the running states of M slave databases connected with the main database; determining a target slave database from M slave databases according to the running state; removing the binding relation between the first virtual address and the domain name, and binding a second virtual address corresponding to the target slave database with the domain name; and sending the access request to the target slave database through the second virtual address so as to execute the operation corresponding to the access request through the target slave database, thereby realizing that the database switching is not perceived by the application.
Because the domain name and the virtual address are bound, the binding relation between the domain name and the virtual address is updated under the condition that the main database fails, so that the main database cannot be accessed at the same time point, only one target slave database can be accessed, the situation that the database switching does not feel the application is realized, the phenomenon that the two databases can both write in data can be avoided, the influence of the database switching on the service is reduced, and the emergency time is shortened.
According to an embodiment of the present disclosure, the method further comprises the steps of: after the binding relation between the first virtual address and the domain name is released, the first virtual address is updated to be a preset address, and the preset address represents an inaccessible address.
According to the embodiment of the disclosure, after updating the binding relation between the domain name and the virtual address, although two master databases (the failed master database and the target slave database) exist in the database server, only one master database (the target slave database) can write data at the same time, and the data in the written master database has time continuous rows, so that the data consistency of the master database and the slave database is ensured.
According to the embodiment of the disclosure, in order to further ensure that the main database which cannot fail cannot write data, the main database is not mounted on the first virtual address by pointing the first virtual address to the preset address which cannot be accessed.
In the embodiment of the disclosure, because the access to the database is realized through the relationship of domain name-virtual address-physical address, after the binding relationship between the domain name and the first virtual address is released, the virtual address is further pointed to the preset address which cannot be accessed, so that the mount between the main database and the virtual address is substantially released, the main database is ensured not to receive the access request, the data writing operation is not executed, and the data consistency is further ensured.
Fig. 3 schematically illustrates a flow chart of a method of determining a target slave database according to an embodiment of the disclosure.
As shown in fig. 3, the determining target slave database method 300 of this embodiment includes operations S331 to S333, which may be a specific embodiment of operation S230.
In operation S331, a return value of a confirmation character from the slave database for characterizing that the slave database has completed data synchronization is acquired, the return value characterizing the number of slave databases that have completed data synchronization.
In operation S332, a standard value of the validation character is determined according to the operation state.
In operation S333, in the case where the return value is greater than or equal to the standard value, one slave database is randomly determined from among the slave databases for which data synchronization has been completed, as the target slave database.
According to the embodiment of the disclosure, in the case that the return value is greater than or equal to the standard value, the slave database which indicates that the data synchronization has been completed by the slave database which has already satisfied the standard value can be used as the target slave database, so as to ensure the integrity and consistency of the data.
According to an embodiment of the present disclosure, in the case that the return value is smaller than the standard value, it is indicated that the slave database having no or less than the standard value has completed data synchronization. In order to avoid a situation that the target slave database starts to execute data writing when data synchronization is not completed, and the data of the target slave database is inconsistent with the data of the master database, the slave database which does not complete data synchronization waits to execute data synchronization and returns a confirmation character when the return value is smaller than the standard value.
For example, the master database corresponds to three slave databases, namely slave database a, slave database B and slave database C. The master database receives an acknowledgment character from database a and from database C indicating that the slave database a and slave database C have completed data synchronization. The master database does not receive the validation character from database B, indicating that the slave database B did not complete the data synchronization, at which point the return value of the validation character is 2.
According to embodiments of the present disclosure, an Acknowledgement character (Acknowledgement) may be abbreviated as an ACK character. In practical applications, an ACK may be used as a field name.
According to the embodiment of the disclosure, the standard value of the validation character is determined according to the running states of M slave databases, so that the standard value can be flexibly adjusted according to the actual running states of the slave databases, and the response time is reduced.
For example, if the standard value is fixed, it is 2. For a database architecture with one master and three slaves, under the condition that two slaves fail, the return value is at most 1, and the standard value cannot be reached, so that the database server cannot be in a waiting state all the time, and the operation cannot be executed.
According to the embodiment of the disclosure, the standard value of the validation character is determined according to the running states of M slave databases, so that the standard value can be flexibly adjusted according to the actual running states of the slave databases, and the response time is reduced.
According to an embodiment of the present disclosure, determining the standard value of the validation character may include the following steps according to the operation state.
And under the condition that the operation states of the M slave databases are all normal, determining the standard value as M-1.
In the case where it is determined that there is an abnormality in the operation states of the M slave databases, the standard value is updated to 1.
For example, for a master-three-slave architecture, when all three slave databases are normal, the default standard value is the total number of slave databases minus one, i.e., 2. In the case of a failure of one slave database, the standard value is set to 1; when two slave databases fail, ACK is set to 1.
In the embodiment of the disclosure, under the condition that the operation states of M slave databases are all normal, the standard value is determined to be M-1; under the condition that the running states of the M slave databases are abnormal, the standard value is updated to 1, so that at least one slave database can be synchronized with the master database data, and meanwhile, the influence of the slave database faults on the continuous running of the whole cluster can be reduced.
Fig. 4 schematically illustrates an application scenario of a data processing flow within a database according to an embodiment of the present disclosure.
As shown in fig. 4, the application scenario 400 of this embodiment includes application software 401 and a database server 402. The database server includes a master database 4021, a slave database a4022, a slave database B4023, a slave database C4024, and a high availability component 4025.
According to an embodiment of the present disclosure, the application software 401 connects with a database within a database server through a domain name system service, DNS service. Specifically, the application software 401 accesses the database through DNS in which the first virtual address VIP1 used by the main database 4021 is configured. In the case that the primary database is not faulty, the application software may determine the first virtual address VIP1 through DNS and access the primary database through a physical address associated with the first virtual address VIP1, such as TIP1. The data access relationship is DNS-VIP1-TIP1.
When the primary repository fails, the primary virtual address VIP1 of the primary database 4021 is unbound to DNS and the primary virtual address VIP1 is set as inaccessible. Binding a second virtual address VIP2 of the target slave database with the DNS, normally accessing the application access flow, and realizing that the database switching has no perception to the application.
According to an embodiment of the present disclosure, in a case where both the master database and the slave database are normal, the slave database a 4022, the slave database B4023, and the slave database C4024 may perform master-slave replication with the master database 4021 to achieve data synchronization.
According to embodiments of the present disclosure, the high availability component 4025 may collect information from the master database 4021, from database a 4022, from database B4023, from database C4024; the high availability component 4025 may also issue instructions to the master database 4021, the slave database a 4022, the slave database B4023, and the slave database C4024.
For example, the high availability component 4025 detects the states of the master database 4021, the slave database a 4022, the slave database B4023 and the slave database C4024 in real time, and when an abnormality occurs in the master database 4021, selects one slave database from the slave databases which have completed the same data, promotes the slave database to the master database, and degrades the failed master database to the slave database. The master database and the slave database are guaranteed to be strong, so that the phenomenon of data loss of the master database and the slave database in the switching process can be avoided.
According to an embodiment of the present disclosure, the method further comprises: the waiting time of the master database is configured to be a preset time so that the master database waits for the M slave databases to return to the running state within the preset time, the preset time is longer than a default processing time, and the default processing time represents a processing time under normal conditions.
According to the embodiment of the present disclosure, in the related art, the waiting time of the master database is 3 seconds, and if the number of confirmation characters received by the master database has not met the standard value, the master database automatically performs data writing using one slave database as the master database only by waiting for 3 seconds. However, in the above case, since the data synchronization is not completed from the database, the semi-synchronous replication mode of the database is degraded to be asynchronous, so that the data integrity of the database cannot be guaranteed.
According to an embodiment of the present disclosure, configuring the waiting time period of the master database to be a preset time period includes the following operation statements: set global rpl_semi_sync_master_timeout=999999999.
According to the embodiment of the disclosure, by configuring the waiting time length to be a standard time length far greater than the default processing time length and configuring the waiting time length of the master database to be an infinite time length, the slave database is ensured not to be degraded, and the data integrity of the slave database is ensured.
According to the embodiment of the disclosure, the waiting time is prolonged to be infinitely long, and the standard value of the confirmation character is determined according to the running state, so that the waiting time of the master database can be reduced while the slave database is ensured not to be degraded and the data integrity of the slave database is ensured.
The embodiment of the disclosure can also detect the transaction execution status of the database server through the detection server so as to close the large transaction in time, avoid the phenomenon of data blocking in the database cluster and ensure the continuity of service data.
Fig. 5 schematically illustrates a flow chart of a method of closing a target transaction according to an embodiment of the disclosure.
As shown in fig. 5, the closing method 500 of the target transaction of this embodiment includes operations S510 to S530. Operations S510 to S530 may be performed in parallel with operations S210 to S250, or may be performed before operations S210 to S250.
In response to receiving the detection request from the detection server, a transaction execution status of the master database is determined according to the operation type in operation S510.
According to an embodiment of the present disclosure, the transaction execution status includes a first amount of data returned in the database after a preset transaction is performed on the original data. Wherein the original data comprises database data to be used by an access request from the application software.
For example, the access request is for logging out information of the user a, the user B, and the user C, and the raw data may be account data of the user a, the user B, and the user C, including account names, attribute information, transaction information, and the like.
According to the embodiment of the disclosure, a plurality of operation types exist in the database, and a plurality of cases exist in the first data volume after the preset transaction is performed on the original data through the plurality of operation types. Thus, according to the operation type and the original data, the transaction execution status of the main database can be determined without requiring the database to execute a preset transaction before determining the first data amount. And the phenomenon that the database is blocked to cause the database ramming after the main database executes large transactions is avoided.
In operation S520, the transaction execution status of the master database is transmitted to the detection server so that the detection server generates a transaction close statement according to the first data amount.
According to an embodiment of the present disclosure, a database server determines a current transaction execution status of a master database in response to receiving a detection request from a detection server, and returns the current transaction execution status to the detection server as a response to the detection request.
According to embodiments of the present disclosure, the detection server may periodically send detection requests to the database server so that the database server reflects the transaction execution status of the master database over a period of time. For example, the detection server may send detection requests to the database server at intervals of 3 seconds, 10 seconds, or 1 minute. The interval duration may also be determined according to the actual situation.
As another specific embodiment, the database server may send the transaction execution status to the detection server at regular time without the detection server sending the detection request, and the database server may not send the transaction execution status in response to the detection request.
According to an embodiment of the present disclosure, after the detection server receives the transaction execution status from the database server, a determination is made of a first amount of data included in the transaction execution status. And generating a transaction closing statement for closing a target transaction of which the first data amount exceeds a preset threshold value under the condition that the first data amount exceeds the preset threshold value, so that the main database closes the target transaction.
In operation S530, in response to receiving the transaction closing statement from the detection server, the transaction closing statement is executed to close the target transaction.
According to the embodiment of the disclosure, after receiving the transaction closing statement from the detection server, the database server executes the transaction closing statement in the main database, closes a large transaction session corresponding to the transaction closing statement, releases database resources, and avoids the whole database cluster ramming.
According to an embodiment of the present disclosure, in case of a failure of a master database, a database server performs a database operation with a target slave database as a new master database. At this time, the transaction execution status pushed by the database server to the detection server further includes the third data amount of the target slave database, so that the detection server generates a target transaction for closing the third data amount exceeding the preset threshold in the target slave database. The large transaction detection operation and the closing operation in the target slave database are the same as those in the master database, and will not be described in detail herein.
According to the embodiment of the disclosure, the transaction execution status of the database server is sent to the detection server, so that the detection server generates the transaction closing statement according to the transaction execution status, so that the database server can close a large transaction in time according to the transaction closing statement, the phenomenon of data blocking in a database cluster is avoided, and the continuity of service data is ensured.
According to the embodiment of the present disclosure, the large transaction may be closed in time through the operations S510 to S530 described above, so as to avoid the phenomenon of data blocking in the database cluster.
The above operations S510 to S530 may also be parallel to setting the waiting time period of the master database according to an embodiment of the present disclosure.
After the waiting time is prolonged to be the preset time, if a large transaction occurs in the master database, the slave database needs a longer time to perform data synchronization, the master database can wait for the slave database to complete data synchronization and feed back, and then submits an execution result to the application software, so that the transaction response time is long, the condition of ramming the database possibly exists in the whole database cluster, and the service continuity is further affected.
According to the embodiment of the disclosure, after the waiting time is prolonged to the preset time through the operations S510-S530, the large transaction of the main database is avoided, and the large transaction can be closed in time without executing the large transaction under the condition that the large transaction is detected to exist according to the original data, so that the phenomenon of data blocking in the database cluster is avoided.
Fig. 6 schematically illustrates an application scenario of closing a target transaction according to an embodiment of the present disclosure.
As shown in fig. 6, the application scenario 600 of this embodiment includes a database server 602 and a detection server 603. Database server 602 is similar to database server 402 in FIG. 4, including high availability components, a master database, a slave database A, a slave database B, and a slave database C.
According to an embodiment of the present disclosure, the database server 602 further includes a large transaction processing module 6026 for acquiring the transaction execution status of the master database or the target slave database in the database server and transmitting the transaction execution status to the detection server 603.
According to embodiments of the present disclosure, the large transaction module 6026 may obtain and send the transaction execution status in response to the detection request from the detection server 603. The large transaction module 6026 may also acquire and send the transaction execution status to the detection server 603 without responding to a detection request from the detection server.
The detection server 603 may send a detection request to the large transaction module 6026 of the database server 602 so that the large transaction module 6026 sends the transaction execution status. The detection server 603 may directly acquire the execution status of the transaction from the large transaction module 6026 without generating the detection request.
According to embodiments of the present disclosure, the detection server 603 may generate a transaction closing statement for closing a target transaction for which the first data amount exceeds a preset threshold according to the transaction execution status sent by the large transaction processing module 6026.
According to an embodiment of the present disclosure, wherein the first data amount comprises a number of returned records or bytes, and the preset threshold comprises a first preset threshold or a second preset threshold.
According to an embodiment of the present disclosure, a transaction closing statement is used to close a target transaction whose number of return records exceeds a first preset threshold.
According to embodiments of the present disclosure, the transaction closing statement may also be used to close a target transaction whose number of bytes exceeds a second preset threshold.
According to an embodiment of the present disclosure, a database in a database server records data update conditions using a binlog log, and data synchronization of a master database and a slave database is achieved by transmitting the binlog. For example, the database may be a MySQL database.
In response to receiving an access request from the application software, the master database blocks other transactions from other application software during the transaction writing binlog, and during the semi-synchronous transmission binlog, such that transactions within the database cluster are blocked. Where the transaction blocking time is proportional to the binlog data amount. Thus, large transactions may be closed according to the number of returned records or bytes within the transaction execution status to avoid database cluster blocking.
For example, for records with a number of single return records exceeding 10 ten thousand lines, the detection server generates a transaction closing statement that closes the transaction. Alternatively, the detection server generates a transaction close statement that closes the transaction upon detecting an SQL statement having a byte count exceeding 100M. The number of updates, inserts, deletes for a single transaction is less than 10 ten thousand lines and the binlog generated should be less than 100M.
According to an embodiment of the present disclosure, the first preset threshold value and the second preset threshold value are both used as a specific embodiment, and in actual use, the first preset threshold value and the second preset threshold value may be determined according to actual situations, and are not limited to the above values.
According to an embodiment of the present disclosure, in response to receiving a detection request from a detection server, determining a transaction execution status of a master database according to an operation type includes:
determining the data quantity relation before and after executing the preset transaction according to the operation type;
acquiring a second data quantity corresponding to the original data; and
and generating a first data volume according to the data volume change relation and the second data volume.
According to the embodiment of the disclosure, the transaction execution status of the main database can be determined according to the operation type and the original data, without determining the first data amount after the database executes the preset transaction. There are multiple operation types in the database, and the multiple operation types correspond to multiple data amount change relations.
For example, in the case where the operation type is insert or update, the first data amount is 2 times the second data amount, and the data amount change relationship is 2. The INSERT operation is an INSERT operation, and the UPDATE operation is an UPDATE operation.
According to the embodiment of the disclosure, the log binlog of the database records the original SQL statement in addition to the ROW data change condition. The data value contained in the INSERT statement, plus the recorded ROW change, results in a data size that is 2 times the original data size.
According to embodiments of the present disclosure, since one UPDATE statement may correspond to multiple ROW changes, in ROW mode, the SQL statement itself is ignored. However, the ROW change of the UPDATE operation will record all field values before and after the UPDATE, so the resulting data size is 2 times the original data size.
According to the embodiment of the present disclosure, in the case where the operation type is delete, the first data amount is 1 times the second data amount, and the data amount change relationship is 1. Wherein the DELETE operation is a DELETE operation.
According to embodiments of the present disclosure, one DELETE statement may correspond to many ROW changes, so the statement itself is ignored, and the ROW change of the DELETE operation will record all field values before deletion, so the resulting amount of data is 1 times the original amount of data.
According to an embodiment of the present disclosure, in the case where the operation type is load, the first data amount is 1-3 times the second data amount, and the data amount relationship is 1 or 2 or 3. Wherein the load operation is a REPLACE intoo operation.
According to embodiments of the present disclosure, for the REPLACE intoo (LOAD DATA) operation, the REPLACE intoo statement itself is ignored. There are two cases of REPLACE intoo: newly adding and replacing. If the data is newly added, the data quantity is 1 time; if so, mySQL internally executes delete+INSERT, i.e., 2 data volumes.
According to an embodiment of the present disclosure, for a REPLACE INTO (non-LOAD DATA) operation, the REPLACE INTO statement contains a DATA value (1-fold), considering two cases of addition (1-fold) and replacement (2-fold). For the newly added case, the data amount finally obtained is the data value plus the newly added data amount which is 2 times of the original data amount. For the replacement case, the resulting data amount data value + replacement is a data amount that is 3 times the original data amount.
According to the embodiment of the disclosure, before data processing is not executed, the final returned data quantity can be determined according to the change relation, so that the waste of computing resources is reduced, and the response time is shortened.
The embodiment of the disclosure provides a data processing method applied to a database, and provides an implementation scheme of automatic checking and killing of large transactions, no degradation in copying from the database and automatic switching of the database, so that the data integrity requirement of master-slave switching of fault scenes is effectively met, and the stability and reliability of the service are ensured. Specifically, through a master-slave non-degradation mechanism, master-slave automatic switching with retransmission timeout time (Retransmission Time Out, RTO) of 0 in a master database fault scene is realized, and zero loss of master-slave switching data is ensured. In order to reduce the negative influence of easy ramming of a main library caused by non-degradation of a master library and a slave library, and give consideration to RTO requirements of service continuity operation, a large transaction automatic detection and closing mechanism is realized, and a pretreatment mechanism is performed before the production database is abnormal, so that the probability of ramming the main library due to the large transaction is greatly reduced. Through high available components and special DNS configuration (DNS is bound with VIP), the database switching is not perceived to the application, the service influence range of the database switching is reduced, and the emergency time is reduced.
Fig. 7 schematically illustrates a block diagram of a data processing apparatus applied to a database according to an embodiment of the present disclosure.
As shown in fig. 7, the data processing apparatus 700 applied to a database of this embodiment includes a first determination module 710, a second determination module 720, a third determination module 730, a binding module 740, and a transmission module 750.
The first determining module 710 is configured to determine, in response to receiving an access request from the application software, a first virtual address according to a domain name of the access request, where the access request is for accessing a primary database, and the first virtual address corresponds to the primary database. In an embodiment, the first determining module 710 may be configured to perform the operation S210 described above, which is not described herein.
And a second determining module 720, configured to determine an operation state of M slave databases connected to the master database in case of determining that the master database fails, where M is greater than or equal to 2. In an embodiment, the second determining module 720 may be configured to perform the operation S220 described above, which is not described herein.
And a third determining module 730, configured to determine a target slave database from the M slave databases according to the operation state. In an embodiment, the third determining module 730 may be configured to perform the operation S230 described above, which is not described herein.
And a binding module 740, configured to unbind the first virtual address from the domain name, and bind the second virtual address corresponding to the target slave database from the domain name. In an embodiment, the binding module 740 may be used to perform the operation S240 described above, which is not described herein.
And a sending module 750, configured to send the access request to the target slave database through the second virtual address, so as to perform an operation corresponding to the access request through the target slave database. In an embodiment, the sending module 750 may be configured to perform the operation S250 described above, which is not described herein.
According to an embodiment of the present disclosure, the data processing apparatus 700 applied to the database further includes an address updating module, configured to update the first virtual address to a preset address, where the preset address characterizes an inaccessible address, after the binding relationship between the first virtual address and the domain name is released.
According to an embodiment of the present disclosure, the third determining module 730 includes a first determining unit, a second determining unit, and a third determining unit.
The first determining unit is used for obtaining a return value of a confirmation character, wherein the confirmation character is from the slave database and used for representing that the slave database has completed data synchronization, and the return value represents the number of the slave databases which have completed data synchronization. In an embodiment, the first determining unit may be configured to perform the operation S331 described above, which is not described herein.
The second determining unit is used for determining a standard value of the confirmation character according to the running state. In an embodiment, the second determining unit may be configured to perform the operation S332 described above, which is not described herein.
The third determination unit is configured to randomly determine, as a target slave database, one slave database from among slave databases for which data synchronization has been completed, in a case where the return value is greater than or equal to the standard value. In an embodiment, the third determining unit may be configured to perform the operation S333 described above, which is not described herein.
According to an embodiment of the present disclosure, the second determination unit includes a first determination subunit and a second determination subunit.
The first determining subunit is used for determining that the standard value is M-1 under the condition that the operation states of the M slave databases are all normal.
The second determination subunit is configured to update the standard value to 1 in a case where it is determined that there are anomalies in the operation states of the M slave databases.
According to an embodiment of the present disclosure, the data processing apparatus 700 applied to the database further includes a duration configuration module, so as to configure the waiting duration of the master database to a preset duration, so that the master database waits for the M slave databases to return to the running state within the preset duration, where the preset duration is greater than a default processing duration, and the default processing duration characterizes a processing duration under normal conditions.
According to an embodiment of the present disclosure, the data processing apparatus 700 applied to the database further includes a large transaction processing module. The large transaction processing module comprises a fourth determining unit, a sending unit and an executing unit.
The fourth determining unit is used for determining a transaction execution status of the main database according to the operation type in response to receiving the detection request from the detection server, wherein the transaction execution status comprises a first data amount returned after the preset transaction is executed on the original data in the database. In an embodiment, the fourth determining unit may be configured to perform the operation S510 described above, which is not described herein.
The sending unit is used for sending the transaction execution status of the main database to the detection server so as to enable the detection server to generate a transaction closing statement according to the first data quantity, wherein the transaction closing statement is used for closing a target transaction of which the first data quantity exceeds a preset threshold value. In an embodiment, the sending unit may be configured to perform the operation S520 described above, which is not described herein.
The execution unit is to execute the transaction close statement to close the target transaction in response to receiving the transaction close statement from the detection server. In an embodiment, the execution unit may be configured to execute the operation S530 described above, which is not described herein.
According to an embodiment of the present disclosure, the first data amount includes a number of returned records or bytes, and the preset threshold includes a first preset threshold or a second preset threshold.
The transaction closing statement is used for closing a target transaction with the number of returned records exceeding a first preset threshold.
The transaction close statement is used to close a target transaction whose number of bytes exceeds a second preset threshold.
According to an embodiment of the present disclosure, the fourth determination unit includes a third determination subunit, an acquisition subunit, and a generation subunit.
The third determining subunit is configured to determine, according to the operation type, a data amount change relationship before and after executing the preset transaction.
The acquisition subunit is configured to acquire a second data amount corresponding to the original data.
The generation subunit is used for generating the first data volume according to the data volume change relation and the second data volume.
According to an embodiment of the present disclosure, any of the first determining module 710, the second determining module 720, the third determining module 730, the binding module 740, and the transmitting module 750 may be combined in one module to be implemented, or any of the modules may be split into a plurality of modules. Alternatively, at least some of the functionality of one or more of the modules may be combined with at least some of the functionality of other modules and implemented in one module.
According to embodiments of the present disclosure, at least one of the first determination module 710, the second determination module 720, the third determination module 730, the binding module 740, and the sending module 750 may be implemented at least in part as hardware circuitry, 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 as hardware or firmware in any other reasonable manner of integrating or packaging the circuitry, or as any one of or a suitable combination of any of the three. Alternatively, at least one of the first determination module 710, the second determination module 720, the third determination module 730, the binding module 740 and the sending module 750 may be at least partially implemented as computer program modules which, when executed, may perform the respective functions.
Fig. 8 schematically illustrates a block diagram of an electronic device adapted for application to a data processing method of a database according to an embodiment of the present disclosure.
As shown in fig. 8, an electronic device 800 according to an embodiment of the present disclosure includes a processor 801 that 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 section 808 into 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 an associated chipset and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), or the like. The processor 801 may also include on-board memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing the different actions of the method flows according to embodiments of the disclosure.
In the RAM 803, various programs and data required for the operation of the electronic device 800 are stored. The processor 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. The processor 801 performs various operations of the method flow according to the embodiments of the present disclosure by executing programs in the ROM 802 and/or the RAM 803. Note that the program may be stored in one or more memories other than the ROM 802 and the RAM 803. The processor 801 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the present disclosure, the electronic device 800 may also include an input/output (I/O) interface 805, the input/output (I/O) interface 805 also being connected to the bus 804. The electronic device 800 may also include one or more of the following components connected to the input/output I/O interface 805: an input portion 806 including a keyboard, mouse, etc.; an output portion 807 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage section 808 including a hard disk or the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. The 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, or the like is mounted on the drive 810 as needed so that a computer program read out therefrom is mounted into the storage section 808 as needed.
The present disclosure also provides a computer-readable storage medium that may be embodied in the apparatus/device/system described in the above embodiments; or may exist alone without being assembled into the apparatus/device/system. The computer-readable storage medium carries one or more programs which, when executed, implement methods in accordance with embodiments of the present disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example, but is not limited to: 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), 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 the context of this disclosure, 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. For example, according to embodiments of the present disclosure, the computer-readable storage medium may include ROM 802 and/or RAM 803 and/or one or more memories other than ROM 802 and RAM 803 described above.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowcharts. The program code, when executed in a computer system, causes the computer system to perform the methods provided by embodiments of the present disclosure.
The above-described functions defined in the system/apparatus of the embodiments of the present disclosure are performed when the computer program is executed by the processor 801. The systems, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted, distributed, and downloaded and installed in the form of a signal on a network medium, and/or from a removable medium 811 via a communication portion 809. The computer program may include program code that may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network via the communication section 809, and/or installed from the removable media 811. The above-described functions defined in the system of the embodiments of the present disclosure are performed when the computer program is executed by the processor 801. The systems, devices, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
According to embodiments of the present disclosure, program code for performing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, such computer programs may be implemented in high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. Programming languages include, but are not limited to, such as Java, c++, python, "C" or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. 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.
Those skilled in the art will appreciate that the features recited in the various embodiments of the disclosure and/or in the claims may be provided in a variety of combinations and/or combinations, even if such combinations or combinations are not explicitly recited in the disclosure. In particular, the features recited in the various embodiments of the present disclosure and/or the claims may be variously combined and/or combined without departing from the spirit and teachings of the present disclosure. All such combinations and/or combinations fall within the scope of the present disclosure.
While the foregoing is directed to embodiments of the present disclosure, other and further details of the invention may be had by the present application, it is to be understood that the foregoing description is merely exemplary of the present disclosure and that no limitations are intended to the scope of the disclosure, except insofar as modifications, equivalents, improvements or modifications may be made without departing from the spirit and principles of the present disclosure.

Claims (12)

1. A data processing method applied to a database, comprising:
in response to receiving an access request from application software, determining a first virtual address according to a domain name of the access request, wherein the access request is used for accessing a main database, and the first virtual address corresponds to the main database;
under the condition that the main database is determined to have faults, determining the running states of M slave databases connected with the main database, wherein M is more than or equal to 2;
determining a target slave database from the M slave databases according to the running state;
removing the binding relation between the first virtual address and the domain name, and binding a second virtual address corresponding to the target slave database with the domain name; and
and sending the access request to the target slave database through the second virtual address so as to execute the operation corresponding to the access request through the target slave database.
2. The method of claim 1, further comprising:
after the binding relation between the first virtual address and the domain name is released, the first virtual address is updated to be a preset address, and the preset address represents an address which cannot be accessed.
3. The method of claim 1, wherein said determining a target slave database from said M slave databases based on said operating state comprises:
obtaining a return value of a confirmation character, wherein the confirmation character is from the slave database and used for representing that the slave database has completed data synchronization, and the return value represents the number of the slave databases which have completed data synchronization;
determining a standard value of the confirmation character according to the running state;
and randomly determining a slave database from the slave databases with the data synchronization completed as the target slave database under the condition that the return value is greater than or equal to the standard value.
4. A method according to claim 3, wherein said determining a standard value of said validation character from said operating state comprises:
under the condition that the operation states of the M slave databases are all normal, determining the standard value as M-1;
And updating the standard value to 1 under the condition that the operation states of the M slave databases are determined to be abnormal.
5. The method of claim 1, further comprising:
the waiting time of the master database is configured to be a preset time, so that the master database waits for the M slave databases to return to the running state within the preset time, the preset time is longer than a default processing time, and the default processing time represents a processing time under normal conditions.
6. The method of claim 1, further comprising:
in response to receiving a detection request from a detection server, determining a transaction execution status of the main database according to an operation type, wherein the transaction execution status comprises a first data volume returned after a preset transaction is executed on original data in the database;
sending the transaction execution status of the main database to a detection server so that the detection server generates a transaction closing statement according to the first data volume, wherein the transaction closing statement is used for closing a target transaction of which the first data volume exceeds a preset threshold;
in response to receiving a transaction closing statement from the detection server, the transaction closing statement is executed to close the target transaction.
7. The method of claim 6, wherein the first amount of data comprises a number of returned records or bytes, the preset threshold comprises a first preset threshold or a second preset threshold,
the transaction closing statement is used for closing the target transaction of which the returned record number exceeds the first preset threshold value; or alternatively, the process may be performed,
and the transaction closing statement is used for closing the target transaction of which the byte number exceeds the second preset threshold value.
8. The method of claim 6, wherein the determining the transaction execution status of the master database according to the operation type in response to receiving the detection request from the detection server comprises:
determining the data quantity change relation before and after executing the preset transaction according to the operation type;
acquiring a second data amount corresponding to the original data; and
and generating the first data volume according to the data volume change relation and the second data volume.
9. A data processing apparatus for use in a database, comprising:
the first determining module is used for determining a first virtual address according to the domain name of the access request in response to receiving the access request from the application software, wherein the access request is used for accessing a main database, and the first virtual address corresponds to the main database;
The second determining module is used for determining the running states of M slave databases connected with the master database under the condition that the master database is determined to have faults, wherein M is more than or equal to 2;
the third determining module is used for determining a target slave database from the M slave databases according to the running state;
the binding module is used for releasing the binding relation between the first virtual address and the domain name and binding a second virtual address corresponding to the target slave database with the domain name; and
and the sending module is used for sending the access request to the target slave database through the second virtual address so as to execute the operation corresponding to the access request through the target slave database.
10. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-8.
11. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any of claims 1-8.
12. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.
CN202310343657.7A 2023-04-03 2023-04-03 Data processing method, device, equipment and storage medium applied to database Pending CN116541461A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310343657.7A CN116541461A (en) 2023-04-03 2023-04-03 Data processing method, device, equipment and storage medium applied to database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310343657.7A CN116541461A (en) 2023-04-03 2023-04-03 Data processing method, device, equipment and storage medium applied to database

Publications (1)

Publication Number Publication Date
CN116541461A true CN116541461A (en) 2023-08-04

Family

ID=87453218

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310343657.7A Pending CN116541461A (en) 2023-04-03 2023-04-03 Data processing method, device, equipment and storage medium applied to database

Country Status (1)

Country Link
CN (1) CN116541461A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117667319A (en) * 2024-02-02 2024-03-08 建信金融科技有限责任公司 Transaction processing method and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117667319A (en) * 2024-02-02 2024-03-08 建信金融科技有限责任公司 Transaction processing method and device

Similar Documents

Publication Publication Date Title
CN109842651B (en) Uninterrupted service load balancing method and system
CN102411598B (en) Method and system for realizing data consistency
CN108712457B (en) Method and device for adjusting dynamic load of back-end server based on Nginx reverse proxy
CN112118315A (en) Data processing system, method, device, electronic equipment and storage medium
CN107707619B (en) Distributed storage method and device
CN110647460B (en) Test resource management method and device and test client
CN113094430B (en) Data processing method, device, equipment and storage medium
US20190317692A1 (en) Method and apparatus for ensuring data consistency
US20150019620A1 (en) High availability for communications based on remote procedure calls
CN108418859B (en) Method and device for writing data
CN116541461A (en) Data processing method, device, equipment and storage medium applied to database
CN112835885B (en) Processing method, device and system for distributed form storage
CN111225003B (en) NFS node configuration method and device
US20130124971A1 (en) Real time web script refresh using asynchronous polling without full web page reload
CN110795495A (en) Data processing method and device, electronic equipment and computer readable medium
US9031969B2 (en) Guaranteed in-flight SQL insert operation support during an RAC database failover
US20150205675A1 (en) Method and System for Improving Reliability of a Background Page
KR20210044281A (en) Method and apparatus for ensuring continuous device operation stability in cloud degraded mode
CN111031126A (en) Cluster cache sharing method, system, equipment and storage medium
US9898490B2 (en) Systems and methods for supporting multiple database server versions on a database machine
CN115098469A (en) Database migration method and device, electronic equipment and readable storage medium
WO2023029485A1 (en) Data processing method and apparatus, computer device, and computer-readable storage medium
CN114338684B (en) Energy management system and method
CN111352916B (en) Data storage method, system and storage medium based on NAS storage system
CN109150986A (en) Store access method, device and the storage medium of data under dual-active mode

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