CN113904914A - Service switching method, device, system and storage medium - Google Patents

Service switching method, device, system and storage medium Download PDF

Info

Publication number
CN113904914A
CN113904914A CN202011627556.5A CN202011627556A CN113904914A CN 113904914 A CN113904914 A CN 113904914A CN 202011627556 A CN202011627556 A CN 202011627556A CN 113904914 A CN113904914 A CN 113904914A
Authority
CN
China
Prior art keywords
node
information
service
lock
master
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011627556.5A
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.)
Jingdong Technology Holding Co Ltd
Original Assignee
Jingdong Technology Holding 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 Jingdong Technology Holding Co Ltd filed Critical Jingdong Technology Holding Co Ltd
Priority to CN202011627556.5A priority Critical patent/CN113904914A/en
Publication of CN113904914A publication Critical patent/CN113904914A/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/0631Management of faults, events, alarms or notifications using root cause analysis; using analysis of correlation between notifications, alarms or events based on decision criteria, e.g. hierarchy, tree or time analysis
    • 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/0668Management of faults, events, alarms or notifications using network fault recovery by dynamic selection of recovery network elements, e.g. replacement by the most appropriate element after failure
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Hardware Redundancy (AREA)

Abstract

The invention discloses a service switching method, a device, a system and a storage medium. Wherein, the method comprises the following steps: if the heartbeat information of the main node is not received within the effective time of the main lock of the corresponding main node, controlling the main lock to be invalid; receiving lock robbing information sent by a service node, wherein the service node comprises at least one of a main node and a backup node; and selecting a new main node from the service nodes according to the lock robbing information, wherein the main node is used for processing an information service request sent by the client. According to the embodiment of the invention, the fault service node is timely found through the heartbeat information, the service is quickly switched under the condition that the service node is ensured to be available according to the locking robbing information, the service switching efficiency is improved, the influence of the fault service node on the information service is reduced, and the information service quality is enhanced.

Description

