CN111200532A - Method, device, equipment and medium for master-slave switching of database cluster node - Google Patents

Method, device, equipment and medium for master-slave switching of database cluster node Download PDF

Info

Publication number
CN111200532A
CN111200532A CN202010002193.XA CN202010002193A CN111200532A CN 111200532 A CN111200532 A CN 111200532A CN 202010002193 A CN202010002193 A CN 202010002193A CN 111200532 A CN111200532 A CN 111200532A
Authority
CN
China
Prior art keywords
node
master
slave
name
instance
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
CN202010002193.XA
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.)
Guangzhou Huya Technology Co Ltd
Original Assignee
Guangzhou Huya Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Huya Technology Co Ltd filed Critical Guangzhou Huya Technology Co Ltd
Priority to CN202010002193.XA priority Critical patent/CN111200532A/en
Publication of CN111200532A publication Critical patent/CN111200532A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Hardware Redundancy (AREA)

Abstract

The embodiment of the invention discloses a method, a device, equipment and a medium for database cluster node master-slave switching. The method comprises the following steps: determining that a first master node fails, wherein the first master node is set to establish master-slave synchronization with a second master node, and the first master node is set to establish master-slave synchronization with a first slave node; taking the instance original access address of the first slave node as the instance current access address of the first master node to replace the instance original access address of the first master node; and setting the first slave node and the second master node to establish master-master synchronization so that the application service continues to access the database according to the name of the first master node. According to the technical scheme, when the cluster node fails, the cluster node is automatically switched to the available node, and transparent master-slave switching access is realized, so that a service user cannot sense the switching.

Description

