[go: up one dir, main page]

HK1175563B - Method and system for processing state transition of database - Google Patents

Method and system for processing state transition of database Download PDF

Info

Publication number
HK1175563B
HK1175563B HK13102905.5A HK13102905A HK1175563B HK 1175563 B HK1175563 B HK 1175563B HK 13102905 A HK13102905 A HK 13102905A HK 1175563 B HK1175563 B HK 1175563B
Authority
HK
Hong Kong
Prior art keywords
database
database server
state transition
standby
main
Prior art date
Application number
HK13102905.5A
Other languages
Chinese (zh)
Other versions
HK1175563A1 (en
Inventor
王福强
Original Assignee
阿里巴巴集团控股有限公司
Filing date
Publication date
Priority claimed from CN201110169312.1A external-priority patent/CN102841895B/en
Application filed by 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of HK1175563A1 publication Critical patent/HK1175563A1/en
Publication of HK1175563B publication Critical patent/HK1175563B/en

Links

Description

Method and system for processing database state transition
Technical Field
The present application relates to the field of databases, and in particular, to a method and system for processing database state transition.
Background
With the continued advancement of database technology and computer network technology, more and more enterprises of information systems use databases as a tool for storing and managing data. Enterprises rely on database systems to run their critical business applications, and database service outages of hours or even minutes are not allowed, so it is important to ensure high availability of databases in these applications. High Availability (HA) means that a user is provided with continuous and uninterrupted service by minimizing the service interruption time due to scheduled daily maintenance operations or unplanned sudden system failures.
Database systems use computer networks to connect geographically dispersed, logically centralized data, and can provide high availability of database systems by providing redundant data at different physical locations. Although redundant data is provided at different physical locations, usually only one database server, namely a main database server, provides services to the outside, one or more database servers are used as backup servers, and when the main database server is scheduled to be stopped or fails to provide data services, one backup server takes over the work of the main database server, so that database users can continuously use the data, and high availability of the database system is realized.
The main database server and the standby database server are transferred by a mechanism provided by the database system, and the mechanism is limited in the database system. The reason that a user usually cannot feel the change of the states of the main and standby database servers is that different application layers exist between the user and the database according to different user requirements, and the application layers adopt switching operation corresponding to the states of the main and standby database servers after the state of the main and standby database servers is transferred, so that the state of the main and standby database servers cannot be transferred due to planned operation or unplanned faults from the perspective of the user.
However, different application layers usually use their own detection logic to detect the state transition of the primary and secondary databases, and when detecting that the state transition of the primary and secondary databases occurs, each application layer executes a corresponding switching operation according to the detection result. Since the detection time and the detection interval are different, it may cause that each application layer uses different database servers as the current primary database server within a period of time after the state transition of the primary and secondary database servers occurs. Further, when a database write operation is performed, data inconsistency will result. It can be seen that simply adopting redundancy to provide high availability of the database may bring about the problem of inconsistent database status.
Disclosure of Invention
In view of this, the present application provides a method and a system for processing database state transition, which provide a uniform state transition scheme for a database application layer, so as to avoid state inconsistency of a database and its peripheral systems caused by discrete switching operations of each application layer when a primary and secondary database servers of a database system undergo state transition to a certain extent.
The application provides a method for processing database state transition, which comprises the following steps:
carrying out unified detection on state transition of the main database server and the standby database server;
and if the state transition of the main and standby database servers is detected, notifying a database application layer so that the database application layer executes switching operation corresponding to the states of the main and standby database servers after receiving the notification.
Preferably, the uniformly detecting the state transition of the active and standby database servers includes: and detecting the state transition of the main database server and the standby database server according to a preset time interval.
Preferably, the uniformly detecting the state transition of the active and standby database servers specifically includes: according to the database strategy, an operation request is sent to the database server, the state transition of the main database server and the standby database server is judged according to different processing results of the database servers on the operation request, and the main database server after transition is determined.
Preferably, the sending an operation request to the database server, determining that state transition of the primary and standby database servers occurs according to different processing results of the operation request by each database server, and determining the primary database server after transition includes:
sending an operation request to a main database server acquired at the previous detection moment;
if the correct processing result of the main database server for the operation request, which is acquired at the last detection moment, cannot be received, the state transition of the main database server and the standby database server is judged to occur, the operation requests are sent to other database servers, and the current main database server is determined according to different processing results of the database servers on the operation requests.
Preferably, the sending an operation request to the database server, determining that state transition of the primary and standby database servers occurs according to different processing results of the operation request by each database server, and determining the primary database server after transition includes:
sending operation requests to all database servers in the system;
determining a current main database server according to different processing results of each database server on the operation request;
and if the current main database server is different from the main database server acquired at the last detection moment, judging that the state transition of the main database server and the standby database server occurs.
Preferably, the uniformly detecting the state transition of the active and standby database servers specifically includes:
the current master database server is obtained by reading a configuration file containing identification information of the current master database server, and if the current master database server is different from the master database server obtained at the last detection moment, the state transition of the master database server and the slave database server is judged to occur.
Preferably, if it is detected that the state transition occurs in the active/standby database server, notifying the database application layer includes: and pushing the notification carrying the state transition of the main database server and the standby database server and the identification information of the current main database server to a database application layer by using a push mode.
Preferably, the uniformly detecting the state transition of the active and standby database servers includes:
carrying out unified detection on the scheduled main and standby database server transfer operation; or
And uniformly detecting the main and standby database server transfer caused by the unplanned system fault.
Preferably, the method further comprises the following steps:
receiving a registration request of a database application layer during starting or within a specific time after starting, and storing relevant information of connection establishment of the application layer in registration information;
the notification database application layer specifically includes:
and reading the registration information to obtain the relevant information of connection establishment of the database application layer, and informing the database application layer through the relevant information of connection establishment.
Preferably, the master database server includes a master database server in a database cluster of a distributed database system.
The application provides a system for processing database state transition, comprising:
the main and standby state transition detection unit is used for uniformly detecting the state transition of the main and standby database servers;
and the active-standby state transition notification unit is used for notifying an application layer of the database after detecting that the active-standby database server has the state transition, so that the database application layer executes switching operation corresponding to the states of the active-standby database server after receiving the notification.
Preferably, the active-standby state transition detection unit is specifically configured to detect state transition of the active-standby database server according to a preset time interval.
Preferably, the active/standby state transition detecting unit further includes:
the operation request sending subunit is used for sending an operation request to the database server according to the database strategy;
and the main/standby state transition judging subunit is used for judging the state transition of the main/standby database servers according to different processing results of the database servers on the operation request, and determining the transferred main database server.
Preferably, the operation request sending subunit is specifically configured to send an operation request to a master database server known at a previous detection time;
the primary and secondary state transition judging subunit is specifically configured to judge that state transition of the primary and secondary database servers occurs if a correct processing result of the primary database server, which is acquired at the last detection time, for the operation request is not received; and triggering the operation request sending subunit to send operation requests to other database servers so as to determine the current main database server according to the correct execution result returned by the current main database server.
Preferably, the operation request sending subunit is specifically configured to send an operation request to all database servers in the system;
the main/standby state transition judging subunit is specifically configured to determine a current main database server according to different processing results of each database server on the operation request; and if the current main database server is different from the main database server acquired at the last detection moment, judging that the state transition of the main database server and the standby database server occurs.
Preferably, the active/standby state transition detecting unit further includes:
and the configuration file reading subunit is used for acquiring the current main database server by reading the configuration file containing the identification information of the current main database server, and judging that the state transition of the main and standby database servers occurs if the current main database server is different from the main database server acquired at the last detection moment.
Preferably, the active/standby state transition notification unit is specifically configured to use a push mode to push a notification carrying the active/standby database server state transition and the current identification information of the primary database server to the database application layer.
Preferably, the active/standby state transition detection unit is specifically configured to perform unified detection on a scheduled active/standby database server transition operation; or
And uniformly detecting the main and standby database server transfer caused by the unplanned system fault.
Preferably, further comprising: the application layer registration unit is used for receiving a registration request of the database application layer during starting or within a specific time after starting and storing the connection establishment related information of the application layer in the registration information;
the active-standby state transition notification unit is specifically configured to, after the active-standby state transition notification unit detects that a state transition occurs in the active-standby database server, read registration information to obtain connection establishment related information of the database application layer, and notify the database application layer of the connection establishment related information, so that the database application layer executes a switching operation corresponding to the state of the active-standby database server after receiving the notification.
Preferably, the master database server includes a master database server in a database cluster of a distributed database system.
According to the specific embodiments provided herein, the present application discloses the following technical effects:
in the embodiment of the application, unified processing of state conversion of the main database server and the standby database server is introduced, that is, the state conversion of the main database server and the standby database server is detected in a unified manner, and when the state conversion is found to occur, each application layer of the database is notified, so that each application layer can obtain unified notification about the state conversion of the main database server and the standby database server at the same time, and a corresponding switching scheme of each application layer is executed according to the notification message. The unified detection and notification method is adopted to avoid the inconsistency of database states caused by the discrete detection and conversion operations of each application layer to a certain extent, and the consistency of the database states is ensured while the high availability of the database is provided. In addition, although the specific switching operation of each application layer on the state transition is different, the process of detecting the state transition of the main and standby database servers is the same, and a uniform detection and notification logic is adopted for the application layers of the database, so that the realization of universality is facilitated, and the complexity between the database and the application layers is reduced.
Of course, it is not necessary for any product to achieve all of the above-described advantages at the same time for the practice of the present application.
Drawings
FIG. 1 is a flow chart of a method of the present application;
FIG. 2 is a system diagram illustrating a first embodiment of the present application;
fig. 3 is a system configuration diagram of the present application.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description.
Referring to fig. 1, the method of the present application is illustrated as a flow chart, which includes the following steps:
s101: carrying out unified detection on state transition of the main database server and the standby database server;
s102: and if the state transition of the main and standby database servers is detected, notifying a database application layer so that the database application layer executes switching operation corresponding to the states of the main and standby database servers after receiving the notification.
In the implementation of the application, through unified state transition detection and notification of the main and standby database servers, different application layers of the database can obtain unified state transition information about the main and standby database servers within the same time range, and then respective corresponding switching operations are started, so that the database servers connected with the application layers are ensured to be the current main database server, and the condition inconsistency of the database and peripheral systems thereof caused by operations such as updating of data of different data sources and the like due to connection of different application layers to different database servers, which may occur in the prior art, is avoided to a certain extent.
Referring to fig. 2, a schematic diagram of a state transition system of a database according to an embodiment of the present application is shown. In the system, a database system is provided with a main database server and a standby database server currently, a main database server provides database services externally, n application layers using the database are provided, and each application layer needs to execute different switching operations corresponding to states of the main database server and the standby database server when the states of the main database server and the standby database server of the database are transferred.
In practical applications, the reason why the database system may have a state transition between the primary and secondary database servers may be planned maintenance operations on the database servers, such as periodically restarting the current primary database server in turn, or finding that when there is a potential hardware or software failure in the primary database server, the primary database server may be planned to be shut down in advance for troubleshooting although the failure has not yet occurred. In addition, it is also possible that the primary database server experiences a sudden hardware or software failure during operation, i.e., an unplanned data service interruption. For any reason, the state transition between the primary and standby database servers will occur, that is, the original backup database server will take over the original primary database server to become the current primary database server, and continue to provide the data server to the outside. The embodiment of the application is to perform unified processing on the state transition events of the main and standby database servers under various conditions, so that the database application layer can execute the switching operation corresponding to the states of the main and standby database servers in time.
S101) carrying out unified detection on the states transferred by the main database server and the standby database server.
In order to avoid data inconsistency caused by the discrete detection and conversion operations of each application layer on the database, the embodiment of the application introduces the unified detection of the state transition of the main database server and the standby database server.
Whether the main database server and the standby database server are switched or not is detected in a unified mode, namely, a timing detection method can be adopted, namely whether the main database server and the standby database server are switched or not is detected according to a preset time interval. Specifically, when detecting whether the state transition of the main database server and the standby database server occurs, the state transition can be realized in various ways. In one embodiment, the database system policy specifies that the data services provided by the primary and secondary database servers are different, that is, the primary database server at a certain detection time is obtained by using different processing results of the primary and secondary database servers on the same operation request, and the detection result of the state transition of the primary and secondary databases is obtained by comparing the primary database servers obtained at the last detection time.
When a state transition of a master database server is detected, there are different ways to know which database server is the current master database server. Usually, when the database server performs the active/standby state transition, the database system elects the current primary database server from the backup database server according to a specific election algorithm. Thus, one way to implement this is to compute the current primary database server using the database system specific election algorithm when a primary database server sending state transition is detected. This implementation presupposes that a specific election algorithm of the database system is known, and when the election algorithm changes, corresponding adjustments are made to calculate the current master database server. Another way to achieve this is to learn about the current master database server without knowing the particular algorithm, using a method similar to detecting a master database server state transition. The second method is independent of the election algorithm of the database system, does not need the specific election algorithm of the known database system, and can still detect the current main database server without corresponding adjustment when the election algorithm of the database system is changed.
According to the second method, the following implementation manners may be specifically adopted:
sending operation requests to all database servers in the system; only the main database server returns a correct execution result due to different processing results of different database servers on the operation request, so that the current main database server can be determined; and if the current main database server is different from the main database server acquired at the last detection moment, judging that the state transition of the main database server and the standby database server occurs.
The other realization method is as follows: sending an operation request to a main database server acquired at the previous detection moment; if the correct processing result of the main database server for the operation request, which is acquired at the last detection moment, cannot be received, the database can no longer provide the main database service at present, so that the state transition of the main database server and the standby database server is judged to occur; and sending operation requests to other database servers, wherein the current master database server is determined by a correct processing result returned by the master database server because only the current master database server can execute the data operation.
The second method avoids the first method in which each check sends an operation request to all the database servers in the system, but sends an operation request to the master database server that is known at the previous detection time. Although in the second method, when the correct processing result of the master database server pin known at the last detection time is not received, the operation request is also sent to the other database servers, the frequency of occurrence of the master/slave state transition is much smaller than the check frequency. Thus, the second approach saves system resources and network bandwidth to some extent.
In this embodiment, the policy of the database system provides that only the primary database provides data update or write operation service, and the backup database provides only read operation service, so that the following steps can be used to detect whether the state transition of the primary and secondary database servers occurs:
in an initial state, at a certain detection moment, a database updating operation request is sent to all the main and standby database servers respectively, and the main database server returns a correct processing result to obtain the identification information of the current main database server. The identification information may be location information such as an IP address or identity information of the database server such as a host name.
After waiting for a set time interval, sending a database updating operation request to a main database server acquired at the previous detection moment, and if the main database server still returns a correct processing result, judging that the state transition of the main database and the standby database does not occur; if the processing result returned by the main database server is abnormal, the state transition of the main database server and the standby database server is judged to have occurred, and a database updating operation request is sent to a backup database server in the system. The detection result comprises the state transition of the main database server and the standby database server and the identification information of the current main database server.
For example, if the policy of the database provides all data services for the main database server, including reading, writing and updating data services, and the backup database server does not provide any data service, the data reading operation request can be sent to detect such a database, because only the main database server returns a correct execution result, and the backup database server does not return a correct execution result, thereby knowing the working state of the main and backup database servers.
In addition to the above-described detection, other methods may be used. For example, because the database system has a configuration file, the configuration file may be updated in real time along with the state transition of the active and standby database servers of the database server, that is, the configuration file records which database server is currently in the active state, and records the identification information of the database server. Therefore, when the state of the master database server needs to be detected, the current master database server can be known by reading the configuration file, and the comparison result with the reading result at the last detection time is compared to know whether the state transition occurs.
S102, if detecting that the state of the main and standby database servers is transferred, notifying a database application layer so that the database application layer executes switching operation corresponding to the state of the main and standby database servers after receiving the notification.
Once detecting that the state transition of the active and standby database servers occurs, the application layer using the database can be immediately notified of the state transition of the database, so that the application layer of the database can obtain notification messages about the state of the database at the same time as much as possible. The notification message includes the primary and secondary database server transfer of the database and the identification information of the current primary database server. The main and standby database servers and each application layer in the database system may be distributed in different physical locations, and are connected through a network, so that there is a time delay, but since the propagation delay is far smaller than the detection time interval in magnitude, the influence caused by the normal network delay can be ignored.
In order to inform the database application layer more quickly, a method of pre-registration may be adopted, that is, the database application layer is registered at the time of starting or within a specific time after starting, and the registered information includes information related to connection establishment where the application layer is located, where the information may be an application layer name and location information such as an IP address of a host where the application layer is located. And sending the notification to the registered application layer according to the registration information included in the registry after detecting the state transition of the main database server and the standby database server.
The notification application layer may be implemented in a push mode, for example, by using a Watch mechanism of Zookeeper, that is, after an event of state transition of the primary and secondary database servers is detected, a notification message including identification information of the primary and secondary database servers that have occurred and the current primary database server is pushed to each application layer. Of course, in practical applications, besides such a push mode, other modes can be used, and are not listed here.
After receiving the notification of the primary and standby database server transfer, the application layer of the database executes corresponding state switching operation similar to that in the prior art. For example, adjusting a data source object according to the states of the active and standby database servers of the database specifically includes: and disconnecting the original main database server and establishing connection with the transferred main database server, thereby realizing the data service provided by the transferred main database server through the newly established connection.
Because the switching operations corresponding to the states of the main database server and the standby database server, which need to be executed by each application layer of the database, are different, the function of executing the respective switching operation is still kept inside each application layer to be realized, so that each application layer can complete the respective switching operation by using a uniform notification message, and the operation correctness is ensured.
According to specific application requirements, after the state transition of the primary and standby database servers occurs, in order to obtain the detection message of the next round of database state, it may be necessary to adjust the detection operation, such as converting the detected target node, and change the detection original primary database server into the detection current primary database server, so as to send the database operation for detection to the current primary database server after waiting for a set time interval. The adjustment operation may be executed immediately after detecting that the primary and secondary database servers of the database are transferred, or may be executed immediately after sending a notification to the application layer.
The method for processing the state transition of the database can be applied to the distributed database. A database cluster is deployed in the distributed database, and the database cluster is provided with a main database server and at least one backup database server. When the master database server and the slave database server are in state transition, the switching operation corresponding to the states of the database application layer and the master database server can be realized by the database state transition processing method.
Referring to fig. 3, this figure is a system structure diagram corresponding to the method for processing database state transition according to the first embodiment of the present application, where the system includes a main/standby state transition detection unit 301 and a main/standby state transition notification unit 302.
The main and standby state transition detection unit is used for carrying out unified detection on the state transition of the main and standby database servers. The state transition of the primary and secondary database servers may be a unified detection of primary and secondary database server transition operations in a plan or a unified detection of primary and secondary database server transition caused by an unplanned system failure.
In order to avoid as much as possible that each application layer separately detects state transition of the active/standby database servers, thereby causing a detection result of the state transition to be obtained at different times, the detection operation is uniformly completed by the active/standby state detection unit introduced in the embodiment of the present application. Different modes can be adopted for specifically detecting whether the conversion of the main database server and the standby database server occurs, and the main state transition detection unit can be used for detecting the state transition of the main database server and the standby database server according to a preset time interval.
The active/standby state transition detection unit may further include an operation request sending subunit and an active/standby state transition determination subunit. And the operation request sending subunit is used for sending the operation request to the database server according to the database strategy. And the main/standby state transition judging subunit is used for judging the state transition of the main/standby database servers according to different processing results of the database servers on the operation request, and determining the transferred main database server.
In particular implementation, one method is: an operation request sending subunit, configured to send an operation request to the primary database server acquired at the previous detection time; if the main/standby state transition judging subunit fails to receive the correct processing result of the main database server for the operation request, which is acquired at the last detection time, the state transition of the main/standby database servers is judged to occur; and triggering the operation request sending subunit to send operation requests to other database servers so as to determine the current main database server according to the correct execution result returned by the current main database server.
The other method is as follows: the operation request sending subunit is used for sending operation requests to all database servers in the system; the main/standby state transition judging subunit determines the current main database server according to different processing results of each database server on the operation request; and if the current main database server is different from the main database server acquired at the last detection moment, judging that the state transition of the main database server and the standby database server occurs.
When the database system has a configuration file recording the current master database server and identification information thereof, the master/slave state transition detection unit further comprises a configuration file reading unit for acquiring the current master database server by reading the configuration file containing the identification information of the current master database server, and the master/slave state transition detection unit judges that the state transition of the master/slave database servers occurs according to the difference between the current master database server and the master database server acquired at the last detection time.
When detecting that the state of the main and standby database servers is transferred, in order to inform the database application layer more quickly, an application layer registration unit can be further added, and is used for receiving a registration request of the database application layer during starting or within a specific time after starting, and storing the connection establishment related information of the application layer in the registration information. When the master-slave state transition notification unit detects that the master-slave database server is transitioned, the registration information is read to obtain the connection establishment related information of the database application layer, and the database application layer is notified through the connection establishment related information, so that the database application layer executes the switching operation corresponding to the master-slave database server state after receiving the notification.
After detecting that the state transition of the main and standby database servers occurs, the main and standby state transition notification unit uniformly notifies the application layers using the database of the state transition message of the database, so that the application layers of the database can obtain the notification message about the state of the database at the same time as far as possible. The notification message contains the state transition of the main and standby database servers of the database and the identification information of the current main database server, so that the database application layer can execute the switching operation corresponding to the state of the main and standby database servers. The master/standby state transition notification unit may use a push mode to push a notification carrying the state transition of the master/standby database server and the current identification information of the master database server to the database application layer.
In specific implementation, the above units may be used as a single detection notification service or an application program, and run on an independent server, and meanwhile, a monitoring module may be respectively deployed at each application layer. The detection notification service or the application program is connected with the database and the application layer monitoring module through a network, and when the state transition message of the main and standby database servers is detected, the detection notification service or the application program uniformly notifies the application layer monitoring module so that the application layer can start the switching operation corresponding to the states of the main and standby database servers.
The system for processing database state transition described in this embodiment may be used in a distributed database system, where the active and standby database servers include active and standby database servers in a database cluster of the distributed database system.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (20)

