CN111209265B - Database switching method and terminal equipment - Google Patents

Database switching method and terminal equipment Download PDF

Info

Publication number
CN111209265B
CN111209265B CN201811400655.2A CN201811400655A CN111209265B CN 111209265 B CN111209265 B CN 111209265B CN 201811400655 A CN201811400655 A CN 201811400655A CN 111209265 B CN111209265 B CN 111209265B
Authority
CN
China
Prior art keywords
database
host
slave
switching
master
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.)
Active
Application number
CN201811400655.2A
Other languages
Chinese (zh)
Other versions
CN111209265A (en
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201811400655.2A priority Critical patent/CN111209265B/en
Publication of CN111209265A publication Critical patent/CN111209265A/en
Application granted granted Critical
Publication of CN111209265B publication Critical patent/CN111209265B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

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

Abstract

The embodiment of the application discloses an information processing method and terminal equipment, which are used for respectively configuring respective disk group resources in a first database and a second database, wherein the switching of a service plane floating IP and the switching of roles of a master database and a slave database are involved in the double-machine switching process, so that the problem of inadaptation between the disks and the databases in the double-machine switching process is avoided, and the data security is improved. The embodiment of the application provides a master-slave database switching method, which comprises the following steps: under the condition that the first database meets the double-machine switching condition, the first host releases the binding between the first database and the service plane floating IP address; the first host switches the first database from the master to the slave; the first host sends indication information to the second host, the indication information is used for indicating that the second database is switched from the slave to the master, and the service plane floating IP address is started on the second database.

Description

Database switching method and terminal equipment
Technical Field
The present application relates to the field of databases, and in particular, to a database switching method and a terminal device.
Background
With the continuous development of computer technology, more and more service requests are sent by users through database clients, and correspondingly, more and more service requests are received by database servers. When the database server fails, the service request sent by the user cannot be responded.
In order to avoid the occurrence of the above situation, in the prior art, a main database and a standby database are simultaneously provided at a database server side, and a set of external shared disk is provided outside the main database and the standby database. When the main database is normally used, the standby database is in a closed state, the main database accesses the data in the shared disk, and responds to a service request sent by a user based on the data in the shared disk; when the main database fails, after the access of the main database to the shared disk is stopped, the standby database is started, the shared disk is accessed through the standby database, and the standby database responds to a service request sent by a user based on data in the shared disk.
However, if the shared disk is not suitable for the standby database or the shared disk fails in the dual-machine switching process, the main database and the standby database cannot respond to the request of the user any more, so that the safety of the data is not ensured, and the service request of the user cannot be satisfied in time.
Disclosure of Invention
The embodiment of the application provides a master-slave database switching method and related equipment, which are used for respectively configuring respective disk group resources in a first database and a second database, wherein the switching of a service plane floating IP and the switching of roles of a master database and a slave database are involved in the double-machine switching process, the disk group resources and the database resources are not required to be disconnected from the master data and then connected to the slave database, the problem of inadaptability between the disks and the databases in the double-machine switching process is avoided, and the situation that a user cannot respond to a request due to the occurrence of a fault of a shared disk is avoided.
In a first aspect, an embodiment of the present application provides a method for switching between a master database and a slave database, where the method is applied to a database system, the database system includes a first host and a second host, where the first host operates a first database, the second host operates a second database, and respective disk group resources are respectively configured in the first database and the second database, and the method includes: the first host can monitor the running condition of the first database, under the condition that the first host detects that the first database runs abnormally and determines that the first database meets the double-machine switching condition, the binding between the first database and a service plane floating Internet Protocol (IP) address can be released, if a service plane monitor exists in the first database, the first host can also close the service plane monitor, wherein the service plane floating IP address is used for bearing the data flow of a service plane, the service plane is a network plane for receiving and responding to the service request, and the service plane monitor is used for monitoring the validity of the connection request received through the service plane; the first host can switch the first database from the master to the slave, and send indication information to the second host, where the indication information is used to instruct the second database to switch from the slave to the master, and start the service plane floating IP address on the second database.
In the application, under the condition that the first database meets the double-machine switching condition, the first host removes the service plane floating IP address bound to the first database and switches the first database from the master to the slave. After the first database completes the role switching operation, sending indication information to the second database, wherein the indication information is used for indicating the second database to be switched from the slave to the master, and starting the service plane floating IP address on the second database. The main database and the slave database are respectively provided with the respective disk group resources, so that the disk group resources and the database resources are activated on the main database and the slave database simultaneously, the problem of inadaptation between the disks and the databases in the double-machine switching process is avoided, the situation that the user cannot respond to the request due to the failure of the shared disk is avoided, and the safety of the data is improved; in the double-machine switching process, the switching of the service plane floating IP and the switching of the roles of the master database and the slave database are involved, so that the disk group resources and the database resources are not required to be disconnected from the master data and then connected to the slave database, the time length of the double-machine switching is shortened, and the time length of the interruption of the user service is shortened; in addition, because the floating IP address of the service plane for bearing the data flow of the service plane before and after the switching is executed is not changed, the IP address accessed by the client before and after the dual-machine switching is not changed, and the influence of the dual-machine switching on the client is reduced.
In a possible implementation manner of the first aspect of the present application, the method further includes: the first host can send a redo log of the first database to the second host through a copy plane, wherein the copy plane is a network plane for realizing the copy of the redo log in the main database from the database, and the redo log is used for enabling the second host to control the second database to execute the transaction executed by the first database according to the redo log so as to enable the data in the disk set resources of the second database to be consistent with the data in the disk set resources of the first database.
In the application, the second host can acquire the redo log of the first database in real time through the replication plane, so that the data in the disk set resources of the second database and the data in the disk set resources of the first database can be consistent in real time, and when the double-machine switching operation is started, the second database can respond to the service request of the client in time according to the data in the disk set resources after the switching operation is completed, thereby further shortening the service interruption time of the user and reducing the influence of the double-machine switching on the client.
In one possible implementation manner of the first aspect of the present application, the first host sending the redo log of the first database to the second host may specifically include: when the first host determines that the first database is in a normal running state, the first host can send a redo log of the first database to the second host in real time through a copy plane; when the first host determines that the first database is abnormally operated, the first host forcibly transmits a redo log of the first database to the second host.
In the application, no matter the first database is in a normal running state or abnormal running state, the first host can send the redo log of the first database to the second host, so that the consistency of real-time data in disk group resources of the first database can be realized, and the safety and stability of the data are improved.
In a possible implementation manner of the first aspect of the present application, switching the first database from the master to the slave includes: after determining that the first database meets the double-machine switching condition, the first host can judge whether the first database meets the requirement of executing the double-machine switching operation switch mode in a planned manner, and under the condition that the first database meets the switch mode, the first host switches the first database from the master mode to the slave mode in the switch mode, wherein the switch mode is a mode that the double-machine switching function of the first database is in a normal operation state to execute the double-machine switching operation.
In the application, under the condition that the first database accords with the switch mode, the first host switches the first database from the master to the slave in the switch mode, thereby improving the realizability of the scheme.
In one possible implementation manner of the first aspect of the present application, the first host switches the first database from the master to the slave, which may specifically include: after the first host determines that the first database meets the dual-computer switching condition, the first host can judge whether the first database meets the requirement of a switch over mode, and under the condition that the first database does not meet the switch over mode, the first host acquires a system change number SCN after the second database is switched into the main use, and executes a flashback operation according to the SCN, so that the first host can switch the first database from the main use to the auxiliary use under the condition that the dual-computer switching operation is carried out when the database is inactive, wherein the SCN is a digital series which is automatically maintained by a database management system and is accumulated and increased, the digital series is used for distinguishing the sequence of transactions, and the fasilover mode is a mode that the dual-computer switching function of the first database is forced to carry out the dual-computer switching operation under a fault state.
In the application, under the condition that the first database does not accord with the switch over mode, the first database is switched into the slave mode through the switch over mode, so that the realizability of the scheme is ensured; in addition, when the first host needs to switch the first database to the slave state in the failover mode, the first host can determine that the first database has a fault when executing the transaction, and because the first database has a fault, even if the redo log of the first database is forcedly sent to the second host, the first host cannot determine whether all the redo logs are sent to the second host, and by executing the flashback operation according to the SCN after the second database is switched to the master state, the consistency of the data of the first database and the data of the second database after executing the double operation can be ensured.
In one possible implementation manner of the first aspect of the present application, the first host switches the first database from the master to the slave, including: after determining that the first database meets the dual-computer switching condition, the first host can determine whether the first database meets the requirement of a switch over mode, and under the condition that the first database meets the switch over mode, the first host can control the first database to be switched from the master to the slave in the switch over mode and check whether the first database is successfully switched, and under the condition that the second database fails to be switched in the switch over mode, that is, under the condition that the second database is not switched in the switch over mode, the first host can acquire the SCN after the second database is switched into the master, and execute a flashback operation according to the SCN, and then the first host can switch the first database from the master to the slave in the failover mode.
In the application, under the condition that the first database fails to be switched in the switch over mode, the first database is switched into the slave mode through the switch over mode, so that the feasibility of the scheme is ensured; in addition, when the first host needs to switch the first database to the slave state in the failover mode, the first host can determine that the first database has a fault when executing the transaction, and because the first database has a fault, even if the redo log of the first database is forcedly sent to the second host, the first host cannot determine whether all the redo logs are sent to the second host, and by executing the flashback operation according to the SCN after the second database is switched to the master state, the consistency of the data of the first database and the data of the second database after executing the double operation can be ensured.
In a possible implementation manner of the first aspect of the present application, the method further includes: after the first host releases the binding of the first database and the management plane floating IP address, the first host can also release the binding of the first database and the management plane floating IP address, if the management plane monitor exists in the first database, the first host can also close the management plane monitor of the first database, wherein after the double-machine switching operation is executed, the management plane floating IP is bound on the second database, the management plane floating IP is used for bearing the data flow of the management plane, and the management plane is a network plane for realizing internal network monitoring.
In the application, the second host and the first host share the same management plane floating IP address on the management plane, so that the management plane floating IP address for bearing the data flow of the management plane before and after the switching is performed is not changed, the IP address accessed by the gateway for monitoring the internal network condition is not changed before and after the double-host switching, and the influence of the double-host switching on the gateway is reduced.
In one possible implementation manner of the first aspect of the present application, the first host determines that the first database meets a dual-machine switching condition, including at least one of the following: the first host judges whether the disk group resource of the first database is online or not, and under the condition that the disk group resource of the first database is not online, the first host can execute the pulling operation on the disk group resource of the first database, if the pulling operation fails, the pulling operation is repeatedly executed, and when the number of times that the first host continuously executes the pulling operation on the disk group resource of the first database exceeds a first threshold value, the first host determines that the first database meets the double-machine switching condition; or the first host judges whether the database resource of the first database is online, and can execute the pulling operation on the database resource of the first database under the condition that the database resource of the first database is not online, if the pulling operation fails, the pulling operation is repeatedly executed, and when the number of times that the first host continuously executes the pulling operation on the database resource of the first database exceeds a second threshold value, the first host determines that the first database meets the double-machine switching condition; or the first host can judge whether the service plane floating IP address of the first database is online, under the condition that the service plane floating IP address of the first database is not online, the first host executes the pulling operation on the service plane floating IP address of the first database, if the pulling operation fails, the pulling operation is repeatedly executed, and when the number of times that the first host continuously executes the pulling operation on the service plane floating IP address of the first database exceeds a third threshold, the first host determines that the first database meets the double-machine switching condition.
In the application, when the first host monitors that any one of the disk group resource, the database resource, the service plane monitor or the service plane floating IP address is not on line and continuous pulling fails, the dual-machine switching operation can be triggered in time, and the service request of the client can not be responded due to the fact that any one of the resources is abnormal, the dual-machine switching operation is triggered in time at this time, and the second database continues to respond to the service request of the client so as to provide good user experience.
In a possible implementation manner of the first aspect of the present application, before the first host unbundles the first database from the service plane floating IP address, the method further includes: the first host starts the first database to an ascending state; the first host starts a flashback mode of the first database; the first host starts the first database to a fully opened open state, wherein the moved state and the open state are two states of the database in the opening process, the moved state is the database state when the database is not fully opened, and the open state is the database state when the database is fully opened, and in the two states, the host can execute different rights of management operation on the database.
In the application, the flashback mode of the first database is started, so that the flashback operation can be realized after the first host switches the first database into the slave mode in the failover mode, and the realizability and fluency of the double-host switching process are improved.
In a second aspect, an embodiment of the present application provides a method for switching between a master database and a slave database, where the method is applied to a database system, the database system includes a first host and a second host, where the first host is operated with a first database, the second host is operated with a second database, and respective disk group resources are respectively configured in the first database and the second database, and the method includes: after receiving the indication information sent by the first host, the second host can switch the second database from the slave to the master, and then starts a service plane floating Internet Protocol (IP) address on the second database, wherein the indication information is used for indicating to start a double-machine switching operation of the second database, the service plane floating IP address is used for bearing a data stream of the service plane, the service plane is used for receiving and responding to the service request, and the service plane floating IP address is bound on the first database before the double-machine switching operation is executed.
In the application, after receiving the indication information, the second host switches the second database from the slave to the master based on the indication information, and starts the service plane floating IP address on the second database. The main database and the slave database are respectively provided with the respective disk group resources, so that the disk group resources and the database resources are activated on the main database and the slave database simultaneously, the problem of inadaptation between the disks and the databases in the double-machine switching process is avoided, the situation that the user cannot respond to the request due to the failure of the shared disk is avoided, and the safety of the data is improved; in the double-machine switching process, the switching of the service plane floating IP and the switching of the roles of the master database and the slave database are involved, so that the disk group resources and the database resources are not required to be disconnected from the master data and then connected to the slave database, the time length of the double-machine switching is shortened, and the time length of the interruption of the user service is shortened; in addition, because the floating IP address of the service plane for bearing the data flow of the service plane before and after the switching is executed is not changed, the IP address accessed by the client before and after the dual-machine switching is not changed, and the influence of the dual-machine switching on the client is reduced.
In a possible implementation manner of the second aspect of the present application, the method further includes: the second host computer can obtain the redo log of the first database through the replication plane, and control the second database to execute the transaction executed by the first database according to the redo log so as to make the data in the disk group resource of the second database consistent with the data in the disk group resource of the first database, wherein the replication plane is a network plane for realizing the replication of the redo log in the master database from the slave database.
In the application, the second host can acquire the redo log of the first database in real time through the replication plane, so that the data in the disk set resources of the second database and the data in the disk set resources of the first database can be consistent in real time, and when the double-machine switching operation is started, the second database can respond to the service request of the client in time according to the data in the disk set resources after the switching operation is completed, thereby further shortening the service interruption time of the user and reducing the influence of the double-machine switching on the client.
In one possible implementation manner of the second aspect of the present application, the second host switches the second database from the slave to the master, including: after receiving the indication information, the second host can judge whether the second database meets the requirement of executing the double-machine switching operation switch mode or not, and under the condition that the second database meets the switch mode, the second host can switch the second database from the slave mode to the master mode, wherein the switch mode is a mode of executing the double-machine switching operation under the normal running state of the double-machine switching function of the first database.
In the application, under the condition that the second database accords with the switch over mode, the second host switches the second database from the master to the slave in the switch over mode, thereby improving the realizability of the scheme.
In one possible implementation manner of the second aspect of the present application, the second host switches the second database from the slave to the master, including: after receiving the indication information, the second host can judge whether the first database meets the requirement of a switch over mode, and under the condition that the second database does not meet the switch over mode, the second host executes a double-machine switching operation in the switch over mode when the database is inactive to switch the second database from the slave mode to the master mode, wherein the switch over mode is a mode that the double-machine switching function of the first database is forced to execute the double-machine switching operation in a fault state.
In the application, under the condition that the second database does not accord with the switch over mode, the second database is forcedly switched into the main use in the failover mode, thereby ensuring that the conversion of the second database from the main use to the sub use can be completed under various conditions, and improving the realizability of the scheme.
In one possible implementation manner of the second aspect of the present application, the second host switches the second database from the slave to the master, including: after receiving the indication information, the second host can judge whether the second database meets the requirement of the switch over mode, and under the condition that the second database meets the switch over mode, the second host can control the second database to be switched from the master mode to the slave mode, check whether the second database is successfully switched, and under the condition that the second database is failed to be switched in the switch over mode, the second host switches the second database from the slave mode to the master mode.
In the application, under the condition of failure in switching the second database in the switching mode, the second database is forcedly switched into the main use in the switching mode, so that the realization scene of the scheme is increased, and the realizability and flexibility of the scheme are improved.
In a possible implementation manner of the second aspect of the present application, switching the second database from the slave to the master in the failover mode includes: under the condition that the second host determines that the second database cannot be switched to be in the master mode, the second host can wait for a period of time, so that the second database can continue to execute the transaction executed by the first database according to the redo log of the first database, and acquire the execution state of the transaction executed by the second database according to the redo log of the first database until the second database executes the transaction executed by the first database, and after the second database executes the transaction executed by the first database, the second host stops the copying process of the second database, and forcibly switches the second database from the slave mode to the master mode in the failover mode.
In the application, when the second host computer can not switch the second database from the slave to the master in the switch over mode, the second host computer can forcedly switch the second database to the master in the failover mode only when determining that the transaction executed by the first database by the second database is in the execution completion state, thereby avoiding the forceful interruption of the database copying process, ensuring the continuity of the second database copying process of the first database, realizing the data consistency of the second database and the first database as soon as possible, and responding the service request of the client as soon as possible.
In a possible implementation manner of the second aspect of the present application, switching the second database from the slave to the master in the switch over mode includes: the second host may preset a waiting duration, and in the case that the second host cannot switch the second database to be active in the switch over mode, the second host may wait for a period of time, so that the second database may continue to execute the transaction executed by the first database according to the redo log of the first database, and when the duration of executing the transaction executed by the first database by the second database reaches the preset duration, the second host stops the replication process of the second database, and in the failover mode, the second database is forcedly switched from active to active.
In the application, the second host can preset the waiting time, if the second database still does not execute all the transactions within the preset time, the second host means that the copying process of the second database may fail, and when the waiting time reaches the preset time, the second database is forcedly switched into the main use in the failover mode, thereby avoiding the overlong time for service interruption.
In a possible implementation manner of the second aspect of the present application, after the second host switches the second database from the slave to the master, the method further includes: the second host can restart the second database and record a system change number SCN when the second database is restarted, that is, the SCN after the second database is switched to be active, where the SCN is used for the first host to control the first database to execute a flashback operation according to the SCN, where the SCN is a number series that is automatically maintained by the database management system and is increased in an accumulation manner, and is used for distinguishing the sequence of transactions.
In the application, because when the first database fails, even if the redo log of the first database is forcedly sent to the second host, the first host cannot determine whether all the redo logs are sent to the second host, and the second host records the SCN after the second database is switched to be in use, so that the first host can control the first database to execute the flashback operation according to the SCN, thereby ensuring the consistency of the data of the first database and the data of the second database after the double operation is executed.
In one possible implementation manner of the second aspect of the present application, the method further includes at least one of the following:
the second host judges whether the disk group resource of the second database is online or not, and if the disk group resource of the second database is not online, the second host executes the pulling operation on the disk group resource of the second database, and if the pulling operation fails, the pulling operation is repeatedly executed; or alternatively
The second host judges whether the database resources of the second database are online or not, and if the database resources of the second database are not online, the second host executes the pulling operation on the database resources of the second database, and if the pulling operation fails, the pulling operation is repeatedly executed; or alternatively
When the monitor function exists in the second database, the second host judges whether the copy plane monitor of the second database is on line, and under the condition that the copy plane monitor of the second database is not on line and the state of the copy process is normal, the second host executes the pull-up operation on the copy plane monitor of the second database, if the pull-up fails, the pull-up operation is repeatedly executed, and under the condition that the copy plane monitor of the second database is not on line and the state of the copy process is abnormal, the second host restarts the copy process and then executes the pull-up operation on the copy plane monitor of the second database.
In the application, in each monitoring period, the second host can check whether the disk group resource, the database resource and the copy plane monitor of the second database are on line, if not, the pulling operation can be repeatedly executed, and when the pulling operation is repeated and the pulling operation is still failed, a warning can be sent to prompt operation and maintenance personnel to perform manual intervention, thereby ensuring that the slave database is in a normal operation state at all times, avoiding the condition that the slave database cannot be switched due to abnormal operation in the process of executing the double-machine switching operation, and improving the stability of the switching process of the master database and the slave database.
In a possible implementation manner of the second aspect of the present application, after the second host switches the second database from the slave to the master, the method further includes: after the second host starts the service plane floating IP address on the second database, the second host may further start the management plane floating IP address on the second database, if the management plane monitor exists in the second database, the second host may further start the management plane monitor of the second database, where before the dual-machine switching operation is performed, the management plane floating IP is bound to the first database, where the management plane floating IP is used to carry a data flow of the management plane, and the management plane is a network plane for implementing internal network monitoring.
In the application, the second host and the first host share the same management plane floating IP address on the management plane, so that the management plane floating IP address for bearing the data flow of the management plane before and after the switching is performed is not changed, the IP address accessed by the gateway for monitoring the internal network condition is not changed before and after the double-host switching, and the influence of the double-host switching on the gateway is reduced.
In a third aspect, an embodiment of the present application provides a host, where the host is a first host, the first host is included in a database system, and the database system further includes a second host, where the first host is running on a first database, the second host is running on a second database, and respective disk group resources are respectively configured in the first database and the second database, where the host includes:
The releasing unit is used for releasing the binding between the first database and the service plane floating IP address, which is used for bearing the data flow of the service plane, and the service plane is a network plane for receiving and responding to the service request under the condition that the first database meets the double-machine switching condition;
the switching unit is used for switching the first database from the master to the slave;
and the sending unit is used for sending indication information to the second host, wherein the indication information is used for indicating that the second database is switched from the slave to the master, and the service plane floating IP address is started on the second database.
In the application, under the condition that the first database meets the double-machine switching condition, the releasing unit releases the service plane floating IP address bound to the first database, and the switching unit switches the first database from the master to the slave. After the first database completes the role switching operation, the sending unit sends indication information to the second database, wherein the indication information is used for indicating the second database to be switched from the slave to the master, and the service plane floating IP address is started on the second database. The main database and the slave database are respectively provided with the respective disk group resources, so that the disk group resources and the database resources are activated on the main database and the slave database simultaneously, the problem of inadaptation between the disks and the databases in the double-machine switching process is avoided, the situation that the user cannot respond to the request due to the failure of the shared disk is avoided, and the safety of the data is improved; in the double-machine switching process, the switching of the service plane floating IP and the switching of the roles of the master database and the slave database are involved, so that the disk group resources and the database resources are not required to be disconnected from the master data and then connected to the slave database, the time length of the double-machine switching is shortened, and the time length of the interruption of the user service is shortened; in addition, because the floating IP address of the service plane for bearing the data flow of the service plane before and after the switching is executed is not changed, the IP address accessed by the client before and after the dual-machine switching is not changed, and the influence of the dual-machine switching on the client is reduced.
In a third aspect of the present application, the constituent modules of the first host may also perform the steps described in the foregoing first aspect and various possible implementations, see the foregoing description of the first aspect and various possible implementations for details.
In a fourth aspect, an embodiment of the present application provides a host, where the host is a second host, the second host is included in a database system, and the database system further includes the second host, where a first database is running on a first host, a second database is running on the second host, and respective disk group resources are respectively configured in the first database and the second database, where the host includes:
the receiving unit is used for receiving indication information sent by the first host, wherein the indication information is used for indicating to start the double-machine switching operation of the second database;
the switching unit is used for switching the second database from the slave to the master;
the starting unit is used for starting the service plane floating IP address on the second database, wherein the service plane is a network plane for receiving and responding to the service request, the service plane floating IP address is used for bearing the data flow of the service plane, the service plane is a network plane for receiving and responding to the service request, and the service plane floating IP address is bound on the first database before the double-machine switching operation is executed.
In the application, after receiving the indication information, the receiving unit switches the second database from the slave to the master based on the indication information, and the starting unit starts the service plane floating IP address on the second database. The main database and the slave database are respectively provided with the respective disk group resources, so that the disk group resources and the database resources are activated on the main database and the slave database simultaneously, the problem of inadaptation between the disks and the databases in the double-machine switching process is avoided, the situation that the user cannot respond to the request due to the failure of the shared disk is avoided, and the safety of the data is improved; in the double-machine switching process, the switching of the service plane floating IP and the switching of the roles of the master database and the slave database are involved, so that the disk group resources and the database resources are not required to be disconnected from the master data and then connected to the slave database, the time length of the double-machine switching is shortened, and the time length of the interruption of the user service is shortened; in addition, because the floating IP address of the service plane for bearing the data flow of the service plane before and after the switching is executed is not changed, the IP address accessed by the client before and after the dual-machine switching is not changed, and the influence of the dual-machine switching on the client is reduced.
In a fourth aspect of the present application, the constituent modules of the second host may also perform the steps described in the foregoing second aspect and various possible implementations, see the foregoing description of the second aspect and various possible implementations for details.
In a fifth aspect, an embodiment of the present application provides a host, where the host is a first host, and includes a memory and a processor;
the memory is used for storing computer program codes;
the processor is configured to execute the memory-stored code to cause the first host to perform the method as described in the first aspect above.
In a sixth aspect, an embodiment of the present application provides a host, where the host is a second host, and includes a memory and a processor;
the memory is used for storing computer program codes;
the processor is configured to execute the memory-stored code to cause the first host to perform the method as described in the second aspect above.
In a seventh aspect, embodiments of the present application provide a computer readable storage medium having stored therein computer program code which, when run on a computer, causes the computer to perform the method as described in the first aspect above.
In an eighth aspect, embodiments of the present application provide a computer readable storage medium having stored therein computer program code which, when run on a computer, causes the computer to perform the method as described in the second aspect above.
In a ninth aspect, embodiments of the present application provide a chip system comprising a processor for supporting a network device to implement the functions involved in the above aspects, e.g. for sending or processing data and/or information involved in the above methods. In one possible design, the system-on-chip also includes memory to hold the program instructions and data necessary for the network device. The chip system can be composed of chips, and can also comprise chips and other discrete devices.
Advantageous effects of the fifth to ninth aspects of the present application reference may be made to the first aspect.
Drawings
Fig. 1 is a schematic diagram of a network structure according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of a method for switching between a master database and a slave database according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating a first host monitoring an operation status of a first database according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating a second host monitoring an operation status of a second database according to an embodiment of the present application;
FIG. 5 is a schematic flow chart of another method for switching between master database and slave database according to an embodiment of the present application;
FIG. 6 is a schematic flow chart of a method for switching between master database and slave database according to an embodiment of the present application;
FIG. 7 is a schematic diagram of a host according to an embodiment of the present application;
FIG. 8 is a schematic diagram of another embodiment of a host;
FIG. 9 is a schematic diagram of a host according to an embodiment of the present application;
fig. 10 is a schematic diagram of another structure of a host according to an embodiment of the present application.
Detailed Description
The embodiment of the application provides a master-slave database switching method and related equipment, which are used for respectively configuring respective disk group resources in a first database and a second database, wherein the switching of a service plane floating IP and the switching of roles of a master database and a slave database are involved in the double-machine switching process, the disk group resources and the database resources are not required to be disconnected from the master data and then connected to the slave database, the problem of inadaptability between the disks and the databases in the double-machine switching process is avoided, and the situation that a user cannot respond to a request due to the occurrence of a fault of a shared disk is avoided.
Embodiments of the present application are described below with reference to the accompanying drawings.
The terms first, second and the like in the description and in the claims and in the above-described figures, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances and are merely illustrative of the manner in which embodiments of the application have been described in connection with the description of the objects having the same attributes. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of elements is not necessarily limited to those elements, but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
In an embodiment of the present application, referring to fig. 1, the present application is applied to a database system 10, where the database system 10 includes a first host 100 and a second host 200, and the first host 100 and the second host 200 are communicatively connected. The first host 100 has a first database 110 running thereon and the second host 200 has a second database 210 running thereon. The first database 110 and the second database 210 are each configured with respective disk group resources.
In the embodiment of the present application, the first host 100 and the second host 200 may have dual-machine management software installed thereon, and manage the first database 110 and the second database 210 through the dual-machine management software, respectively. The first database 110 accesses and manages data in disk group resources through the operating system of the first host 100; the second database 210 accesses and manages data in disk group resources through the operating system of the second host 200.
In the embodiment of the present application, the first host 100 and the second host 200 may be a computer device, a server, a personal computer, a notebook computer, or other types of communication devices.
In the embodiment of the present application, the first database 110 is a master database (active) and the second database 210 is a slave database slave), and the second database 210 may also be referred to as a standby database (standby), it should be understood that the first database 110 and the second database 210 may also be other names, as long as the relationship between the first database 110 and the second database 210 that are backed up can be shown.
In the embodiment of the present application, the first database 110 and the second database 210 may be an Oracle database management system, a MySQL database management system, or other types of database management systems, which are not described herein.
In the embodiment of the present application, at least two redo log groups are configured in the first database 110 and the second database 210, and are used for storing the redo logs, for example, there are a first redo log group and a second redo log group, where when the first redo log group is written fully, log group switching may occur, and the redo log is written into the second redo log group continuously, and when the second redo log group is written fully, log group switching may occur again, and the redo log is written into the first redo log group continuously.
It should be understood that, in the embodiment of the present application, the first database is taken as a master database, the second database is taken as a slave database, and the first database and the second database are taken as uniform Oracle database management systems for example, which will be described in detail.
The embodiment of the application provides a master-slave database switching method, which is applied to the database system 10, and when a first database 110 meets the double-machine switching condition, a first host releases a service plane floating IP bound to the first database, switches the first database from a master to a slave, sends indication information to a second host, and after receiving the indication information, the second host switches the second database from the slave to the master, and starts a service plane floating IP address on the second database, thereby realizing double-machine switching. However, in the process of switching the database from the master to the slave or from the slave to the master, there may be two switching modes of performing a dual switching operation (switch over) in a planned manner and performing a dual switching operation (failover) when the database is inactive, and in different modes, the switching processes performed by the first host and the second host are different.
In the embodiment of the application, when the double-machine operation is triggered, partial resources or parts of the main database are abnormal, but the double-machine switching function of the main database may be in a normal running state, the switch mode is a mode of executing the double-machine switching operation when the double-machine switching function of the database is in the normal running state, and the failover mode is a mode of executing the double-machine switching operation forcedly when the double-machine switching function of the database is in a fault state. When the first database is switched to be used as a slave in the switch over mode, the second database can be switched to be used as a master in the switch over mode or can be switched to be used as a master in the failover mode; when the first database is switched to the slave in the failover mode, the second database can only be switched to the master in the failover mode, and the switching modes in the above three cases are respectively described in detail below.
1. The first host and the second host switch the master and the slave in a switch over mode
In the embodiment of the present application, referring specifically to fig. 2, an embodiment of a master-slave database switching method provided in the embodiment of the present application may include:
201. the first host initiates a first database.
In some embodiments of the present application, the first host may launch the first database to a raised state, launch the replication plane listener, set the first database to the primary database, and launch the first database to a full-boot (open) state. The management plane floating IP address and the traffic plane floating IP address are started on the first database, and the management plane listener and the traffic plane listener are started.
In the embodiment of the application, the detected state and the open state are two states of the database in the starting process, wherein the detected state (rising state) is the database state when the database is not completely started, and the open state (complete starting state) is the database state when the database is completely started, and in the two states, the host can execute different rights of management operation on the database.
In an embodiment of the present application, the floating internet protocol (Internet Protocol, IP) address is an IP address that can drift between the first database and the second database under a dual-set networking, always bound to the primary database. Wherein the management plane floating IP is used to carry the data flow of the management plane, and the service plane floating IP address is used to carry the data flow of the service plane.
In the embodiment of the application, in order to realize network isolation, a plurality of network planes are introduced in the communication process. Wherein the replication plane is a network plane planned by the first host and the second host for realizing replication of the redo log in the master database from the slave database, i.e. a network plane for communication between the first host and the second host; the management plane refers to a network plane for realizing internal network monitoring; the service plane refers to a network plane that receives and responds to service requests.
In the embodiment of the application, the monitor is a network service in the Oracle database management system and can be used for legally checking the received connection request, if the connection request is valid, the connection is performed, otherwise, the connection is refused. The replication plane monitor is used for monitoring connection requests on the replication plane, the management plane monitor is used for monitoring connection requests on the management plane, and the service plane monitor is used for monitoring connection requests on the service plane. It should be appreciated that while there are listeners in the Oracle database management system, there are some types of database management systems in which there is no listener, and accordingly there is no step to launch a listener.
202. The second host initiates a second database.
In the embodiment of the application, the second host can start the second database to a monitored state, start the copy plane monitor, set the second database as a slave database, start the copy process of the second database, start the flashback mode of the second database, and then start the second database to an open state.
203. The first host sends a redo log of the first database to the second host.
In the embodiment of the application, after the first host starts the first database, the first database can receive the service request sent by the client, so that the redo log of the first database can be generated according to the received service request and written into the redo log group, and the first host can send the redo log in the redo log group to the second host through the IP address of the copy plane.
Because the first host and the second host communicate with each other through the replication plane, the second host can acquire the redo log of the first database in real time.
204. The second host controls the second database to execute the transaction executed by the first database.
In the embodiment of the application, after the second host obtains the redo log of the first database, the second host can control the second database to execute the transaction executed by the first database according to the redo log, so that the data in the disk group resource of the second database is consistent with the data in the disk group resource of the first database.
In the embodiment of the application, the second host can acquire the redo log of the first database in real time through the IP address of the copy plane, so that the data in the disk group resource of the second database is consistent with the data in the disk group resource of the first database in real time, and when the double-machine switching operation is started, the second database can respond to the service request of the client in time according to the data in the disk group resource after the double-machine switching operation is completed, thereby further shortening the duration of user service interruption and reducing the influence of the double-machine switching on the client.
205. The first host monitors the operation of the first database.
In the embodiment of the present application, the first host may periodically monitor the operation condition of the first database, so that when the first database is abnormal, the dual-host switching operation may be triggered in time, and referring specifically to fig. 3, the manner in which the first host monitors the operation condition of the first database specifically includes:
the first host judges whether the disk group resource of the first database is online or not, and under the condition that the disk group resource of the first database is not online, the first host executes pulling operation on the disk group resource of the first database, if the pulling operation fails, the pulling operation is repeatedly executed, and when the number of times that the first host continuously executes the pulling operation on the disk group resource of the first database exceeds a first threshold value, the first host determines that the first database meets a double-machine switching condition; or alternatively
The first host judges whether the database resource of the first database is online or not, and under the condition that the database resource of the first database is not online, the first host executes pulling operation on the database resource of the first database, if the pulling operation fails, the pulling operation is repeatedly executed, and when the number of times that the first host continuously executes the pulling operation on the database resource of the first database exceeds a second threshold value, the first host determines that the first database meets the double-machine switching condition; or alternatively
The first host judges whether the service plane monitor of the first database is online or not, and under the condition that the service plane monitor of the first database is not online, the first host executes pulling operation on the service plane monitor of the first database, if the pulling operation fails, the pulling operation is repeatedly executed, and when the number of times that the first host continuously executes the pulling operation on the service plane monitor of the first database exceeds a fourth threshold value, the first host determines that the first database meets a double-machine switching condition; or alternatively
The first host judges whether the management plane monitor of the first database is online or not, and if the management plane monitor of the first database is not online, the first host executes the pulling operation on the management plane monitor of the first database, and if the pulling operation fails, the pulling operation is repeatedly executed; or alternatively
The first host judges whether the copy plane monitor of the first database is on line or not, and if the copy plane monitor of the first database is not on line, the first host executes a pull-up operation on the copy plane monitor of the first database, and if the pull-up operation fails, the first host repeatedly executes the pull-up operation;
the first host judges whether the service plane floating IP address of the first database is online or not, and under the condition that the service plane floating IP address of the first database is not online, the first host executes pulling operation on the service plane floating IP address of the first database, if the pulling operation fails, the pulling operation is repeatedly executed, and when the number of times that the first host continuously executes the pulling operation on the service plane floating IP address of the first database exceeds a third threshold value, the first host determines that the first database meets a double-machine switching condition; or alternatively
The first host judges whether the management plane floating IP address of the first database is on line or not, and if the management plane floating IP address of the first database is not on line, the first host executes the pulling operation on the management plane floating IP address of the first database, and if the pulling operation fails, the pulling operation is repeatedly executed.
In an embodiment of the present application, the database resource consists of instance (instance) and database (database) structures. Examples consist of background processes and memory structures, which may be, by way of example, a system Global Area (System Global Area, SGA), program Global Area (Process Global Area, PGA), user Global Area (UGA), or other types of memory structures. The database structure is determined by a physical structure determined by operating system files such as database data files, redo log files, control files, parameter files, or archive log files, and a logical structure determined by tablespaces, data blocks, or index ends, etc.
In the embodiment of the application, when the first host monitors that any one of the disk group resource, the database resource, the service plane monitor or the service plane floating IP address is not on line and continuous pulling fails, the dual-computer switching operation can be triggered in time, and the service request of the client cannot be responded due to the fact that any one of the resources is abnormal, the dual-computer switching operation is triggered in time at this time, and the second database continues to respond to the service request of the client so as to provide good user experience.
When any resource in the management plane monitor, the copying plane monitor or the management plane floating IP address is not on line, the pulling operation can be repeatedly executed, and when the repeated pulling operation is still failed, a warning can be sent out to prompt operation and maintenance personnel to perform manual intervention, so that the operation stability of the main database is improved; however, the dual-mode switching operation is not triggered, and because the service request of the client cannot be responded directly when any resource is abnormal, the dual-mode switching operation is not triggered at the moment, and the interruption of the user service is avoided.
It should be appreciated that since there are listeners in the Oracle database management system, the first host needs to determine whether the listeners of the first database are online, but there are some types of database management systems in which there are no listeners, and accordingly, there is no step of determining whether the listeners are online.
In addition, in some embodiments of the present application, the abnormal judging order of the first host to the various resources or components of the first database is not limited, for example, the first host may first judge whether the database resources are online or not, then judge whether the disk group resources are online or not, and specifically, the judging order of each resource or component should be flexibly set according to the actual order.
206. The second host monitors the operation of the second database.
In an embodiment of the present application, the second host may periodically monitor the operation condition of the second database, referring to fig. 4, and the manner in which the second host monitors the operation condition of the second database specifically includes:
the second host judges whether the disk group resource of the second database is online or not, and if the disk group resource of the second database is not online, the second host executes the pulling operation on the disk group resource of the second database, and if the pulling operation fails, the pulling operation is repeatedly executed; or alternatively
The second host judges whether the database resources of the second database are online or not, and if the database resources of the second database are not online, the second host executes the pulling operation on the database resources of the second database, and if the pulling operation fails, the pulling operation is repeatedly executed; or alternatively
The second host judges whether the copy plane monitor of the second database is on line, and under the condition that the copy plane monitor of the second database is not on line and the state of the copy process is normal, the second host executes the pulling operation on the copy plane monitor of the second database, if the pulling failure occurs, the pulling operation is repeatedly executed, and under the condition that the copy plane monitor of the second database is not on line and the state of the copy process is abnormal, the second host restarts the copy process and then executes the pulling operation on the copy plane monitor of the second database.
In the embodiment of the application, in each monitoring period, the second host can check whether the disk group resource, the database resource and the copy plane monitor of the second database are on line, if not, the pulling operation can be repeatedly executed, and when the pulling operation is repeated and the pulling operation is still failed, a warning can be sent to prompt operation and maintenance personnel to perform manual intervention, thereby ensuring that the slave database is in a normal operation state at all times, avoiding the condition that the slave database cannot be switched due to abnormal operation in the process of executing the double-machine switching operation, and improving the stability of the master-slave database switching process.
It should be understood that, in some embodiments of the present application, the execution order of steps 205 and 206 is not limited, and step 205 may be executed first and then step 206 may be executed. Step 206 may be performed first, and then step 205 may be performed; step 205 and step 206 may also be performed simultaneously.
207. The first host unbinds the first database from the floating IP address of the service plane.
In the embodiment of the present application, when the first host determines that the first database meets the dual-host switching condition through step 205, the first host stops using the service plane floating IP address on the first database, that is, unbinding the first database and the service plane floating IP address, and closes the service plane listener.
208. The first host unbinds the first database from the management plane floating IP address.
In the embodiment of the present application, when the first host determines that the first database meets the dual-host switching condition through step 205, the first host stops using the management plane floating IP address on the first database, that is, unbinding the first database and the management plane floating IP address, and closes the management plane listener.
It should be appreciated that the steps of turning off the listener in steps 207 and 208 are optional steps, and that in a database management system where no listener is present, the step of turning off the listener is also not present.
It should be understood that, in some embodiments of the present application, the execution order of steps 207 and 208 is not limited, and step 207 may be executed first and then step 208 may be executed. Step 208 may be performed first, and then step 207 may be performed; step 207 and step 208 may also be performed simultaneously.
209. The first host switches the first database from the master to the slave in a planned execution of a switch over mode of the dual-mode switching operation.
In some embodiments of the present application, after the first host unbinds the first database from the floating IP address, it may be determined whether the first database meets a switch over mode requirement, and if the first database meets the switch over mode, the first database is switched from the master to the slave in the switch over mode.
In the embodiment of the present application, the manner in which the first host and the second host determine whether the database meets the requirements of the switch over mode may be consistent, specifically, the host may determine whether the database meets the requirements of the switch over mode by determining whether the switch over mode of the database is in a normal running state, for example, by querying whether a switch_status (status of the switch over mode) in the database is a TO STANDBY (switch TO ACTIVE) status or a session ACTIVE (ACTIVE) status through a structured query language (structured query language, SQL) command, which should be understood herein only for convenience in understanding the present scheme, and not particularly limited.
210. The first host sends indication information to the second host.
In some embodiments of the present application, after the first host switches the first database to the slave in the switch over mode, the indication information may be sent to the second host, where the indication information is used to indicate that the second database is switched from the slave to the master, and the service plane floating IP address is started on the second database.
211. The second host switches the second database from the slave to the master in a planned execution of a switch over mode of the dual-mode switch operation.
In some embodiments of the present application, after receiving the indication information of the first host, the second host may determine whether the second database meets a requirement of a switch over mode, and if the second database meets the switch over mode, switch the second database from the slave to the master in the switch over mode.
212. The second host initiates a traffic plane floating IP address on the second database.
213. The second host initiates a management plane floating IP address on the second database.
In the embodiment of the application, the address information of the service plane floating IP address and the management plane floating IP address can be stored in advance on the second host, after the second host switches the second database to the active state, the second database can be started to the locked state, the copy plane monitor is started, the second database is set as the active database, and then the second database is started to the open state. And starting the management plane floating IP address and the service plane floating IP address on the second database, and starting the management plane monitor and the service plane monitor, thereby completing the switching of the second database from the slave to the master.
In the embodiment of the application, the second host and the first host share the same management plane floating IP address on the management plane, so that the management plane floating IP address for bearing the data flow of the management plane before and after the switching is executed is unchanged, the IP address accessed by the gateway for monitoring the internal network condition before and after the double-host switching is unchanged, and the influence of the double-host switching on the gateway is reduced.
2. The first host is in a switch over mode and the second host is in a failover mode to switch between the master and the slave
Referring specifically to fig. 5, another embodiment of a master-slave database switching method provided by an embodiment of the present application may include:
501. the first host initiates a first database.
502. The second host initiates a second database.
503. The first host sends a redo log of the first database to the second host.
504. The second host controls the second database to execute the transaction executed by the first database.
505. The first host monitors the operation of the first database.
506. The second host monitors the operation of the second database.
507. The first host unbinds the first database from the floating IP address of the service plane.
508. The first host unbinds the first database from the management plane floating IP address.
509. The first host switches the first database from the master to the slave in a planned execution of a switch over mode of the dual-mode switching operation.
510. The first host sends indication information to the second host.
In the embodiment of the present application, steps 501 to 510 are similar to steps 201 to 210 in the embodiment shown in fig. 2, and are not repeated here.
511. The second host performs a dual-machine switching operation failover mode when the database is inactive to switch the second database from the slave to the master.
In some embodiments of the present application, after receiving the indication information of the first host, the second host may determine whether the second database meets the requirement of the switch over mode, and if the second database does not meet the switch over mode, or if the second database meets the switch over mode but fails to switch in the switch over mode, the second host may switch the second database from the slave to the master in the switch over mode, and then the second host may switch the second database from the slave to the master in the failover mode.
In one implementation manner, under the condition that the second host determines that the second database cannot be switched to be in the master mode, the second host can wait for a period of time, so that the second database can continue to execute the transaction executed by the first database according to the redo log of the first database, and acquire the execution state of the transaction executed by the second database according to the redo log of the first database, until the second database finishes executing the transaction executed by the first database, the second host stops the replication process of the second database, and forcedly switches the second database from the slave mode to the master mode in the failover mode.
In some embodiments of the present application, when the second host computer cannot switch the second database from the slave to the master in the switch over mode, the second host computer may force the second database to be switched to the master in the failover mode only when determining that the transaction executed by the second database and the first database is in the execution completion state, so as to avoid the forced interruption of the database replication process, thereby ensuring the continuity of the second database replication process in the first database, so as to achieve data consistency between the second database and the first database as soon as possible, and thus respond to the service request of the client as soon as possible.
In another implementation manner, the second host may obtain a preset duration, and when the duration of the second database executing the transaction executed by the first database reaches the preset duration, the second host switches the second database from the slave to the master in the failover mode.
In some embodiments of the present application, the second host may preset a waiting duration, where the second host may wait a period of time when the second host cannot switch the second database to be active in the switch over mode, so that the second database may continue to execute the transaction executed by the first database according to the redo log of the first database, and when the duration of executing the transaction executed by the first database by the second database reaches the preset duration, stop the replication process of the second database, and force the second database to be switched from active to active in the failover mode.
In the embodiment of the present application, the preset duration may be 60 seconds, 45 seconds, 75 seconds, or other preset durations, which are not limited herein.
In the embodiment of the application, the second host can preset a waiting time period, if the second database still does not execute all the transactions within the preset time period, the second host means that the copying process of the second database may fail, and when the waiting time period reaches the preset time period, the second database is forcedly switched to be in primary use in a failover mode, so that the overlong time for service interruption is avoided.
512. The second host initiates a traffic plane floating IP address on the second database.
513. The second host initiates a management plane floating IP address on the second database.
In the embodiment of the present application, steps 512 and 513 are similar to steps 212 and 213 in the embodiment shown in fig. 2, and will not be described again here.
3. The first host is in a failover mode and the second host is in the failover mode for switching between the master and the slave
Referring specifically to fig. 6, another embodiment of a master-slave database switching method provided by an embodiment of the present application may include:
601. the first host starts the first database to an ascending state;
602. The first host starts a flashback mode of the first database;
603. the first host initiates the first database to a fully open state.
In some embodiments of the present application, after the first database is started to the locked state, the first host may start the replication plane listener, set the first database as the primary database, start the archive mode of the redo log group of the first database, start the flashback mode of the first database, and then start the first database to the open state. The management plane floating IP address and the traffic plane floating IP address are started on the first database, and the management plane listener and the traffic plane listener are started.
604. The second host initiates a second database.
605. The first host sends a redo log of the first database to the second host.
606. The second host controls the second database to execute the transaction executed by the first database.
607. The first host monitors the operation of the first database.
608. The second host monitors the operation of the second database.
609. The binding of the first database and the floating IP address of the service plane is released at the first host.
610. The binding of the first database and the floating IP address of the management plane is released at the first host.
In some embodiments of the present application, steps 604 to 610 are similar to steps 202 to 208 in the embodiment shown in fig. 2, and are not repeated here.
611. The first host sends indication information to the second host.
In some embodiments of the present application, after determining that the first database cannot switch from master to slave in the switch over mode, the first host may check whether all the redo logs of the first host are sent to the second host, and if not all the redo logs of the first host are sent to the second host, force all the redo logs of the first host to be sent to the second host, and send an indication information to the second host after determining that all the redo logs are sent to the second host, where the indication information is used to indicate that the second database is switched from slave to master, and start the service plane floating IP address on the second database.
Under the condition that the first database cannot complete double-machine switching in the switch over mode, the first host can determine that the first database has faults, the possibility that the first host sends the redo log to the second host also has faults exists, and the second host can acquire all the redo logs of the first host in a forced sending mode, so that the consistency of the data of the second database and the data of the first database is ensured, and the safety of user data is improved.
612. The second host performs a dual-machine switching operation failover mode when the database is inactive to switch the second database from the slave to the master.
In the embodiment of the present application, step 612 is similar to step 511 in the embodiment shown in fig. 5, and will not be described here again.
613. The second host reboots the second database.
614. The second host records the system change number SCN when the second database is restarted.
In some embodiments of the present application, after the second database is switched to the active state, the second host may restart the second database and record the system change number (System Change Number, SCN) when the second database is restarted, that is, the second database is switched to the SCN after the active state. Wherein SCN is a series of numbers automatically maintained by the database management system in cumulative increments for distinguishing the order of transactions,
615. the second host initiates a traffic plane floating IP address on the second database.
616. The second host initiates a management plane floating IP address on the second database.
In the embodiment of the present application, steps 615 and 616 are similar to steps 212 and 213 in the embodiment shown in fig. 2, and are not described here again.
617. The first host acquires a system change number after the second database is switched to be the main use.
In some embodiments of the present application, when the first host determines that the first database meets the dual-machine switching condition in step 607, it may determine whether the first database meets the requirement of the switch over mode, and if the first database does not meet the switch over mode, or if the first database meets the switch over mode but fails to switch in the switch over mode, the first database needs to be switched from the master to the slave in the failure mode. The first host may acquire the SCN after the second database is switched from slave to master, i.e., the SCN at the time the second database was restarted in step 614.
618. And the first host executes the flashback operation according to the system change number.
In some embodiments of the present application, after the first host acquires the SCN after the second database is switched to the active state, since the first host has already started the flashback mode of the first database in step 602, a flashback operation may be performed according to the SCN.
It should be appreciated that step 602 is an optional step, and when step 602 is not performed, after the first host obtains that the second database is switched to the SCN after the primary service through step 618, the first host may restart the first database, and start the archiving mode of the redo log group and the flashback mode of the first database.
619. And the first host computer executes a double-machine switching operation failover mode when the database is inactive to switch the first database from the master to the slave.
In some embodiments of the present application, after performing a flashback operation according to the SCN after the second database is switched to the master, the first host may switch the first database from the master to the slave in the failover mode. And the second host controls the first database to continue executing the transaction according to the SCN number and the redo log.
In the embodiment of the application, when the first database and the second database are switched from the secondary to the primary in the failover mode, the second host database is switched from the secondary to the primary in the failover mode, and after restarting the second database, the SCN of the restarting of the second database is obtained, the first host obtains the SCN, and the flashback operation is executed according to the SCN. When the first database and the second database are in a fault state, the consistency of the data of the first database and the second database is ensured in a unified SCN mode, so that the accuracy of the data in the databases is improved.
In order to better implement the above-described aspects of the embodiments of the present application, the following provides related apparatuses for implementing the above-described aspects.
Referring to fig. 7, a schematic structural diagram of a host provided in an embodiment of the present application is shown, where the host is a first host, the first host is included in a database system, the database system further includes a second host, a first database is running on the first host, a second database is running on the second host, and the first database and the second database are respectively configured with respective disk group resources, where the host includes: a release unit 701, a switching unit 702, and a transmission unit 703, wherein,
a releasing unit 701, configured to release binding between the first database and a service plane floating IP address, where the service plane floating IP address is used to carry a data flow of a service plane, and the service plane is a network plane that receives and responds to a service request, where the first database meets a dual-machine switching condition;
a switching unit 702, configured to switch the first database from a master to a slave;
a sending unit 703, configured to send, to the second host, indication information, where the indication information is used to instruct that the second database is switched from the slave to the master, and start the service plane floating IP address on the second database.
In the embodiment of the present application, when the first database satisfies the dual-machine switching condition, the releasing unit 701 releases the service plane floating IP address bound to the first database, and the switching unit 702 switches the first database from the master to the slave. After the first database completes the role switch operation, the sending unit 703 sends, to the second database, indication information for indicating to switch the second database from the slave to the master, and starts the above-described service plane floating IP address on the second database. The main database and the slave database are respectively provided with the respective disk group resources, so that the disk group resources and the database resources are activated on the main database and the slave database simultaneously, the problem of inadaptation between the disks and the databases in the double-machine switching process is avoided, the situation that the user cannot respond to the request due to the failure of the shared disk is avoided, and the safety of the data is improved; in the double-machine switching process, the switching of the service plane floating IP and the switching of the roles of the master database and the slave database are involved, so that the disk group resources and the database resources are not required to be disconnected from the master data and then connected to the slave database, the time length of the double-machine switching is shortened, and the time length of the interruption of the user service is shortened; in addition, because the floating IP address of the service plane for bearing the data flow of the service plane before and after the switching is executed is not changed, the IP address accessed by the client before and after the dual-machine switching is not changed, and the influence of the dual-machine switching on the client is reduced.
In this embodiment of the present application, the sending unit 703 is further configured to send a redo log of the first database to the second host, where the redo log is used to instruct the second host to control the second database to execute, according to the redo log, a transaction executed by the first database, so that data in a disk set resource of the second database is consistent with data in a disk set resource of the first database.
In the embodiment of the present application, the sending unit 703 is specifically configured to:
when the first host determines that the first database is in a normal running state, the first host can send a redo log of the first database to the second host in real time through an IP address of a copy plane; when the first host determines that the first database runs abnormally, the first host forcedly sends the redo log of the first database to the second host.
In some embodiments of the present application, the switching unit 702 is specifically configured to:
and under the condition that the first database does not accord with a planned execution double-machine switching operation switch mode, acquiring a system change number SCN when the second database is started, executing a flashback operation according to the SCN, and switching the first database from a master to a slave under the condition that the double-machine switching operation switch mode is executed when the database is not active.
In some embodiments of the present application, the switching unit 702 is specifically configured to:
and under the condition that the first database accords with a switch over mode, switching the first database from a master to a slave in the switch over mode.
In some embodiments of the present application, the switching unit 702 is specifically configured to:
and under the condition that the role of the second database is switched to fail in a switch over mode, acquiring the SCN of the second database when the second database is started, executing a flashback operation according to the SCN, and switching the first database from the master to the slave in a switch over mode.
In the embodiment of the present application, the releasing unit 701 is further configured to release the binding between the first database and a management plane floating IP address, where after the dual-machine switching operation is performed, the management plane floating IP is bound to the second database, the management plane floating IP is used for carrying a data flow of a management plane, and the management plane is a network plane for implementing internal network monitoring.
In the embodiment of the present application, the first host further includes a pull-up unit 704, and the means for determining, by the release unit 701, that the first database meets a dual-machine switching condition includes at least one of the following:
When the number of times that the pulling unit 704 continuously performs the pulling operation on the disk set resources of the first database exceeds a first threshold, the releasing unit 701 determines that the first database meets a two-machine switching condition; or alternatively
When the number of times that the pulling unit 704 continuously performs the pulling operation on the database resource of the first database exceeds a second threshold, the releasing unit 701 determines that the first database meets a two-machine switching condition; or alternatively
In a case that the service plane floating IP address resource of the first database is not on line, the pulling unit 704 performs a pulling operation on the service plane floating IP address resource of the first database, and when the number of times that the pulling unit 704 continuously performs the pulling operation on the service plane floating IP address of the first database exceeds a third threshold, the releasing unit 701 determines that the first database satisfies a two-machine switching condition.
In an embodiment of the present application, the host further includes:
the starting unit 705 is configured to start the first database to a raised state, start a flashback mode of the first database, and start the first database to a fully open state.
Referring to fig. 8, a schematic diagram of another structure of a host according to an embodiment of the present application is shown, where the host is a second host, the second host is included in a database system, the database system further includes a second host, where a first database is running on the first host, a second database is running on the second host, and the first database and the second database are respectively configured with respective disk group resources, and the host includes: a receiving unit 801, a switching unit 802 and a starting unit 803, wherein,
a receiving unit 801, configured to receive indication information sent by a first host, where the indication information is used to indicate to start a dual-machine switching operation of the second database;
a switching unit 802, configured to switch the second database from a slave to a master;
a starting unit 803, configured to start a service plane floating IP address on the second database, where the service plane is a network plane that receives and responds to a service request, and before performing a dual-machine switching operation, the service plane floating IP address is bound to the first database.
In the embodiment of the present application, after receiving the indication information, based on the indication information, the switching unit 802 switches the second database from the slave to the master, and the starting unit 803 starts the service plane floating IP address on the second database. The main database and the slave database are respectively provided with the respective disk group resources, so that the disk group resources and the database resources are activated on the main database and the slave database simultaneously, the problem of inadaptation between the disks and the databases in the double-machine switching process is avoided, the situation that the user cannot respond to the request due to the failure of the shared disk is avoided, and the safety of the data is improved; in the double-machine switching process, the switching of the service plane floating IP and the switching of the roles of the master database and the slave database are involved, so that the disk group resources and the database resources are not required to be disconnected from the master data and then connected to the slave database, the time length of the double-machine switching is shortened, and the time length of the interruption of the user service is shortened; in addition, because the floating IP address of the service plane for bearing the data flow of the service plane before and after the switching is executed is not changed, the IP address accessed by the client before and after the dual-machine switching is not changed, and the influence of the dual-machine switching on the client is reduced.
In an embodiment of the present application, the host further includes: an acquisition unit 804, and a control unit 805, wherein,
an obtaining unit 804, configured to obtain a redo log of the first database;
and the control unit 805 is configured to control, according to the redo log, the second database to execute the transaction executed by the first database, so that data in the disk group resource of the second database is consistent with data in the disk group resource of the first database.
In some embodiments of the present application, the switching unit 802 is specifically configured to:
and under the condition that the second database does not accord with the planned execution double-machine switching operation switch mode, the second database is switched from the slave mode to the master mode under the condition that the database is inactive and the double-machine switching operation switch mode is executed.
In some embodiments of the present application, the switching unit 802 is specifically configured to:
and when the second database accords with a switch over mode, switching the second database from the slave mode to the master mode in the switch over mode.
In some embodiments of the present application, the switching unit 802 is specifically configured to:
and under the condition that the role switching of the second database fails in the switch mode, switching the second database from the slave mode to the master mode in the failover mode.
In some embodiments of the present application, the switching unit 802 is specifically configured to:
acquiring a preset duration; and when the time length of the second database executing the transaction executed by the first database reaches the preset time length, switching the second database from the slave mode to the master mode in the failover mode.
In some embodiments of the present application, the switching unit 802 is specifically configured to:
and when the second database executes the transaction executed by the first database, switching the second database from the slave to the master in the failover mode.
In an embodiment of the present application, the host further includes: a recording unit 806, configured to record the system change number SCN after the second database is switched to the active state, where the SCN is used for the first host to control the first database to execute a flashback operation according to the SCN.
In an embodiment of the present application, the host further includes a pull-up unit 807, where the pull-up unit 807 is specifically configured to:
executing a pull-up operation on the disk group resources of the second database under the condition that the disk group resources of the second database are not online; or alternatively
Executing a pull-up operation on the database resources of the second database under the condition that the database resources of the second database are not online; or alternatively
The starting unit 803 is further configured to execute, by a replication process, a transaction executed by the first database according to a redo log of the first database, and restart the replication process when a state of the replication process is abnormal.
In the embodiment of the present application, the starting unit 803 is further configured to start a management plane floating IP address on the second database, where before the dual-machine switching operation is performed, the management plane floating IP is bound to the first database, the management plane floating IP is used to carry a data flow of a management plane, and the management plane is a network plane for implementing internal network monitoring.
It should be noted that, because the content of information interaction and execution process between the modules/units of the above-mentioned device is based on the same concept as the method embodiment of the present application, the technical effects brought by the content are the same as the method embodiment of the present application, and the specific content can be referred to the description in the foregoing illustrated method embodiment of the present application, which is not repeated herein.
Next, another host provided in the embodiment of the present application is described, referring to fig. 9, which is a schematic structural diagram of a first host provided in the embodiment of the present application, a terminal device 900 includes:
A receiver 901, a transmitter 902, a processor 903 and a memory 904 (where the number of processors 903 in the terminal device 900 may be one or more, one processor being an example in fig. 10). In some embodiments of the application, the receiver 901, transmitter 902, processor 903, and memory 904 may be connected by a bus or other means, with the bus connection being exemplified in fig. 10.
Memory 904 may include read-only memory and random access memory, and provides instructions and data to the processor 903. A portion of the memory 904 may also include non-volatile random access memory (NVRAM). The memory 904 stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, where the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various underlying services and handling hardware-based tasks.
The processor 903 controls the operation of the terminal device, the processor 903 may also be referred to as a central processing unit (central processing unit, CPU). In a specific application, the individual components of the terminal device are coupled together by a bus system, which may comprise, in addition to a data bus, a power bus, a control bus, a status signal bus, etc. For clarity of illustration, however, the various buses are referred to in the figures as bus systems.
The method disclosed in the above embodiments of the present application may be applied to the processor 903 or implemented by the processor 903. The processor 903 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuitry of hardware in the processor 903 or instructions in the form of software. The processor 903 described above may be a general purpose processor, a digital signal processor (digital signal processing, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), a field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software modules in a decoding processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in the memory 904, and the processor 903 reads information in the memory 904, and in combination with its hardware, performs the steps of the method described above.
The receiver 901 may be used to receive input numeric or character information and to generate signal inputs related to the relevant settings of the first host and the control of functions.
The transmitter 902 may be configured to output numeric or character information via the first interface, such as, for example, to a second host computer for outputting a redo log of the first database; the transmitter 902 is further operable to send instructions to the disk stack via the second interface to modify data in the disk stack; the transmitter 902 may also include a display device such as a display screen.
In the embodiment of the present application, the processor 903 is configured to execute the foregoing master-slave database switching method executed by the first host.
Referring to fig. 10, referring to another host provided in the embodiment of the present application, a second host 1000 includes:
a receiver 1001, a transmitter 1002, a processor 1003, and a memory 1004 (where the number of processors 1003 in the network device 1000 may be one or more, one processor being exemplified in fig. 10). In some embodiments of the application, the receiver 1001, transmitter 1002, processor 1003, and memory 1004 may be connected by a bus or other means, with the bus connection being exemplified in fig. 10.
Memory 1004 may include read only memory and random access memory and provide instructions and data to processor 1003. A portion of the memory 1004 may also include NVRAM. The memory 1004 stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, where the operating instructions may include various operating instructions for performing various operations. The operating system may include various system programs for implementing various underlying services and handling hardware-based tasks.
The processor 1003 controls the operation of the network device, and the processor 1003 may also be referred to as a CPU. In a specific application, the various components of the network device are coupled together by a bus system, which may include a power bus, a control bus, a status signal bus, and the like, in addition to a data bus. For clarity of illustration, however, the various buses are referred to in the figures as bus systems.
The method disclosed in the above embodiment of the present application may be applied to the processor 1003 or implemented by the processor 1003. The processor 1003 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuitry of hardware in the processor 1003 or instructions in the form of software. The processor 1003 may be a general purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software modules in a decoding processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory 1004, and the processor 1003 reads information in the memory 1004 and performs the steps of the method in combination with its hardware.
The receiver 1001 may be used to receive numeric or character information, such as for example a redo log of a first database sent by a first host, and may also be used to generate signal inputs related to the relevant settings and function control of a second host.
The transmitter 1002 may be configured to output digital or character information through the first interface, for example, output information such as a system change number SCN to the first host; the transmitter 1002 may also be configured to send instructions to the disk stack via the second interface to modify data in the disk stack; the transmitter 1002 may also include a display device such as a display screen.
In the embodiment of the present application, the processor 1003 is configured to execute the foregoing master-slave database switching method executed by the second host.
Embodiments of the present application also provide a computer program product comprising master-slave database switch instructions which, when executed on a computer, cause the computer to perform the steps performed by a first host in the method described in the embodiments of figures 2 to 6 above.
Embodiments of the present application also provide a computer program product comprising master-slave database switch instructions which, when executed on a computer, cause the computer to perform the steps performed by the second host in the method described in the embodiments of figures 2 to 6 above.
Embodiments of the present application also provide a computer readable storage medium having stored therein instructions for switching between master and slave databases, which when executed on a computer, cause the computer to perform the steps performed by the first host in the method described in the embodiments of fig. 2 to 6.
Embodiments of the present application also provide a computer readable storage medium having stored therein instructions for switching between master and slave databases, which when executed on a computer, cause the computer to perform the steps performed by the second host in the method described in the embodiments of fig. 2 to 6.
The processor mentioned in any of the above may be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the program of the method of the first aspect.
Embodiments of the present application also provide a chip system, where the chip system includes a processor, and is configured to support a network device to implement the functions involved in the above aspects, for example, to send or process data and/or information involved in the above method. In one possible design, the system-on-chip further includes a memory to hold program instructions and data necessary for the network device. The chip system can be composed of chips, and can also comprise chips and other discrete devices.
It should be further noted that the above-described apparatus embodiments are merely illustrative, and that the units described as separate units may or may not be physically separate, and that units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the drawings of the embodiment of the device provided by the application, the connection relation between the modules represents that the modules have communication connection, and can be specifically implemented as one or more communication buses or signal lines.
From the above description of the embodiments, it will be apparent to those skilled in the art that the present application may be implemented by means of software plus necessary general purpose hardware, or of course by means of special purpose hardware including application specific integrated circuits, special purpose CPUs, special purpose memories, special purpose components, etc. Generally, functions performed by computer programs can be easily implemented by corresponding hardware, and specific hardware structures for implementing the same functions can be varied, such as analog circuits, digital circuits, or dedicated circuits. However, a software program implementation is a preferred embodiment for many more of the cases of the present application. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a readable storage medium, such as a floppy disk, a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random-access Memory (RAM, random Access Memory), a magnetic disk or an optical disk of a computer, etc., including several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to execute the method according to the embodiments of the present application.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product.
The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by a wired (e.g., coaxial cable, fiber optic, digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be stored by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.

Claims (22)

1. A master-slave database switching method, wherein the method is applied to a database system, the database system includes a first host and a second host, wherein the first host is operated with a first database, the second host is operated with a second database, and the first database and the second database are respectively configured with respective disk group resources, the method includes:
under the condition that the first database meets the double-machine switching condition, the first host releases the binding of the first database and a service plane floating Internet Protocol (IP) address, wherein the service plane floating IP address is used for bearing a data stream of a service plane, and the service plane is a network plane for receiving and responding to a service request;
the first host switches the first database from the master to the slave;
the first host sends indication information to the second host, wherein the indication information is used for indicating that the second database is switched from the slave mode to the master mode, and the service plane floating IP address is started on the second database;
the first host switching the first database from a master to a slave, including:
When the first database does not accord with a planned execution double-machine switching operation switch mode or the role of the second database fails to switch in the switch mode, the first host acquires a system change number SCN when the second database is started;
the first host executes a flashback operation according to the SCN;
and the first host computer executes a double-machine switching operation failover mode when the database is inactive, and switches the first database from the master to the slave.
2. The method according to claim 1, wherein the method further comprises:
the first host sends a redo log of the first database to the second host, wherein the redo log is used for controlling the second database to execute the transaction executed by the first database according to the redo log by the second host so as to enable the data in the disk group resource of the second database to be consistent with the data in the disk group resource of the first database.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
the first host releases the binding between the first database and a management plane floating IP address, wherein after the dual-host switching operation is executed, the management plane floating IP is bound on the second database, the management plane floating IP is used for bearing the data flow of the management plane, and the management plane is a network plane for realizing internal network monitoring.
4. The method of claim 1 or 2, wherein the first host determining that the first database satisfies a two-machine handoff condition comprises at least one of:
under the condition that the disk group resources of the first database are not online, the first host executes a pulling operation on the disk group resources of the first database;
when the number of times that the first host continuously executes the pulling operation on the disk group resource of the first database exceeds a first threshold value, the first host determines that the first database meets a double-machine switching condition;
or alternatively
Under the condition that the database resources of the first database are not online, the first host executes a pulling operation on the database resources of the first database;
when the number of times that the first host continuously executes the pulling operation on the database resources of the first database exceeds a second threshold value, the first host determines that the first database meets a double-machine switching condition;
or alternatively
Under the condition that the service plane floating IP address of the first database is not on line, the first host executes a pulling operation on the service plane floating IP address of the first database;
And when the number of times that the first host continuously executes the pulling operation on the service plane floating IP address of the first database exceeds a third threshold value, the first host determines that the first database meets a double-machine switching condition.
5. A master-slave database switching method, wherein the method is applied to a database system, the database system includes a first host and a second host, wherein the first host is operated with a first database, the second host is operated with a second database, and the first database and the second database are respectively configured with respective disk group resources, the method includes:
the second host receives indication information sent by the first host, wherein the indication information is used for indicating to start the double-machine switching operation of the second database;
the second host switches the second database from the slave to the master;
the second host starts a service plane floating Internet Protocol (IP) address on the second database, wherein the service plane is a network plane for receiving and responding to a service request, the service plane floating IP address is used for bearing a data stream of the service plane, the service plane is a network plane for receiving and responding to the service request, and before the dual-host switching operation is executed, the service plane floating IP address is bound on the first database;
After the second host switches the second database from the slave to the master, the method further comprises:
the second host records a system change number SCN after the second database is switched to be in use, and the SCN is used for the first host to control the first database to execute a flashback operation according to the SCN;
wherein the second host switches the second database from the slave to the master, comprising:
under the condition that the second database does not accord with a planned execution double-machine switching operation switch mode, the second host machine executes double-machine switching operation failover mode when the database is inactive, and switches the second database from a slave to a master; or alternatively
And under the condition that the second database fails to be switched in the switch mode, the second host switches the second database from the slave mode to the master mode in the failover mode.
6. The method of claim 5, wherein the method further comprises:
the second host acquires a redo log of the first database;
and the second host controls the second database to execute the transaction executed by the first database according to the redo log so as to make the data in the disk group resource of the second database consistent with the data in the disk group resource of the first database.
7. The method of claim 5, wherein switching the second database from slave to master in a failover mode comprises:
and when the second database executes the transaction executed by the first database, the second host switches the second database from the slave mode to the master mode in the failover mode.
8. The method of claim 5, wherein switching the second database from active to active in the failover mode comprises:
the second host acquires a preset duration;
and when the time length of the second database executing the transaction executed by the first database reaches the preset time length, the second host switches the second database from the slave to the master in the failover mode.
9. The method according to any one of claims 5 to 8, further comprising at least one of:
under the condition that the disk group resources of the second database are not online, the second host executes a pulling operation on the disk group resources of the second database;
or alternatively
In the case that the database resource of the second database is not online, the second host performs a pull-up operation on the database resource of the second database;
Or alternatively
The second host executes the transaction executed by the first database according to the redo log of the first database through a copying process;
and restarting the copying process when the state of the copying process is abnormal.
10. The method of any of claims 5 to 8, wherein after the second host switches the second database from active to active, the method further comprises:
and the second host starts a management plane floating IP address on the second database, wherein before the dual-host switching operation is executed, the management plane floating IP is bound on the first database, the management plane floating IP is used for bearing the data flow of a management plane, and the management plane is a network plane for realizing internal network monitoring.
11. A host, wherein the host is a first host, the first host is included in a database system, the database system further includes a second host, wherein a first database is running on the first host, a second database is running on the second host, and the first database and the second database are respectively configured with respective disk group resources, the host includes:
The releasing unit is used for releasing the binding of the first database and a service plane floating Internet Protocol (IP) address, which is used for bearing the data flow of a service plane, under the condition that the first database meets the double-machine switching condition, wherein the service plane is a network plane for receiving and responding to the service request;
the switching unit is used for switching the first database from the master to the slave;
the sending unit is used for sending indication information to the second host, wherein the indication information is used for indicating that the second database is switched from the slave mode to the master mode, and the service plane floating IP address is started on the second database;
the switching unit is specifically configured to:
and under the condition that the first database does not accord with a planned execution double-machine switching operation switch mode or the role of the second database fails to switch in the switch mode, acquiring the SCN when the second database is started, executing a flashback operation according to the SCN, and switching the first database from a master to a slave in the switch mode.
12. The host machine of claim 11, wherein the host machine comprises a host computer,
the sending unit is further configured to send a redo log of the first database to the second host, where the redo log is used to instruct the second host to control the second database to execute the transaction executed by the first database according to the redo log, so that data in a disk group resource of the second database is consistent with data in a disk group resource of the first database.
13. The host computer of any one of claim 11 or 12,
the releasing unit is further configured to release binding between the first database and a management plane floating IP address, where after the dual-machine switching operation is performed, the management plane floating IP is bound to the second database, the management plane floating IP is used to carry a data flow of a management plane, and the management plane is a network plane for implementing internal network monitoring.
14. The host according to any one of claims 11 or 12, wherein the first host further comprises a pull-up unit, and wherein the release unit determines a manner in which the first database satisfies a two-machine switching condition, comprising at least one of:
when the number of times that the pulling unit continuously executes the pulling operation on the disk group resources of the first database exceeds a first threshold value, the releasing unit determines that the first database meets a double-machine switching condition;
or alternatively
When the number of times that the pulling unit continuously executes the pulling operation on the database resources of the first database exceeds a second threshold value, the releasing unit determines that the first database meets a double-machine switching condition;
Or alternatively
And under the condition that the service plane floating IP address resource of the first database is not on line, the pulling-up unit executes pulling-up operation on the service plane floating IP address resource of the first database, and when the number of times that the pulling-up unit continuously executes the pulling-up operation on the service plane floating IP address of the first database exceeds a third threshold value, the releasing unit determines that the first database meets a double-machine switching condition.
15. The host computer is characterized in that the host computer is a second host computer, the second host computer is contained in a database system, the database system further comprises a first host computer, wherein a first database runs on the first host computer, a second database runs on the second host computer, and the first database and the second database are respectively configured with respective disk group resources, and the host computer comprises:
the receiving unit is used for receiving indication information sent by the first host, and the indication information is used for indicating to start the double-machine switching operation of the second database;
a switching unit for switching the second database from the slave to the master;
the starting unit is used for starting a service plane floating Internet Protocol (IP) address on the second database, wherein the service plane is a network plane for receiving and responding to a service request, the service plane floating IP address is used for bearing a data stream of the service plane, the service plane is a network plane for receiving and responding to the service request, and before the double-machine switching operation is executed, the service plane floating IP address is bound on the first database;
The recording unit is used for recording the system change number SCN after the second database is switched to be in use, and the SCN is used for controlling the first database to execute a flashback operation by the first host according to the SCN;
the switching unit is specifically configured to:
under the condition that the second database does not accord with a planned execution double-machine switching operation switch mode, the second database is switched from a slave to a master in a double-machine switching operation failover mode when the database is inactive; or alternatively
And under the condition that the second database fails to be switched in the switch mode, switching the second database from the slave mode to the master mode in the failover mode.
16. The host of claim 15, wherein the host further comprises:
the acquisition unit is used for acquiring the redo log of the first database;
and the control unit is used for controlling the second database to execute the transaction executed by the first database according to the redo log so as to make the data in the disk group resource of the second database consistent with the data in the disk group resource of the first database.
17. The host of claim 15, wherein the switching unit is specifically configured to:
Acquiring a preset duration; and when the time length of the second database executing the transaction executed by the first database reaches the preset time length, switching the second database from the slave mode to the master mode in the failover mode.
18. The host of claim 15, wherein the switching unit is specifically configured to:
and when the second database executes the transaction executed by the first database, switching the second database from the slave to the master in the failover mode.
19. The host according to any one of claims 15 to 18, further comprising a pull-up unit, in particular for:
executing a pull-up operation on the disk group resources of the second database under the condition that the disk group resources of the second database are not online; or alternatively
Executing a pull-up operation on the database resources of the second database under the condition that the database resources of the second database are not online; or alternatively
The starting unit is further configured to execute, by using a replication process, a transaction executed by the first database according to a redo log of the first database, and restart the replication process when a state of the replication process is abnormal.
20. The host machine of any one of claims 15 to 18, wherein the host machine comprises,
the starting unit is further configured to start a management plane floating IP address on the second database, where before the dual-machine switching operation is executed, the management plane floating IP is bound to the first database, the management plane floating IP is used to carry a data flow of a management plane, and the management plane is a network plane for implementing internal network monitoring.
21. A host, wherein the host is a first host, and comprises a memory and a processor;
the memory is used for storing computer program codes;
the processor is configured to execute the memory-stored code such that the first host performs the method of any one of claims 1 to 4.
22. A host, wherein the host is a second host, comprising a memory and a processor;
the memory is used for storing computer program codes;
the processor is configured to execute the memory-stored code such that the first host performs the method of any one of claims 5 to 10.
CN201811400655.2A 2018-11-22 2018-11-22 Database switching method and terminal equipment Active CN111209265B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811400655.2A CN111209265B (en) 2018-11-22 2018-11-22 Database switching method and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811400655.2A CN111209265B (en) 2018-11-22 2018-11-22 Database switching method and terminal equipment

Publications (2)

Publication Number Publication Date
CN111209265A CN111209265A (en) 2020-05-29
CN111209265B true CN111209265B (en) 2023-11-17

Family

ID=70785841

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811400655.2A Active CN111209265B (en) 2018-11-22 2018-11-22 Database switching method and terminal equipment

Country Status (1)

Country Link
CN (1) CN111209265B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110119392B (en) * 2019-03-25 2022-02-11 福建天晴数码有限公司 Method and storage medium for switching database IP (Internet protocol) application
CN112199440A (en) * 2020-08-31 2021-01-08 阿里巴巴集团控股有限公司 Database control method, database control system, database switching method, electronic equipment and storage medium
CN113535738B (en) * 2021-09-16 2021-12-17 上海爱可生信息技术股份有限公司 Fault transfer method of MySQL database system, high-availability system and electronic equipment
CN114676118B (en) * 2022-05-30 2022-08-12 深圳市科力锐科技有限公司 Database switching method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043686A (en) * 2009-10-20 2011-05-04 华为技术有限公司 Disaster tolerance method, backup server and system of memory database
CN102855163A (en) * 2011-06-27 2013-01-02 华为软件技术有限公司 Memory database hot-standby method and host
CN104679604A (en) * 2015-02-12 2015-06-03 大唐移动通信设备有限公司 Method and device for switching between master node and standby node
CN106850269A (en) * 2016-12-29 2017-06-13 曙光信息产业(北京)有限公司 A kind of management system of cloud platform
CN107480014A (en) * 2017-07-24 2017-12-15 北京奇安信科技有限公司 A kind of High Availabitity equipment switching method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7574508B1 (en) * 2002-08-07 2009-08-11 Foundry Networks, Inc. Canonical name (CNAME) handling for global server load balancing
US7549079B2 (en) * 2005-11-30 2009-06-16 Oracle International Corporation System and method of configuring a database system with replicated data and automatic failover and recovery
US20180025066A1 (en) * 2016-07-19 2018-01-25 Sap Se Zero downtime database updates with database configuration changes

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043686A (en) * 2009-10-20 2011-05-04 华为技术有限公司 Disaster tolerance method, backup server and system of memory database
CN102855163A (en) * 2011-06-27 2013-01-02 华为软件技术有限公司 Memory database hot-standby method and host
CN104679604A (en) * 2015-02-12 2015-06-03 大唐移动通信设备有限公司 Method and device for switching between master node and standby node
CN106850269A (en) * 2016-12-29 2017-06-13 曙光信息产业(北京)有限公司 A kind of management system of cloud platform
CN107480014A (en) * 2017-07-24 2017-12-15 北京奇安信科技有限公司 A kind of High Availabitity equipment switching method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种自动管理的高可用架构的实现.《技术与方法》.2016,第77-83. *

Also Published As

Publication number Publication date
CN111209265A (en) 2020-05-29

Similar Documents

Publication Publication Date Title
CN111209265B (en) Database switching method and terminal equipment
US7062676B2 (en) Method and system for installing program in multiple system
US8966318B1 (en) Method to validate availability of applications within a backup image
US6425093B1 (en) Methods and apparatuses for controlling the execution of software on a digital processing system
US9239715B1 (en) Cancel and rollback update stack requests
JPH0576654B2 (en)
US11706080B2 (en) Providing dynamic serviceability for software-defined data centers
CN111552489B (en) User mode file system hot upgrading method, device, server and medium
US8533525B2 (en) Data management apparatus, monitoring apparatus, replica apparatus, cluster system, control method and computer-readable medium
US20120324436A1 (en) Method of updating versioned software using a shared cache
CN109361542A (en) The fault handling method of client, device, system, terminal and server
CN112506702A (en) Data center disaster tolerance method, device, equipment and storage medium
US20050066017A1 (en) Deterministically electing an active node
CN114640709B (en) Edge node processing method, device and medium
CN113630443A (en) Service management method, device, server and medium
CN111342986B (en) Distributed node management method and device, distributed system and storage medium
CN115658390A (en) Container disaster tolerance method, system, device, equipment and computer readable storage medium
CN116302352A (en) Cluster disaster recovery processing method and device, electronic equipment and storage medium
US8499080B2 (en) Cluster control apparatus, control system, control method, and control program
CN111090537B (en) Cluster starting method and device, electronic equipment and readable storage medium
CN117076196A (en) Database disaster recovery management and control method and device
CN115643168B (en) Node super-fusion upgrading method, device, equipment and storage medium
CN114443148B (en) Method for centrally managing server starting disk and server
CN116010174A (en) Method and device for switching servers, storage medium and electronic device
CN107783855B (en) Fault self-healing control device and method for virtual network element

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
GR01 Patent grant
GR01 Patent grant