WO2020063197A1 - 数据库切换方法、系统、电子设备和计算机可读介质 - Google Patents

数据库切换方法、系统、电子设备和计算机可读介质 Download PDF

Info

Publication number
WO2020063197A1
WO2020063197A1 PCT/CN2019/101626 CN2019101626W WO2020063197A1 WO 2020063197 A1 WO2020063197 A1 WO 2020063197A1 CN 2019101626 W CN2019101626 W CN 2019101626W WO 2020063197 A1 WO2020063197 A1 WO 2020063197A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
switching
module
data
master node
Prior art date
Application number
PCT/CN2019/101626
Other languages
English (en)
French (fr)
Inventor
孙文晖
高新刚
Original Assignee
京东数字科技控股有限公司
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 京东数字科技控股有限公司 filed Critical 京东数字科技控股有限公司
Publication of WO2020063197A1 publication Critical patent/WO2020063197A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0796Safety measures, i.e. ensuring safe condition in the event of error, e.g. for controlling element

Definitions

  • the present disclosure relates to the field of Internet technologies, and more particularly, to a database switching method, system, electronic device, and computer-readable medium.
  • a master-slave replication technology of a database is usually combined with a high-availability switching scheme to improve database availability. For example, when the master node database is down or the system hardware maintenance or version upgrade is used, the current master node database is switched to the slave node database using a high-availability switching scheme, and a slave node database is switched to the master node database. To ensure high availability of the database.
  • the inventors found that at least the following problems exist in the prior art: the switching between the existing master node database and the slave node database is prone to switching interruptions, and the success rate is low.
  • the present disclosure provides a database switching method, system, electronic device, and computer-readable medium.
  • An aspect of the present disclosure provides a database switching method including obtaining a switching request, the switching request being used to switch a master node database from a first database to a second database, determining a switching type based on the switching request, and detecting the switching based on the switching type. Whether the environment meets the switching conditions, and if the switching environment meets the switching conditions, switches the master node database from the first database to the second database.
  • a database switching system including an acquisition module for acquiring a switching request, the switching request for switching a master node database from a first database to a second database, and a determining module for determining based on the switching request.
  • Switching type The first detection module is used to detect whether the switching environment meets the switching conditions based on the switching type, and the switching module is used to switch the master node database from the first database to the second database if the switching environment meets the switching conditions.
  • Another aspect of the present disclosure provides an electronic device including one or more processors and a storage device for storing one or more programs, wherein when the one or more programs are used by the one or more programs, When the processor executes, the one or more processors are caused to execute the method of any one of the foregoing.
  • Another aspect of the present disclosure provides a non-volatile storage medium storing computer-executable instructions that, when executed, implement the method as described above.
  • Another aspect of the present disclosure provides a computer program including computer-executable instructions that, when executed, implement the method as described above.
  • FIG. 1 schematically illustrates an exemplary system architecture to which a database switching method can be applied according to an embodiment of the present disclosure
  • FIG. 2 schematically illustrates a flowchart of a database switching method according to an embodiment of the present disclosure
  • FIG. 3 schematically illustrates a flowchart of generating a handover request in a case where an abnormality occurs in a first database as a master node database according to an embodiment of the present disclosure
  • FIG. 4 schematically illustrates a flowchart of switching a master node database from a first database to a second database in a case where a switching type is an online switching according to an embodiment of the present disclosure
  • FIG. 5 schematically illustrates a flowchart of a database switching method according to another embodiment of the present disclosure
  • FIG. 6 schematically illustrates a flowchart of a database switching method according to another embodiment of the present disclosure
  • FIG. 8 schematically illustrates a flowchart of switching a master node database from a first database to a second database according to another embodiment of the present disclosure
  • FIG. 10 schematically illustrates a flowchart of a data switching method according to another embodiment of the present disclosure
  • FIG. 11A schematically illustrates a flowchart of an online switching method according to an embodiment of the present disclosure
  • FIG. 11B schematically illustrates an effect of an online switching method according to an embodiment of the present disclosure
  • FIG. 12A schematically illustrates a flowchart of a failover method according to an embodiment of the present disclosure
  • FIG. 12B schematically illustrates an effect of a failover method according to an embodiment of the present disclosure
  • FIG. 13 schematically illustrates a block diagram of a database switching system according to an embodiment of the present disclosure.
  • FIG. 14 schematically illustrates a block diagram of an electronic device according to an embodiment of the present disclosure.
  • An embodiment of the present disclosure provides a database switching method including obtaining a switching request for switching a master node database from a first database to a second database, determining a switching type based on the switching request, and detecting the switching based on the switching type. Whether the environment meets the switching conditions, and if the switching environment meets the switching conditions, switches the master node database from the first database to the second database.
  • FIG. 1 schematically illustrates an exemplary system architecture 100 to which a database switching method can be applied according to an embodiment of the present disclosure. It should be noted that FIG. 1 is only an example of a system architecture to which the embodiments of the present disclosure can be applied, to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used for other applications.
  • the system architecture 100 may include a server 110, a business system 120, and a database system 130, wherein the database system 130 may include a master node database 131, and slave node databases 132 and 133.
  • the slave node databases 132 and 133 can copy data from the master node database 131 to ensure consistency with the data of the master node database 131.
  • the database system 130 may be, for example, a MySQL database.
  • the server 110 may be a management server for managing the database system 130. For example, monitoring the working status of the master node database 131 and the slave node databases 132 and 133 in the database system 130, or controlling the master-slave switching operation of the database system 130, and the like.
  • the business system 120 can access the data stored in the master node database 131, and can also store logs in the master node database 131.
  • the master node database of the database system 130 may be switched from the server 131 to a slave node database to maintain the normality of the business system 120 run.
  • the switching between the master node database and the slave node database is prone to switching interruption, and the switching success rate is low.
  • the database switching method provided by the embodiment of the present disclosure may generally be executed by the server 110.
  • the database switching system provided in the embodiment of the present disclosure may generally be provided in the server 110.
  • the numbers of the master node database and the slave node database in FIG. 1 are merely exemplary. Depending on the implementation needs, there can be any number of master node databases and slave node databases.
  • FIG. 2 schematically illustrates a flowchart of a database switching method according to an embodiment of the present disclosure. As shown in FIG. 2, the method may include operations S210-S240.
  • a handover request is obtained, and the handover request is used to switch the master node database from the first database to the second database.
  • a switching type is determined based on the switching request.
  • the master node database is switched from the first database to the second database.
  • This method detects whether the switching environment meets the switching conditions before executing the switching of the master node database from the first database to the second database. Only when the switching conditions are met, the switching of the master-slave database is performed, which is at least partially avoided. An abnormality occurred during the execution of the master-slave switchover, which caused the interruption of the switchover, thereby improving the success rate of the master-slave database switchover.
  • obtaining a switching request includes generating a switching request based on a user input. For example, when the master node database is working normally and the user needs to maintain the database hardware, the user actively sends a request to switch between the master and slave databases through the client.
  • obtaining a handover request includes generating a handover request in a case where an abnormality occurs in the first database as a master node database. For example, the electronic device monitoring the master node database finds that the master node database is down or the process is stopped, thereby generating a master-slave switch request.
  • FIG. 3 schematically illustrates a flowchart of generating a handover request in a case where an abnormality occurs in a first database as a master node database according to an embodiment of the present disclosure. As shown in FIG. 3, the method includes operations S310-S330.
  • operation S310 the statuses of the multiple slave node databases are obtained.
  • operation S320 one slave node database is determined as the second database based on the states of the multiple slave node databases.
  • operation S330 a switching request for switching the master node database from the first database to the second database is generated.
  • the state of the slave node database may be, for example, a degree of consistency between the log data in the slave node database and the log data in the master node database.
  • the slave node database 132 is consistent with the log data in the master node database 131, and the log data in the slave node database 133 lacks part of the log data in the master node database 131.
  • the slave node database containing the latest log data may be used as the second database, or the slave node database containing the most log data may be used as the second database.
  • the slave database 132 may be used as the second database.
  • a switch request specifying the slave node database 132 as the second database is generated.
  • the database switching type may include, for example, online switching and failover.
  • Online switching may be, for example, a switching performed when a user actively issues a database switching request through a client when the master node database is working normally.
  • a failover can be, for example, a switchover performed when the working state of the master node database is abnormal.
  • determining the handover type includes reading a parameter representing the handover type from the handover request to determine the handover type.
  • the switching request includes a parameter, which is used to indicate whether the switching type of the database is online switching or failover.
  • determining the switching type based on the switching request includes detecting whether the first database is abnormal based on the switching request, and determining that the switching type is a failover if the first database is abnormal, When the first database is normal, it is determined that the switching type is online switching. For example, when a switch request is obtained, it is detected whether the current master node database is abnormal. If the master node database is abnormal, a failover operation is performed. When the master node database is normal, an online switch operation is performed.
  • different switching types may correspond to different switching conditions.
  • a failover may be that the master node database is abnormal, and the success rate of the switch needs to be guaranteed.
  • the switching conditions include the abnormal working state of the first database and the normal working state of the second database.
  • the online switching is a type of switching performed when the master node database is normal.
  • the switching conditions include that the working state of the first database is normal. If it is detected that the working state of the first database is abnormal, the online switching operation is not performed.
  • detecting whether the switching environment satisfies the switching condition includes at least one of the following methods: detecting whether there is a database with abnormal working status, and detecting whether it has access to each database Or verify that the slave database included in the switch request is the slave of the first database.
  • detecting whether a database with abnormal working status includes detecting whether the working status of the first database, that is, the current master node database is abnormal, and whether the working status of each slave node database is abnormal. If the working status of any database is abnormal, the switching conditions are not met.
  • the management server 110 it is detected whether the user has permission to access each database.
  • the slave node database included in the handover request is a slave node of the first database.
  • the configuration information in the handover request may represent the current slave node.
  • the database includes a slave node database 132, a slave node database 133, and other slave node databases, and it is verified that the other slave node databases are not slave nodes of the master node database 131.
  • there is an error in the configuration information passed in the handover request and the error needs to be corrected or the handover is aborted.
  • the master node database is switched from the first database to the first database. Two databases.
  • FIG. 4 schematically illustrates a flowchart of switching a master node database from a first database to a second database in a case where a switching type is an online switching according to an embodiment of the present disclosure. As shown in FIG. 4, the method includes operations S241 to S244.
  • operation S241 the writing process of the first database is prohibited.
  • operation S242 if the data in the second database is consistent with the data in the first database, the current log position of the second database is recorded.
  • operation S243 the second database is set to a read-write mode.
  • operation S244 if the data in the third database is consistent with the data in the first database, the master node database is switched from the first database to the second database based on the current log location.
  • the third database includes other slave node databases except the second database. Switching the master node database from the first database to the second database includes controlling the third database to read data from the second database instead of reading data from the first database.
  • the writing process of the first database is prohibited.
  • the first database may be logged in, a read lock is added to the first database, and a global read-only setting is set.
  • whether the read lock is successfully added can be confirmed through a change in the log position of the first database, and if there is no change in the log position of the first database, it is determined that there is no write operation.
  • a log site of the first database can be recorded.
  • operation S242 for example, when the data in the second database is changed to the log position of the first database recorded in operation S241, it is determined that the data in the second database is consistent with the data in the first database. .
  • the current log position of the second database is recorded, and it is used to make other slave database copy data from the current log position of the second database.
  • operation S243 the second database is set to a read-write mode, so that the second database has the conditions for upgrading to the master node database.
  • operation S243 may be performed after it is determined that the data in the third database is consistent with the data of the first database, so as to avoid the abnormality of the third database in the process of performing log data change, which may cause the switchover complete.
  • operation S244 it may be waiting for the third database to execute to the log location of the first database, execute a CHANGEMASTER statement, switch the master node of the third database to the second database, and start the slave database from the first The current log position of the second database starts the operation of copying log data.
  • the method further includes recording the master-slave replication configuration information stored in the third database.
  • the master-slave complex configuration information stored in the third database is recorded, where the third database is controlled to read data from the second database instead of the first database
  • Reading data includes controlling the third database to read data from the second database based on the master-slave replication configuration information.
  • the method records the replication configuration of the slave node.
  • the configuration information of the slave node includes delayed synchronization, so that after the master node database is switched from the first database to the second database, the replication configuration information of the slave node is maintained. The same, improves the accuracy of data synchronization between the master and slave databases, and at least partially avoids problems such as master or slave data synchronization or failure to synchronize.
  • FIG. 5 schematically illustrates a flowchart of a database switching method according to another embodiment of the present disclosure. As shown in FIG. 5, the method further includes operation S510 on the basis of the foregoing embodiment.
  • operation S510 if an abnormality occurs during the process of switching the primary node database from the first database to the second database, the switching is suspended and a predetermined operation is performed.
  • the switching conditions of the first database, the second database, and the third database can be checked in real time. If an abnormality occurs at any time, Abort the switch and perform the scheduled operation.
  • the predetermined operation may be, for example, sending an error report or displaying a warning.
  • the predetermined operation includes a rollback operation.
  • FIG. 6 schematically illustrates a flowchart of a database switching method according to another embodiment of the present disclosure. As shown in FIG. 6, the method further includes operation S610 on the basis of the foregoing embodiment.
  • a log site of the first database is stored.
  • the predetermined operation includes performing a rollback operation based on the log location of the first database. This method performs a rollback operation when the online switching is abnormal, and undoes the previous switching operation, so that the data from the node database including the second database and the third database continues to be copied from the log location of the first database to ensure that the database of each node is normal. jobs.
  • operation S610 for example, in operation S241, in a case where the write process of the first database is prohibited, the log position of the current master node database, that is, the log position of the first database is recorded.
  • data is copied from the node database including the second database and the third database from the log site of the first database to restore the working state before the switching.
  • FIG. 7 schematically illustrates a flowchart of a database switching method according to another embodiment of the present disclosure. As shown in FIG. 7, the method further includes operations S710 and S720 on the basis of the foregoing embodiments.
  • operation S710 it is detected whether the working states of the plurality of third databases are abnormal, and the third database includes other slave node databases except the second database.
  • operation S720 if the working status of the at least one third database is abnormal, the at least one third database is set as the ignore node.
  • the third database with abnormal working status is set as the ignored node.
  • the log data of the ignored node is not changed, thereby improving the success rate of the master-slave switching.
  • the working state of the third database includes, for example, the process of changing the log data of the third database being stopped, or the third database being down.
  • the ignored node may be, for example, no longer performing a switching operation of the master node database on the node, or no longer performing log data change.
  • detecting whether the switching environment meets a preset condition includes detecting whether an incoming parameter in the switching request is correct.
  • the incoming parameter may be, for example, a current master node database, The slave database etc. detect whether there is a down node, detect whether the access authority is normal, detect whether all the third databases are slave nodes of the current master node, detect whether the replication status of the third database is normal, etc.
  • detecting whether the switching environment meets a preset condition includes detecting whether the working state of the first database is abnormal. According to the embodiment of the present disclosure, if the working state of the first database is normal, the switching environment does not satisfy the preset condition, and if the working state of the first database is abnormal, the switching environment meets the preset condition. According to an embodiment of the present disclosure, in a case where a switching type is a failover and a switching request is generated based on a user input, the detecting whether the switching environment meets a preset condition further includes detecting whether the second database is normal. If the second database is normal, the switching environment meets a preset condition, and if the second database is abnormal, the switching environment does not satisfy the preset condition.
  • FIG. 8 schematically illustrates a flowchart of switching a master node database from a first database to a second database according to another embodiment of the present disclosure. As shown in FIG. 8, the method includes operations S245 to S247.
  • operation S245 it is determined whether there is data missing in the second database.
  • operation S246 if there is no missing data in the second database, the current log location of the second database is recorded, and the working mode of the second database is set to a read-write mode.
  • operation S247 based on the current log location, the master node database is switched from the first database to the second database. Switching the master node database from the first database to the second database includes controlling the third database to read data from the second database instead of reading data from the first database, where the third database includes other than the second database From the node database.
  • This method does not need to wait for the log data in the third database to be the same as the first database, which shortens the switching time and improves the success rate of switching. For example, even if the replication status of the third database is abnormal, the switching operation will not be affected.
  • the semi-synchronization mechanism of MySQL enables at least one slave node to receive all the master node logs.
  • the slave node with the most logs can be found and stored in the list. If the second database is no longer on the list, it appears that the second database has data missing.
  • FIG. 9 schematically illustrates a flowchart of a data switching method according to another embodiment of the present disclosure. As shown in FIG. 9, the method further includes operations S910 to S920 on the basis of the foregoing embodiment.
  • This method can automatically recover the missing data in the second database when there is data missing in the second database, which further improves the success rate of switching.
  • the second database in operation S910, for example, in a case where data is missing in the second database, after waiting for the second database to execute all the logs that have been received, the second database is described with the operation described in operation S245.
  • a database in the list establishes a connection for data replication.
  • the GTID (global transaction identifier) feature of MySQL can be used to obtain log data of the difference between the second database and the fourth database, copy the difference log data to the second database, and complete the second database. Recovery of missing data.
  • operation S246 if there is no missing data in the second database, the current log location of the second database is recorded, and the working mode of the second database is set to read and write. mode.
  • operation S247 it may be waiting for the third database to execute to the log site of the first database, execute a CHANGEMASTER statement, switch the master node of the third database to the second database, and start the slave The current log position of the second database starts the operation of copying log data.
  • the method further includes recording the master-slave replication configuration information stored in the third database.
  • the master-slave complex configuration information stored in the third database is recorded, where the third database is controlled to read data from the second database instead of the first database
  • Reading data includes controlling the third database to read data from the second database based on the master-slave replication configuration information.
  • the method records the replication configuration of the slave node.
  • the configuration information of the slave node includes delayed synchronization, so that after the master node database is switched from the first database to the second database, the replication configuration information of the slave node is maintained. The same, improves the accuracy of data synchronization between the master and slave databases, and at least partially avoids problems such as master or slave data synchronization or failure to synchronize.
  • the database switching method further includes forcibly shutting down the first database process.
  • the first database is forcibly closed.
  • the main database node is switched from the first database to the second database.
  • the process of the first database may be on its own. Recovery. If the business system has established a long connection with the first database, after the first database is restored, the business system still accesses the first database through the long connection. However, at this time, the main database node is already the second database, causing There was a problem accessing the business system.
  • By forcibly closing the process of the first database it can be ensured that after the master-slave switchover is completed, the business system will not access the first database through a long connection.
  • FIG. 10 schematically illustrates a flowchart of a data switching method according to another embodiment of the present disclosure. As shown in FIG. 10, the method further includes operations S1010 to S1020 on the basis of the foregoing embodiment.
  • connection between the service system and the first database is interrupted.
  • operation S1020 when the master node database is switched, the virtual address of the first database is allocated to the second database, and the database accessed by the business system through the virtual address is the second database instead of the first database.
  • the method switches the database access direction by assigning the virtual address of the first database to the second database, which does not require complicated operations and is easy to implement.
  • a long connection between the service system and the first database is interrupted. Disabling the connection between the business system and the first database can ensure that after the master node database is switched from the first database to the second library, the business system accesses the second database instead of accessing the first database through the long connection established before the switch.
  • the management server logs in to the first database, clears information about the virtual IP of the first database, and assigns the virtual IP of the first database to the second database, so that the business system passes The virtual IP can access the second database.
  • the method of switching the access direction of the database is not limited to the method of changing the virtual IP.
  • methods such as domain name resolution change and LVS (Linux Virtual Server) can also be used.
  • the database switching method further includes sending a switching report of switching the master node database from the first database to the second database on the basis of the foregoing embodiments.
  • the switching process is actively performed by the database and the management machine.
  • the database switching process is opaque, and the user does not know which switching was performed. In order to make the switching process clear to the user, it can be sent to the user.
  • the handover report may be in the form of an email or a short message, for example.
  • the database switching method further includes, based on the foregoing embodiments, interacting with the external system through the first interface for switching information, wherein the switching information includes switching the master node database from the first database to the second database. , And / or configuration information required to switch the primary node database from the first database to the second database.
  • the switching process is displayed on the user interface of the external system through the first interface, so that the user can clearly understand the switching process.
  • parameters of an external system can be transmitted to a management server in the database switching system through the first interface, so that the switching of the database no longer depends on the local static configuration file.
  • the management server may log on to each node server by default, and may rely on SSH (Secure Shell). If the external system has implemented other login methods, the login method of the management server to log in to each node server can be modified through the first interface, so as to implement a more convenient and secure remote login function.
  • SSH Secure Shell
  • the progress and status during the switching process are printed as a log in a local file of the switching management server by default.
  • a custom log sending module can also be written through the logging module in Python to send progress and status information. Send to other systems to facilitate the control and display of the overall switching process.
  • the database switching method uses a virtual IP method to switch the access point of the database by default, and through the first interface, it is possible to use other methods to switch the access point of the database.
  • FIG. 11A schematically illustrates a flowchart of an online switching method according to an embodiment of the present disclosure. As shown in FIG. 11A, the method includes operations S1110 to S1150.
  • detecting whether the switching environment meets the switching conditions includes at least one of the following: detecting whether a database with abnormal working status exists; detecting whether the database has permission to access each database; or verifying whether the slave node database included in the switching request is A slave node of the database.
  • the first database prohibits writing.
  • the operation S241 is similar to that described above. For example, you can log in to the first database, add a read lock to the first database, and set global read-only.
  • the second database is provided with the conditions for becoming a master node database. Similar to the operation S243 described above, when the data of the second database is consistent with the data of the first database, the second database is set to the read-write mode.
  • the master node of the third database is changed to the second database. This is similar to operation S244 described above. For example, it can wait for the third database to execute to the log location of the first database, execute the CHANGE MASTER statement, switch the master node of the third database to the second database, and start copying log data from the current log location of the second database. Operation.
  • operation S1150 the database access point is switched. Similar to operations S1010 and S1020 described above, the connection between the service system and the first database is interrupted and the database is switched to the second database.
  • FIG. 11B schematically illustrates an effect of an online switching method according to an embodiment of the present disclosure.
  • FIG. 11B includes the system architecture diagram 1110 before the master node database and the slave node database are switched, and the system architecture diagram 1120 after the master node database and the slave database is switched.
  • the master node database is the first database 1112.
  • the slave node database includes a second database 1113 and a third database.
  • the third database includes slave node databases 1114-1115, and the slave database copies data from the first database 1112 to ensure synchronization with the data of the first database 1112.
  • the read and write requests of the business system access the first database 1112 through the virtual IP 1111.
  • the master node database is switched from the first database 1112 to the second database 1113.
  • the first database 1112 and the third databases 1114-1115 are slave database of the second database 1113, and data is copied from the second database 1113 to ensure synchronization with the data of the second database 1113.
  • the business system accesses the second database 1113 through the virtual IP 1111.
  • FIG. 12A schematically illustrates a flowchart of a failover method according to an embodiment of the present disclosure. As shown in FIG. 12A, the method includes operations S1210 to S1250.
  • detecting whether the switching environment meets a preset condition includes detecting whether an incoming parameter in the switching request is correct.
  • the incoming parameter may be, for example, a current master node database, The slave database etc. detect whether there is a down node, detect whether the access authority is normal, detect whether all the third databases are slave nodes of the current master node, detect whether the replication status of the third database is normal, etc.
  • the first database process is forcibly stopped.
  • the business system has established a long connection with the first database.
  • the process of the first database may recover by itself.
  • the business The system still accesses the first database through the long connection.
  • the primary database node is already the second database, which causes problems in accessing the business system.
  • the second database is provided with the conditions to become a master node database.
  • the operations S245 to S246 described above are performed to determine whether there is missing data in the second database, and if there is no missing data in the second database, record the current log position of the second database, and The working mode of the second database is set to a read-write mode.
  • the master node of the third database is changed to the second database. Similar to the operation S247 described above, the master node database is switched from the first database to the second database based on the current log location.
  • the switching of the database is similar to the operations S1010 and S1020 described above, the connection between the service system and the first database is interrupted, and the database is switched to the second database.
  • FIG. 12B schematically illustrates an effect of a failover method according to an embodiment of the present disclosure.
  • FIG. 12B includes a system architecture diagram 1110 before the master node database and a slave node database are switched, and a system architecture diagram 1220 after the master node database and the slave node database are switched.
  • the master node database is the first database 1112.
  • the slave node database includes a second database 1113 and a third database.
  • the third database includes slave node databases 1114-1115, and the slave database copies data from the first database 1112 to ensure synchronization with the data of the first database 1112.
  • the read and write requests of the business system access the first database 1112 through the virtual IP 1111.
  • the master node database is switched from the first database 1112 to the second database 1113.
  • the third database 1114-1115 is a slave node database of the second database 1113, and data is copied from the second database 1113 to ensure synchronization with the data of the second database 1113.
  • the business system accesses the second database 1113 through the virtual IP 1111.
  • FIG. 13 schematically illustrates a block diagram of a database switching system 1300 according to an embodiment of the present disclosure.
  • the database switching system 1300 includes an obtaining module 1310, a determining module 1320, a first detecting module 1330, and a switching module 1340.
  • the obtaining module 1310 performs the operation S210 described above with reference to FIG. 2 to obtain a handover request, and the handover request is used to switch the master node database from the first database to the second database.
  • the determining module 1320 performs operation S220 described above with reference to FIG. 2 for determining a switching type based on the switching request.
  • the first detection module 1330 for example, performs operation S230 described above with reference to FIG. 2, and is configured to detect whether a switching environment meets a switching condition based on a switching type.
  • the switching module 1340 for example, performs the operation S240 described above with reference to FIG. 2, and is configured to switch the master node database from the first database to the second database if the switching environment meets the switching conditions.
  • the obtaining module 1310 includes a first generating sub-module for generating a switching request based on user input, or a second generating sub-module for generating in the event that an exception occurs in the first database as the master node database. Switch request.
  • the determining module 1320 includes at least one of the following.
  • a first determining submodule is configured to read a parameter representing a switching type from a switching request to determine a switching type, or a second determining submodule is configured to: Based on the switching request, it is detected whether the first database is abnormal. In the case where the first database is abnormal, it is determined that the switching type is failover, and when the first database is normal, it is determined that the switching type is online switching.
  • the first detection module 1330 includes at least one of the following: a first detection submodule for detecting whether a database having an abnormal working state exists; and a second detection submodule , Used to detect whether the user has the authority to access each database, or a verification submodule, used to verify whether the slave node database included in the switch request is a slave node of the first database.
  • the second generation sub-module may include an acquisition unit, a determination unit, and a generation unit.
  • the obtaining unit performs, for example, operation S310 described above with reference to FIG. 3, for obtaining the states of the multiple slave node databases.
  • the determining unit performs, for example, operation S320 described above with reference to FIG. 3, and is configured to determine one slave node database as the second database based on the states of multiple slave node databases.
  • the generating unit performs, for example, operation S330 described above with reference to FIG. 3, for generating a switching request to switch the master node database from the first database to the second database.
  • the database switching system may further include an interruption module on the basis of the foregoing embodiments.
  • the interruption module for example, performs operation S510 described above with reference to FIG. 5, and is used to terminate the switchover and perform a predetermined operation if an abnormality occurs during the process of switching the master node database from the first database to the second database.
  • the database switching system may further include a storage module on the basis of the foregoing embodiments.
  • the interruption module may include a rollback submodule.
  • the storage module performs, for example, the operation S610 described above with reference to FIG. 6 for storing the log site of the first database.
  • the rollback submodule is used to perform a rollback operation based on the log location of the first database.
  • the switching module may include a prohibition submodule, a recording submodule, a setting submodule, and a first switching submodule, wherein the first switching submodule may include a switching unit 1710.
  • the prohibition submodule performs, for example, operation S241 described above with reference to FIG. 4, and is used to inhibit the write process of the first database.
  • the recording submodule performs, for example, operation S242 described above with reference to FIG. 4, and is configured to record the current log position of the second database if the data in the second database is consistent with the data in the first database.
  • the setting submodule performs, for example, operation S243 described above with reference to FIG. 4 for setting the second database to a read-write mode.
  • the first switching submodule performs, for example, operation S244 described above with reference to FIG. 4, and is used to remove the master node database from the first database based on the current log location if the data in the third database is consistent with the data in the first database.
  • the database is switched to a second database, where the third database includes other slave node databases besides the second database.
  • the switching unit is configured to control the third database to read data from the second database, instead of reading data from the first database.
  • the first detection module 1330 includes a third detection sub-module for detecting whether the working state of the first database is abnormal.
  • the database switching system may include a second detection module and a setting module.
  • the second detection module performs, for example, the operation S710 described above with reference to FIG. 7, and is configured to detect whether the working statuses of the plurality of third databases are abnormal, and the third database includes other slave node databases besides the second database.
  • the setting module performs, for example, the operation S720 described above with reference to FIG. 7, and is configured to set the at least one third database as an ignored node in a case where the working status of the at least one third database is abnormal.
  • the first detection module further includes a fourth detection sub-module for detecting whether the working state of the second database is normal.
  • the switching module may include a judgment submodule, an execution submodule, and a second switching submodule, wherein the second switching submodule may include a switching unit.
  • the judging submodule performs, for example, operation S245 described above with reference to FIG. 8, and is used for judging whether there is missing data in the second database.
  • the execution submodule performs, for example, the operation S246 described above with reference to FIG. 8, and is used to record the current log position of the second database and set the working mode of the second database to read if there is no missing data in the second database Write mode.
  • the second switching submodule 1343 performs, for example, operation S247 described above with reference to FIG. 8, and is configured to switch the master node database from the first database to the second database based on the current log location.
  • the switching unit is configured to control the third database to read data from the second database, instead of reading data from the first database.
  • the third database includes other slave node databases except the second database.
  • the database switching system further includes a recording module on the basis of the foregoing embodiment, and is configured to record the master-slave configuration information stored in the third database.
  • the switching unit includes a switching sub-unit for controlling the third database to read data from the second database based on the master-slave configuration information.
  • the switching system may further include a connection module and a recovery module on the basis of the foregoing embodiments.
  • the connection module performs, for example, the operation S910 described above with reference to FIG. 9, and is used to establish a data replication connection between the second database and the fourth database in which data is absent when the second database is missing data.
  • the recovery module for example, performs operation S920 described above with reference to FIG. 9 for recovering the missing data of the second database based on the fourth database.
  • the database switching system may further include a sending module on the basis of the foregoing embodiments.
  • the sending module is configured to send a switching report of switching the master node database from the first database to the second database.
  • the switching process is actively performed by the database and the management machine.
  • the database switching process is opaque, and the user does not know which switching was performed. In order to make the switching process clear to the user, it can be sent to the user.
  • the handover report may be in the form of an email or a short message, for example.
  • the database switching system further includes an interaction module on the basis of the foregoing embodiments, and is configured to interact with an external system through a first interface, wherein the switching information includes removing a master node database from the first database. The result of switching to the second database, and / or configuration information required to switch the master node database from the first database to the second database.
  • the database switching system may further include an interruption module and an allocation module on the basis of the foregoing embodiments.
  • the interruption module performs, for example, operation S1010 described above with reference to FIG. 10, for interrupting the connection between the service system and the first database.
  • the allocation module performs, for example, the operation S1020 described above with reference to FIG. 10, and is used to allocate the virtual address of the first database to the second database when the master node database is switched, and is used to make the business system access the database through the virtual address. Is the second database, not the first database.
  • At least some of the modules, sub-modules, units, sub-units, or at least a part of any of the functions according to the embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present disclosure may be implemented by being split into multiple modules.
  • any one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present disclosure may be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), System-on-chip, system-on-substrate, system-on-package, application-specific integrated circuit (ASIC), or any other reasonable means of hardware or firmware that can integrate or package the circuit, or software, hardware, and firmware Any one of the implementation manners or an appropriate combination of any of them may be implemented.
  • FPGA field programmable gate array
  • PLA programmable logic array
  • ASIC application-specific integrated circuit
  • any one of the implementation manners or an appropriate combination of any of them may be implemented.
  • one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present disclosure may be at least partially implemented as computer program modules, and when the computer program modules are executed, corresponding functions may be performed.
  • any number of the acquisition module 1310, the determination module 1320, the first detection module 1330, and the switching module 1340 may be combined into one module, or any one of the modules may be split into multiple modules.
  • at least part of the functions of one or more of these modules may be combined with at least part of the functions of other modules and implemented in one module.
  • At least one of the acquisition module 1310, the determination module 1320, the first detection module 1330, and the switching module 1340 may be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable Logic array (PLA), system on chip, system on substrate, system on package, application specific integrated circuit (ASIC), or hardware or firmware that can be implemented by any other reasonable means of integrating or packaging the circuit, or Any one of the three implementations of software, hardware, and firmware or an appropriate combination of any of them.
  • FPGA field programmable gate array
  • PDA programmable Logic array
  • ASIC application specific integrated circuit
  • at least one of the acquisition module 1310, the determination module 1320, the first detection module 1330, and the switching module 1340 may be at least partially implemented as a computer program module, and when the computer program module is executed, it may perform a corresponding function.
  • FIG. 14 schematically illustrates a block diagram of an electronic device 1400 according to an embodiment of the present disclosure.
  • the electronic device shown in FIG. 14 is only an example, and should not impose any limitation on the functions and use ranges of the embodiments of the present disclosure.
  • an electronic device 1400 includes a processor 1401 that can be loaded into a random access memory (RAM) 1403 according to a program stored in a read-only memory (ROM) 1402 or from a storage portion 1408.
  • the program performs various appropriate actions and processes.
  • the processor 1401 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (such as an application-specific integrated circuit (ASIC)), and so on.
  • the processor 1401 may also include on-board memory for cache use.
  • the processor 1401 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.
  • the processors 1401, ROM 1402, and RAM 1403 are connected to each other through a bus 1404.
  • the processor 1401 executes various operations of the method flow according to the embodiment of the present disclosure by executing programs in the ROM 1402 and / or the RAM 1403. It should be noted that the program may also be stored in one or more memories other than the ROM 1402 and the RAM 1403.
  • the processor 1401 may also execute various operations of the method flow according to the embodiment of the present disclosure by executing a program stored in the one or more memories.
  • the electronic device 1400 may further include an input / output (I / O) interface 1405, and the input / output (I / O) interface 1405 is also connected to the bus 1404.
  • the electronic device 1400 may further include one or more of the following components connected to the I / O interface 1405: an input portion 1406 including a keyboard, a mouse, and the like; including, such as a cathode ray tube (CRT), a liquid crystal display (LCD), and the like; and An output portion 1407 of a speaker or the like; a storage portion 1408 including a hard disk or the like; and a communication portion 1409 including a network interface card such as a LAN card, a modem, or the like.
  • the communication section 1409 performs communication processing via a network such as the Internet.
  • the driver 1410 is also connected to the I / O interface 1405 as needed.
  • a removable medium 1411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1410 as needed, so that a computer program read therefrom is installed into the storage section 1408 as needed.
  • the method flow according to the embodiment of the present disclosure may be implemented as a computer software program.
  • embodiments of the present disclosure include a computer program product including a computer program carried on a computer-readable medium, the computer program containing program code for performing a method shown in a flowchart.
  • the computer program may be downloaded and installed from a network through the communication section 1409, and / or installed from a removable medium 1411.
  • the processor 1401 When the computer program is executed by the processor 1401, the above functions defined in the system of the embodiment of the present disclosure are executed.
  • the systems, devices, devices, modules, units, and the like described above may be implemented by computer program modules.
  • the present disclosure also provides a computer-readable medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist alone without being assembled into the device / apparatus / System.
  • the computer-readable medium described above carries one or more programs, and when the one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
  • the computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium or any combination of the foregoing.
  • the computer-readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable Programming read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in combination with an instruction execution system, apparatus, or device.
  • a computer-readable signal medium may include a data signal that is included in baseband or propagated as part of a carrier wave, and which carries computer-readable program code. Such a propagated data signal may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device .
  • the program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, optical fiber cable, radio frequency signals, etc., or any suitable combination of the foregoing.
  • the computer-readable medium may include one or more memories other than the ROM 1402 and / or the RAM 1403 and / or the ROM 1402 and the RAM 1403 described above.
  • each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, which contains one or more of the logic functions used to implement the specified logic.
  • Executable instructions may also occur in a different order than those marked in the drawings. For example, two successively represented boxes may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved.
  • each block in the block diagram or flowchart, and combinations of blocks in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with A combination of dedicated hardware and computer instructions.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本公开提供了一种数据库切换方法,包括获取切换请求,所述切换请求用于将主节点数据库从第一数据库切换为第二数据库,基于所述切换请求,确定切换类型,基于所述切换类型,检测切换环境是否满足切换条件,以及在所述切换环境满足所述切换条件的情况下,将主节点数据库从所述第一数据库切换为所述第二数据库。本公开还提供了一种数据库切换系统、一种电子设备以及一种计算机可读介质。