Method, device, equipment and medium for master-slave switching of database cluster node
Technical Field
The embodiment of the invention relates to a database technology, in particular to a method, a device, equipment and a medium for database cluster node master-slave switching.
Background
Mysql is a relational database management system that keeps data in different tables, rather than putting all the data in one large data warehouse, thereby increasing processing speed and flexibility. But MySQL is inherently of high availability characteristics that are not sufficient to support various incidents in a production environment. For example, this would make the Mysql instance unusable after the machine on which it is located is down. The best solution for this situation is to switch the Mysql standby instance to primary to provide normal service.
In the prior art, the Mysql instance mainly implements master-slave switching based on a proxy layer or a client SDK (Software development kit), but has a few disadvantages, for example, a service user needs to manually maintain access addresses of a master-slave cluster, and switches to other available nodes when a current cluster node is unavailable; when the database agent layer realizes master-slave switching, the switching service of the database agent layer needs to be developed, so that the development and maintenance cost is high and the performance loss is large; the client SDK realizes the development and maintenance cost in case of instance intrusion and iteration; when a service party configures a Host (Host) scheme, a local Host file needs to be manually replaced, and service can only take effect after Host restart, so that the master-slave switching time is too long, and the like.
Disclosure of Invention
The embodiment of the invention provides a method, a device, equipment and a medium for database cluster node master-slave switching, which are used for optimizing the prior technical scheme and realizing transparent master-slave switching access when a cluster node fails.
In a first aspect, an embodiment of the present invention provides a database cluster node master-slave switching method based on name service, including:
determining that a first master node fails, wherein the first master node is set to establish master-slave synchronization with a second master node, and the first master node is set to establish master-slave synchronization with a first slave node;
taking the instance original access address of the first slave node as the instance current access address of the first master node to replace the instance original access address of the first master node;
and setting the first slave node and the second master node to establish master-master synchronization so that the application service continues to access the database according to the name of the first master node.
In a second aspect, an embodiment of the present invention further provides a device for database cluster node master-slave handover based on name service, where the device includes:
the system comprises a fault detection module, a first slave node and a second slave node, wherein the fault detection module is used for determining that a first master node has a fault, the first master node is set to establish master-slave synchronization with the second master node, and the first master node is set to establish master-slave synchronization with the first slave node;
a master node access address replacing module, configured to use an instance original access address of the first slave node as an instance current access address of the first master node to replace the instance original access address of the first master node;
and the master-master synchronization setting module is used for setting the first slave node and the second master node to establish master-master synchronization so that the application service can continuously access the database according to the name of the first master node.
In a third aspect, an embodiment of the present invention further provides a computer device, where the computer device includes:
one or more processors;
a memory for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the method for name service based database cluster node master-slave switching according to any embodiment.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for master-slave switching of a database cluster node based on name service according to any embodiment.
In the embodiment of the invention, the first master node and the second master node establish master-slave synchronization, the first master node and the first slave node establish master-slave synchronization, when the first master node is detected to be out of order, the instance access address of the first master node is only required to be modified and replaced by the instance original access address of the first slave node, and the first slave node and the second master node are set to establish master-slave synchronization, so that the application service can still access the database through the name of the first master node, however, the database instance accessed by the application service is automatically switched from the instance of the first master node to the instance of the first slave node.
Drawings
Fig. 1 is a flowchart of a method for master-slave switching of a database cluster node based on name service according to an embodiment of the present invention;
fig. 2 is a schematic diagram of main/standby deployment of a Mysql example across an internet data center according to an embodiment of the present invention;
fig. 3 is a flowchart of a method for database cluster node master-slave switching based on name service according to a second embodiment of the present invention;
fig. 4 is a schematic diagram of deployment of a Mysql high availability scheme based on a domain name system and a name service according to a second embodiment of the present invention;
fig. 5 is a schematic block diagram of a device for performing master-slave handover on a database cluster node based on name service according to a third embodiment of the present invention;
fig. 6 is a schematic structural diagram of a computer device according to a fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a method for database cluster node master-slave switching based on name service according to an embodiment of the present invention, where this embodiment is applicable to a case where a database cluster node fails and needs to perform master-slave switching, and the method may be executed by a cluster node master-slave switching apparatus based on name service according to any embodiment of the present invention, where the apparatus may be composed of hardware and/or software and may be generally integrated in a computer device, for example, a computer device running a database management system.
As shown in fig. 1, the method for database cluster node master-slave switching based on name service provided in this embodiment includes the following steps:
s110, determining that a first main node fails, wherein the first main node is set to establish main-master synchronization with a second main node, and the first main node is set to establish master-slave synchronization with a first slave node.
The first master node, the first slave node and the second master node are different nodes in master-slave deployment of a database cluster node, wherein the first master node and the second master node are nodes in which databases are deployed in different IDCs (Internet Data centers ), the first master node and the first slave node are nodes in which databases are deployed in the same IDC (machine room for short), the number of the first master nodes is one, and the number of the first slave nodes may be multiple.
And master-master synchronization refers to a process that two master nodes authorize connection with each other, read the log of the other side and update the log to a local database, and as long as the data of one node changes, the data of the other node changes.
The master-slave synchronization refers to a process that a master node authorizes remote connection of slave nodes, the slave nodes read master node logs and update the master node logs to a local database, and after the master node writes data, the slave nodes can automatically synchronize, namely the slave nodes change along with the master node.
It should be noted that, in this embodiment, any failed master node may be regarded as a first master node, and correspondingly, a node that establishes master-slave synchronization with the failed master node is a first slave node, and a node that establishes master-master synchronization with the failed master node is a second master node.
Taking the database as Mysql as an example, the Mysql is respectively deployed in two or more IDCs, at least one or more main nodes are designated, and the slave nodes can be expanded as required. Each computer room is provided with multiple instances, high availability of the cluster is guaranteed, data synchronization is completed between the master cluster and the slave cluster through the binlog, and data consistency is kept. Fig. 2 is a schematic diagram of main and standby deployment of a common Mysql example across an internet data center, where an M1 node is a master node of a computer room a database, an S1 node is a master node of a computer room B database, an S2 node is a slave node of an M1 node of a computer room a, and an S3 node is a slave node of an S1 node of a computer room B.
In an example, referring to fig. 2, the first master node is an M1 node, the first slave node is an S2 node, the second master node is an S1 node, the second slave node is an S3 node, the first master node establishes a master-master sync with the second master node, the first master node establishes a master-slave sync with the first slave node, and the second master node establishes a master-slave sync with the second slave node.
A Database Management System (DMS) detects whether each master node has a failure and needs to be switched.
Specifically, when determining that the first master node fails, the DMS may determine that the first master node fails according to a heartbeat signal of a lower instance of the first master node.
The DMS sends heartbeat signals to the instances under the main nodes at regular time, whether the main nodes break down or not is determined according to whether the main nodes reply the heartbeat signals or not, if the DMS cannot receive the heartbeat signals of the first main node, the first main node can be determined to break down, and when the failure meets set conditions, the master-slave switching of the node of the machine room where the first main node is located is determined to be needed.
After determining that the first master node fails, the first slave node corresponding to the first master node actively breaks the master-slave synchronization with the first master node, and the second master node corresponding to the second master node also actively breaks the master-slave synchronization with the first master node.
S120, taking the original access address of the first slave node as the current access address of the first master node to replace the original access address of the first master node.
And modifying the instance access address of the first master node, specifically, modifying the instance access address of the first master node into the instance original access address of the first slave node.
For example, if the instance original access address of the first master node is x.x.x.1 and the instance original access address of the first slave node is x.x.x.2, the modified instance access address of the first master node is x.x.x.2.
S130, setting the first slave node and the second master node to establish master-master synchronization so that the application service can continuously access the database according to the name of the first master node.
After the first slave node is used for replacing the failed first master node and the second master node to establish the master-master synchronization, that is, after the first slave node and the second master node are set to establish the master-master synchronization, the data synchronization can be realized.
In this embodiment, the Host (Host) application service (i.e., the business user) implements database access based on a name service. The name service bears an important role of operation and maintenance automation, and shields back-end node information such as ip of a physical machine, pod name of a container and the like by abstracting with a name. The systems can interact and communicate through names, ip or pod names corresponding to the names change, and a service calling party does not need to care about the change, so that the systems are decoupled, and the cost of the inter-system connection is reduced.
After the name service is deployed, the DMS automatically registers the name service when the database service is started, and the name service provides a unified name to the service user externally, for example, the name of the M1 node (i.e., the first master node) is "M1. mysql", the name of the S2 node (i.e., the first slave node) is "S2. mysql", the name of the S1 node (i.e., the second master node) is "S1. mysql", the name of the S3 node (i.e., the second slave node) is "S3. mysql", and the access request can be resolved to the IDC nearby according to the source address of the service user internally.
After the current access address of the instance of the first master node is modified to the original access address of the instance of the first slave node, the name of the first master node is not modified, for example, it is still "m 1. mysql", but the current access address of the instance of the first master node already points to the first slave node. At this time, when the Host application service accesses the database based on the name "m 1. mysql", it accesses the first master node and actually accesses the first slave node for the Host application service, and the database cluster node has completed the master-slave switching.
Further, if the failure recovery of the first master node is determined, taking the instance original access address of the first master node as the instance current access address of the first master node to replace the instance original access address of the first slave node; and setting the first master node and the second master node to establish master-slave synchronization, and setting the first master node and the first slave node to establish master-slave synchronization.
And if the DMS determines that the fault of the first main node is recovered according to the heartbeat signal, the example current access address of the first main node is replaced to the example original access address, and the previous example is continued, namely the example current access address of the first main node is replaced to the example original access address X.X.X.1 of the first main node from the example original access address X.X.X.2 of the first slave node.
Meanwhile, the first master node establishes master-slave synchronization with the second master node again, and the first master node recovers the master-slave synchronization with the first slave node, namely, restores the master-slave deployment state before the failure of the first master node.
In the embodiment of the invention, the first master node and the second master node establish master-slave synchronization, the first master node and the first slave node establish master-slave synchronization, when the first master node is detected to be out of order, the instance access address of the first master node is only required to be modified and replaced by the instance original access address of the first slave node, and the first slave node and the second master node are set to establish master-slave synchronization, so that the application service can still access the database through the name of the first master node, however, the database instance accessed by the application service is automatically switched from the instance of the first master node to the instance of the first slave node.
Example two
This embodiment is embodied on the basis of the foregoing embodiment, wherein after the setting of the first slave node and the second master node to establish master-master synchronization, the method further includes:
registering the Name of the first main node and the instance original access address of the first slave node to a matched Name server, and updating registered information in the Name server, so that the Name server pushes the updated registered information to a host Domain Name System (DNS) proxy component in real time;
wherein the host DNS proxy component is configured to intercept and resolve a DNS request for the application service, and respond to the DNS request based on a name service when the DNS request is directed to an internal local area network.
As shown in fig. 3, the method of this embodiment specifically includes:
s310, determining that a first main node fails, wherein the first main node is set to establish main-master synchronization with a second main node, and the first main node is set to establish master-slave synchronization with a first slave node.
S320, taking the original access address of the first slave node as the current access address of the first master node to replace the original access address of the first master node.
S330, setting the first slave node and the second master node to establish master-master synchronization.
S340, registering the name of the first main node and the instance original access address of the first slave node to a matched name server, and updating registered information in the name server, so that the name server pushes the updated registered information to a host DNS proxy component in real time.
Taking the first master node as an example, the registered information in the name server is the name of the first master node and the instance original access address of the first master node, the name of the first master node and the instance original access address of the first slave node are registered to the matched name server, and the registered information in the name server is updated to the name of the first master node and the instance original access address of the first slave node.
Wherein the host DNS proxy component is configured to intercept and resolve a DNS request for the application service, and respond to the DNS request based on a name service when the DNS request is directed to an internal local area network.
And a DNS proxy component (DNS-f component) integrated in the Host, intercepting DNS requests of all native application services by modifying a native/conf/resolve. conf file, resolving the DNS requests after intercepting the DNS requests, determining an instance access address of a target node corresponding to the name of 'M1. mysql' if the DNS requests refer to an internal local area network and a domain name corresponding to the DNS requests is registered in a name server, such as 'M1. mysql', and returning to the corresponding application services, thereby realizing the response to the DNS requests.
As a specific implementation manner, the host DNS proxy component is specifically configured to, if it is determined that the DNS request points to an internal local area network, determine, according to an internal local area network domain name corresponding to the DNS request, a target node corresponding to the DNS request after directly determining or accessing a name server in a cache, and return an instance current access address of the target node to the application service, so that the application performs access based on the instance current access address.
When determining that the DNS request points to the internal lan, the DNS-f component may directly access the name server according to the internal lan domain name corresponding to the DNS request to obtain the instance access address of the target node corresponding to the internal lan domain name, and return the instance access address to the corresponding application service.
The DNS-f component can also cache the result of the name which is queried locally, update the information in the cache by monitoring the name change of the name service, and realize the real-time perception of the change of the node. Furthermore, when it is determined that the DNS request is directed to the internal lan, the local lan domain name corresponding to the DNS request may be directly searched in the cache to obtain the instance access address of the target node corresponding to the local lan domain name, and the instance access address is quickly returned to the corresponding application service. If the name server is not found in the cache, the name server is accessed.
Further, the host DNS proxy component is further specifically configured to, if it is determined that the DNS request is directed to the public network, forward the DNS request to a public network DNS server for resolution, and transmit a result returned by the public network DNS server to the corresponding application service, so that the corresponding application service performs corresponding access based on the returned result.
As an optional implementation manner, when the registration of the name of the first master node and the instance original access address of the first slave node to the matching name server is implemented, the name of the first master node and the instance original access address of the first slave node are pushed to the global load balancing server, so that the load balancing server determines the matching name server according to the name of the first master node, and registers the name of the first master node and the instance original access address of the first slave node to the matching name server.
To ensure the accuracy of name services, name services cannot be implemented across regions, and therefore, specialized name servers are provided for different regions. When the database management system modifies the instance access address of the target node, the name of the target node (i.e. the intranet domain name) and the corresponding modified instance access address are firstly sent to a global Load balancing (GSLB) server, so that the GSLB server sends the registration information to a name server matched with the intranet domain name. And after receiving the information, the matched name server updates the related registered information.
The technical scheme is a database cluster cross-IDC active/standby deployment scheme based on DNS proxy service and name service, and under the condition that any node fails, a service user can rapidly switch access flow to an available backup cluster without any modification, so that extremely high availability of the system is ensured. In addition, in the process, the service user does not sense the master-slave switching at all, that is, the technical scheme realizes the transparent access instance switching process.
Fig. 4 shows a schematic diagram of Mysql high availability scheme deployment based on DNS and name services. As shown in fig. 4, the database management system registers the database instance and name to the name service through the interface provided by the name service and manages the database instance, wherein the instance resolution record can be managed and specified by self-definition through the access interface of the database management system.
When a fault node is found through a heartbeat signal of a database cluster node example, and the node M1 is determined to be unavailable (refer to fig. 2), the database management system only needs to modify the instance IP under the name M1.mysql and replace the instance IP with the instance IP of the original S2 node, the S1 node and the S2 node establish main-master synchronization, and meanwhile, the database management system sends the registration modification information to the corresponding name server through the global load balancing server.
Host operating systems that need to use database instances need to install a DNS proxy component for hijacking local full DNS requests. When a DNS request is initiated by a related service user needing to access the database in the host, a DNS proxy component intercepts the DNS request and analyzes the DNS request, if the DNS request points to an internal local area network, domain name request content is forwarded to a name server to obtain an IP address of a Mysql instance and returns the IP address to the service user so that the service user can access the database according to the IP address; and if the DNS request points to the public network, forwarding the DNS request to a public network DNS server for resolution.
For those parts of this embodiment that are not explained in detail, reference is made to the aforementioned embodiments, which are not repeated herein.
According to the technical scheme, the primary Mysql example and the standby Mysql example are deployed through the multi-IDC, the availability of the Mysql example is effectively improved, meanwhile, the connection database example is accessed through the DNS domain name, when the node providing the service fails and is unavailable, the access flow can be automatically switched to other available nodes, and a service user is unaware of the process.
EXAMPLE III
Fig. 5 is a schematic block structure diagram of a device for database cluster node master-slave switching based on name service according to a third embodiment of the present invention, where this embodiment is applicable to a case where a database cluster node fails and needs to perform master-slave switching, and the device may be implemented in a software and/or hardware manner, and may be generally integrated in a computer device, for example, a computer device running a database management system. As shown in fig. 5, the apparatus includes: a failure detection module 510, a master node access address replacement module 520, and a master synchronization setup module 530. Wherein the content of the first and second substances,
a failure detection module 510, configured to determine that a first master node fails, where the first master node is configured to establish master-slave synchronization with a second master node, and the first master node is configured to establish master-slave synchronization with a first slave node;
a master node access address replacing module 520, configured to use the instance original access address of the first slave node as the instance current access address of the first master node to replace the instance original access address of the first master node;
a master synchronization setting module 530, configured to set the first slave node to establish a master synchronization with the second master node, so that the application service continues to access the database according to the name of the first master node.
In the embodiment of the invention, the first master node and the second master node establish master-slave synchronization, the first master node and the first slave node establish master-slave synchronization, when the first master node is detected to be out of order, the instance access address of the first master node is only required to be modified and replaced by the instance original access address of the first slave node, and the first slave node and the second master node are set to establish master-slave synchronization, so that the application service can still access the database through the name of the first master node, however, the database instance accessed by the application service is automatically switched from the instance of the first master node to the instance of the first slave node.
Further, the above apparatus further comprises: a name service registration information updating module, configured to register the name of the first master node and the instance original access address of the first slave node to a matched name server after the setting of master synchronization between the first slave node and the second master node is performed, and update registered information in the name server, so that the name server pushes updated registration information to a host DNS proxy component in real time;
wherein the host DNS proxy component is configured to intercept and resolve a DNS request for the application service, and respond to the DNS request based on a name service when the DNS request is directed to an internal local area network.
Further, the name service registration information updating module is specifically configured to push the name of the first master node and the instance original access address of the first slave node to the global load balancing server, so that the load balancing server determines a matched name server according to the name of the first master node, and registers the name of the first master node and the instance original access address of the first slave node to the matched name server.
Further, the host DNS proxy component is specifically configured to, if it is determined that the DNS request points to an internal local area network, directly determine, in a cache, or after accessing a name server, a target node corresponding to the DNS request according to an internal local area network domain name corresponding to the DNS request, and return an instance current access address of the target node to the application service, so that the application program accesses based on the instance current access address.
Further, the host DNS proxy component is further specifically configured to forward the DNS request to a public network DNS server for resolution if it is determined that the DNS request is directed to a public network.
Further, the above apparatus further comprises: the master node access address restoring module is used for taking an instance original access address of the first master node as an instance current access address of the first master node to replace the instance original access address of the first slave node if the first master node is determined to be recovered due to failure; and setting the first master node and the second master node to establish master-slave synchronization, and setting the first master node and the first slave node to establish master-slave synchronization.
Specifically, the failure detection module 510 is configured to determine that the first master node fails according to a heartbeat signal of the instance below the first master node.
The device for database cluster node master-slave switching based on name service provided by the embodiment of the invention can execute the method for database cluster node master-slave switching based on name service provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example four
Fig. 6 is a schematic structural diagram of a computer apparatus according to a fourth embodiment of the present invention, as shown in fig. 6, the computer apparatus includes a processor 60, a memory 61, an input device 62, and an output device 63; the number of processors 60 in the computer device may be one or more, and one processor 60 is taken as an example in fig. 6; the processor 60, the memory 61, the input device 62 and the output device 63 in the computer apparatus may be connected by a bus or other means, and the connection by the bus is exemplified in fig. 6.
The memory 61 serves as a computer-readable storage medium, and may be used for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the name service based database cluster node master-slave switching method in the embodiment of the present invention (for example, the failure detection module 510, the master node access address replacement module 520, and the master synchronization setting module 530 in the name service based database cluster node master-slave switching apparatus in fig. 5). The processor 60 executes various functional applications and data processing of the computer device by running software programs, instructions and modules stored in the memory 61, namely, the method for the master-slave switching of the database cluster node based on the name service is realized.
The memory 61 may mainly include a storage program area and a storage data table area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data table area may store data created according to use of the computer device, and the like. Further, the memory 61 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the memory 61 may further include memory located remotely from the processor 60, which may be connected to a computer device over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 62 may be used to receive input numeric or character information and to generate key signal inputs relating to user settings and function controls of the computer apparatus. The output device 63 may include a display device such as a display screen.
EXAMPLE five
An embodiment of the present invention further provides a computer-readable storage medium storing a computer program, where the computer program is executed by a computer processor to perform a method for database cluster node master-slave switching based on name service, where the method includes:
determining that a first master node fails, wherein the first master node is set to establish master-slave synchronization with a second master node, and the first master node is set to establish master-slave synchronization with a first slave node;
taking the instance original access address of the first slave node as the instance current access address of the first master node to replace the instance original access address of the first master node;
and setting the first slave node and the second master node to establish master-master synchronization so that the application service continues to access the database according to the name of the first master node.
Of course, the computer program of the computer-readable storage medium storing the computer program provided in the embodiment of the present invention is not limited to the above method operations, and may also perform related operations in the method for master-slave switching of a database cluster node based on name service provided in any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the apparatus for switching between master and slave of a database cluster node based on name service, the included units and modules are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments illustrated herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A method for database cluster node master-slave switching based on name service is characterized by comprising the following steps:
determining that a first master node fails, wherein the first master node is set to establish master-slave synchronization with a second master node, and the first master node is set to establish master-slave synchronization with a first slave node;
taking the instance original access address of the first slave node as the instance current access address of the first master node to replace the instance original access address of the first master node;
and setting the first slave node and the second master node to establish master-master synchronization so that the application service continues to access the database according to the name of the first master node.
2. The method of claim 1, wherein after the setting the first slave node to establish master-master synchronization with the second master node, further comprising:
registering the name of the first main node and the instance original access address of the first slave node to a matched name server, and updating registered information in the name server so that the name server pushes the updated registered information to a host DNS proxy component in real time;
wherein the host DNS proxy component is configured to intercept and resolve a DNS request for the application service, and respond to the DNS request based on a name service when the DNS request is directed to an internal local area network.
3. The method of claim 2, wherein registering the name of the first master node and the instance original access address of the first slave node with the matching name server comprises:
and pushing the name of the first main node and the original access address of the instance of the first slave node to a global load balancing server, so that the load balancing server determines a matched name server according to the name of the first main node, and registers the name of the first main node and the original access address of the instance of the first slave node to the matched name server.
4. The method according to claim 2, wherein the host DNS proxy component is specifically configured to, if it is determined that the DNS request points to an internal local area network, determine, according to an internal local area network domain name corresponding to the DNS request, a target node corresponding to the DNS request in a cache directly or after accessing a name server, and return an instance current access address of the target node to the application service, so that the application performs access based on the instance current access address.
5. The method of claim 4, wherein the host DNS proxy component is further configured to forward the DNS request to a public network DNS server for resolution if it is determined that the DNS request is directed to a public network.
6. The method of claim 1, further comprising:
if the failure recovery of the first main node is determined, taking the instance original access address of the first main node as the instance current access address of the first main node to replace the instance original access address of the first slave node;
and setting the first master node and the second master node to establish master-slave synchronization, and setting the first master node and the first slave node to establish master-slave synchronization.
7. The method of any of claims 1-6, wherein determining that the first master node has failed comprises:
and determining that the first main node fails according to the heartbeat signal of the lower instance of the first main node.
8. An apparatus for database cluster node master-slave switching based on name service, comprising:
the system comprises a fault detection module, a first slave node and a second slave node, wherein the fault detection module is used for determining that a first master node has a fault, the first master node is set to establish master-slave synchronization with the second master node, and the first master node is set to establish master-slave synchronization with the first slave node;
a master node access address replacing module, configured to use an instance original access address of the first slave node as an instance current access address of the first master node to replace the instance original access address of the first master node;
and the master-master synchronization setting module is used for setting the first slave node and the second master node to establish master-master synchronization so that the application service can continuously access the database according to the name of the first master node.
9. A computer device, characterized in that the computer device comprises:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202010002193.XA 2020-01-02 2020-01-02 Method, device, equipment and medium for master-slave switching of database cluster node Pending CN111200532A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010002193.XA CN111200532A (en) 2020-01-02 2020-01-02 Method, device, equipment and medium for master-slave switching of database cluster node

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010002193.XA CN111200532A (en) 2020-01-02 2020-01-02 Method, device, equipment and medium for master-slave switching of database cluster node