Service switching method, device, system and storage medium
Technical Field
The embodiment of the invention relates to the technical field of automation control, in particular to a service switching method, device and system and a storage medium.
Background
With the development of communication network technology, information services are becoming essential parts of life, and the availability of information services depends on the stable operation of servers. The existing information service providing modes of the server mainly comprise the following modes: 1. and in single-point deployment, only one server provides information services. 2. And (3) multi-point deployment, wherein a plurality of servers provide information services, and each server node runs the same information service and meets the service request of a user side in a load balancing mode.
In the process of implementing the invention, the following technical problems in the prior art are found:
for a single-point deployed server, the availability of the information service provided by the single-point deployed server is poor, and once the server fails, the information service cannot be switched, so that a client cannot acquire the information service. For a multi-point deployed server, a load balancing mode is adopted to forward an information service request of a user side to each service node, and when a service node fails, a management node needs to adjust a forwarding rule of the information service request after actively detecting the service node failure, so that switching of information services is realized.
Disclosure of Invention
The invention provides a service switching method, a device, a system and a storage medium, which are used for realizing the rapid discovery of node faults, improving the real-time performance of information service switching and improving the quality of information service.
In a first aspect, an embodiment of the present invention provides a service switching method, which is applied to a management node, and the method includes:
if the heartbeat information of the main node is not received within the effective time of the main lock of the corresponding main node, controlling the main lock to be invalid;
receiving lock robbing information sent by a service node, wherein the service node comprises at least one of a main node and a backup node;
and selecting a new main node from the service nodes according to the lock robbing information, wherein the main node is used for processing an information service request sent by the client.
In a second aspect, an embodiment of the present invention further provides a service switching method, applied to a service node, where the method includes:
sending lock grabbing information and heartbeat information to a management node so that the management node determines a new main node;
and providing the information service for the client according to the current node role when the information service request is received.
In a third aspect, an embodiment of the present invention further provides a service switching apparatus, which is applied to a management node, and the apparatus includes:
the master lock failure module is used for controlling the master lock to fail if the heartbeat information of the master node is not received within the valid time of the master lock of the corresponding master node;
the system comprises a lock acquisition triggering module, a service node and a backup node, wherein the lock acquisition triggering module is used for receiving lock acquisition information sent by the service node, and the service node comprises at least one of a main node and a backup node;
and the switching execution module is used for selecting a new main node from the service nodes according to the lock robbing information, wherein the main node is used for processing the information service request sent by the client.
In a fourth aspect, an embodiment of the present invention further provides a service switching apparatus, which is applied to a service node, and the apparatus includes:
the information sending module is used for sending the lock robbing information and the heartbeat information to the management node so that the management node determines a new main node;
and the information service module is used for providing information service for the client according to the current node role when receiving the information service request.
In a fifth aspect, an embodiment of the present invention further provides a service switching system, where the system includes: the system comprises a management node, a service node and a client; wherein, the management node is configured to execute any of the service switching methods in the embodiments of the present invention; the service node is configured to execute the service switching method according to any one of the embodiments of the present invention; the client is used for sending the information server to the service node to obtain the information service.
In a sixth 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 service switching method according to any one of the embodiments of the present invention.
In the embodiment of the invention, the failure of the main lock is controlled by determining that the heartbeat information of the main node is not received within the effective time of the main lock of the corresponding main node, and the lock robbing information sent by the service node is obtained, wherein the service node can comprise at least one of the main node and the backup node, the service node is selected as a new main node according to the lock robbing information, the main node is used for processing the information service request sent by the client, the fault of the main node is timely found through the effective time of the main lock and the heartbeat information, and the new main node is selected through the lock robbing information, so that the timeliness of the fault finding of the service node is realized, the service switching efficiency can be improved, the influence of the fault service node on the information service is reduced, and the information service quality can be enhanced.
Drawings
Fig. 1 is a flowchart of a service switching method according to an embodiment of the present invention;
fig. 2 is a flowchart of another service switching method according to a second embodiment of the present invention;
fig. 3 is a flowchart of a service switching method according to a third embodiment of the present invention;
fig. 4 is an exemplary diagram of a service switching method according to a third embodiment of the present invention;
fig. 5 is an exemplary diagram of address feedback of a backup node according to a third embodiment of the present invention;
fig. 6 is a schematic structural diagram of a service switching apparatus according to a fourth embodiment of the present invention;
fig. 7 is a schematic structural diagram of another service switching apparatus according to a fifth embodiment of the present invention;
fig. 8 is a schematic structural diagram of a service switching system according to a sixth embodiment of the present invention;
fig. 9 is a schematic structural diagram of an electronic device according to a sixth 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 noted that, for convenience of description, only a part of the structures related to the present invention, not all of the structures, are shown in the drawings, and furthermore, embodiments of the present invention and features of the embodiments may be combined with each other without conflict.
Example one
Fig. 1 is a flowchart of a service switching method according to an embodiment of the present invention, where this embodiment is applicable to a case where a service node switches a service to another service node when the service node fails, and the method may be executed by a service switching device, where the service switching device may be implemented in a hardware and/or software manner and is generally integrated in a management node, referring to fig. 1, where the method according to the embodiment of the present invention specifically includes the following steps:
and 110, if the heartbeat information of the main node is not received within the effective time of the main lock of the corresponding main node, controlling the main lock to be invalid.
The main node can be a node for providing information service for users by a system service provider, and a thread of the information service can be set in the main node; the master lock may be information for locking the service node as the master node, the valid time of the master lock may be the valid time of the service node as the master node, and the valid time of the master lock may be specifically determined by a timer; the heartbeat information may be information that the master node notifies the management node that the master node itself is operating normally, and the heartbeat information may include master node identification information and state information.
In the embodiment of the present invention, the management node may continuously monitor the heartbeat information sent by the master node, and when the heartbeat information is received and the heartbeat information of the master node is not received after a time length corresponding to an effective time of the master node is exceeded, the management node may determine that the master node is faulty, and the master node cannot continue to provide information services for the user. Furthermore, if the heartbeat information of the main node is received within the effective time of the main lock, the effective time of the main lock can be prolonged, so that the main node continues to provide information service.
And 120, receiving the lock robbing information sent by the service node, wherein the service node comprises at least one of a main node and a backup node.
The lock preemption information can be information that the service node preempts the master lock, the lock preemption information can include identification information, running information and the like of the service node, and the lock preemption information can change the master lock in the management node. The backup node may be a service node, the backup node may be configured with the same service as the master node, when the master node fails, the backup node may take over the master node to provide information service, the master node and the backup node may be service nodes that back up each other, when the service node occupies the master lock, the service node may be the master node, and other service nodes that do not occupy the master lock may be backup nodes.
Specifically, after the master lock is controlled by the management node to be failed, the management node may receive the lock robbing information sent by one or more service nodes, where the lock robbing information may be actively sent by the service nodes at regular time, the service nodes may send the lock robbing information to the management node every 300 milliseconds, the management node may receive the lock robbing information after the master lock is failed, and the service nodes that send the lock robbing information may include service nodes that were previously determined as master node service nodes or service nodes that were previously determined as backup nodes.
And step 130, selecting a new master node from the service nodes according to the lock robbing information, wherein the master node is used for processing an information service request sent by the client.
The client may provide software and hardware programs of local services for the user, the client may send an information service request to the host node to obtain the information service, and the information service request may include the type, duration, and the like of the requested information service.
In the embodiment of the present invention, a service node may be reselected from one or more service nodes that send the lock robbing information as a standard to serve as a new master node, where the standard for selecting the new master node may include an operation state included in the lock robbing information or a time of receiving the lock robbing information, for example, a service node with a minimum load may be selected from the service nodes that send the lock robbing information to serve as the new master node, and a service node corresponding to an earliest time of receiving the lock robbing information may be selected from the service nodes that send the lock robbing information to serve as the new master node. It is understood that the original master node may also be selected as the new master node according to the corresponding lock preemption information.
According to the embodiment of the invention, the master lock is controlled to be invalid when the heartbeat information of the master node is not received within the master lock effective time of the master node, the lock robbing information sent by each service node is collected, the service node is selected as a new master node according to the lock robbing information, the master node is used for processing the information service request sent by the client, the master node fault is timely found through the master lock effective time and the heartbeat information, and the new master node is selected through the lock robbing information, so that the timeliness of the service node fault finding is realized, the service switching efficiency can be improved, the influence of the fault service node on the information service is reduced, and the information service quality can be enhanced.
Example two
Fig. 2 is a flowchart of another service switching method provided in the second embodiment of the present invention, the second embodiment of the present invention is embodied on the basis of the foregoing embodiment of the present invention, and referring to fig. 2, the method provided in the second embodiment of the present invention specifically includes the following steps:
step 210, after at least two service nodes are started simultaneously, acquiring the lock robbing information of each service node.
In the embodiment of the invention, when a service is started, the service node corresponding to the service can be controlled by the management node to be started, after the service node is started, the lock robbing information can be sent to the management node, and the management node can receive the lock robbing information comprising the identification information and the running state information of the corresponding service node. It is to be understood that one or more service nodes may be configured with information related to providing a service, and the configuration information of the service nodes corresponding to the same service may be the same.
And step 220, taking the service node corresponding to the first received lock preemption information as a master node, and generating a master lock of the master node.
Specifically, when receiving the first lock acquisition information, the management node may select a service node corresponding to the lock acquisition information as a master node, and correspondingly, other service nodes that are not selected as the master node may be recorded as backup nodes. When the master node is selected, the identification information of the service node may be recorded and an effective time may be set to implement the master lock of the master node, where the effective time may be the effective time of the master lock of the corresponding master node.
And step 230, if the heartbeat information of the main node is not received within the effective time of the main lock of the corresponding main node, controlling the main lock to be invalid.
And 240, receiving the lock robbing information sent by the service node, wherein the service node comprises at least one of a main node and a backup node.
Further, on the basis of the above embodiment of the present invention, the lock robbing information sent by the service node is heartbeat information.
In the embodiment of the invention, the service node can send heartbeat information to the management node regularly according to the heartbeat duration, and the main node can take the received heartbeat information as the corresponding lock grabbing information.
And step 250, taking the first received lock preemption information as target lock preemption information, and acquiring a target service node corresponding to the target lock preemption information.
The target lock acquisition information may be lock acquisition information used for selecting a master node to use, and the target service node may be a service node corresponding to the target lock acquisition information.
In the embodiment of the invention, the management node can take the first received lock preemption information as the target lock preemption information after the master lock fails, can extract the service node identification included in the target lock preemption information, and selects the corresponding service node as the target service node according to the service node identification.
Step 260, generating a master lock corresponding to the target service node, so that the target service node is used as a master node for processing the information service request sent by the client.
Specifically, a master lock may be generated for the target service node, and the process of generating the master lock may include recording a service node identifier of the target service node, setting valid time of the master lock, and the like, for example, the service node identifier may be stored in a fixed storage area, and a write permission prohibition may be set for the fixed storage area, where the valid time of the write permission prohibition may be the valid time of the master lock of the master node.
According to the embodiment of the invention, after at least two service nodes are started, the locking information corresponding to each service node is acquired, the service node corresponding to the first received locking information is selected as the master node and the corresponding master lock is generated, when the master lock is not used for receiving the heartbeat information of the master node, the master node is controlled to be invalid, the heartbeat information of the service node is acquired as the locking information, the first received locking information is taken as the target locking information, the target service node corresponding to the target locking information is acquired, and the master lock of the target service node is generated, so that the target service node processes the information service request sent by the client, the service node fault can be found in time, the information service is rapidly switched, the influence of the fault service node on the information service is reduced, and the information service quality is enhanced.
Further, on the basis of the foregoing embodiment of the present invention, the generating a master lock corresponding to the target service node includes: determining the receiving time and the node identification of the target lock grabbing information; and generating a master lock corresponding to the target service node according to the node identification, and setting the valid time of the master lock as the sum of the receiving time and the duration of a preset heartbeat.
The receiving time may be the time when the management node receives the target locking information sent by the target service node, and the node identifier may be a node identifier of the target service node, and may be a node name or a node number.
In the embodiment of the invention, the management node can acquire the receiving time of the target lock grabbing information, extract the node identification of the target service node from the target lock grabbing information, and generate the master lock corresponding to the node identification. When the master lock is generated, master lock effective time is set for the master lock, the value of the master lock effective time can be the sum of receiving time and preset heartbeat duration time, the preset heartbeat duration time can be the maximum heartbeat detection duration time designed by the master node, and when the heartbeat information of the master node is not acquired in the preset heartbeat duration time, the fault of the master node can be determined. For example, the etcd database may be used to store the node identifier of the target serving node, and set an update permission for the storage record containing the node identifier, where the effective time of the update permission may be set to be the sum of the receiving time and the duration of the preset heartbeat.
Fig. 3 is a flowchart of a service switching method provided in a third embodiment of the present invention, where this embodiment is applicable to a case where a service node switches a service to another service node when the service node fails, and the method may be executed by a service switching device, where the service switching device may be implemented in a hardware and/or software manner and is generally integrated in the service node, referring to fig. 3, the method provided in the third embodiment of the present invention specifically includes the following steps:
and step 310, sending the lock robbing information and the heartbeat information to the management node so that the management node determines a new main node.
In the embodiment of the invention, the service node can send the lock robbing information and the heartbeat information to the management node at regular time, so that the management node can select the service node as a new main node according to the sent heartbeat information and the lock robbing information, wherein the time intervals for sending the lock robbing information and the heartbeat information can be the same or different, for example, the service node can send the lock robbing information and the heartbeat information of the service node to the management node at the same time, and the service node can also respectively send the lock robbing information and the heartbeat information to the management node at different moments.
And step 320, providing the information service for the client according to the current node role when the information service request is received.
The current node role may be a role in which the service node currently provides a service for the client, and may include a master node that provides a service for the client, a backup node that does not provide a service for the client, and the like.
Specifically, when the service node receives the information service request, the node role in which the service node is currently located may be determined, if the service node is the master node, the information service request may be responded to provide information service for the client, and if the service node is the backup node, the information service request may be denied to be responded to and not processed.
According to the embodiment of the invention, the service node sends the lock robbing information and the heartbeat information to the management node, so that the management node determines the new master node, and the service node provides service for the client according to the current node role when receiving the information service request, thereby realizing timely discovery of the fault service node, improving service switching efficiency, reducing the influence of the fault of the service node on the information service, and enhancing the information service quality.
Further, on the basis of the above embodiment of the present invention, the sending lock snatching information and heartbeat information to a management node to enable the management node to select a new master node includes: and sending the heartbeat information to the management node according to a preset heartbeat cycle so that the management node determines a new main node by taking the heartbeat information as the lock robbing information.
In the embodiment of the invention, the service node can only send heartbeat information to the management node, and when the management node receives the heartbeat information, the heartbeat information can be used as the lock robbing information to be processed, and a new main node is selected through the heartbeat information.
Further, on the basis of the above embodiment of the invention, the method further includes: and acquiring the feedback information of the management node to acquire the internet protocol address of the main node.
The feedback information may be information sent by the management node to the service node, and the feedback information may carry an internet protocol address of the current host node.
In the embodiment of the present invention, the management node may send feedback information to the service node, where the feedback information includes an internet protocol address, and the service node may determine the location of the master node through the feedback information.
Further, on the basis of the above embodiment of the present invention, the providing information service for the client according to the current node role when receiving the information service request includes: if the current node role is the main node, responding to the information service request to provide information service; and if the current node role is the backup node, refusing to respond to the information service request and feeding back the Internet protocol address of the main node.
Specifically, when the service node is a master node, the information service node may respond to an information service request sent by the client and provide information service for the client. And when the service node is a backup node, refusing to respond to the information service request sent by the client, and sending the Internet protocol address of the main node to the client so that the client acquires the position of the main node.
In an exemplary implementation manner, fig. 4 is an exemplary diagram of a service switching method provided in a third embodiment of the present invention, and referring to fig. 4, in the method provided in the third embodiment of the present invention, a distributed consistency component may be used as a management node, the method may include two service nodes, and the two service nodes may include the same information service. When the service is started, two service nodes can be started, the two service nodes simultaneously seize the master lock to the consistency service component, only one service node seizes the master lock, the service node serves as a master node, and the other service node serves as a backup node. For the master node, the main service logic is executed: maintaining and consistency heartbeat of service components, once every 300 milliseconds; and processing the information service request of the client. For the backup node, the backup service logic is executed: continuously preempting the main lock once every 300 milliseconds, and once the heartbeat disappears, the backup preempting the main lock to become a main node; not processing the information service request of the client; and after receiving an information service request of the client, informing the address of the main node of the client. Fig. 5 is an exemplary diagram of address feedback of a backup node according to a third embodiment of the present invention, where the diagram is shown in fig. 5, when the primary/backup node switches over, the backup node will tell the client the internet protocol address of the primary node after receiving an information service request from the client, and the client sends the information service request to the primary node after receiving a return result from the backup node.
Example four
Fig. 6 is a schematic structural diagram of a service switching apparatus according to a fourth embodiment of the present invention, and referring to fig. 6, the service switching method according to any embodiment of the present invention can be executed, and the service switching apparatus has functional modules and beneficial effects corresponding to the execution method. The device can be implemented by software and/or hardware, is generally integrated in a management node, and specifically includes: a master lock failure module 401, a lock robbing triggering module 402 and a switching execution module 403.
The master lock failure module 401 is configured to control the master lock to fail if the heartbeat information of the master node is not received within the master lock valid time of the corresponding master node;
a lock preemption triggering module 402, configured to receive lock preemption information sent by a service node, where the service node includes at least one of a master node and a backup node;
and a switching execution module 403, configured to select a new master node from the service nodes according to the lock robbing information, where the master node is configured to process an information service request sent by the client.
According to the embodiment of the invention, the master lock is controlled to be invalid when the master lock invalidation module does not receive the heartbeat information of the master node within the master lock valid time of the master node, the lock robbing trigger module acquires the lock robbing information sent by each service node, the switching execution module selects the service node as a new master node according to the lock robbing information, the master node is used for processing the information service request sent by the client, the master node fault is timely found through the master lock valid time and the heartbeat information, and the new master node is selected through the lock robbing information, so that the timeliness of service node fault finding is realized, the service switching efficiency can be improved, the influence of the fault service node on information service is reduced, and the information service quality can be enhanced.
Further, on the basis of the embodiment of the present invention, the starting module is configured to obtain the lock robbing information of each service node after at least two service nodes are simultaneously started; and taking the service node corresponding to the first received lock preemption information as a master node, and generating a master lock of the master node.
Further, on the basis of the above embodiment of the present invention, the lock robbing information sent by the service node in the lock robbing triggering module 402 is heartbeat information.
Further, on the basis of the foregoing embodiment of the present invention, the handover performing module 403 includes:
and the node determining unit is used for taking the first received lock preemption information as target lock preemption information and acquiring a target service node corresponding to the target lock preemption information.
And the master lock setting unit is used for generating a master lock corresponding to the target service node so that the target service node is used as a master node for processing an information service request sent by a client.
Further, on the basis of the above embodiment of the present invention, the master lock setting unit is specifically configured to: determining the receiving time and the node identification of the target lock grabbing information; and generating a master lock corresponding to the target service node according to the node identification, and setting the valid time of the master lock as the sum of the receiving time and the duration of a preset heartbeat.
EXAMPLE five
Fig. 7 is a schematic structural diagram of another service switching apparatus provided in the fifth embodiment of the present invention, and referring to fig. 7, the service switching method provided in any embodiment of the present invention can be executed, and the service switching apparatus has functional modules and beneficial effects corresponding to the execution method. The apparatus, which may be implemented by software and/or hardware, is generally integrated in a service node, and specifically includes: an information sending module 501 and an information service module 502.
An information sending module 501, configured to send lock robbing information and heartbeat information to a management node, so that the management node determines a new master node.
The information service module 502 is configured to provide an information service for the client according to the current node role when receiving the information service request.
According to the embodiment of the invention, the information sending module sends the locking robbing information and the heartbeat information to the management node, so that the management node determines a new main node, and the information service module provides service for the client according to the current node role when receiving the information service request, thereby realizing timely discovery of the fault service node, improving service switching efficiency, reducing the influence of the service node fault on the information service, and enhancing the information service quality.
Further, on the basis of the above embodiment of the present invention, the information sending module 501 includes:
and the heartbeat sending unit is used for sending the heartbeat information to the management node according to a preset heartbeat cycle so that the management node determines a new main node by taking the heartbeat information as the lock grabbing information.
Further, on the basis of the above embodiment of the invention, the apparatus further includes:
and the master address module is used for acquiring the feedback information of the management node so as to acquire the internet protocol address of the master node.
Further, on the basis of the above embodiment of the present invention, the information service module 502 includes:
and the main processing unit is used for responding to the information service request to provide information service if the current node role is the main node.
And the standby processing unit is used for refusing to respond to the information service request and feeding back the Internet protocol address of the main node if the current node is in the role of a backup node.
Fig. 8 is a schematic structural diagram of a service switching system provided in a sixth embodiment of the present invention, where the system shown in fig. 8 at least includes a management node, a service node, and a client, the management node is connected to the service node to obtain lock robbing information and heartbeat information, and the management node may execute any service switching method provided in the sixth embodiment of the present invention, where the method includes: if the heartbeat information of the main node is not received within the effective time of the main lock of the corresponding main node, controlling the main lock to be invalid; receiving lock robbing information sent by a service node, wherein the service node comprises at least one of a main node and a backup node; and selecting a new main node from the service nodes according to the lock robbing information, wherein the main node is used for processing an information service request sent by the client. The service node is respectively connected with the client and the management node, sends heartbeat information and locking information to the management node, receives an information service request sent by the client and responds to the information service request according to conditions, and the service node can execute any service switching method provided by the embodiment of the invention, wherein the method comprises the following steps: sending lock grabbing information and heartbeat information to a management node so that the management node determines a new main node; and providing the information service for the client according to the current node role when the information service request is received. The client is used for sending an information service request to the service node to acquire the information service.
Further, fig. 9 is a schematic structural diagram of an electronic device according to a sixth embodiment of the present invention, and as shown in fig. 9, the electronic device includes a processor 60, a memory 61, an input device 62, and an output device 63; the number of the processors 60 in the electronic device may be one or more, and one processor 60 is taken as an example in fig. 9; the processor 60, the memory 61, the input device 62 and the output device 63 in the electronic apparatus may be connected by a bus or other means, and the connection by the bus is exemplified in fig. 9.
The memory 61 is a computer-readable storage medium, and can be used for storing software programs, computer-executable programs, and modules, such as program modules corresponding to the service switching method in the embodiment of the present invention (for example, the master lock failure module 401, the lock robbery triggering module 402, and the switching execution module 403 in the service switching apparatus, or the information sending module 501 and the information service module 502). The processor 60 executes various functional applications and data processing of the electronic device by executing software programs, instructions and modules stored in the memory 61, that is, implements the service switching method described above.
The memory 61 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, 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 the electronic device through 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 generate key signal inputs related to user settings and function controls of the electronic apparatus. The output device 63 may include a display device such as a display screen.
EXAMPLE seven
An embodiment of the present invention further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform a service switching method, where the method includes:
if the heartbeat information of the main node is not received within the effective time of the main lock of the corresponding main node, controlling the main lock to be invalid;
receiving lock robbing information sent by a service node, wherein the service node comprises at least one of a main node and a backup node;
and selecting a new main node from the service nodes according to the lock robbing information, wherein the main node is used for processing an information service request sent by the client.
Alternatively, the first and second electrodes may be,
sending lock grabbing information and heartbeat information to a management node so that the management node determines a new main node;
and providing the information service for the client according to the current node role when the information service request is received.
Of course, the storage medium containing the computer-executable instructions provided by the embodiments of the present invention is not limited to the method operations described above, and may also perform related operations in the service switching method provided by 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 can 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 service switching apparatus, each included unit and module are only divided according to functional logic, but are not limited to the above division as long as the corresponding function 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 described 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 (13)

