CN112199440A - Database control method, database control system, database switching method, electronic equipment and storage medium - Google Patents

Database control method, database control system, database switching method, electronic equipment and storage medium Download PDF

Info

Publication number
CN112199440A
CN112199440A CN202010899559.8A CN202010899559A CN112199440A CN 112199440 A CN112199440 A CN 112199440A CN 202010899559 A CN202010899559 A CN 202010899559A CN 112199440 A CN112199440 A CN 112199440A
Authority
CN
China
Prior art keywords
database
master
switching
access point
slave
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010899559.8A
Other languages
Chinese (zh)
Inventor
董光清
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010899559.8A priority Critical patent/CN112199440A/en
Publication of CN112199440A publication Critical patent/CN112199440A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the disclosure discloses a database control method, a system, a switching method, an electronic device and a storage medium, wherein the database control method comprises the following steps: receiving a specific operation of the main database through the database access link address and a database switching request; according to the database switching request, switching a first database serving as a master database into a slave database, and switching a second database serving as a slave database into the master database; the specific operation is executed on the switched main database by the link address accessed by the database, so that the link address of the database can be kept unchanged when the cluster switching is carried out on the cross-regional database, the related operation of a user is not required to be changed or restarted, and the user operation is simplified.

Description

Database control method, database control system, database switching method, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of internet technologies, and in particular, to a database control method, a database control system, a database switching method, an electronic device, and a storage medium.
Background
With a distributed database, e.g., a global database, across regions or regions, data distribution can be spread across regions (regions) throughout the globe. For example, a master cluster of databases, such as a global database, is distributed in one of the regions to provide the user with the ability to read and write. And distributing the database slave cluster in other areas to provide read-only capability for users. The global database is designed for global distributed applications, which enables the ability to achieve fast local reads with low latency in each area by copying the data of the master cluster (A-area) to the slave clusters (other areas). When a user service is migrated from an area a to an area B, it is often necessary to switch a database master cluster to a corresponding area B. However, in the method for switching the main cluster across areas in the related art, after the database is switched, the user is required to change the link address configuration of the related operation. Therefore, when the user switches the database master cluster from the a area to the B area, the link address of the database cannot be kept unchanged, and the related operations of the user need to be changed or restarted.
Disclosure of Invention
In order to solve the problems in the related art, embodiments of the present disclosure provide a database control method, a database control system, a database switching method, an electronic device, and a storage medium.
In a first aspect, an embodiment of the present disclosure provides a database control method, including:
receiving a specific operation of the main database through the database access link address and a database switching request;
according to the database switching request, switching a first database serving as a master database into a slave database, and switching a second database serving as a slave database into the master database;
and executing the specific operation on the switched master database through the database access link address.
With reference to the first aspect, in a first implementation manner of the first aspect, before the receiving a specific operation on the master database via the database access link address and a database switching request, the method further includes:
copying first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database.
With reference to the first aspect, in a second implementation manner of the first aspect, the first database and the second database are different database clusters belonging to the same database network.
With reference to the first aspect, or any one of the first implementation manner and the second implementation manner of the first aspect, in a third implementation manner of the first aspect, the receiving a specific operation and a database switching request to a master database via a database access link address includes:
receiving, by a global access point pointing to a master database, a specific operation to the master database and a database switching request via a database access link address for linking to the global access point.
With reference to the third implementation manner of the first aspect, the present disclosure provides in a fourth implementation manner of the first aspect, that the first database as the master database is connected to the global access point through a first access point for connecting the first database to receive a specific operation on the master database via a database access link address, or
The second database, which is a master database, is connected with the global access point through a second access point for connecting the second database to receive a specific operation on the master database via the database access link address.
With reference to the fourth implementation manner of the first aspect, in a fifth implementation manner of the first aspect, the receiving, by a global access point pointing to a master database, a specific operation and a database switching request to the master database via a database access link address includes:
pointing the global access point to a corresponding address of an access point of a master database;
receiving, by the global access point, a specific operation to the master database via the database access link address and a database switch request.
With reference to the fourth implementation manner of the first aspect, in a sixth implementation manner of the first aspect, the receiving a database switching request includes:
checking whether a replication delay time required to replicate first data that is a difference between a first database as a master database and a second database as a slave database is less than a first threshold,
wherein, according to the database switching request, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database comprises:
and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
With reference to the sixth implementation manner of the first aspect, the present disclosure in a seventh implementation manner of the first aspect, where in response to the replication delay time being less than the first threshold, the switching a first database as a master database to a slave database and a second database as a slave database to the master database according to the database switching request includes:
adding the address of the host where the first database is located into a white list of the second database;
setting the first database to a read-only state;
detecting that first data that is a difference between said first database and said second database has been synchronized to said second database;
setting the second database to the particular operational state;
the global access point is directed to an address of a second access point of a second database.
With reference to the first implementation manner of the first aspect, the present disclosure, in an eighth implementation manner of the first aspect, replicating, from a first database as a master database to a second database as a slave database, first data that is a difference between the first database and the second database includes:
in a case where the first database and the second database are located in different virtual private clouds, first data that is different between the first database and the second database is replicated from the first database to the second database through a cloud enterprise network or a private domain.
With reference to the first aspect, or any one of the first implementation manner and the second implementation manner of the first aspect, in a ninth implementation manner of the first aspect, the present disclosure further includes:
copying second data that is different between the second database and the first database from the second database as a master database to the first database as a slave database.
With reference to the first aspect, the first implementation manner of the first aspect, and any one of the second implementation manners of the first aspect, in a tenth implementation manner of the first aspect, the specific operation at least includes a write operation.
In a second aspect, embodiments of the present disclosure provide a database control system, comprising a global controller, a first database, and a second database, wherein,
the global controller includes:
a receiving module configured to receive a specific operation on the master database via the database access link address and a database switching request;
a switching module configured to switch a first database as a master database to a slave database and a second database as a slave database to the master database according to the database switching request;
an execution module configured to execute the specific operation on the switched master database via the database access link address.
With reference to the second aspect, in a first implementation manner of the second aspect, the present disclosure further includes:
a first database controller configured to copy first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database.
With reference to the second aspect, in a second implementation manner of the second aspect, the first database and the second database are different database clusters belonging to the same database network.
With reference to the second aspect, or any one of the first implementation manner and the second implementation manner of the second aspect, in a third implementation manner of the second aspect, the global controller includes a global access point, and the receiving module is further configured to:
receiving, by a global access point pointing to a master database, a specific operation to the master database and a database switching request via a database access link address for linking to the global access point.
With reference to the third implementation manner of the second aspect, in a fourth implementation manner of the second aspect, the first database includes a first access point, and the second database includes a second access point, wherein,
the first database as a master database is connected with the global access point through the first access point for connecting the first database to receive a specific operation on the master database via the database access link address, or
The second database, which is a master database, is connected with the global access point through a second access point for connecting the second database to receive a specific operation on the master database via the database access link address.
With reference to the fourth implementation manner of the second aspect, in a fifth implementation manner of the second aspect, the receiving module includes:
a pointing submodule configured to point the global access point to a corresponding address of an access point of a master database;
a receiving sub-module configured to receive a specific operation to the master database via the database access link address and a database switching request through the global access point.
With reference to the fourth implementation manner of the second aspect, in a sixth implementation manner of the second aspect, the receiving module is further configured to:
checking whether a replication delay time required to replicate first data that is a difference between a first database as a master database and a second database as a slave database is less than a first threshold,
wherein the switching module is further configured to:
and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
With reference to the sixth implementation manner of the second aspect, in a seventh implementation manner of the second aspect, the switching module includes:
the adding sub-module is configured to add the address of the host where the first database is located into a white list of the second database;
a first setting submodule configured to set the first database to a read-only state;
a detection sub-module configured to detect that first data that is a difference between the first database and the second database has been synchronized to the second database;
a second setting sub-module that sets the second database to the specific operation state;
a pointing submodule configured to point the global access point to an address of a second access point of a second database.
With reference to the first implementation manner of the second aspect, in an eighth implementation manner of the second aspect, the first database controller is further configured to:
in a case where the first database and the second database are located in different virtual private clouds, first data that is different between the first database and the second database is replicated from the first database to the second database through a cloud enterprise network or a private domain.
With reference to the second aspect, or any one of the first implementation manner and the second implementation manner of the second aspect, in a ninth implementation manner of the second aspect, the present disclosure further includes:
a second database controller configured to copy second data, which is different between the second database and the first database, from the second database as a master database to the first database as a slave database.
With reference to the second aspect, or any one of the first implementation manner and the second implementation manner of the second aspect, in a tenth implementation manner of the second aspect, the specific operation at least includes a write operation.
In a third aspect, an embodiment of the present disclosure provides a database switching method, including:
copying first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database;
receiving a database switching request;
in response to receiving the database switch request, checking whether a replication delay time required to replicate first data, which is a difference between a first database as a master database and a second database as a slave database, is less than a first threshold value;
and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
In a fourth aspect, an embodiment of the present disclosure provides an electronic device, including a memory and a processor; wherein,
the memory is configured to store one or more computer instructions, where the one or more computer instructions are executed by the processor to implement the method according to the first aspect, the first implementation manner to the tenth implementation manner of the first aspect, and the third aspect.
In a fifth aspect, an embodiment of the present disclosure provides a readable storage medium, on which computer instructions are stored, and the computer instructions, when executed by a processor, implement the method according to any one of the first aspect, the first implementation manner to the tenth implementation manner of the first aspect, and the third aspect.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
according to the technical scheme provided by the embodiment of the disclosure, a specific operation and database switching request of a main database is received by accessing a link address through the database; according to the database switching request, switching a first database serving as a master database into a slave database, and switching a second database serving as a slave database into the master database; the specific operation is executed on the switched main database by the link address accessed by the database, so that the link address of the database can be kept unchanged when the cluster switching is carried out on the cross-regional database, the related operation of a user is not required to be changed or restarted, and the user operation is simplified.
According to the technical scheme provided by the embodiment of the present disclosure, before the receiving a specific operation on a master database via a database access link address and a database switching request, the method further includes: the first data which is different between the first database and the second database is copied from the first database which is used as a master database to the second database which is used as a slave database, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of the operation result of a user are ensured in the case of switching databases.
According to the technical scheme provided by the embodiment of the disclosure, the first database and the second database belong to different database clusters of the same database network, so that when the cluster switching is performed on the cross-regional database, the link address of the database is kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, the receiving of the specific operation of the link address to the main database through the database access and the database switching request comprises the following steps: the method comprises the steps that a global access point pointing to a main database receives a specific operation of a database access link address on the main database and a database switching request, wherein the database access link address is used for linking to the global access point, so that the link address of the database can be kept unchanged when cluster switching is carried out on a cross-regional database, related operations of a user do not need to be changed or restarted, and user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, the first database serving as the main database is connected with the global access point through the first access point for connecting the first database to receive the specific operation of accessing the link address to the main database through the database, or the second database serving as the main database is connected with the global access point through the second access point for connecting the second database to receive the specific operation of accessing the link address to the main database through the database, so that the link address of the database can be kept unchanged when the cluster switching is performed on the cross-regional database, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, receiving a specific operation and a database switching request to a master database through a global access point pointing to the master database by accessing a link address through the database includes: pointing the global access point to a corresponding address of an access point of a master database; the global access point receives the specific operation of the link address accessed by the database to the main database and the database switching request, so that the link address of the database can be kept unchanged without changing or restarting the related operation of a user when the cluster switching is carried out on the cross-regional database, and the user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, the receiving the database switching request comprises: checking whether a replication delay time required to replicate first data, which is a difference between a first database and a second database, from the first database, which is a master database, to the second database, which is a slave database, is less than a first threshold, wherein the switching of the first database, which is the master database, to the slave database and the second database, which is the slave database, to the master database according to the database switching request, includes: and in response to the copying delay time being less than the first threshold, switching the first database serving as the master database to the slave database and switching the second database serving as the slave database to the master database according to the database switching request, wherein the switching of the databases can be performed under the condition that the data consistency of the first database and the second database is ensured, and the reliability and the accuracy of a user operation result after the switching of the databases are ensured.
According to the technical solution provided by the embodiment of the present disclosure, by responding to the replication delay time being smaller than the first threshold, according to the database switching request, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database includes: adding the address of the host where the first database is located into a white list of the second database; setting the first database to a read-only state; detecting that first data that is a difference between said first database and said second database has been synchronized to said second database; setting the second database to the particular operational state; the global access point points to the address of the second access point of the second database, so that the link address of the database can be kept unchanged when the cluster switching is carried out on the cross-regional database, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, copying first data which is different between a first database and a second database from the first database as a master database to the second database as a slave database comprises the following steps: under the condition that the first database and the second database are located in different virtual private clouds, the first data which is different between the first database and the second database is copied from the first database to the second database through a cloud enterprise network or a private domain, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of a user operation result are ensured under the condition of switching the databases.
According to the technical scheme provided by the embodiment of the disclosure, by copying the second data which is different between the second database and the first database from the second database as a master database to the first database as a slave database, the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of the user operation result are ensured under the condition of switching databases.
According to the technical scheme provided by the embodiment of the disclosure, the specific operation at least comprises a write operation, so that when the cluster switching is performed on the cross-regional database, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, the system comprises a global controller, a first database and a second database, wherein the global controller comprises: a receiving module configured to receive a specific operation on the master database via the database access link address and a database switching request; a switching module configured to switch a first database as a master database to a slave database and a second database as a slave database to the master database according to the database switching request; the execution module is configured to execute the specific operation on the switched main database by accessing the link address through the database, so that the link address of the database can be kept unchanged without changing or restarting the related operation of a user when the cluster switching is performed on the cross-regional database, and the user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, the first database controller is configured to copy the first data which is different between the first database and the second database from the first database as a master database to the second database as a slave database, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of the user operation result are ensured under the condition of switching the databases.
According to the technical scheme provided by the embodiment of the disclosure, the first database and the second database belong to different database clusters of the same database network, so that when the cluster switching is performed on the cross-regional database, the link address of the database is kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
According to the technical solution provided by the embodiment of the present disclosure, the global controller includes a global access point, and the receiving module is further configured to: the method comprises the steps that a global access point pointing to a main database receives a specific operation of a database access link address on the main database and a database switching request, wherein the database access link address is used for linking to the global access point, so that the link address of the database can be kept unchanged when cluster switching is carried out on a cross-regional database, related operations of a user do not need to be changed or restarted, and user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, the first database comprises a first access point, and the second database comprises a second access point, wherein the first database as a main database is connected with the global access point through the first access point for connecting the first database to receive the specific operation of accessing the link address to the main database through the database, or the second database as a main database is connected with the global access point through the second access point for connecting the second database to receive the specific operation of accessing the link address to the main database through the database, when the cross-regional database is subjected to cluster switching, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, the receiving module comprises: a pointing submodule configured to point the global access point to a corresponding address of an access point of a master database; the receiving submodule is configured to receive a specific operation of accessing the link address to the main database through the database and a database switching request through the global access point, and can keep the link address of the database unchanged without changing or restarting the related operation of a user when performing cluster switching on the cross-regional database, thereby simplifying the user operation.
According to the technical scheme provided by the embodiment of the disclosure, the receiving module is further configured to: checking whether a replication delay time required to replicate first data, which is a difference between a first database as a master database and a second database as a slave database, from the first database to the second database is less than a first threshold, wherein the switching module is further configured to: and in response to the copying delay time being less than the first threshold, switching the first database serving as the master database to the slave database and switching the second database serving as the slave database to the master database according to the database switching request, wherein the switching of the databases can be performed under the condition that the data consistency of the first database and the second database is ensured, and the reliability and the accuracy of a user operation result after the switching of the databases are ensured.
According to the technical scheme provided by the embodiment of the disclosure, the switching module comprises: the adding sub-module is configured to add the address of the host where the first database is located into a white list of the second database; a first setting submodule configured to set the first database to a read-only state; a detection sub-module configured to detect that first data that is a difference between the first database and the second database has been synchronized to the second database; a second setting sub-module that sets the second database to the specific operation state; and the pointing submodule is configured to point the global access point to the address of the second access point of the second database, so that when the cluster switching is performed on the cross-regional database, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
According to the technical solution provided by the embodiment of the present disclosure, the first database controller is further configured to: under the condition that the first database and the second database are located in different virtual private clouds, the first data which is different between the first database and the second database is copied from the first database to the second database through a cloud enterprise network or a private domain, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of a user operation result are ensured under the condition of switching the databases.
According to the technical scheme provided by the embodiment of the disclosure, the second database controller is configured to copy the second data which is different between the second database and the first database from the second database as a master database to the first database as a slave database, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of the user operation result are ensured under the condition of switching databases.
According to the technical scheme provided by the embodiment of the disclosure, the specific operation at least comprises a write operation, so that when the cluster switching is performed on the cross-regional database, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
According to the technical scheme provided by the embodiment of the disclosure, the differential first data between a first database and a second database is copied from the first database serving as a master database to the second database serving as a slave database; receiving a database switching request; in response to receiving the database switch request, checking whether a replication delay time required to replicate first data, which is a difference between a first database as a master database and a second database as a slave database, is less than a first threshold value; and in response to the copying delay time being less than the first threshold, switching the first database serving as the master database to the slave database and switching the second database serving as the slave database to the master database according to the database switching request, so that when the cluster switching is performed on the cross-regional database, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
Other features, objects, and advantages of the present disclosure will become more apparent from the following detailed description of non-limiting embodiments when taken in conjunction with the accompanying drawings. In the drawings:
FIG. 1 illustrates a flow diagram of a database control method according to an embodiment of the present disclosure;
FIG. 2a shows an exemplary schematic diagram of a database control system according to the related art;
FIG. 2b shows an exemplary schematic diagram of a database control system according to an embodiment of the present disclosure;
FIG. 3 illustrates a block diagram of a database control system according to an embodiment of the present disclosure;
FIG. 4 illustrates a flow diagram of a database switching method according to an embodiment of the present disclosure;
FIG. 5 shows a block diagram of an electronic device according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a computer system suitable for implementing a database control method or a database switching method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings so that those skilled in the art can easily implement them. Also, for the sake of clarity, parts not relevant to the description of the exemplary embodiments are omitted in the drawings.
In the present disclosure, it is to be understood that terms such as "including" or "having," etc., are intended to indicate the presence of labels, numbers, steps, actions, components, parts, or combinations thereof disclosed in the present specification, and are not intended to preclude the possibility that one or more other labels, numbers, steps, actions, components, parts, or combinations thereof are present or added.
It should be further noted that the embodiments and labels in the embodiments of the present disclosure may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
When switching clusters in different areas of a distributed database, a user service is migrated from an area a to an area B, and often a database master cluster needs to be switched to a corresponding area B. Generally, the reason for handover is mainly that user traffic wants to migrate from one area to another. The reasons for handover include, but are not limited to, the following:
1. the current regional resources are insufficient, and the future development requirements of the service are not met.
2. The switched area is closer to most users, and the network delay is smaller.
3. Planning future development of operators of distributed databases.
However, in the method for switching the main cluster across areas in the related art, after the database is switched, the user is required to change the link address configuration of the related operation. Therefore, when the user switches the database master cluster from the a area to the B area, the link address of the database cannot be kept unchanged, and the related operations of the user need to be changed or restarted.
In order to solve the above problems, the present disclosure provides a database control method, a database control system, a switching method, an electronic device, and a storage medium.
According to the technical scheme provided by the embodiment of the disclosure, a specific operation and database switching request of a main database is received by accessing a link address through the database; according to the database switching request, switching a first database serving as a master database into a slave database, and switching a second database serving as a slave database into the master database; the specific operation is executed on the switched main database by the link address accessed by the database, so that the link address of the database can be kept unchanged when the cluster switching is carried out on the cross-regional database, the related operation of a user is not required to be changed or restarted, and the user operation is simplified.
Fig. 1 illustrates a flow chart of a database control method according to an embodiment of the present disclosure. As shown in fig. 1, the message pushing method includes steps S110, S120, and S130.
In step S110, a specific operation to the master database via the database access link address and a database switching request are received.
In step S120, a first database, which is a master database, is switched to a slave database, and a second database, which is a slave database, is switched to the master database, according to the database switching request.
In step S130, the specific operation is performed on the switched master database via the database access link address.
In one embodiment of the present disclosure, the specific operation includes at least a write operation. In one embodiment of the present disclosure, operations on a database may include read operations, write operations, read and write operations, and the like. For example, for a distributed database system such as a global database, the master cluster of databases (or master database) is distributed in one of the regions to provide the user with the ability to read and write. The distributed database in the other region provides read-only capability to users from the cluster (or from the database). Thus, a particular operation, such as a write operation, to the master database via a database access link address is different from a general operation, such as a read operation, that may be performed to each database in the distributed database system. In one embodiment of the present disclosure, the specific operation may include a read-write operation. It should be understood that a read operation does not change the data stored in the database and therefore may directly perform a read-only operation on the database in any region, but a write operation is only allowed to the master database since a write operation changes the data in the database.
According to the technical scheme provided by the embodiment of the disclosure, the specific operation at least comprises a write operation, so that when the cluster switching is performed on the cross-regional database, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
In one embodiment of the present disclosure, the database access link address may be a URL (uniform resource locator) and a port. Since a write operation may change data of the database, when a write operation needs to be performed on the database, the master database needs to be accessed through the database access link address.
In an embodiment of the present disclosure, the database switching request may be a request issued by a user initiating a cross-regional database cluster switching, or may be a request initiated by an application to switch the database cluster according to a situation, which is not limited by the present disclosure.
In one embodiment of the present disclosure, performing the specific operation on the switched master database via the database access link address means that a specific operation such as a write operation may be performed through a first database having the database access link address as a master database before switching, and a specific operation such as a write operation may be performed through a second database having the database access link address as a master database after switching.
In an embodiment of the present disclosure, the database control method further includes, before step S110: copying first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database.
In one embodiment of the present disclosure, since a specific operation such as a write operation may be performed on the database master cluster or master database so that data in the database master cluster or master database is in a changed state compared to data in the slave cluster or slave database, it is necessary to copy data in the database master cluster or master database to the slave cluster or slave database to ensure consistency of the data.
According to the technical scheme provided by the embodiment of the present disclosure, before the receiving a specific operation on a master database via a database access link address and a database switching request, the method further includes: the first data which is different between the first database and the second database is copied from the first database which is used as a master database to the second database which is used as a slave database, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of the operation result of a user are ensured in the case of switching databases.
In one embodiment of the present disclosure, the first database and the second database are different database clusters belonging to the same database network.
In one embodiment of the present disclosure, the same database network may refer to a distributed database across regions or zones, such as a global database.
According to the technical scheme provided by the embodiment of the disclosure, the first database and the second database belong to different database clusters of the same database network, so that when the cluster switching is performed on the cross-regional database, the link address of the database is kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
In one embodiment of the present disclosure, step S110 includes: receiving, by a Global access point (Global Endpoint) pointing to a master database, a specific operation to the master database and a database switch request via a database access link address for linking to the Global access point.
In one embodiment of the present disclosure, in order to implement a specific operation, such as a write operation, performed on the switched database master cluster or master database via the same database access link address as before the switching, it may be implemented with a global access point that is permanently bound to the database master cluster or master database. In one embodiment of the present disclosure, the read and write operations may both be initiated by a user to the global access point and redirected by the global access point to the database master cluster or to a link address (e.g., a virtual IP address) of the master database. Because the user access interface before and after the switching of the database main cluster or the main database is not changed and is always the global access point, the link address configuration of the user service is not changed.
According to the technical scheme provided by the embodiment of the disclosure, the receiving of the specific operation of the link address to the main database through the database access and the database switching request comprises the following steps: the method comprises the steps that a global access point pointing to a main database receives a specific operation of a database access link address on the main database and a database switching request, wherein the database access link address is used for linking to the global access point, so that the link address of the database can be kept unchanged when cluster switching is carried out on a cross-regional database, related operations of a user do not need to be changed or restarted, and user operation is simplified.
In one embodiment of the present disclosure, each database cluster or database of the distributed database system has its own access point to facilitate access by users or applications. In the related art, a user or an application may directly access the access point through the database access link address, but after switching the database master cluster or the master database, the database access link address needs to be reconfigured to access the database master cluster or the master database for a specific operation.
In one embodiment of the present disclosure, the first database as the master database is connected with the global access point through the first access point for connecting the first database to receive a specific operation on the master database via the database access link address, or the second database as the master database is connected with the global access point through the second access point for connecting the second database to receive a specific operation on the master database via the database access link address.
In one embodiment of the present disclosure, the receiving, by a global access point pointing to a master database, a specific operation to the master database via a database access link address and a database switching request includes: pointing the global access point to a corresponding address of an access point of a master database; receiving, by the global access point, a specific operation to the master database via the database access link address and a database switch request.
In one embodiment of the present disclosure, since the database access link address is linked to the global access point and the global access point points to a corresponding address of an access point of the master database, a user or an application can access the master database through the global access point and perform a specific operation without additionally adjusting the database access link address.
According to the technical scheme provided by the embodiment of the disclosure, receiving a specific operation and a database switching request to a master database through a global access point pointing to the master database by accessing a link address through the database includes: pointing the global access point to a corresponding address of an access point of a master database; the global access point receives the specific operation of the link address accessed by the database to the main database and the database switching request, so that the link address of the database can be kept unchanged without changing or restarting the related operation of a user when the cluster switching is carried out on the cross-regional database, and the user operation is simplified.
In one embodiment of the disclosure, the receiving a database switch request includes: checking whether a replication delay time required to replicate first data, which is a difference between a first database and a second database, from the first database, which is a master database, to the second database, which is a slave database, is less than a first threshold, wherein the switching of the first database, which is the master database, to the slave database and the second database, which is the slave database, to the master database according to the database switching request, includes: and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
In one embodiment of the present disclosure, when the replication delay time is less than the first threshold, the database switch may be completed quickly, which does not cause excessive delay for users and applications. However, if the replication delay time is equal to or greater than the first threshold, this means that the time for replicating the first data from the first database as the master database to the second database as the slave database is too long, and therefore, the database switching time becomes correspondingly long, and it is not suitable for performing the database switching. For example, the first threshold may be a value such as 10 seconds, 20 seconds, 30 seconds, or the like.
According to the technical scheme provided by the embodiment of the disclosure, the receiving the database switching request comprises: checking whether a replication delay time required to replicate first data, which is a difference between a first database and a second database, from the first database, which is a master database, to the second database, which is a slave database, is less than a first threshold, wherein the switching of the first database, which is the master database, to the slave database and the second database, which is the slave database, to the master database according to the database switching request, includes: and in response to the copying delay time being less than the first threshold, switching the first database serving as the master database to the slave database and switching the second database serving as the slave database to the master database according to the database switching request, wherein the switching of the databases can be performed under the condition that the data consistency of the first database and the second database is ensured, and the reliability and the accuracy of a user operation result after the switching of the databases are ensured.
In one embodiment of the disclosure, the switching a first database as a master database to a slave database and a second database as a slave database to a master database according to the database switching request in response to the replication delay time being less than the first threshold value includes: adding the address of the host where the first database is located into a white list of the second database; setting the first database to a read-only state; detecting that first data that is a difference between said first database and said second database has been synchronized to said second database; setting the second database to the particular operational state; the global access point is directed to an address of a second access point of a second database.
In one embodiment of the present disclosure, adding the address of the host where the first database is located to the white list of the second database allows the master database to switch from the first database to the second database, allowing the second database, which is the master database after the switch, to copy the differential first data to the first database, which is the slave database. In one embodiment of the present disclosure, setting the first database to a read-only state causes the first database to be no longer written to, ensuring that data in the two databases are not consistent before the switch is completed because the data in the first database cannot be copied to the second database due to the continuous writing. In one embodiment of the present disclosure, detecting that first data that is a difference between the first database and the second database has been synchronized to the second database refers to waiting for data in the first data to be fully synchronized to the second database after stopping writes to the first database. In one embodiment of the present disclosure, setting the second database to a particular operational state may refer to setting the second data to allow a particular operation, such as writing. In one embodiment of the present disclosure, the address of the second access point pointing the global access point to the second database refers to binding the global access point to the second database as a new master database.
According to the technical solution provided by the embodiment of the present disclosure, by responding to the replication delay time being smaller than the first threshold, according to the database switching request, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database includes: adding the address of the host where the first database is located into a white list of the second database; setting the first database to a read-only state; detecting that first data that is a difference between said first database and said second database has been synchronized to said second database; setting the second database to the particular operational state; the global access point points to the address of the second access point of the second database, so that the link address of the database can be kept unchanged when the cluster switching is carried out on the cross-regional database, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
In one embodiment of the present disclosure, replicating, from a first database as a master database to a second database as a slave database, first data that is a difference between the first database and the second database includes: in a case where the first database and the second database are located in different virtual private clouds, first data that is different between the first database and the second database is replicated from the first database to the second database through a cloud enterprise network or a private domain.
In one embodiment of the present disclosure, the virtual Private cloud vpc (virtual Private cloud): the method is an isolated network environment, the VPC networks and the traditional classical networks are logically and thoroughly isolated, and mutual access cannot be performed by default. Therefore, for a VPC scenario, databases or database clusters of a primary area and a secondary area are often under different VPCs, and in order to enable a global access point to work after cross-area switching, network access under different VPCs needs to be opened, which can be solved by using a cloud enterprise network or a private domain.
According to the technical scheme provided by the embodiment of the disclosure, copying first data which is different between a first database and a second database from the first database as a master database to the second database as a slave database comprises the following steps: under the condition that the first database and the second database are located in different virtual private clouds, the first data which is different between the first database and the second database is copied from the first database to the second database through a cloud enterprise network or a private domain, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of a user operation result are ensured under the condition of switching the databases.
In one embodiment of the present disclosure, the database control method further includes: copying second data that is different between the second database and the first database from the second database as a master database to the first database as a slave database.
In one embodiment of the present disclosure, after the switching is completed, the second database, which is the master database, may be performed with a specific operation such as a write operation, and the first database, which is the slave database, is no longer allowed to perform a specific operation such as a write operation, but can only perform a general operation such as a read operation. In this case, it is necessary to copy second data, which is different between the second database and the first database, from the second database as a master database to the first database as a slave database.
According to the technical scheme provided by the embodiment of the disclosure, by copying the second data which is different between the second database and the first database from the second database as a master database to the first database as a slave database, the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of the user operation result are ensured under the condition of switching databases.
Fig. 2a shows an exemplary schematic diagram of a database control system according to the related art.
As shown in fig. 2a, there is a database master cluster in the area a and a database slave cluster in the area B, and data in the master cluster is synchronized (copied) to the slave cluster in real time. The master cluster includes an access point a, a database node 1, a database node 2, and a database storage section. The slave cluster includes an access point B, a database node 1, a database node 2, and a database storage section. Both the access point a of the master cluster and the access point B of the slave cluster may provide reading capability to the user (or application). But the user (or application) has to use the link address of access point a of the main cluster for a write operation.
When a user initiates cross-region switching, the database in the region A becomes a slave cluster, and the database in the region B becomes a master cluster. At this point, if the user (or application) has to change the database link address configuration of the service if a write operation is to be performed, i.e. the link address of the access point of the master cluster needs to be adjusted. In this case, the user (or application) has to use the link address of the access point B of the master cluster for a write operation. In the related art solution, after the inter-region handover, the user is also required to change the link address configuration of the service, the related operation of the user needs to be changed or restarted, and the user operation is cumbersome.
FIG. 2b illustrates an exemplary schematic diagram of a database control system according to an embodiment of the present disclosure.
In the embodiment shown in fig. 2b, a distributed Database system, such as a Global Database Network (Global Database Network), consists of one Database cluster in the primary region (primary cluster instance) and several Database clusters in the secondary region (standby region) (or standby cluster instances). For example, a master cluster instance in a master region provides a user with a specific service such as a read-write service, and a standby cluster instance in a secondary region provides a user with a general service such as a read-only service. And performing real-time data synchronization (replication) between the main cluster instance and the standby cluster instance by constructing a replication link. The user (or application) can actively promote the standby cluster instance of the secondary area to the main cluster instance to switch the read-write service of the global database to the secondary area. The embodiment shown in fig. 2b mainly introduces a scheme for switching a specific service, such as a read-write service, from a primary area to a secondary area, which can keep the link address used by a user (or an application) for reading and writing unchanged while ensuring that RPO (Recovery Point object) is 0 during the switching process. In the embodiments of the present disclosure, RPO mainly refers to the amount of data loss during the migration handover process.
The scheme in fig. 2b may remain the same as the database master and database slave clusters in fig. 2a, with the difference that fig. 2b adds a global controller for global control, a first database controller for controlling the first database cluster, and a second database controller for controlling the second database cluster.
In the control system shown in fig. 2b, there is often one database controller per zone for service availability and user control, which is responsible for the management of database cluster instances in that zone. In order to manage the entire distributed database network, a global controller is introduced and a global access point is provided in addition to access point a and access point B, whose back-end permanently binds the master cluster access point, so its capabilities always remain the same as those of the master cluster access point. The global controller, the first database controller and the second database controller transmit control data through control links. The global controller controls the first database controller and the second database controller to perform data synchronization from the master database cluster to the slave database cluster.
For example, the access point a and the access point B may use SLB (Server Load Balance) VIP (Virtual IP) for Load balancing. To ensure that the global access point always aligns with the capabilities of the primary cluster access point, this may be accomplished by binding the global access point to the VIP corresponding to the primary cluster access point. Normally, the global access point capability always remains the same as the capability of the master cluster access point. Therefore, the service needing write operation only needs to use the global access point. When a user or an application initiates cross-region switching, the global access point becomes a back-end node of a new main cluster access point, and the read-write capability is kept unchanged.
In one embodiment, for a Private virtual cloud (VPC) (virtual Private cloud) scenario, the database clusters of the primary area and the secondary area are often under different VPCs, and in order to enable the global access point to work after cross-area switching, network access under different VPCs needs to be opened. This can be solved using a cloud enterprise network or a Private realm (Private Zone).
An example of a state transition procedure in a handover scheme across a regional database according to an embodiment of the present disclosure is described below, which may guarantee that RPO is 0 in the handover procedure.
0. Before a user (or application) initiates a cross-region switch, the distributed databases are all in a state of a database master cluster (master database cluster instance) synchronizing to a database slave cluster (standby database cluster instance) in real time, namely, an a _ to _ B _ synchronizing state.
1. When a user sends a switching request, the user checks whether the copying delay meets a condition (for example, the copying delay is required to be less than 30s) in real time, and if the switching condition is met, the user jumps to the add _ ip _ to _ whitelist state.
Add _ ip _ to _ whitelist state: and adding the host IP of the database master cluster instance A into the white list packet of the database slave cluster instance B.
3, alter _ a _ to _ ready state: the master database cluster instance a is set to read only.
Wait _ all _ data _ synchronized _ to _ B state: wait for all incremental data to synchronize to the standby database cluster instance B.
Alter _ B _ to _ readwrite state: the standby database cluster instance B is set to a read-write state.
Modify _ global _ endpoint _ to _ B state: the global access point is pointed to the VIP corresponding to the new primary cluster instance B.
B _ to _ A _ syncing state: the completion state is switched, at which point the data will be synchronized in real time from the new master database cluster instance B to the standby database cluster instance A.
Fig. 3 illustrates a block diagram of a database control system according to an embodiment of the present disclosure. As shown in fig. 3, the database control system 300 includes: global controller 310, first database 320, second database 330.
The global controller 310 includes: a receiving module 311, a switching module 312 and an executing module 313. The receiving module 311 is configured to receive a specific operation to the master database via the database access link address and a database switching request. The switching module 312 is configured to switch a first database as a master database to a slave database and a second database as a slave database to the master database according to the database switching request. The execution module 313 is configured to perform the specific operation on the switched master database via the database access link address.
According to the technical scheme provided by the embodiment of the disclosure, the system comprises a global controller, a first database and a second database, wherein the global controller comprises: a receiving module configured to receive a specific operation on the master database via the database access link address and a database switching request; a switching module configured to switch a first database as a master database to a slave database and a second database as a slave database to the master database according to the database switching request; the execution module is configured to execute the specific operation on the switched main database by accessing the link address through the database, so that the link address of the database can be kept unchanged without changing or restarting the related operation of a user when the cluster switching is performed on the cross-regional database, and the user operation is simplified.
In one embodiment of the present disclosure, the database control system 300 may further include: a first database controller configured to copy first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database.
According to the technical scheme provided by the embodiment of the disclosure, the first database controller is configured to copy the first data which is different between the first database and the second database from the first database as a master database to the second database as a slave database, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of the user operation result are ensured under the condition of switching the databases.
In one embodiment of the present disclosure, the first database and the second database are different database clusters belonging to the same database network.
According to the technical scheme provided by the embodiment of the disclosure, the first database and the second database belong to different database clusters of the same database network, so that when the cluster switching is performed on the cross-regional database, the link address of the database is kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
In one embodiment of the disclosure, the global controller 310 may further include a global access point, and the receiving module is further configured to: receiving, by a global access point pointing to a master database, a specific operation to the master database and a database switching request via a database access link address for linking to the global access point.
According to the technical solution provided by the embodiment of the present disclosure, the global controller includes a global access point, and the receiving module is further configured to: the method comprises the steps that a global access point pointing to a main database receives a specific operation of a database access link address on the main database and a database switching request, wherein the database access link address is used for linking to the global access point, so that the link address of the database can be kept unchanged when cluster switching is carried out on a cross-regional database, related operations of a user do not need to be changed or restarted, and user operation is simplified.
In one embodiment of the present disclosure, the first database includes a first access point, and the second database includes a second access point, wherein the first database as a master database is connected with the global access point through the first access point for connecting the first database to receive a specific operation on the master database via a database access link address, or the second database as a master database is connected with the global access point through the second access point for connecting the second database to receive a specific operation on the master database via a database access link address.
According to the technical scheme provided by the embodiment of the disclosure, the first database comprises a first access point, and the second database comprises a second access point, wherein the first database as a main database is connected with the global access point through the first access point for connecting the first database to receive the specific operation of accessing the link address to the main database through the database, or the second database as a main database is connected with the global access point through the second access point for connecting the second database to receive the specific operation of accessing the link address to the main database through the database, when the cross-regional database is subjected to cluster switching, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
In one embodiment of the present disclosure, the receiving module 311 includes: a pointing submodule configured to point the global access point to a corresponding address of an access point of a master database; a receiving sub-module configured to receive a specific operation to the master database via the database access link address and a database switching request through the global access point.
According to the technical scheme provided by the embodiment of the disclosure, the receiving module comprises: a pointing submodule configured to point the global access point to a corresponding address of an access point of a master database; the receiving submodule is configured to receive a specific operation of accessing the link address to the main database through the database and a database switching request through the global access point, and can keep the link address of the database unchanged without changing or restarting the related operation of a user when performing cluster switching on the cross-regional database, thereby simplifying the user operation.
In one embodiment of the present disclosure, the receiving module 311 is further configured to: checking whether a replication delay time required to replicate first data, which is a difference between a first database as a master database and a second database as a slave database, from the first database to the second database is less than a first threshold, wherein the switching module 312 is further configured to: and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
According to the technical scheme provided by the embodiment of the disclosure, the receiving module is further configured to: checking whether a replication delay time required to replicate first data, which is a difference between a first database as a master database and a second database as a slave database, from the first database to the second database is less than a first threshold, wherein the switching module is further configured to: and in response to the copying delay time being less than the first threshold, switching the first database serving as the master database to the slave database and switching the second database serving as the slave database to the master database according to the database switching request, wherein the switching of the databases can be performed under the condition that the data consistency of the first database and the second database is ensured, and the reliability and the accuracy of a user operation result after the switching of the databases are ensured.
In one embodiment of the present disclosure, the switching module 312 may include: the adding sub-module is configured to add the address of the host where the first database is located into a white list of the second database; a first setting submodule configured to set the first database to a read-only state; a detection sub-module configured to detect that first data that is a difference between the first database and the second database has been synchronized to the second database; a second setting sub-module that sets the second database to the specific operation state; a pointing submodule configured to point the global access point to an address of a second access point of a second database.
According to the technical scheme provided by the embodiment of the disclosure, the switching module comprises: the adding sub-module is configured to add the address of the host where the first database is located into a white list of the second database; a first setting submodule configured to set the first database to a read-only state; a detection sub-module configured to detect that first data that is a difference between the first database and the second database has been synchronized to the second database; a second setting sub-module that sets the second database to the specific operation state; and the pointing submodule is configured to point the global access point to the address of the second access point of the second database, so that when the cluster switching is performed on the cross-regional database, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
In one embodiment of the present disclosure, the first database controller is further configured to: in a case where the first database and the second database are located in different virtual private clouds, first data that is different between the first database and the second database is replicated from the first database to the second database through a cloud enterprise network or a private domain.
According to the technical solution provided by the embodiment of the present disclosure, the first database controller is further configured to: under the condition that the first database and the second database are located in different virtual private clouds, the first data which is different between the first database and the second database is copied from the first database to the second database through a cloud enterprise network or a private domain, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of a user operation result are ensured under the condition of switching the databases.
In one embodiment of the present disclosure, the database control system 300 may further include: a second database controller configured to copy second data, which is different between the second database and the first database, from the second database as a master database to the first database as a slave database.
According to the technical scheme provided by the embodiment of the disclosure, the second database controller is configured to copy the second data which is different between the second database and the first database from the second database as a master database to the first database as a slave database, so that the data consistency of the first database and the second database can be maintained, and the reliability and the accuracy of the user operation result are ensured under the condition of switching databases.
In one embodiment of the present disclosure, the specific operation includes at least a write operation.
According to the technical scheme provided by the embodiment of the disclosure, the specific operation at least comprises a write operation, so that when the cluster switching is performed on the cross-regional database, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
It will be understood by those skilled in the art that the technical solution described with reference to fig. 3 may be combined with the embodiment described with reference to fig. 1 to 2b, so as to have the technical effects achieved by the embodiment described with reference to fig. 1 to 2 b. For details, reference may be made to the description made above with reference to fig. 1 to 2b, and details thereof are not repeated herein.
Fig. 4 shows a flow chart of a database switching method according to an embodiment of the present disclosure.
As shown in fig. 4, the database switching method includes steps S410, S420, S430, and S440.
In step S410, first data that is different between the first database and the second database is copied from the first database as the master database to the second database as the slave database.
In step S420, a database switch request is received.
In step S430, in response to receiving the database switch request, it is checked whether a replication delay time required to replicate first data, which is a difference between a first database as a master database and a second database as a slave database, is less than a first threshold.
In step S440, in response to the replication delay time being less than the first threshold, a first database as a master database is switched to a slave database and a second database as a slave database is switched to a master database according to the database switching request.
According to the technical scheme provided by the embodiment of the disclosure, the differential first data between a first database and a second database is copied from the first database serving as a master database to the second database serving as a slave database; receiving a database switching request; in response to receiving the database switch request, checking whether a replication delay time required to replicate first data, which is a difference between a first database as a master database and a second database as a slave database, is less than a first threshold value; and in response to the copying delay time being less than the first threshold, switching the first database serving as the master database to the slave database and switching the second database serving as the slave database to the master database according to the database switching request, so that when the cluster switching is performed on the cross-regional database, the link address of the database can be kept unchanged, the related operation of a user does not need to be changed or restarted, and the user operation is simplified.
It will be understood by those skilled in the art that the technical solution described with reference to fig. 4 may be combined with the embodiment described with reference to fig. 1 to 3, so as to have the technical effects achieved by the embodiment described with reference to fig. 1 to 3. For details, reference may be made to the description made above with reference to fig. 1 to 3, and details thereof are not repeated herein.
Fig. 5 shows a block diagram of an electronic device according to an embodiment of the present disclosure.
The disclosed embodiment also provides an electronic device, as shown in fig. 5, including at least one processor 501; and a memory 502 communicatively coupled to the at least one processor 501; wherein the memory 502 stores instructions executable by the at least one processor 501, the instructions being executable by the at least one processor 501 to implement the steps of:
receiving a specific operation of the main database through the database access link address and a database switching request;
according to the database switching request, switching a first database serving as a master database into a slave database, and switching a second database serving as a slave database into the master database;
and executing the specific operation on the switched master database through the database access link address.
In one embodiment of the present disclosure, before the receiving the specific operation on the master database via the database access link address and the database switching request, the method further includes:
copying first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database.
In one embodiment of the present disclosure, the first database and the second database are different database clusters belonging to the same database network.
In one embodiment of the present disclosure, the receiving a specific operation to the master database via the database access link address and a database switching request includes:
receiving, by a global access point pointing to a master database, a specific operation to the master database and a database switching request via a database access link address for linking to the global access point.
In one embodiment of the present disclosure, the first database as the master database is connected with the global access point through the first access point for connecting the first database to receive a specific operation on the master database via the database access link address, or
The second database, which is a master database, is connected with the global access point through a second access point for connecting the second database to receive a specific operation on the master database via the database access link address.
In one embodiment of the present disclosure, the receiving, by a global access point pointing to a master database, a specific operation to the master database via a database access link address and a database switching request includes:
pointing the global access point to a corresponding address of an access point of a master database;
receiving, by the global access point, a specific operation to the master database via the database access link address and a database switch request.
In one embodiment of the present disclosure, the receiving a database switching request includes:
checking whether a replication delay time required to replicate first data that is a difference between a first database as a master database and a second database as a slave database is less than a first threshold,
wherein, according to the database switching request, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database comprises:
and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
In one embodiment of the disclosure, the switching a first database as a master database to a slave database and a second database as a slave database to a master database according to the database switching request in response to the replication delay time being less than the first threshold value includes:
adding the address of the host where the first database is located into a white list of the second database;
setting the first database to a read-only state;
detecting that first data that is a difference between said first database and said second database has been synchronized to said second database;
setting the second database to the particular operational state;
the global access point is directed to an address of a second access point of a second database.
In one embodiment of the present disclosure, replicating, from a first database as a master database to a second database as a slave database, first data that is a difference between the first database and the second database includes:
in a case where the first database and the second database are located in different virtual private clouds, first data that is different between the first database and the second database is replicated from the first database to the second database through a cloud enterprise network or a private domain.
In one embodiment of the present disclosure, the database control method further includes:
copying second data that is different between the second database and the first database from the second database as a master database to the first database as a slave database.
In one embodiment of the present disclosure, the specific operation includes at least a write operation.
In one embodiment of the present disclosure, the memory 502 stores instructions executable by the at least one processor 501, the instructions being further executable by the at least one processor 501 to implement the steps of:
copying first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database;
receiving a database switching request;
in response to receiving the database switch request, checking whether a replication delay time required to replicate first data, which is a difference between a first database as a master database and a second database as a slave database, is less than a first threshold value;
and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
Fig. 6 is a schematic structural diagram of a computer system suitable for implementing a database control method or a database switching method according to an embodiment of the present disclosure.
As shown in fig. 6, the computer system 600 includes a processing unit 601 which can execute various processes in the embodiments shown in the above-described drawings in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the system 600 are also stored. The processing unit 601, the ROM602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary. The processing unit 601 may be implemented as a CPU, a GPU, a TPU, an FPGA, an NPU, or other processing units.
In particular, according to embodiments of the present disclosure, the methods described above with reference to the figures may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a medium readable thereby, the computer program comprising program code for performing the methods of the figures. In such embodiments, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowcharts or block diagrams may represent a module, a program segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present disclosure may be implemented by software or hardware. The units or modules described may also be provided in a processor, and the names of the units or modules do not in some cases constitute a limitation of the units or modules themselves.
As another aspect, the present disclosure also provides a computer-readable storage medium, which may be the computer-readable storage medium included in the node in the above embodiment; or it may be a separate computer readable storage medium not incorporated into the device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the methods described in the present disclosure.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is possible without departing from the inventive concept. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.