Publications (1)

Publication Number Publication Date
CN111200532A true CN111200532A (en) 2020-05-26

Family

ID=70747475

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010002193.XA Pending CN111200532A (en) 2020-01-02 2020-01-02 Method, device, equipment and medium for master-slave switching of database cluster node

Country Status (1)

Country Link
CN (1) CN111200532A (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651523A (en) * 2020-05-29 2020-09-11 烽火通信科技股份有限公司 MySQL data synchronization method and system of Kubernetes container platform
CN111858628A (en) * 2020-06-30 2020-10-30 北京百度网讯科技有限公司 Database-based management method, database-based management platform, electronic device and storage medium
CN111866094A (en) * 2020-07-01 2020-10-30 天津联想超融合科技有限公司 Timed task processing method, node and computer readable storage medium
CN112015595A (en) * 2020-08-28 2020-12-01 掌阅科技股份有限公司 Master-slave database switching method, computing device and storage medium
CN112286738A (en) * 2020-11-19 2021-01-29 政采云有限公司 Method, system, equipment and readable storage medium for accessing database
CN112653734A (en) * 2020-12-11 2021-04-13 邦彦技术股份有限公司 Server cluster real-time master-slave control and data synchronization system and method
CN112835649A (en) * 2021-02-24 2021-05-25 紫光云技术有限公司 Method for constructing postgresql with high availability
CN113162797A (en) * 2021-03-03 2021-07-23 山东英信计算机技术有限公司 Method, system and medium for switching master node fault of distributed cluster
CN113515574A (en) * 2021-05-17 2021-10-19 聚好看科技股份有限公司 Data synchronization method and device
CN113704029A (en) * 2021-09-24 2021-11-26 携程旅游信息技术(上海)有限公司 Node availability management and control method, node, cluster, device and medium
CN113760445A (en) * 2020-11-24 2021-12-07 北京沃东天骏信息技术有限公司 Service switching method and device
CN114598711A (en) * 2022-03-29 2022-06-07 百果园技术(新加坡)有限公司 Data migration method, device, equipment and medium
CN115794769A (en) * 2022-10-09 2023-03-14 云和恩墨(北京)信息技术有限公司 Method for managing high-availability database, electronic device and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102194009A (en) * 2011-06-09 2011-09-21 北京新媒传信科技有限公司 Database hosting method and database hosting platform system
CN105224637A (en) * 2015-09-24 2016-01-06 珠海许继芝电网自动化有限公司 A kind of based on PostgreSQL database active and standby/the comprehensive method of cluster application
CN106341454A (en) * 2016-08-23 2017-01-18 世纪龙信息网络有限责任公司 Across-room multiple-active distributed database management system and across-room multiple-active distributed database management method
CN106713487A (en) * 2017-01-16 2017-05-24 腾讯科技(深圳)有限公司 Data synchronization method and device
US20180048587A1 (en) * 2016-05-16 2018-02-15 Yang Bai Port switch service
CN108599996A (en) * 2018-04-03 2018-09-28 武汉斗鱼网络科技有限公司 Fault handling method, device and the terminal of data-base cluster
CN109254876A (en) * 2018-09-11 2019-01-22 郑州云海信息技术有限公司 The management method and device of database in cloud computing system
CN110162428A (en) * 2019-05-17 2019-08-23 中国铁道科学研究院集团有限公司 Method of data synchronization and device, electronic equipment and computer readable storage medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102194009A (en) * 2011-06-09 2011-09-21 北京新媒传信科技有限公司 Database hosting method and database hosting platform system
CN105224637A (en) * 2015-09-24 2016-01-06 珠海许继芝电网自动化有限公司 A kind of based on PostgreSQL database active and standby/the comprehensive method of cluster application
US20180048587A1 (en) * 2016-05-16 2018-02-15 Yang Bai Port switch service
CN106341454A (en) * 2016-08-23 2017-01-18 世纪龙信息网络有限责任公司 Across-room multiple-active distributed database management system and across-room multiple-active distributed database management method
CN106713487A (en) * 2017-01-16 2017-05-24 腾讯科技(深圳)有限公司 Data synchronization method and device
CN108599996A (en) * 2018-04-03 2018-09-28 武汉斗鱼网络科技有限公司 Fault handling method, device and the terminal of data-base cluster
CN109254876A (en) * 2018-09-11 2019-01-22 郑州云海信息技术有限公司 The management method and device of database in cloud computing system
CN110162428A (en) * 2019-05-17 2019-08-23 中国铁道科学研究院集团有限公司 Method of data synchronization and device, electronic equipment and computer readable storage medium

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651523A (en) * 2020-05-29 2020-09-11 烽火通信科技股份有限公司 MySQL data synchronization method and system of Kubernetes container platform
CN111651523B (en) * 2020-05-29 2022-09-16 烽火通信科技股份有限公司 MySQL data synchronization method and system of Kubernetes container platform
CN111858628A (en) * 2020-06-30 2020-10-30 北京百度网讯科技有限公司 Database-based management method, database-based management platform, electronic device and storage medium
CN111866094A (en) * 2020-07-01 2020-10-30 天津联想超融合科技有限公司 Timed task processing method, node and computer readable storage medium
CN111866094B (en) * 2020-07-01 2023-10-31 天津联想超融合科技有限公司 Timing task processing method, node and computer readable storage medium
CN112015595A (en) * 2020-08-28 2020-12-01 掌阅科技股份有限公司 Master-slave database switching method, computing device and storage medium
CN112015595B (en) * 2020-08-28 2021-03-02 掌阅科技股份有限公司 Master-slave database switching method, computing device and storage medium
CN112286738A (en) * 2020-11-19 2021-01-29 政采云有限公司 Method, system, equipment and readable storage medium for accessing database
CN112286738B (en) * 2020-11-19 2024-01-26 政采云有限公司 Method, system, equipment and readable storage medium for accessing database
CN113760445A (en) * 2020-11-24 2021-12-07 北京沃东天骏信息技术有限公司 Service switching method and device
CN112653734B (en) * 2020-12-11 2023-09-19 邦彦技术股份有限公司 Real-time master-slave control and data synchronization system and method for server cluster
CN112653734A (en) * 2020-12-11 2021-04-13 邦彦技术股份有限公司 Server cluster real-time master-slave control and data synchronization system and method
CN112835649A (en) * 2021-02-24 2021-05-25 紫光云技术有限公司 Method for constructing postgresql with high availability
CN113162797A (en) * 2021-03-03 2021-07-23 山东英信计算机技术有限公司 Method, system and medium for switching master node fault of distributed cluster
CN113515574A (en) * 2021-05-17 2021-10-19 聚好看科技股份有限公司 Data synchronization method and device
CN113704029A (en) * 2021-09-24 2021-11-26 携程旅游信息技术(上海)有限公司 Node availability management and control method, node, cluster, device and medium
CN114598711A (en) * 2022-03-29 2022-06-07 百果园技术(新加坡)有限公司 Data migration method, device, equipment and medium
CN114598711B (en) * 2022-03-29 2024-04-16 百果园技术(新加坡)有限公司 Data migration method, device, equipment and medium
CN115794769A (en) * 2022-10-09 2023-03-14 云和恩墨(北京)信息技术有限公司 Method for managing high-availability database, electronic device and storage medium
CN115794769B (en) * 2022-10-09 2024-03-19 云和恩墨(北京)信息技术有限公司 Method for managing high-availability database, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111200532A (en) Method, device, equipment and medium for master-slave switching of database cluster node
US20200257593A1 (en) Storage cluster configuration change method, storage cluster, and computer system
JP6416745B2 (en) Failover and recovery for replicated data instances
CN102148850B (en) Cluster system and service processing method thereof
EP3159794B1 (en) Distributed storage replication system and method
US9847907B2 (en) Distributed caching cluster management
US20020152293A1 (en) Dynamic server directory for distributed computing system
CN113572831B (en) Communication method, computer equipment and medium between Kubernetes clusters
CN112084072B (en) Method, system, medium and terminal for improving disaster tolerance capability of PostgreSQL cluster
US20210014106A1 (en) High availability on a distributed networking platform
US10069941B2 (en) Scalable event-based notifications
US11953997B2 (en) Systems and methods for cross-regional back up of distributed databases on a cloud service
CN108920489B (en) Method, device and equipment for deploying database
US9529772B1 (en) Distributed caching cluster configuration
US11892982B2 (en) Facilitating immediate performance of volume resynchronization with the use of passive cache entries
CN101706781A (en) Method and system for centralized management of database caches
CN111600794B (en) Server switching method, terminal, server and storage medium
CN111865632A (en) Switching method of distributed data storage cluster and switching instruction sending method and device
CN112000444B (en) Database transaction processing method and device, storage medium and electronic equipment
CN112202601B (en) Application method of two physical node mongo clusters operated in duplicate set mode
CN112685486B (en) Data management method and device for database cluster, electronic equipment and storage medium
CN112131201B (en) Method, system, equipment and medium for high availability of network additional storage
CN113596195A (en) Public IP address management method, device, main node and storage medium
JP2020098598A (en) Transparent database session recovery with client-side caching
CN117290385B (en) Data read-write method, device and medium based on transaction inquiry application layer separation

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: 20200526

RJ01 Rejection of invention patent application after publication