1. A service switching method is applied to a management node, and the method comprises the following steps:
if the heartbeat information of the main node is not received within the effective time of the main lock of the corresponding main node, controlling the main lock to be invalid;
receiving lock robbing information sent by a service node, wherein the service node comprises at least one of a main node and a backup node;
and selecting a new main node from the service nodes according to the lock robbing information, wherein the main node is used for processing an information service request sent by the client.
2. The method of claim 1, further comprising:
after at least two service nodes are started simultaneously, acquiring the lock robbing information of each service node;
and taking the service node corresponding to the first received lock preemption information as a master node, and generating a master lock of the master node.
3. The method of claim 1, wherein the lock snatching message sent by the service node is a heartbeat message.
4. The method of claim 1, wherein selecting a new master node from the service nodes according to the lock snatching information comprises:
taking the first received lock preemption information as target lock preemption information, and acquiring a target service node corresponding to the target lock preemption information;
and generating a master lock corresponding to the target service node so that the target service node is used as a master node for processing an information service request sent by a client.
5. The method of claim 4, wherein generating the master lock for the target service node comprises:
determining the receiving time and the node identification of the target lock grabbing information;
and generating a master lock corresponding to the target service node according to the node identification, and setting the valid time of the master lock as the sum of the receiving time and the duration of a preset heartbeat.
6. A service switching method is applied to a service node, and the method comprises the following steps:
sending lock grabbing information and heartbeat information to a management node so that the management node determines a new main node;
and providing the information service for the client according to the current node role when the information service request is received.
7. The method of claim 6, wherein sending the lock snatching information and the heartbeat information to a management node to cause the management node to select a new master node comprises:
and sending the heartbeat information to the management node according to a preset heartbeat cycle so that the management node determines a new main node by taking the heartbeat information as the lock robbing information.
8. The method of claim 6, further comprising:
and acquiring the feedback information of the management node to acquire the internet protocol address of the main node.
9. The method of claim 8, wherein providing information services for the client according to the current node role when receiving the information service request comprises:
if the current node role is the main node, responding to the information service request to provide information service;
and if the current node role is the backup node, refusing to respond to the information service request and feeding back the Internet protocol address of the main node.
10. A service switching apparatus, applied to a management node, the apparatus comprising:
the master lock failure module is used for controlling the master lock to fail if the heartbeat information of the master node is not received within the valid time of the master lock of the corresponding master node;
the system comprises a lock acquisition triggering module, a service node and a backup node, wherein the lock acquisition triggering module is used for receiving lock acquisition information sent by the service node, and the service node comprises at least one of a main node and a backup node;
and the switching execution module is used for selecting a new main node from the service nodes according to the lock robbing information, wherein the main node is used for processing the information service request sent by the client.
11. A service switching apparatus, applied to a service node, the apparatus comprising:
the information sending module is used for sending the lock robbing information and the heartbeat information to the management node so that the management node determines a new main node;
and the information service module is used for providing information service for the client according to the current node role when receiving the information service request.
12. A service switching system, characterized in that the system comprises at least: the system comprises a management node, a service node and a client;
wherein the management node is configured to perform the service switching method of any one of claims 1-5;
the service node is configured to perform the service switching method of any one of claims 6 to 9;
the client is used for sending an information service request to the service node to acquire information service.
13. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a service switching method according to any one of claims 1-5 or 6-9.
CN202011627556.5A 2020-12-31 2020-12-31 Service switching method, device, system and storage medium Pending CN113904914A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011627556.5A CN113904914A (en) 2020-12-31 2020-12-31 Service switching method, device, system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011627556.5A CN113904914A (en) 2020-12-31 2020-12-31 Service switching method, device, system and storage medium