Description

数据库切换方法、系统、电子设备和计算机可读介质 技术领域
本公开涉及互联网技术领域,更具体地,涉及一种数据库切换方法、系统、电子设备和计算机可读介质。
背景技术
数据库的高可用已经成为了信息化建设的重中之重。在现有技术中,通常将数据库的主从复制技术与高可用切换方案相结合来提高数据库的可用性。例如,在主节点数据库宕机或者对系统的硬件维护、版本升级等情况下,利用高可用切换方案将当前的主节点数据库切换成从节点数据库,并将某个从节点数据库切换成主节点数据库,以保证数据库的高可用。
在实现本公开构思的过程中,发明人发现现有技术中至少存在如下问题:现有的主节点数据库与从节点数据库的切换容易出现切换中断,成功率较低。
发明内容
有鉴于此,本公开提供了一种数据库切换方法、系统、电子设备和计算机可读介质。
本公开的一个方面提供了一种数据库切换方法包括,获取切换请求,切换请求用于将主节点数据库从第一数据库切换为第二数据库,基于切换请求,确定切换类型,基于切换类型,检测切换环境是否满足切换条件,以及在切换环境满足切换条件的情况下,将主节点数据库从第一数据库切换为第二数据库。
本公开的另一个方面提供了一种数据库切换系统包括,获取模块用于获取切换请求,切换请求用于将主节点数据库从第一数据库切换为第二数据库,确定模块用于基于切换请求,确定切换类型,第一检测模块用于基于切换类型,检测切换环境是否满足切换条件,以及切换模块用于在切换环境满足切换条件的情况下, 将主节点数据库从第一数据库切换为第二数据库。
本公开的另一个方面提供了一种电子设备,包括一个或多个处理器,存储装置,用于存储一个或多个程序,其中,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器执行上述任意一项的方法。
本公开的另一方面提供了一种非易失性存储介质,存储有计算机可执行指令,所述指令在被执行时用于实现如上所述的方法。
本公开的另一方面提供了一种计算机程序,所述计算机程序包括计算机可执行指令,所述指令在被执行时用于实现如上所述的方法。
根据本公开的实施例,可以至少部分地解决主节点数据库与从节点数据库的切换容易出现切换中断,成功率较低的问题,并因此可以实现提高主从切换成功率的技术效果。
附图说明
通过以下参照附图对本公开实施例的描述,本公开的上述以及其他目的、特征和优点将更为清楚,在附图中:
图1示意性示出了根据本公开实施例的可以应用数据库切换方法的示例性系统架构;
图2示意性示出了根据本公开的实施例的数据库切换方法的流程图;
图3示意性示出了根据本公开的实施例的在第一数据库作为主节点数据库发生异常的情况下,生成切换请求的流程图;
图4示意性示出了根据本公开的实施例的切换类型为在线切换的情况下,将主节点数据库从第一数据库切换为第二数据库的流程图;
图5示意性示出了根据本公开的另一实施例的数据库切换方法的流程图;
图6示意性示出了根据本公开的另一实施例的数据库切换方法的流程图;
图7示意性示出了根据本公开的另一实施例的数据库切换方法的流程图;
图8示意性示出了根据本公开的另一实施例的将主节点数据库从第一数据库切换为第二数据库的流程图;
图9示意性示出了根据本公开的另一实施例的数据切换方法的流程图;
图10示意性示出了根据本公开的另一实施例的数据切换方法的流程图;
图11A示意性示出了根据本公开的实施例的在线切换方法的流程图;
图11B示意性示出了根据本公开的实施例的在线切换方法的效果示意图;
图12A示意性示出了根据本公开的实施例的故障切换方法的流程图;
图12B示意性示出了根据本公开的实施例的故障切换方法的效果示意图;
图13示意性示出了根据本公开的实施例的数据库切换系统的框图;以及
图14示意性示出了根据本公开实施例的电子设备的方框图。
具体实施方式
以下,将参照附图来描述本公开的实施例。但是应该理解,这些描述只是示例性的,而并非要限制本公开的范围。在下面的详细描述中,为便于解释,阐述了许多具体的细节以提供对本公开实施例的全面理解。然而,明显地,一个或多个实施例在没有这些具体细节的情况下也可以被实施。此外,在以下说明中,省略了对公知结构和技术的描述,以避免不必要地混淆本公开的概念。
在此使用的术语仅仅是为了描述具体实施例,而并非意在限制本公开。在此使用的术语“包括”、“包含”等表明了所述特征、步骤、操作和/或部件的存在,但是并不排除存在或添加一个或多个其他特征、步骤、操作或部件。
在此使用的所有术语(包括技术和科学术语)具有本领域技术人员通常所理解的含义,除非另外定义。应注意,这里使用的术语应解释为具有与本说明书的上下文相一致的含义,而不应以理想化或过于刻板的方式来解释。
在使用类似于“A、B和C等中至少一个”这样的表述的情况下,一般来说应该按照本领域技术人员通常理解该表述的含义来予以解释(例如,“具有A、B和C中至少一个的系统”应包括但不限于单独具有A、单独具有B、单独具有C、具有A和B、具有A和C、具有B和C、和/或具有A、B、C的系统等)。在使用类似于“A、B或C等中至少一个”这样的表述的情况下,一般来说应该按照本领域技术人员通常理解该表述的含义来予以解释(例如,“具有A、B或C中至少一个的系统”应包括但不限于单独具有A、单独具有B、单独具有C、具有A和B、具有A和C、具有B和C、和/或具有A、B、C的系统等)。
本公开的实施例提供了一种数据库切换方法包括,获取切换请求,切换请求用于将主节点数据库从第一数据库切换为第二数据库,基于切换请求,确定切换 类型,基于切换类型,检测切换环境是否满足切换条件,以及在切换环境满足切换条件的情况下,将主节点数据库从第一数据库切换为第二数据库。
图1示意性示出了根据本公开实施例的可以应用数据库切换方法的示例性系统架构100。需要注意的是,图1所示仅为可以应用本公开实施例的系统架构的示例,以帮助本领域技术人员理解本公开的技术内容,但并不意味着本公开实施例不可以用于其他设备、系统、环境或场景。
如图1所示,根据该实施例的系统架构100可以包括服务器110,业务系统120以及数据库系统130,其中,数据库系统130可以包括主节点数据库131、从节点数据库132和133。从节点数据库132和133可以从主节点数据库131中复制数据,保证与主节点数据库131的数据一致。数据库系统130例如可以是MySQL数据库。
服务器110可以是管理服务器,用于管理数据库系统130。例如,监控数据库系统130中的主节点数据库131以及从节点数据库132和133的工作状态,或者控制数据库系统130的主从切换操作等。业务系统120可以访问主节点数据库131中存储的数据,也可以将日志存储在主节点数据库131中。
在主节点数据库131的工作状态异常或者管理员对系统硬件维护、版本升级的情况下,可以将数据库系统130的主节点数据库由服务器131切换成某一从节点数据库,以维持业务系统120的正常运行。
然而,在现有技术中,主节点数据库与从节点数据库的切换容易出现切换中断,切换成功率较低。
需要说明的是,本公开实施例所提供的数据库切换方法一般可以由服务器110执行。相应地,本公开实施例所提供的数据库切换系统一般可以设置于服务器110中。应该理解,图1中的主节点数据库和从节点数据库的数目仅仅是示意性的。根据实现需要,可以具有任意数目的主节点数据库和从节点数据库。
图2示意性示出了根据本公开的实施例的数据库切换方法的流程图。如图2所示,该方法可以包括操作S210~S240。
在操作S210,获取切换请求,切换请求用于将主节点数据库从第一数据库切换为第二数据库。在操作S220,基于切换请求,确定切换类型。在操作S230,基于切换类型,检测切换环境是否满足切换条件。在操作S240,在切换环境满足 切换条件的情况下,将主节点数据库从第一数据库切换为第二数据库。
该方法在执行主节点数据库从第一数据库切换为第二数据库之前,会检测切换环境是否满足切换条件,只有在满足切换条件的情况下,才会执主从数据库的切换,至少部分地避免了在执行主从切换的过程中出现异常,导致切换的中断的情况,进而提高了主从数据库切换的成功率。
根据本公开的实施例,在操作S210,获取切换请求包括基于用户输入生成切换请求。例如,主节点数据库正常工作,而用户需要对数据库的硬件进行维护的情况下,用户通过客户端主动发出主从数据库切换的请求。根据本公开的实施例,获取切换请求包括在第一数据库作为主节点数据库发生异常的情况下,生成切换请求。例如,监控主节点数据库的电子设备发现主节点数据库宕机或者进程停止,从而生成了主从切换请求。
图3示意性示出了根据本公开的实施例的在第一数据库作为主节点数据库发生异常的情况下,生成切换请求的流程图。如图3所示,该方法包括操作S310~S330。
在操作S310,获得多个从节点数据库的状态。在操作S320,基于多个从节点数据库的状态,确定一个从节点数据库为第二数据库。在操作S330,生成用于将主节点数据库从第一数据库切换为第二数据库的切换请求。
根据本公开的实施例,在操作S310,从节点数据库的状态例如可以是从节点数据库中的日志数据与主节点数据库中的日志数据的一致程度。在图1所示的情景中,例如,从节点数据库132与主节点数据库131中的日志数据一致,而从节点数据库133中的日志数据缺少主节点数据库131中的部分日志数据。
根据本公开的实施例,在操作S320,例如可以将含有最新日志数据的从节点数据库作为第二数据库,或者可以将含有日志数据最多的从节点数据库作为第二数据库。例如,在操作S310描述的图1的情景中,可以将从节点数据库132作为第二数据库。根据本公开的实施例,在操作S330,例如,生成指定从节点数据库132为第二数据库的切换请求。
返回参考图2,根据本公开的实施例,在操作S220,数据库切换类型例如可以包括在线切换和故障切换。在线切换,例如可以是在主节点数据库工作状态正常的情况下,用户通过客户端主动发出数据库切换的请求时执行的切换。故障切换,例如可以是主节点数据库工作状态异常时执行的切换。基于所述切换请求, 确定切换类型包括从所述切换请求中读取表征切换类型的参数,以确定切换类型。例如,切换请求中包括一参数,该参数用于指示数据库的切换类型是在线切换或者故障切换。根据本公开的实施例,基于所述切换请求,确定切换类型包括基于所述切换请求,检测所述第一数据库是否异常,在所述第一数据库异常的情况下,确定切换类型是故障切换,在所述第一数据库正常的情况下,确定切换类型是在线切换。例如,在获取到切换请求的情况下,检测当前的主节点数据库是否异常,若主节点数据库异常,执行故障切换的操作,在主节点数据库正常的情况下,执行在线切换的操作。
根据本公开的实施例,在操作S230,不同的切换类型可以对应不同的切换条件。例如,故障切换可以是主节点数据库出现异常,需要保证切换的成功率,为了提高切换的成功率,切换条件包括第一数据库工作状态异常,第二数据库的工作状态正常。而在线切换是主节点数据库正常的情况下执行的切换类型,切换条件包括第一数据库的工作状态正常,若检测到第一数据库的工作状态不正常,则不执行在线切换的操作。
根据本公开的实施例,在操作S230,在切换类型为在线切换的情况下,检测切换环境是否满足切换条件包括以下至少一种检测是否存在工作状态异常的数据库,检测是否具备访问各个数据库的权限,或者验证切换请求中包括的从节点数据库是否是第一数据库的从节点。
根据本公开的实施例,检测是否存在工作状态异常的数据库包括检测第一数据库即当前主节点数据库工作状态是否异常,以及各个从节点数据库工作状态是否异常。若任何一个数据库的工作状态出现异常,则不满足切换条件。
根据本公开的实施例,检测是否具备访问各个数据库的权限,在图1所示的情景中,例如可以是检测管理服务器110是否具有访问、登陆主节点数据库131以及从节点数据库132和133的权限。
根据本公开的实施例,验证切换请求中包括的从节点数据库是否是所述第一数据库的从节点,在图1所示的情景中,例如可以是切换请求中的配置信息表征当前的从节点数据库包括从节点数据库132、从节点数据库133以及其他从节点数据库,而验证出其他从节点数据库不是主节点数据库131的从节点。在该情景中,切换请求中传入的配置信息出现错误,需要将该错误进行修正,或者中止本 次切换。
在切换类型为在线切换的情况下,根据本公开的实施例,在操作S240,在所述切换环境满足所述切换条件的情况下,将主节点数据库从所述第一数据库切换为所述第二数据库。
图4示意性示出了根据本公开的实施例的切换类型为在线切换的情况下,将主节点数据库从第一数据库切换为第二数据库的流程图。如图4所示,该方法包括操作S241~S244。
在操作S241,禁止第一数据库的写入进程。在操作S242,在第二数据库中的数据与第一数据库的数据一致的情况下,记录第二数据库的当前日志位点。在操作S243,将第二数据库设置为读写模式。在操作S244,在第三数据库中的数据与第一数据库的数据一致的情况下,基于当前日志位点,将主节点数据库从第一数据库切换为第二数据库。其中,第三数据库包括除第二数据库以外的其他从节点数据库。将主节点数据库从第一数据库切换为第二数据库包括控制第三数据库从第二数据库读取数据,而非从第一数据库读取数据。
根据本公开的实施例,在操作S241,禁止第一数据库的写入进程,例如可以是登录第一数据库,对第一数据库加读锁,设置全局只读。根据本公开的实施例,例如可以通过第一数据库的日志位点的变化情况来确认是否加读锁成功,若第一数据库的日志位点未出现变化,则确定没有了写入操作。根据本公开的实施例,可以记录下第一数据库的日志位点。
根据本公开的实施例,在操作S242,例如可以是第二数据库中的数据变更到在操作S241记录的第一数据库的日志位点时,确定第二数据库中的数据与第一数据库的数据一致。根据本公开的实施例,记录第二数据库的当前日志位点,用于使其他从节点数据库从第二数据库的当前日志位点开始复制数据。
根据本公开的实施例,在操作S243,将第二数据库设置为读写模式,使第二数据库具备升级为主节点数据库的条件。根据本公开的实施例,操作S243可以是在确定第三数据库中的数据与所述第一数据库的数据一致后执行,以避免第三数据库在执行日志数据变更的过程中出现异常而导致切换不完整。
根据本公开的实施例,在操作S244,例如可以是等待第三数据库执行到第一数据库的日志位点,执行CHANGE MASTER语句,将第三数据库的主节点切换 到第二数据库,并启动从第二数据库的当前日志位点开始复制日志数据的操作。
根据本公开的实施例,在操作S244,还包括记录第三数据库存储的主从复制配置信息。在第三数据库中的数据与第一数据库的数据一致的情况下,记录第三数据库存储的主从复杂配置信息,其中,控制第三数据库从第二数据库读取数据,而非从第一数据库读取数据包括,基于主从复制配置信息,控制第三数据库从第二数据库读取数据。该方法在切换的过程中,记录从节点的复制配置,例如该从节点的配置信息包括延时同步,使得将主节点数据库从第一数据库切换到第二数据库后,从节点的复制配置信息保持不变,提高了主从数据库数据同步的准确性,至少部分地避免了主从数据同步出现问题,或者无法同步等情况。
图5示意性示出了根据本公开的另一实施例的数据库切换方法的流程图。如图5所示,该方法在前述实施例的基础上还包括操作S510。
在操作S510,若在将主节点数据库从第一数据库切换为第二数据库的过程中出现异常,则中止切换并执行预定操作。
根据本公开的实施例,在操作S510,在执行在线切换的过程中,可以实时对第一数据库、第二数据库以及第三数据库的工作状态等切换环境进行检查,若在任何时候出现异常,则中止切换并执行预定操作。预定操作例如可以是发送错误报告或者显示警告等。根据本公开的实施例,预定操作包括回滚操作。
图6示意性示出了根据本公开的另一实施例的数据库切换方法的流程图。如图6所示,该方法在前述实施例的基础上还包括操作S610。
在操作S610,存储第一数据库的日志位点。其中,预定操作包括基于第一数据库的日志位点,执行回滚操作。该方法在在线切换出现异常时,执行回滚操作,撤销之前的切换操作,使得从节点数据库包括第二数据库以及第三数据库从第一数据库的日志位点继续复制数据,以保证各个节点数据库正常工作。
根据本公开的实施例,在操作S610,例如在操作S241,在禁止第一数据库的写入进程的情况下,记录当前主节点数据库的日志位点即第一数据库的日志位点。在切换过程出现异常的情况下,从节点数据库包括第二数据库和第三数据库从第一数据库的日志位点开始复制数据,恢复切换之前的工作状态。
图7示意性示出了根据本公开的另一实施例的数据库切换方法的流程图。如图7所示,该方法在前述实施例的基础上还包括操作S710和操作S720。
在操作S710,检测多个第三数据库的工作状态是否异常,第三数据库包括除第二数据库以外的其他从节点数据库。在操作S720,在至少一个第三数据库的工作状态异常的情况下,将至少一个第三数据库设为忽略节点。
该方法将工作状态异常的第三数据库设为忽略节点,在主从切换的过程中,不对忽略节点进行日志数据的变更,进而提高主从切换的成功率。
根据本公开的实施例,在操作S710,第三数据库的工作状态例如包括第三数据库日志数据变更进程停止,或者第三数据库宕机等。在操作S720,忽略节点例如可以是不再对该节点进行主节点数据库的切换操作,或者不再执行日志数据变更。
根据本公开的实施例,在切换类型为故障切换的情况下,检测切换环境是否满足预设条件包括,检测切换请求中的传入参数是否正确,传入参数例如可以是当前的主节点数据库,从节点数据库等,检测是否存在宕机节点,检测访问权限是否正常,检测所有第三数据库是否都是当前主节点的从节点,检测第三数据库的复制状态是否正常等。
根据本公开的实施例,在切换类型为故障切换的情况下,检测切换环境是否满足预设条件包括,检测所述第一数据库工作状态是否异常。根据本公开的实施例,若第一数据库的工作状态正常,切换环境不满足预设条件,若第一数据库的工作状态异常,切换环境满足预设条件。根据本公开的实施例,切换类型为故障切换,并且基于用户输入生成切换请求的情况下,所述检测切换环境是否满足预设条件还包括检测所述第二数据库是否正常。若第二数据库正常,切换环境满足预设条件,若第二数据库异常,切换环境不满足预设条件。
图8示意性示出了根据本公开的另一实施例的将主节点数据库从第一数据库切换为第二数据库的流程图。如图8所示,该方法包括操作S245~S247。
在操作S245,判断第二数据库是否存在数据缺失。在操作S246,在第二数据库不存在数据缺失的情况下,记录第二数据库的当前日志位点,并将第二数据库的工作模式设置为读写模式。在操作S247,基于当前日志位点,将主节点数据库从第一数据库切换为第二数据库。将主节点数据库从第一数据库切换为第二数据库包括,控制第三数据库从第二数据库读取数据,而非从第一数据库读取数据,其中,第三数据库包括除第二数据库以外的其他从节点数据库。
该方法不需要等待第三数据库与第一数据库中的日志数据相同,缩短了切换时间,提高了切换的成功率。例如,即使第三数据库的复制状态出现异常,也不会影响切换操作。
根据本公开的实施例,在复制状态正常的情况下,MySQL的半同步机制,使得至少有一个从节点接收了所有的主节点日志。在操作S245,例如可以是根据接收到的日志信息,找到日志最全的从节点并存储在列表中,如果第二数据库不再列表上,表面第二数据库存在数据缺失。
图9示意性示出了根据本公开的另一实施例的数据切换方法的流程图。如图9所示,该方法在前述实施例的基础上还包括操作S910~S920。
在操作S910,在第二数据库存在数据缺失的情况下,第二数据库与不存在数据缺失的第四数据库的建立数据复制的连接。在操作S920,基于第四数据库,恢复第二数据库的缺失数据。
该方法在第二数据库存在数据缺失的情况下,能够自动恢复第二数据库的缺失数据,进一步提高了切换的成功率。
根据本公开的实施例,在操作S910,例如,在所述第二数据库存在数据缺失的情况下,等待第二数据库执行完已经接收的所有日志后,将第二数据库与在操作S245中所述的列表中的一个数据库建立数据复制的连接。在操作S920,例如可以是利用MySQL的GTID(global transacition identifiers,全局事务标志)特性,获取第二数据库与第四数据库差异的日志数据,将差异日志数据复制到第二数据库中,完成第二数据库缺失数据的恢复。
返回参考图8,根据本公开的实施例,在操作S246,在第二数据库不存在数据缺失的情况下,记录第二数据库的当前日志位点,并将第二数据库的工作模式设置为读写模式。
根据本公开的实施例,在操作S247,例如可以是等待第三数据库执行到第一数据库的日志位点,执行CHANGE MASTER语句,将第三数据库的主节点切换到第二数据库,并启动从第二数据库的当前日志位点开始复制日志数据的操作。
根据本公开的实施例,在操作S247,还包括记录第三数据库存储的主从复制配置信息。在第三数据库中的数据与第一数据库的数据一致的情况下,记录第三数据库存储的主从复杂配置信息,其中,控制第三数据库从第二数据库读取数据, 而非从第一数据库读取数据包括,基于主从复制配置信息,控制第三数据库从第二数据库读取数据。该方法在切换的过程中,记录从节点的复制配置,例如该从节点的配置信息包括延时同步,使得将主节点数据库从第一数据库切换到第二数据库后,从节点的复制配置信息保持不变,提高了主从数据库数据同步的准确性,至少部分地避免了主从数据同步出现问题,或者无法同步等情况。
根据本公开的实施例,在进行故障切换的过程中,数据库切换方法还包括强制关闭第一数据库进程。在检测切换环境满足预设条件之后,强制关闭第一数据库。例如,第一数据库的服务器虽然没有宕机,但是第一数据库的进程停止,此时,将主数据库节点从第一数据库切换至第二数据库,在一段时间之后,第一数据库的进程可能会自行恢复,若业务系统与第一数据库已经建立了长连接,在第一数据库的进行恢复后,业务系统依然通过该长连接访问第一数据库,然而此时,主数据库节点已经是第二数据库,造成业务系统的访问出现问题。通过强制关闭第一数据库的进程,能够保证在主从切换完成后,业务系统不会通过长连接访问到第一数据库。
图10示意性示出了根据本公开的另一实施例的数据切换方法的流程图。如图10所示,该方法在前述实施例的基础上还包括操作S1010~S1020。
在操作S1010,中断业务系统与第一数据库的连接。在操作S1020,在主节点数据库切换完成的情况下,将第一数据库的虚拟地址分配给第二数据库,用于使业务系统通过虚拟地址访问的数据库为第二数据库,而非第一数据库。
该方法通过将第一数据库的虚拟地址分配给第二数据库来切换数据库访问指向,不需要复杂的操作,易于实现。
根据本公开的实施例,在操作S1010,例如中断业务系统与第一数据库的长连接。中断业务系统与第一数据库的连接能够保证在将主节点数据库从第一数据库切换到第二书库之后,业务系统访问第二数据库,而不是通过切换之前建立的长连接依然访问到第一数据库。
根据本公开的实施例,在操作S1020,例如,管理服务器登录到第一数据库,清除第一数据库的虚拟IP的相关信息,并将第一数据库的虚拟IP分配给第二数据库,使得业务系统通过该虚拟IP即可访问到第二数据库。
根据本公开的实施例,切换数据库的访问指向的方法不限于变更虚拟IP的方 法。例如,还可以是域名解析变更、LVS(Linux Virtual Server,Linux虚拟服务器)等方法。
根据本公开的实施例,数据库切换方法在前述实施例的基础上还包括发送将主节点数据库从第一数据库切换为第二数据库的切换报告。例如,在故障切换中,切换过程是数据库和管理机主动执行的,对于用户来说,数据库的切换过程是不透明的,用户不知道进行了哪些切换,为了使用户清楚切换过程,可以向用户发送切换报告。该切换报告例如可以是邮件或者短信等形式。
根据本公开的实施例,数据库切换方法在前述实施例的基础上还包括通过第一接口与外部系统进行切换信息的交互,其中,切换信息包括将主节点数据库从第一数据库切换为第二数据库的结果,和/或将主节点数据库从第一数据库切换为第二数据库所需要的配置信息。例如,将切换过程通过第一接口展示到外部系统的用户界面上,使用户清楚切换的过程。
根据本公开的实施例,例如外部系统的参数可以通过该第一接口传入该数据库切换系统中的管理服务器,使得数据库的切换不再依赖本地静态配置文件。
根据本公开的实施例,例如管理服务器登录各个节点服务器可以默认依赖SSH(Secure Shell,安全外壳协议)。若外部系统已经实现其它登录方式,可以通过该第一接口修改理服务器登录各个节点服务器的登录方式,实现更便捷安全的远程登录功能。
根据本公开的实施例,例如切换过程中的进度以及状态默认以日志形式打印在切换管理服务器的本地文件中,也可以通过Python语言的logging模块编写自定义的日志发送模块,将进度和状态信息发送到其他系统,方便对整体的切换流程进行控制和显示。
根据本公开的实施例,例如数据库切换方法默认使用虚拟IP的方法来切换数据库的访问指向,而通过该第一接口可以实现使用其他的方法来切换数据库的访问指向。
图11A示意性示出了根据本公开的实施例的在线切换方法的流程图。如图11A所示,该方法包括操作S1110~S1150。
在操作S1110,检测切换环境是否满足在线切换的预设条件。类似于上文描述的操作S230。根据本公开的实施例,检测切换环境是否满足切换条件包括以下 至少一种检测是否存在工作状态异常的数据库,检测是否具备访问各个数据库的权限,或者验证切换请求中包括的从节点数据库是否是第一数据库的从节点。
在操作S1120,第一数据库禁止写入。类似于上文描述的操作S241。例如可以是登录第一数据库,对第一数据库加读锁,设置全局只读。
在操作S1130,使第二数据库具备成为主节点数据库的条件。类似于上文描述的操作S243,在第二数据库与第一数据库的数据一致的情况下,将第二数据库设置为读写模式。
在操作S1140,将第三数据库的主节点变为第二数据库。类似于上文描述的操作S244。例如可以是等待第三数据库执行到第一数据库的日志位点,执行CHANGE MASTER语句,将第三数据库的主节点切换到第二数据库,并启动从第二数据库的当前日志位点开始复制日志数据的操作。
在操作S1150,切换数据库访问指向。类似于上文描述的操作S1010和S1020,中断业务系统与第一数据库的连接以及将数据库指向切换成第二数据库。
图11B示意性示出了根据本公开的实施例的在线切换方法的效果示意图。图11B中包括主节点数据库与从节点数据库切换之前的系统架构图1110,以及主节点数据库与从节点数据库切换之后的系统架构图1120。
在主节点数据库与从节点数据库切换之前,如系统架构1110所示,主节点数据库是第一数据库1112。从节点数据库包括第二数据库1113和第三数据库,其中,第三数据库包括从节点数据库1114~1115,从节点数据库从第一数据库1112复制数据,以保证与第一数据库1112的数据同步。业务系统的读写请求通过虚拟IP 1111访问到第一数据库1112。
在主节点数据库与从节点数据库切换之后,如系统架构1120所示,主节点数据库从第一数据库1112切换为第二数据库1113。第一数据库1112和第三数据库1114~1115均是第二数据库1113的从节点数据库,从第二数据库1113中复制数据,以保证与第二数据库1113的数据同步。业务系统通过虚拟IP 1111访问第二数据库1113。
图12A示意性示出了根据本公开的实施例的故障切换方法的流程图。如图12A所示,该方法包括操作S1210~S1250。
在操作S1210,检测切换环境是否满足故障切换的预设条件。类似于上文描 述的操作S230。根据本公开的实施例,在切换类型为故障切换的情况下,检测切换环境是否满足预设条件包括,检测切换请求中的传入参数是否正确,传入参数例如可以是当前的主节点数据库,从节点数据库等,检测是否存在宕机节点,检测访问权限是否正常,检测所有第三数据库是否都是当前主节点的从节点,检测第三数据库的复制状态是否正常等。
在操作S1220,强制停止第一数据库进程。例如,业务系统与第一数据库建立了长连接,在第一数据库的服务器没有宕机,但进程停止的情况下,第一数据库的进程可能会自行恢复,在第一数据库的进行恢复后,业务系统依然通过该长连接访问第一数据库,然而此时,主数据库节点已经是第二数据库,造成业务系统的访问出现问题。通过强制关闭第一数据库的进程,能够保证在主从切换完成后,业务系统不会通过长连接访问到第一数据库。
在操作S1230,使第二数据库具备成为主节点数据库的条件。例如,执行上文描述的操作S245~S246,判断所述第二数据库是否存在数据缺失以及在所述第二数据库不存在数据缺失的情况下,记录所述第二数据库的当前日志位点,并将所述第二数据库的工作模式设置为读写模式。
在操作S1240,将第三数据库的主节点变为第二数据库。类似于上文描述的操作S247,基于所述当前日志位点,将主节点数据库从第一数据库切换为第二数据库。在操作S1250,切换数据库指向类似于上文描述的操作S1010和S1020,中断业务系统与所述第一数据库的连接以及将数据库指向切换成第二数据库。
图12B示意性示出了根据本公开的实施例的故障切换方法的效果示意图。图12B中包括主节点数据库与从节点数据库切换之前的系统架构图1110,以及主节点数据库与从节点数据库切换之后的系统架构图1220。
在主节点数据库与从节点数据库切换之前,如系统架构1110所示,主节点数据库是第一数据库1112。从节点数据库包括第二数据库1113和第三数据库,其中,第三数据库包括从节点数据库1114~1115,从节点数据库从第一数据库1112复制数据,以保证与第一数据库1112的数据同步。业务系统的读写请求通过虚拟IP 1111访问到第一数据库1112。
在主节点数据库与从节点数据库切换之后,如系统架构1220所示,主节点数据库从第一数据库1112切换为第二数据库1113。第三数据库1114~1115是第二数 据库1113的从节点数据库,从第二数据库1113中复制数据,以保证与第二数据库1113的数据同步。业务系统通过虚拟IP 1111访问第二数据库1113。
图13示意性示出了根据本公开的实施例的数据库切换系统1300的框图。如图13所示,数据库切换系统1300包括获取模块1310、确定模块1320、第一检测模块1330以及切换模块1340。
获取模块1310,例如执行上文参考图2描述的操作S210,用于获取切换请求,切换请求用于将主节点数据库从第一数据库切换为第二数据库。确定模块1320,例如执行上文参考图2描述的操作S220,用于基于切换请求,确定切换类型。第一检测模块1330,例如执行上文参考图2描述的操作S230,用于基于切换类型,检测切换环境是否满足切换条件。切换模块1340,例如执行上文参考图2描述的操作S240,用于在切换环境满足切换条件的情况下,将主节点数据库从第一数据库切换为第二数据库。
根据本公开的实施例,获取模块1310包括第一生成子模块,用于基于用户输入生成切换请求,或者第二生成子模块,用于在第一数据库作为主节点数据库发生异常的情况下,生成切换请求。
根据本公开的实施例,确定模块1320包括以下至少一种,第一确定子模块,用于从切换请求中读取表征切换类型的参数,以确定切换类型,或者第二确定子模块,用于基于切换请求,检测第一数据库是否异常,在第一数据库异常的情况下,确定切换类型是故障切换,在第一数据库正常的情况下,确定切换类型是在线切换。
根据本公开的实施例,在切换类型为在线切换的情况下,第一检测模块1330包括以下至少一种,第一检测子模块,用于检测是否存在工作状态异常的数据库,第二检测子模块,用于检测是否具备访问各个数据库的权限,或者验证子模块,用于验证切换请求中包括的从节点数据库是否是第一数据库的从节点。
根据本公开的实施例,第二生成子模块可以包括获取单元、确定单元以及生成单元。
获取单元例如执行上文参考图3描述的操作S310,用于获得多个从节点数据库的状态。确定单元例如执行上文参考图3描述的操作S320,用于基于多个从节点数据库的状态,确定一个从节点数据库为第二数据库。生成单元例如执行上文 参考图3描述的操作S330,用于生成以将主节点数据库从第一数据库切换为第二数据库的切换请求。
根据本公开的实施例,数据库切换系统在前述实施例的基础上还可以包括中断模块。中断模块例如执行上文参考图5描述的操作S510,用于若在将主节点数据库从第一数据库切换为第二数据库的过程中出现异常,则中止切换并执行预定操作。
根据本公开的实施例,数据库切换系统在前述实施例的基础上还可以包括存储模块。其中,中断模块可以包括回滚子模块。存储模块例如执行上文参考图6描述的操作S610,用于存储第一数据库的日志位点。回滚子模块用于基于第一数据库的日志位点,执行回滚操作。
根据本公开的实施例,切换模块可以包括禁止子模块、记录子模块、设置子模块以及第一切换子模块,其中,第一切换子模块可以包括切换单元1710。禁止子模块例如执行上文参考图4描述的操作S241,用于禁止第一数据库的写入进程。记录子模块例如执行上文参考图4描述的操作S242,用于在第二数据库中的数据与第一数据库中的数据一致的情况下,记录第二数据库的当前日志位点。设置子模块例如执行上文参考图4描述的操作S243,用于将第二数据库设置为读写模式。
第一切换子模块例如执行上文参考图4描述的操作S244,用于在第三数据库中的数据与第一数据库的数据一致的情况下,基于当前日志位点,将主节点数据库从第一数据库切换为第二数据库,其中,第三数据库包括除第二数据库以外的其他从节点数据库。其中,切换单元用于控制第三数据库从第二数据库读取数据,而非从第一数据库读取数据。
根据本公开的实施例,在切换类型为故障切换的情况下,第一检测模块1330包括第三检测子模块,用于检测第一数据库工作状态是否异常。
根据本公开的实施例,数据库切换系统可以包括第二检测模块和设置模块。第二检测模块例如执行上文参考图7描述的操作S710,用于检测多个第三数据库的工作状态是否异常,第三数据库包括除第二数据库以外的其他从节点数据库。设置模块例如执行上文参考图7描述的操作S720,用于在至少一个第三数据库的工作状态异常的情况下,将至少一个第三数据库设为忽略节点。
根据本公开的实施例,在基于用户输入生成切换请求的情况下,第一检测模 块还包括第四检测子模块,用于检测第二数据库工作状态是否正常。
根据本公开的实施例,切换模块可以包括判断子模块、执行子模块以及第二切换子模块,其中,第二切换子模块可以包括切换单元。
判断子模块例如执行上文参考图8描述的操作S245,用于判断第二数据库是否存在数据缺失。执行子模块例如执行上文参考图8描述的操作S246,用于在第二数据库不存在数据缺失的情况下,记录第二数据库的当前日志位点,并将第二数据库的工作模式设置为读写模式。
第二切换子模块1343例如执行上文参考图8描述的操作S247,用于基于当前日志位点,将主节点数据库从第一数据库切换为第二数据库。其中,切换单元用于控制第三数据库从第二数据库读取数据,而非从第一数据库读取数据,其中,第三数据库包括除第二数据库以外的其他从节点数据库。
根据本公开的实施例,数据库切换系统在前述实施例的基础上还包括记录模块,用于记录第三数据库存储的主从配置信息。其中,切换单元包括切换子单元,用于用于基于主从配置信息,控制第三数据库从第二数据库读取数据。
根据本公开的实施例,切换系统在前述实施例的基础上还可以包括连接模块和恢复模块。连接模块例如执行上文参考图9描述的操作S910,用于在第二数据库存在数据缺失的情况下,第二数据库与不存在数据缺失的第四数据库的建立数据复制的连接。恢复模块例如执行上文参考图9描述的操作S920,用于基于第四数据库,恢复第二数据库的缺失数据。
根据本公开的实施例,数据库切换系统在前述实施例的基础上还可以包括发送模块。发送模块用于发送将主节点数据库从第一数据库切换为第二数据库的切换报告。例如,在故障切换中,切换过程是数据库和管理机主动执行的,对于用户来说,数据库的切换过程是不透明的,用户不知道进行了哪些切换,为了使用户清楚切换过程,可以向用户发送切换报告。该切换报告例如可以是邮件或者短信等形式。
根据本公开的实施例,数据库切换系统在前述实施例的基础上还包括交互模块,用于通过第一接口与外部系统进行切换信息的交互,其中,切换信息包括将主节点数据库从第一数据库切换为第二数据库的结果,和/或将主节点数据库从第一数据库切换为第二数据库所需要的配置信息。
根据本公开的实施例,数据库切换系统在前述实施例的基础上还可以包括中断模块和分配模块。中断模块例如执行上文参考图10描述的操作S1010,用于中断业务系统与第一数据库的连接。分配模块例如执行上文参考图10描述的操作S1020,用于在主节点数据库切换完成的情况下,将第一数据库的虚拟地址分配给第二数据库,用于使业务系统通过虚拟地址访问的数据库为第二数据库,而非第一数据库。
根据本公开的实施例的模块、子模块、单元、子单元中的任意多个、或其中任意多个的至少部分功能可以在一个模块中实现。根据本公开实施例的模块、子模块、单元、子单元中的任意一个或多个可以被拆分成多个模块来实现。根据本公开实施例的模块、子模块、单元、子单元中的任意一个或多个可以至少被部分地实现为硬件电路,例如现场可编程门阵列(FPGA)、可编程逻辑阵列(PLA)、片上系统、基板上的系统、封装上的系统、专用集成电路(ASIC),或可以通过对电路进行集成或封装的任何其他的合理方式的硬件或固件来实现,或以软件、硬件以及固件三种实现方式中任意一种或以其中任意几种的适当组合来实现。或者,根据本公开实施例的模块、子模块、单元、子单元中的一个或多个可以至少被部分地实现为计算机程序模块,当该计算机程序模块被运行时,可以执行相应的功能。
例如,获取模块1310、确定模块1320、第一检测模块1330和切换模块1340中的任意多个可以合并在一个模块中实现,或者其中的任意一个模块可以被拆分成多个模块。或者,这些模块中的一个或多个模块的至少部分功能可以与其他模块的至少部分功能相结合,并在一个模块中实现。根据本公开的实施例,获取模块1310、确定模块1320、第一检测模块1330和切换模块1340中的至少一个可以至少被部分地实现为硬件电路,例如现场可编程门阵列(FPGA)、可编程逻辑阵列(PLA)、片上系统、基板上的系统、封装上的系统、专用集成电路(ASIC),或可以通过对电路进行集成或封装的任何其他的合理方式等硬件或固件来实现,或以软件、硬件以及固件三种实现方式中任意一种或以其中任意几种的适当组合来实现。或者,获取模块1310、确定模块1320、第一检测模块1330和切换模块1340中的至少一个可以至少被部分地实现为计算机程序模块,当该计算机程序模块被运行时,可以执行相应的功能。
图14示意性示出了根据本公开实施例的电子设备1400的方框图。图14示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图14所示,根据本公开实施例的电子设备1400包括处理器1401,其可以根据存储在只读存储器(ROM)1402中的程序或者从存储部分1408加载到随机访问存储器(RAM)1403中的程序而执行各种适当的动作和处理。处理器1401例如可以包括通用微处理器(例如CPU)、指令集处理器和/或相关芯片组和/或专用微处理器(例如,专用集成电路(ASIC)),等等。处理器1401还可以包括用于缓存用途的板载存储器。处理器1401可以包括用于执行根据本公开实施例的方法流程的不同动作的单一处理单元或者是多个处理单元。
在RAM 1403中,存储有电子设备1400操作所需的各种程序和数据。处理器1401、ROM 1402以及RAM 1403通过总线1404彼此相连。处理器1401通过执行ROM 1402和/或RAM 1403中的程序来执行根据本公开实施例的方法流程的各种操作。需要注意,所述程序也可以存储在除ROM 1402和RAM 1403以外的一个或多个存储器中。处理器1401也可以通过执行存储在所述一个或多个存储器中的程序来执行根据本公开实施例的方法流程的各种操作。
根据本公开的实施例,电子设备1400还可以包括输入/输出(I/O)接口1405,输入/输出(I/O)接口1405也连接至总线1404。电子设备1400还可以包括连接至I/O接口1405的以下部件中的一项或多项:包括键盘、鼠标等的输入部分1406;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分1407;包括硬盘等的存储部分1408;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分1409。通信部分1409经由诸如因特网的网络执行通信处理。驱动器1410也根据需要连接至I/O接口1405。可拆卸介质1411,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器1410上,以便于从其上读出的计算机程序根据需要被安装入存储部分1408。
根据本公开的实施例,根据本公开实施例的方法流程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分1409从网络上被下载 和安装,和/或从可拆卸介质1411被安装。在该计算机程序被处理器1401执行时,执行本公开实施例的系统中限定的上述功能。根据本公开的实施例,上文描述的系统、设备、装置、模块、单元等可以通过计算机程序模块来实现。
本公开还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备/装置/系统中所包含的;也可以是单独存在,而未装配入该设备/装置/系统中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被执行时,实现根据本公开实施例的方法。
根据本公开的实施例,计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、有线、光缆、射频信号等等,或者上述的任意合适的组合。
例如,根据本公开的实施例,计算机可读介质可以包括上文描述的ROM 1402和/或RAM 1403和/或ROM 1402和RAM 1403以外的一个或多个存储器。
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或 代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
本领域技术人员可以理解,本公开的各个实施例和/或权利要求中记载的特征可以进行多种组合或/或结合,即使这样的组合或结合没有明确记载于本公开中。特别地,在不脱离本公开精神和教导的情况下,本公开的各个实施例和/或权利要求中记载的特征可以进行多种组合和/或结合。所有这些组合和/或结合均落入本公开的范围。
以上对本公开的实施例进行了描述。但是,这些实施例仅仅是为了说明的目的,而并非为了限制本公开的范围。尽管在以上分别描述了各实施例,但是这并不意味着各个实施例中的措施不能有利地结合使用。本公开的范围由所附权利要求及其等同物限定。不脱离本公开的范围,本领域技术人员可以做出多种替代和修改,这些替代和修改都应落在本公开的范围之内。