Claims (25)

1. A database control method, comprising:
receiving a specific operation of the main database through the database access link address and a database switching request;
according to the database switching request, switching a first database serving as a master database into a slave database, and switching a second database serving as a slave database into the master database;
and executing the specific operation on the switched master database through the database access link address.
2. The method of claim 1, further comprising, prior to said receiving a database switch request and a specific operation on a master database via a database access link address:
copying first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database.
3. The method of claim 1, the first database and the second database being different database clusters belonging to the same database network.
4. The method of any of claims 1 to 3, the receiving of the specific operation on the master database via the database access link address and the database switch request, comprising:
receiving, by a global access point pointing to a master database, a specific operation to the master database and a database switching request via a database access link address for linking to the global access point.
5. The method of claim 4, wherein the first database as a master database is connected to the global access point through the first access point for connecting the first database to receive a specific operation on the master database via a database access link address, or
The second database, which is a master database, is connected with the global access point through a second access point for connecting the second database to receive a specific operation on the master database via the database access link address.
6. The method of claim 5, the receiving, by a global access point pointing to a master database, a specific operation to the master database via a database access link address and a database switch request, comprising:
pointing the global access point to a corresponding address of an access point of a master database;
receiving, by the global access point, a specific operation to the master database via the database access link address and a database switch request.
7. The method of claim 5, the receiving a database switch request comprising:
checking whether a replication delay time required to replicate first data that is a difference between a first database as a master database and a second database as a slave database is less than a first threshold,
wherein, according to the database switching request, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database comprises:
and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
8. The method of claim 7, wherein switching a first database as a master database to a slave database and a second database as a slave database to a master database in accordance with the database switch request in response to the replication delay time being less than the first threshold comprises:
adding the address of the host where the first database is located into a white list of the second database;
setting the first database to a read-only state;
detecting that first data that is a difference between said first database and said second database has been synchronized to said second database;
setting the second database to the particular operational state;
the global access point is directed to an address of a second access point of a second database.
9. The method of claim 2, replicating from a first database as a master database to a second database as a slave database first data that is differential between the first database and the second database comprises:
in a case where the first database and the second database are located in different virtual private clouds, first data that is different between the first database and the second database is replicated from the first database to the second database through a cloud enterprise network or a private domain.
10. The method of any of claims 1 to 3, further comprising:
copying second data that is different between the second database and the first database from the second database as a master database to the first database as a slave database.
11. The method according to any of claims 1 to 3, the specific operation comprising at least a write operation.
12. A database control system includes a global controller, a first database, and a second database, wherein,
the global controller includes:
a receiving module configured to receive a specific operation on the master database via the database access link address and a database switching request;
a switching module configured to switch a first database as a master database to a slave database and a second database as a slave database to the master database according to the database switching request;
an execution module configured to execute the specific operation on the switched master database via the database access link address.
13. The system of claim 12, further comprising:
a first database controller configured to copy first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database.
14. The system of claim 12, the first database and the second database being different database clusters belonging to the same database network.
15. The system of any of claims 12 to 14, the global controller comprising a global access point, the receiving module further configured to:
receiving, by a global access point pointing to a master database, a specific operation to the master database and a database switching request via a database access link address for linking to the global access point.
16. The system of claim 15, the first database comprising a first access point and the second database comprising a second access point, wherein,
the first database as a master database is connected with the global access point through the first access point for connecting the first database to receive a specific operation on the master database via the database access link address, or
The second database, which is a master database, is connected with the global access point through a second access point for connecting the second database to receive a specific operation on the master database via the database access link address.
17. The system of claim 16, the receiving module comprising:
a pointing submodule configured to point the global access point to a corresponding address of an access point of a master database;
a receiving sub-module configured to receive a specific operation to the master database via the database access link address and a database switching request through the global access point.
18. The system of claim 16, the receiving module further configured to:
checking whether a replication delay time required to replicate first data that is a difference between a first database as a master database and a second database as a slave database is less than a first threshold,
wherein the switching module is further configured to:
and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
19. The system of claim 18, the switching module comprising:
the adding sub-module is configured to add the address of the host where the first database is located into a white list of the second database;
a first setting submodule configured to set the first database to a read-only state;
a detection sub-module configured to detect that first data that is a difference between the first database and the second database has been synchronized to the second database;
a second setting sub-module that sets the second database to the specific operation state;
a pointing submodule configured to point the global access point to an address of a second access point of a second database.
20. The system of claim 13, the first database controller further configured to:
in a case where the first database and the second database are located in different virtual private clouds, first data that is different between the first database and the second database is replicated from the first database to the second database through a cloud enterprise network or a private domain.
21. The system of any of claims 12 to 14, further comprising:
a second database controller configured to copy second data, which is different between the second database and the first database, from the second database as a master database to the first database as a slave database.
22. The system of any of claims 12 to 14, the particular operation comprising at least a write operation.
23. A database switching method comprises the following steps:
copying first data, which is a difference between a first database and a second database, from the first database as a master database to the second database as a slave database;
receiving a database switching request;
in response to receiving the database switch request, checking whether a replication delay time required to replicate first data, which is a difference between a first database as a master database and a second database as a slave database, is less than a first threshold value;
and responding to the copying delay time being smaller than the first threshold, switching a first database as a master database to a slave database and switching a second database as a slave database to the master database according to the database switching request.
24. An electronic device comprising a memory and a processor; wherein,
the memory is to store one or more computer instructions, wherein the one or more computer instructions are to be executed by the processor to implement the method of any of claims 1-11, 23.
25. A readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the method of any one of claims 1-11, 23.
CN202010899559.8A 2020-08-31 2020-08-31 Database control method, database control system, database switching method, electronic equipment and storage medium Pending CN112199440A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010899559.8A CN112199440A (en) 2020-08-31 2020-08-31 Database control method, database control system, database switching method, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010899559.8A CN112199440A (en) 2020-08-31 2020-08-31 Database control method, database control system, database switching method, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112199440A true CN112199440A (en) 2021-01-08