1. A method of handling database state transitions, comprising the steps of:
carrying out unified detection on state transition of the main database server and the standby database server;
and if the state transition of the main and standby database servers is detected, notifying each database application layer so that each database application layer executes switching operation corresponding to the state of the main and standby database servers after receiving a notification message in the same time range, wherein the notification message comprises the state transition of the main and standby database servers and the identification information of the current main database server.
2. The method according to claim 1, wherein the performing unified detection on the state transition of the active and standby database servers comprises: and detecting the state transition of the main database server and the standby database server according to a preset time interval.
3. The method for processing database state transition according to claim 1 or 2, wherein the unified detection of the state transition of the active and standby database servers specifically includes: according to the database strategy, an operation request is sent to the database server, the state transition of the main database server and the standby database server is judged according to different processing results of the database servers on the operation request, and the main database server after transition is determined.
4. The method according to claim 3, wherein the sending an operation request to the database server, determining that the state transition of the primary and backup database servers occurs according to different processing results of each database server on the operation request, and determining the primary database server after the transition comprises:
sending an operation request to a main database server acquired at the previous detection moment;
if the correct processing result of the main database server for the operation request, which is acquired at the last detection moment, cannot be received, the state transition of the main database server and the standby database server is judged to occur, the operation requests are sent to other database servers, and the current main database server is determined according to different processing results of the database servers on the operation requests.
5. The method according to claim 3, wherein the sending an operation request to the database server, determining that the state transition of the primary and backup database servers occurs according to different processing results of each database server on the operation request, and determining the primary database server after the transition comprises:
sending operation requests to all database servers in the system;
determining a current main database server according to different processing results of each database server on the operation request;
and if the current main database server is different from the main database server acquired at the last detection moment, judging that the state transition of the main database server and the standby database server occurs.
6. The method for processing database state transition according to claim 1 or 2, wherein the unified detection of the state transition of the active and standby database servers specifically includes:
the current master database server is obtained by reading a configuration file containing identification information of the current master database server, and if the current master database server is different from the master database server obtained at the last detection moment, the state transition of the master database server and the slave database server is judged to occur.
7. The method according to claim 1, wherein if it is detected that the state transition occurs between the active and standby database servers, notifying a database application layer, specifically includes: and pushing the notification carrying the state transition of the main database server and the standby database server and the identification information of the current main database server to a database application layer by using a push mode.
8. The method according to claim 1, wherein the performing unified detection on the state transition of the active and standby database servers comprises:
carrying out unified detection on the scheduled main and standby database server transfer operation; or
And uniformly detecting the main and standby database server transfer caused by the unplanned system fault.
9. The method of processing database state transitions of claim 1, further comprising:
receiving a registration request of a database application layer during starting or within a specific time after starting, and storing relevant information of connection establishment of the application layer in registration information;
the notification database application layer specifically includes:
and reading the registration information to obtain the relevant information of connection establishment of the database application layer, and informing the database application layer through the relevant information of connection establishment.
10. The method of processing database state transitions of any of claims 1, 2, 7-9, wherein the primary and secondary database servers comprise primary and secondary database servers in a database cluster of a distributed database system.
11. A system for processing state transitions of a database, comprising:
the main and standby state transition detection unit is used for uniformly detecting the state transition of the main and standby database servers;
and the master-slave state transition notification unit is used for notifying the application layers of the databases after detecting that the master-slave database server has the state transition, so that the application layers of the databases execute the switching operation corresponding to the states of the master-slave database server after receiving a notification message in the same time range, wherein the notification message comprises the state transition of the master-slave database server and the identification information of the current master database server.
12. The system for processing database state transition according to claim 11, wherein the active/standby state transition detecting unit is specifically configured to detect state transition of an active/standby database server according to a preset time interval.
13. The system for processing database state transition according to claim 11 or 12, wherein the active/standby state transition detection unit further comprises:
the operation request sending subunit is used for sending an operation request to the database server according to the database strategy;
and the main/standby state transition judging subunit is used for judging the state transition of the main/standby database servers according to different processing results of the database servers on the operation request, and determining the transferred main database server.
14. The system for processing database state transitions of claim 13,
the operation request sending subunit is specifically configured to send an operation request to a master database server that is known at a previous detection time;
the primary and secondary state transition judging subunit is specifically configured to judge that state transition of the primary and secondary database servers occurs if a correct processing result of the primary database server, which is acquired at the last detection time, for the operation request is not received; and triggering the operation request sending subunit to send operation requests to other database servers so as to determine the current main database server according to the correct execution result returned by the current main database server.
15. The system for processing database state transitions of claim 13,
the operation request sending subunit is specifically configured to send operation requests to all database servers in the system;
the main/standby state transition judging subunit is specifically configured to determine a current main database server according to different processing results of each database server on the operation request; and if the current main database server is different from the main database server acquired at the last detection moment, judging that the state transition of the main database server and the standby database server occurs.
16. The system for processing database state transition according to claim 11 or 12, wherein the active/standby state transition detection unit further comprises:
and the configuration file reading subunit is used for acquiring the current main database server by reading the configuration file containing the identification information of the current main database server, and judging that the state transition of the main and standby database servers occurs if the current main database server is different from the main database server acquired at the last detection moment.
17. The system for processing database state transition according to claim 11, wherein the active/standby state transition notification unit is specifically configured to use a push mode to push a notification carrying the state transition of the active/standby database server and the current identification information of the primary database server to the database application layer.
18. The system according to claim 11, wherein the active/standby state transition detection unit is specifically configured to perform unified detection on a scheduled active/standby database server transition operation; or
And uniformly detecting the main and standby database server transfer caused by the unplanned system fault.
19. The system for processing database state transitions of claim 11, further comprising: the application layer registration unit is used for receiving a registration request of the database application layer during starting or within a specific time after starting and storing the connection establishment related information of the application layer in the registration information;
the active-standby state transition notification unit is specifically configured to, after the active-standby state transition notification unit detects that a state transition occurs in the active-standby database server, read registration information to obtain connection establishment related information of the database application layer, and notify the database application layer of the connection establishment related information, so that the database application layer executes a switching operation corresponding to the state of the active-standby database server after receiving the notification.
20. A system for handling database state transitions according to any of claims 11, 12, 17-19, wherein said primary and secondary database servers comprise primary and secondary database servers in a database cluster of a distributed database system.
HK13102905.5A 2013-03-08 Method and system for processing state transition of database HK1175563B (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110169312.1A CN102841895B (en) 2011-06-22 2011-06-22 Method and system for processing database state transition

Publications (2)

Publication Number Publication Date
HK1175563A1 HK1175563A1 (en) 2013-07-05
HK1175563B true HK1175563B (en) 2015-12-18

Family

ID=

Similar Documents

Publication Publication Date Title
CN107291787B (en) Active-standby database switching method and device
TWI677797B (en) Management method, system and equipment of master and backup database
KR100575497B1 (en) Fault Tolerant Computer System
CN111427728B (en) State management method, main/standby switching method and electronic equipment
WO2017067484A1 (en) Virtualization data center scheduling system and method
CN106156318B (en) System and method for realizing high availability of multi-node database
CN102467508A (en) Method for providing database service and database system
EP2902922A1 (en) Distributed file system and data backup method for distributed file system
CN104717077B (en) A kind of method, apparatus and system for managing data center
CN103036719A (en) Cross-regional service disaster method and device based on main cluster servers
US20050234919A1 (en) Cluster system and an error recovery method thereof
CN107071189B (en) Connection method of communication equipment physical interface
JP5285045B2 (en) Failure recovery method, server and program in virtual environment
CN109189854B (en) Method and node equipment for providing continuous service
CN102841895B (en) Method and system for processing database state transition
WO2015196692A1 (en) Cloud computing system and processing method and apparatus for cloud computing system
JP5285044B2 (en) Cluster system recovery method, server, and program
CN110569303B (en) MySQL application layer high-availability system and method suitable for various cloud environments
CN116185697B (en) Container cluster management method, device and system, electronic equipment and storage medium
JP2010231257A (en) High availability system and method for handling failure of high availability system
HK1175563B (en) Method and system for processing state transition of database
US8713359B1 (en) Autonomous primary-mirror synchronized reset
CN105306256A (en) Hot-standby implementation method based on VxWorks equipment
CN111064608A (en) Master-slave switching method and device of message system, electronic equipment and storage medium
CN114422567B (en) Data request processing method, device, system, computer equipment and medium