Claims (36)

  1. 一种数据库切换方法,包括:
    获取切换请求,所述切换请求用于将主节点数据库从第一数据库切换为第二数据库;
    基于所述切换请求,确定切换类型;
    基于所述切换类型,检测切换环境是否满足切换条件;以及
    在所述切换环境满足所述切换条件的情况下,将主节点数据库从所述第一数据库切换为所述第二数据库。
  2. 根据权利要求1所述的数据库切换方法,其中,所述获取切换请求包括:
    基于用户输入生成切换请求;或者
    在第一数据库作为主节点数据库发生异常的情况下,生成切换请求。
  3. 根据权利要求2所述的数据库切换方法,其中,所述在第一数据库作为主节点数据库发生异常的情况下,生成切换请求包括:
    获得多个从节点数据库的状态;
    基于所述多个从节点数据库的状态,确定一个从节点数据库为第二数据库;
    生成用于将主节点数据库从第一数据库切换为第二数据库的切换请求。
  4. 根据权利要求1所述的数据库切换方法,其中,所述基于所述切换请求,确定切换类型包括:
    从所述切换请求中读取表征切换类型的参数,以确定切换类型;或者
    基于所述切换请求,检测所述第一数据库是否异常,在所述第一数据库异常的情况下,确定切换类型是故障切换,在所述第一数据库正常的情况下,确定切换类型是在线切换。
  5. 根据权利要求1所述的数据库切换方法,其中,在所述切换类型为在线切换的情况下,所述检测切换环境是否满足切换条件包括以下至少一种:
    检测是否存在工作状态异常的数据库;
    检测是否具备访问各个数据库的权限;或者
    验证切换请求中包括的从节点数据库是否是所述第一数据库的从节点。
  6. 根据权利要求1所述的数据库切换方法,其中,在所述切换类型为在线切 换的情况下,所述方法还包括:
    若在将主节点数据库从所述第一数据库切换为所述第二数据库的过程中出现异常,则中止所述切换并执行预定操作。
  7. 根据权利要求6所述的方法,还包括存储所述第一数据库的日志位点,所述预定操作包括:
    基于所述第一数据库的日志位点,执行回滚操作。
  8. 根据权利要求1所述的数据库切换方法,其中,在所述切换类型为在线切换的情况下,所述将主节点数据库从第一数据库切换为第二数据库包括:
    禁止所述第一数据库的写入进程;
    在所述第二数据库中的数据与所述第一数据库的数据一致的情况下,记录所述第二数据库的当前日志位点;
    将所述第二数据库设置为读写模式;以及
    在第三数据库中的数据与所述第一数据库的数据一致的情况下,基于所述当前日志位点,将所述主节点数据库从第一数据库切换为第二数据库,其中,所述第三数据库包括除第二数据库以外的其他从节点数据库,所述将所述主节点数据库从第一数据库切换为第二数据库包括:
    控制所述第三数据库从所述第二数据库读取数据,而非从所述第一数据库读取数据。
  9. 根据权利要求3所述的数据库切换方法,其中,在所述切换类型为故障切换的情况下,所述检测切换环境是否满足预设条件包括:
    检测所述第一数据库工作状态是否异常。
  10. 根据权利要求1所述的方法,还包括:
    检测多个第三数据库的工作状态是否异常,所述第三数据库包括除第二数据库以外的其他从节点数据库;以及
    在至少一个所述第三数据库的工作状态异常的情况下,将所述至少一个第三数据库设为忽略节点。
  11. 根据权利要求9所述的数据库切换方法,其中,在基于用户输入生成切换请求的情况下,所述检测切换环境是否满足预设条件还包括:
    检测所述第二数据库是否正常。
  12. 根据权利要求1所述的数据库切换方法,其中,在所述切换类型为故障切换的情况下,所述将主节点数据库从第一数据库切换为第二数据库包括:
    判断所述第二数据库是否存在数据缺失;
    在所述第二数据库不存在数据缺失的情况下,记录所述第二数据库的当前日志位点,并将所述第二数据库的工作模式设置为读写模式;以及
    基于所述当前日志位点,将主节点数据库从第一数据库切换为第二数据库,所述将主节点数据库从第一数据库切换为第二数据库包括:
    控制第三数据库从所述第二数据库读取数据,而非从所述第一数据库读取数据,其中,所述第三数据库包括除第二数据库以外的其他从节点数据库。
  13. 根据权利要求8或12所述的数据库切换方法,还包括:记录所述第三数据库存储的主从复制配置信息,
    其中,所述控制所述第三数据库从所述第二数据库读取数据包括:
    基于所述主从复制配置信息,控制所述第三数据库从所述第二数据库读取数据。
  14. 根据权利要求12所述的数据库切换方法,还包括:
    在所述第二数据库存在数据缺失的情况下,第二数据库与不存在数据缺失的第四数据库的建立数据复制的连接;以及
    基于所述第四数据库,恢复所述第二数据库的缺失数据。
  15. 根据权利要求1所述的数据库切换方法,还包括:
    发送将主节点数据库从第一数据库切换为第二数据库的切换报告。
  16. 根据权利要求1所述的数据库切换方法,还包括通过第一接口与外部系统进行切换信息的交互,其中,所述切换信息包括:
    将主节点数据库从第一数据库切换为第二数据库的结果;和/或
    将主节点数据库从第一数据库切换为第二数据库所需要的配置信息。
  17. 根据权利要求1所述的数据库切换方法,还包括:
    中断业务系统与所述第一数据库的连接;以及
    在所述主节点数据库切换完成的情况下,将所述第一数据库的虚拟地址分配给所述第二数据库,用于使业务系统通过所述虚拟地址访问的数据库为所述第二数据库,而非所述第一数据库。
  18. 一种数据库切换系统,包括:
    获取模块,用于获取切换请求,所述切换请求用于将主节点数据库从第一数据库切换为第二数据库;
    确定模块,用于基于所述切换请求,确定切换类型;
    第一检测模块,用于基于所述切换类型,检测切换环境是否满足切换条件;以及
    切换模块,用于在所述切换环境满足所述切换条件的情况下,将主节点数据库从所述第一数据库切换为所述第二数据库。
  19. 根据权利要求18所述的数据库切换系统,其中,所述获取模块包括:
    第一生成子模块,用于基于用户输入生成切换请求;或者
    第二生成子模块,用于在第一数据库作为主节点数据库发生异常的情况下,生成切换请求。
  20. 根据权利要求19所述的数据库切换系统,其中,所述第二生成子模块包括:
    获取单元,用于获得多个从节点数据库的状态;
    确定单元,用于基于所述多个从节点数据库的状态,确定一个从节点数据库为第二数据库;
    生成单元,用于生成以将主节点数据库从第一数据库切换为第二数据库的切换请求。
  21. 根据权利要求18所述的数据库切换系统,其中,所述确定模块包括以下至少一种:
    第一确定子模块,用于从所述切换请求中读取表征切换类型的参数,以确定切换类型;或者
    第二确定子模块,用于基于所述切换请求,检测所述第一数据库是否异常,在所述第一数据库异常的情况下,确定切换类型是故障切换,在所述第一数据库正常的情况下,确定切换类型是在线切换。
  22. 根据权利要求18所述的数据库切换系统,其中,在所述切换类型为在线切换的情况下,所述第一检测模块包括以下至少一种:
    第一检测子模块,用于检测是否存在工作状态异常的数据库;
    第二检测子模块,用于检测是否具备访问各个数据库的权限;或者
    验证子模块,用于验证切换请求中包括的从节点数据库是否是所述第一数据库的从节点。
  23. 根据权利要求18所述的数据库切换系统,其中,在所述切换类型为在线切换的情况下,所述系统还包括:
    中断模块,用于若在将主节点数据库从所述第一数据库切换为第二数据库的过程中出现异常,则中止所述切换并执行预定操作。
  24. 根据权利要求23所述的数据库切换系统,还包括存储模块,用于存储所述第一数据库的日志位点,
    所述中断模块包括:
    回滚子模块,用于基于所述第一数据库的日志位点,执行回滚操作。
  25. 根据权利要求18所述的数据库切换系统,在所述切换类型为在线切换的情况下,所述切换模块包括:
    禁止子模块,用于禁止所述第一数据库的写入进程;
    记录子模块,用于在所述第二数据库中的数据与所述第一数据库中的数据一致的情况下,记录所述第二数据库的当前日志位点;
    设置子模块,用于将所述第二数据库设置为读写模式;
    第一切换子模块,用于在第三数据库中的数据与所述第一数据库的数据一致的情况下,基于所述当前日志位点,将所述主节点数据库从第一数据库切换为第二数据库,其中,所述第三数据库包括除第二数据库以外的其他从节点数据库,
    其中,所述第一切换子模块包括:
    切换单元,用于控制所述第三数据库从所述第二数据库读取数据,而非从所述第一数据库读取数据。
  26. 根据权利要求20所述的数据库切换系统,所述切换类型为故障切换的情况下,所述第一检测模块包括:
    第三检测子模块,用于检测所述第一数据库工作状态是否异常。
  27. 根据权利要求18所述的数据库切换系统,所述系统还包括:
    第二检测模块,用于检测多个第三数据库的工作状态是否异常,所述第三数据库包括除第二数据库以外的其他从节点数据库;以及
    设置模块,用于在至少一个所述第三数据库的工作状态异常的情况下,将所述至少一个第三数据库设为忽略节点。
  28. 根据权利要求26所述的数据库切换系统,其中,在基于用户输入生成切换请求的情况下,所述第一检测模块还包括:
    第四检测子模块,用于检测所述第二数据库工作状态是否正常。
  29. 根据权利要求18所述的数据库切换系统,在所述切换类型为故障切换的情况下,所述切换模块包括:
    判断子模块,用于判断所述第二数据库是否存在数据缺失;
    执行子模块,用于在所述第二数据库不存在数据缺失的情况下,记录所述第二数据库的当前日志位点,并将所述第二数据库的工作模式设置为读写模式;
    第二切换子模块,用于基于所述当前日志位点,将主节点数据库从第一数据库切换为第二数据库,
    其中,所述第二切换子模块包括:
    切换单元,用于控制第三数据库从所述第二数据库读取数据,而非从所述第一数据库读取数据,其中,所述第三数据库包括除第二数据库以外的其他从节点数据库。
  30. 根据权利要求25或29所述的数据库切换系统,还包括:
    记录模块,用于记录所述第三数据库存储的主从配置信息,
    其中,所述切换单元包括:
    切换子单元,用于基于所述主从配置信息,控制所述第三数据库从所述第二数据库读取数据。
  31. 根据权利要求29所述的数据库切换系统,还包括:
    连接模块,用于在所述第二数据库存在数据缺失的情况下,第二数据库与不存在数据缺失的第四数据库的建立数据复制的连接;以及
    恢复模块,用于基于所述第四数据库,恢复所述第二数据库的缺失数据。
  32. 根据权利要求18所述的数据库切换系统,还包括:
    发送模块,用于发送将主节点数据库从第一数据库切换为第二数据库的切换报告。
  33. 根据权利要求18所述的数据库切换系统,还包括:
    交互模块,用于通过第一接口与外部系统进行切换信息的交互,其中,所述切换信息包括:
    将主节点数据库从第一数据库切换为第二数据库的结果;和/或
    将主节点数据库从第一数据库切换为第二数据库所需要的配置信息。
  34. 根据权利要求18所述的数据库切换系统,还包括:
    中断模块,用于中断业务系统与所述第一数据库的连接;以及
    分配模块,用于在所述主节点数据库切换完成的情况下,将所述第一数据库的虚拟地址分配给所述第二数据库,用于使业务系统通过所述虚拟地址访问的数据库为所述第二数据库,而非所述第一数据库。
  35. 一种电子设备,包括:
    一个或多个处理器;
    存储装置,用于存储一个或多个程序,
    其中,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器执行如权利要求1~17所述任意一项的方法。
  36. 一种计算机可读介质,其上存储有可执行指令,该指令被处理器执行时使处理器执行如权利要求1~17所述任意一项的方法。