Family

ID=74005145

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010899559.8A Pending CN112199440A (en) 2020-08-31 2020-08-31 Database control method, database control system, database switching method, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112199440A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106534226A (en) * 2015-09-09 2017-03-22 阿里巴巴集团控股有限公司 Processing method and apparatus for data migration
CN106570021A (en) * 2015-10-10 2017-04-19 阿里巴巴集团控股有限公司 Database connection establishment method and device
CN109388630A (en) * 2018-09-29 2019-02-26 北京京东金融科技控股有限公司 Database switching method, system, electronic equipment and computer-readable medium
CN111209265A (en) * 2018-11-22 2020-05-29 华为技术有限公司 Database switching method and terminal equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106534226A (en) * 2015-09-09 2017-03-22 阿里巴巴集团控股有限公司 Processing method and apparatus for data migration
CN106570021A (en) * 2015-10-10 2017-04-19 阿里巴巴集团控股有限公司 Database connection establishment method and device
CN109388630A (en) * 2018-09-29 2019-02-26 北京京东金融科技控股有限公司 Database switching method, system, electronic equipment and computer-readable medium
CN111209265A (en) * 2018-11-22 2020-05-29 华为技术有限公司 Database switching method and terminal equipment

Similar Documents

Publication Publication Date Title
US11563809B2 (en) Live migration of clusters in containerized environments
US10091120B2 (en) Secondary input queues for maintaining a consistent network state
US20060047776A1 (en) Automated failover in a cluster of geographically dispersed server nodes using data replication over a long distance communication link
CN103620578B (en) Local cloud computing via network segmentation
JP5509313B2 (en) Method and apparatus for live replication
US20080104588A1 (en) Creation of temporary virtual machine clones of multiple operating systems
EP3311272B1 (en) A method of live migration
US20210089379A1 (en) Computer system
CN111158949A (en) Configuration method, switching method and device of disaster recovery architecture, equipment and storage medium
US12058210B2 (en) Multichannel virtual internet protocol address affinity
CN112148430A (en) Method for online safe migration of virtual machine with virtual network function
CN116954816A (en) Container cluster control method, device, equipment and computer storage medium
CN111459416A (en) Distributed storage-based thermal migration system and migration method thereof
CN110113217B (en) Micro-service management method, device, management platform and storage medium
CN112199440A (en) Database control method, database control system, database switching method, electronic equipment and storage medium
US20200089801A1 (en) Disturbance-free partitioning and migration of data from one storage account to another storage account
CN109992447B (en) Data copying method, device and storage medium
CN111400098B (en) Copy management method and device, electronic equipment and storage medium
JP2021507351A (en) Managing data written to the storage controller over the bus interface during remote copy operations
US11853785B1 (en) Virtual machine cloning and resource configuration
JP3239463B2 (en) Electronic conference system
US20200125387A1 (en) System and method for gradually switching computer environmental between local computer and remote computer
CN113553314A (en) Service processing method, device, equipment and medium of super-convergence system
CN113138722B (en) Replication snapshot method, system and medium for distributed block storage system
CN112948348B (en) Operation and maintenance control method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20210108

RJ01 Rejection of invention patent application after publication