Publications (1)

Publication Number Publication Date
CN113904914A true CN113904914A (en) 2022-01-07

Family

ID=79186876

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011627556.5A Pending CN113904914A (en) 2020-12-31 2020-12-31 Service switching method, device, system and storage medium

Country Status (1)

Country Link
CN (1) CN113904914A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115277379A (en) * 2022-07-08 2022-11-01 北京城市网邻信息技术有限公司 Distributed lock disaster tolerance processing method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7478263B1 (en) * 2004-06-01 2009-01-13 Network Appliance, Inc. System and method for establishing bi-directional failover in a two node cluster
CN103530200A (en) * 2012-07-04 2014-01-22 腾讯科技(深圳)有限公司 Server hot backup system and method
CN106856489A (en) * 2015-12-08 2017-06-16 阿里巴巴集团控股有限公司 A kind of service node switching method and apparatus of distributed memory system
CN109005045A (en) * 2017-06-06 2018-12-14 北京金山云网络技术有限公司 Active and standby service system and host node fault recovery method
CN109240840A (en) * 2017-07-11 2019-01-18 阿里巴巴集团控股有限公司 Disaster recovery method, device and the machine readable media of group system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7478263B1 (en) * 2004-06-01 2009-01-13 Network Appliance, Inc. System and method for establishing bi-directional failover in a two node cluster
CN103530200A (en) * 2012-07-04 2014-01-22 腾讯科技(深圳)有限公司 Server hot backup system and method
CN106856489A (en) * 2015-12-08 2017-06-16 阿里巴巴集团控股有限公司 A kind of service node switching method and apparatus of distributed memory system
CN109005045A (en) * 2017-06-06 2018-12-14 北京金山云网络技术有限公司 Active and standby service system and host node fault recovery method
CN109240840A (en) * 2017-07-11 2019-01-18 阿里巴巴集团控股有限公司 Disaster recovery method, device and the machine readable media of group system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115277379A (en) * 2022-07-08 2022-11-01 北京城市网邻信息技术有限公司 Distributed lock disaster tolerance processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN108847982B (en) Distributed storage cluster and node fault switching method and device thereof
CN109344014B (en) Main/standby switching method and device and communication equipment
US10846185B2 (en) Method for processing acquire lock request and server
US6859889B2 (en) Backup system and method for distributed systems
US10038593B2 (en) Method and system for recovering virtual network
CN106936613B (en) Method and system for rapidly switching main and standby Openflow switch
CN110597664A (en) High-availability cluster resource deployment method, device and related components
CN111459749A (en) Prometous-based private cloud monitoring method and device, computer equipment and storage medium
CN110971702A (en) Service calling method and device, computer equipment and storage medium
CN111865632A (en) Switching method of distributed data storage cluster and switching instruction sending method and device
CN113904914A (en) Service switching method, device, system and storage medium
CN112511326A (en) Switching method, device, equipment and storage medium
CN115168031A (en) Fog calculation system, method, electronic equipment and storage medium
CN112787918B (en) Data center addressing and master-slave switching method based on service routing tree
CN112383414B (en) Dual-machine hot backup quick switching method and device
CN112737844A (en) Method and device for switching between main and standby in redundant system
JPH09293059A (en) Decentralized system and its operation management method
CN111385324A (en) Data communication method, device, equipment and storage medium
CN115145782A (en) Server switching method, mooseFS system and storage medium
CN114745413A (en) Access control method and device for server, computer equipment and storage medium
CN115001956B (en) Method, device, equipment and storage medium for running server cluster
WO2024061219A1 (en) Information updating method, apparatus and device, storage medium, and program product
CN117806815B (en) Data processing method, system, electronic device and storage medium
CN112905719A (en) Data processing method, device, equipment and medium
CN115549751A (en) Remote sensing satellite ground station monitoring system and method

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