PCT/CN2019/101626 2018-09-29 2019-08-20 数据库切换方法、系统、电子设备和计算机可读介质 WO2020063197A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811153495.6 2018-09-29
CN201811153495.6A CN109388630B (zh) 2018-09-29 2018-09-29 数据库切换方法、系统、电子设备和计算机可读介质

Publications (1)

Publication Number Publication Date
WO2020063197A1 true WO2020063197A1 (zh) 2020-04-02

Family

ID=65419219

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/101626 WO2020063197A1 (zh) 2018-09-29 2019-08-20 数据库切换方法、系统、电子设备和计算机可读介质

Country Status (2)

Country Link
CN (1) CN109388630B (zh)
WO (1) WO2020063197A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109388630B (zh) * 2018-09-29 2020-09-29 京东数字科技控股有限公司 数据库切换方法、系统、电子设备和计算机可读介质
CN110532278B (zh) * 2019-10-30 2020-01-31 上海爱可生信息技术股份有限公司 声明式的MySQL数据库系统高可用方法
CN110879718A (zh) * 2019-11-15 2020-03-13 北京浪潮数据技术有限公司 mariadb升级方法、装置及电子设备和存储介质
CN113297002B (zh) * 2020-02-21 2023-12-05 北京京东振世信息技术有限公司 数据库工作模式的切换方法和装置
CN111460029B (zh) * 2020-03-11 2024-04-19 中移动信息技术有限公司 数据同步方法和装置
CN111581287A (zh) * 2020-05-07 2020-08-25 上海茂声智能科技有限公司 一种数据库管理的控制方法、系统和存储介质
CN112199440A (zh) * 2020-08-31 2021-01-08 阿里巴巴集团控股有限公司 数据库控制方法、系统、切换方法、电子设备及存储介质
CN114253620B (zh) * 2021-12-27 2024-07-09 中国建设银行股份有限公司 主机系统切换方法、装置、电子设备及计算机存储介质
CN114676118B (zh) * 2022-05-30 2022-08-12 深圳市科力锐科技有限公司 数据库切换方法、装置、设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105373563A (zh) * 2014-08-28 2016-03-02 北京奇虎科技有限公司 数据库切换方法及装置
CN106202075A (zh) * 2015-04-29 2016-12-07 中兴通讯股份有限公司 一种数据库主备切换的方法及装置
CN106909568A (zh) * 2015-12-23 2017-06-30 北京奇虎科技有限公司 一种数据库集群主数据库的切换方法及装置
CN107203617A (zh) * 2017-05-24 2017-09-26 杭州铭师堂教育科技发展有限公司 基于MHA的mysql在线迁移系统及方法
US20180157560A1 (en) * 2016-12-02 2018-06-07 Vmware, Inc. Methods and apparatus for transparent database switching using master-replica high availability setup in relational databases
CN109388630A (zh) * 2018-09-29 2019-02-26 北京京东金融科技控股有限公司 数据库切换方法、系统、电子设备和计算机可读介质

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106777126B (zh) * 2016-12-16 2020-05-19 广东电网有限责任公司电力调度控制中心 一种支持异构时序数据库的数据在线迁移方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105373563A (zh) * 2014-08-28 2016-03-02 北京奇虎科技有限公司 数据库切换方法及装置
CN106202075A (zh) * 2015-04-29 2016-12-07 中兴通讯股份有限公司 一种数据库主备切换的方法及装置
CN106909568A (zh) * 2015-12-23 2017-06-30 北京奇虎科技有限公司 一种数据库集群主数据库的切换方法及装置
US20180157560A1 (en) * 2016-12-02 2018-06-07 Vmware, Inc. Methods and apparatus for transparent database switching using master-replica high availability setup in relational databases
CN107203617A (zh) * 2017-05-24 2017-09-26 杭州铭师堂教育科技发展有限公司 基于MHA的mysql在线迁移系统及方法
CN109388630A (zh) * 2018-09-29 2019-02-26 北京京东金融科技控股有限公司 数据库切换方法、系统、电子设备和计算机可读介质

Also Published As

Publication number Publication date
CN109388630B (zh) 2020-09-29
CN109388630A (zh) 2019-02-26

Similar Documents

Publication Publication Date Title
WO2020063197A1 (zh) 数据库切换方法、系统、电子设备和计算机可读介质
US10140115B2 (en) Applying update to snapshots of virtual machine
CN112840318A (zh) 用于计算机系统的自动化操作管理
US9442809B2 (en) Management computer used to construct backup configuration of application data
US8910172B2 (en) Application resource switchover systems and methods
CN106843749B (zh) 写入请求处理方法、装置及设备
CN108469986B (zh) 一种数据迁移方法及装置
US9678682B2 (en) Backup storage of vital debug information
KR20190041033A (ko) 서비스의 2차 위치에서의 작업의 재생 기법
US20140258659A1 (en) Protection of former primary volumes in a synchronous replication relationship
US10048978B2 (en) Apparatus and method for identifying a virtual machine having changeable settings
US11281550B2 (en) Disaster recovery specific configurations, management, and application
CN111158955B (zh) 一种基于卷复制的高可用系统以及多服务器数据同步方法
US20090249010A1 (en) Apparatus and method for controlling copying
WO2024017274A1 (zh) 一种虚拟机克隆方法、装置及存储介质
US10976941B2 (en) Validation of storage volumes that are in a peer to peer remote copy relationship
US20230275931A1 (en) Dynamic management of role-based access control systems
US20230267053A1 (en) Automatic Selection of Data Movers for Protecting Virtual Machines
US11849037B1 (en) Cross-region replication of secrets
US9990491B2 (en) Methods and systems for assessing and remediating online servers with minimal impact
US20170230452A1 (en) Network optimized scan with dynamic fallback recovery
CN113138722B (zh) 用于分布式块存储系统的复制快照方法、系统和介质
McCabe Introducing Windows Server 2016 Technical Preview
JP6908827B2 (ja) 試験装置、試験方法、試験プログラム及び試験システム
CN118489109A (zh) 管理复制存储系统中加密密钥状态变化的数据可用性

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19864324

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19864324

Country of ref document: EP

Kind code of ref document: A1