CN112422320A - Master-slave switching method and device of server and server - Google Patents

Master-slave switching method and device of server and server Download PDF

Info

Publication number
CN112422320A
CN112422320A CN202011167180.4A CN202011167180A CN112422320A CN 112422320 A CN112422320 A CN 112422320A CN 202011167180 A CN202011167180 A CN 202011167180A CN 112422320 A CN112422320 A CN 112422320A
Authority
CN
China
Prior art keywords
server
slave
master
priority
switching
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.)
Granted
Application number
CN202011167180.4A
Other languages
Chinese (zh)
Other versions
CN112422320B (en
Inventor
邱海港
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network 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 Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202011167180.4A priority Critical patent/CN112422320B/en
Publication of CN112422320A publication Critical patent/CN112422320A/en
Application granted granted Critical
Publication of CN112422320B publication Critical patent/CN112422320B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/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/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • H04L43/0817Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking functioning

Abstract

The invention provides a master-slave switching method, a master-slave switching device and a server, wherein the method comprises the following steps: if the current master server is monitored to be in an abnormal state, selecting a target slave server with the highest priority from a plurality of slave servers based on a preset priority sequence; each slave server is preset with a corresponding priority; and switching the target slave server into a new master server. The invention not only can select the slave server with the highest priority according to the requirement of the user, but also saves the multiple communication time required in the existing election process and improves the master-slave switching efficiency.

Description

Master-slave switching method and device of server and server
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a master-slave switching method and apparatus for a server, and a server.
Background
Due to the frequent occurrence of network abnormality, server instability and other reasons, in order to ensure high availability and continuous availability of database storage, a database is usually distributed and deployed in a server cluster in a form of one master and multiple slaves (one master and multiple slaves), and other slaves are changed into master servers when the master server is abnormal.
Disclosure of Invention
In view of this, the present invention provides a method, an apparatus, and a server for master-slave switching of a server, which can select a slave server with the highest priority according to a user requirement, save multiple communication time required in an existing election process, and improve master-slave switching efficiency.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, an embodiment of the present invention provides a master-slave switching method for a server, where the method is applied to a management server in a server cluster, and includes: if the current master server is monitored to be in an abnormal state, selecting a target slave server with the highest priority from a plurality of slave servers based on a preset priority sequence; each slave server is preset with a corresponding priority; and switching the target slave server into a new master server.
In one embodiment, the step of selecting a target slave server with the highest priority from the plurality of slave servers based on a preset priority order includes: searching a slave server with the highest priority from a plurality of slave servers according to the information of each slave server recorded in the cluster list; the server information comprises a master-slave state identifier, a priority level identifier and a service state identifier; and if the service state identifier of the searched slave server represents normal service, taking the searched slave server as a target slave server.
In one embodiment, the method further comprises: verifying whether the new main server operates normally; if not, determining that the network is abnormal, and recovering the new main server to be the slave server.
In one embodiment, the step of verifying whether the new primary server is operating normally comprises: and verifying whether the new main server operates normally or not by adopting a consensus algorithm.
In one embodiment, the step of verifying whether the new primary server operates normally by using a consensus algorithm includes: counting the response numbers of the information packets sent out by other slave servers aiming at the new master server; and if the number of the answers is less than half of the number of the information packets, determining that the new main server is abnormally operated.
In one embodiment, the priority order is associated with a server locale.
In one embodiment, a master database is arranged in the master server, and a slave database is arranged in the slave server; the main database is used for the client to read and/or edit.
In a second aspect, an embodiment of the present invention further provides a server, including a memory and a processor, where the memory stores a computer program operable on the processor, and the processor implements the steps of the method according to any one of the above first aspects when executing the computer program.
In a third aspect, embodiments of the present invention provide a machine-readable storage medium storing machine executable instructions, which when invoked and executed by a processor, cause the processor to execute the method of any one of the first aspect.
The embodiment of the invention provides a master-slave switching method, a master-slave switching device and a server of a server. In the method, each slave server is preset with a corresponding priority, and when the current master server is abnormal, the slave servers are directly selected as a new master server based on the priority sequence, so that the slave server with the highest priority can be selected according to the requirements of users, the multiple communication time required in the existing election process is saved, and the master-slave switching efficiency is improved.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention as set forth above.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 shows a flowchart of a master-slave switching method of a server according to an embodiment of the present invention;
fig. 2 is a schematic diagram illustrating a master-slave library switching provided in an embodiment of the present invention;
fig. 3 shows a flowchart of a master-slave library switching method according to an embodiment of the present invention;
fig. 4 shows a block diagram of a master-slave switching apparatus of a server according to an embodiment of the present invention;
fig. 5 shows a block diagram of a master-slave switching apparatus of a server according to an embodiment of the present invention;
fig. 6 shows a block diagram of a server according to an embodiment of the present invention.
Detailed Description
To make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the related art, most servers deployed by a database adopt an X86 server, and there are many abnormal situations in the operation process, which may be caused by downtime of the server itself or network abnormality, so that server instability becomes a common recognition, and therefore, data backup is realized mostly by adopting a master server (leader) and a plurality of slave servers (follower), and the contents of databases between the master server and the slave servers are synchronized, thereby increasing the availability of the database system. By having other slave servers as the master server when a problem occurs with the master server. In the prior art, a slave server is selected randomly as a master server by adopting an election mode when the abnormality of the master server is found. For example, when the slave server does not receive a heartbeat from the master server within a specified time, an election is actively initiated, and the election result has a certain uncertainty, that is, the election can become a slave server of the master server finally and has a certain randomness, such as that the slave server which is possibly the first to monitor the abnormality of the master server elects, but is not required by the user. In addition, multiple communications (votes) between multiple slave servers are required in the election process, so that master-slave switching time is long, certain time delay is provided, and switching efficiency is low.
In order to solve the above problems, embodiments of the present invention mainly provide a method, an apparatus, and a server for master-slave switching of a server, where the method has a core idea that a corresponding priority is configured for the server according to a user requirement, so as to determine a slave server that can become a leader according to a priority order during master-slave switching, so that not only can the slave server with the highest priority be selected according to a user requirement, but also multiple communication times required in an existing election process are saved, and master-slave switching efficiency is improved. In this way, high availability and stability of the server cluster data storage can be effectively ensured.
For ease of understanding, the following detailed description will discuss embodiments of the present invention.
Referring first to a flowchart of a master-slave switching method for a server shown in fig. 1, the method may be applied to a distributed environment, and may be specifically executed by a management server (also referred to as a management node) in a server cluster, where the master server referred to in the method may also be referred to as a master node, and a slave server may also be referred to as a slave node, so that the method may also be referred to as a master-slave switching method, which mainly includes the following steps S102 to S104:
step S102, if the current master server is monitored to be in an abnormal state, selecting a target slave server with the highest priority from a plurality of slave servers based on a preset priority sequence; wherein each slave server is preset with a corresponding priority.
For example, if the heartbeat of the master server is not monitored, or the number of slave servers responding to the communication packet of the master server is monitored to be small, it is determined that the master server is in an abnormal state, and possible reasons for the master server in the abnormal state are as follows: 1) the primary server itself fails, such as the primary server going down. 2) And (6) network exception. After the master server is determined to be in an abnormal state, in order to ensure the availability of the server cluster, a master-slave switching operation needs to be performed, that is, a certain slave server is selected as a new master server. In order to enable the selected slave servers to meet the user requirements and shorten the master-slave switching time as much as possible, in the embodiment, each slave server is preset with a corresponding priority, and the target slave server with the highest priority is selected from the multiple slave servers based on the priority order.
Step S104, the target slave server is switched to be a new master server.
In practical applications, the management server may modify the identifier used for characterizing the master-slave state of the target slave server in the cluster list, for example, if the target slave server is originally characterized as the slave state by "1", that is, the target slave server is currently characterized as the follower, when the target slave server is switched to a new master server, the "1" is modified to "0" used for characterizing the master state, that is, the target slave server is currently switched to the leader.
According to the master-slave switching method for the servers, each slave server is preset with the corresponding priority, when the current master server is abnormal, the slave server is directly selected as the new master server based on the priority sequence, the slave server with the highest priority can be selected according to the user requirements, multiple communication time required in the existing election process is saved, and the master-slave switching efficiency is improved.
The user can configure the priority according to the self requirement, such as setting the priority order based on the server related factors which are more concerned by the user, such as the server location factor, the server performance factor, the server service duration factor, and the like. In one embodiment, the priority order may be set in relation to the server site. The priority order setting mode is beneficial to making the server cluster more stable, such as setting the priority of the slave server closest to the master server to be the highest, for example, compared with the mode that the master server is located in the same machine room to perform master-slave switching and the mode that the slave server located in a different place from the master server is selected to perform master-slave switching, the switching process has less influence on the server cluster.
In a data storage application scene, databases are arranged in servers, wherein a master database (also called as master database) is arranged in the master server, and slave databases (also called as slave database) are arranged in the slave servers; the main library is used for reading and/or editing by the client. The contents in both the slave and master libraries are synchronized to determine the high and sustained availability of the database storage. For convenience of understanding, reference may be made to a master-slave library switching diagram shown in fig. 2, which simply illustrates three priorities, where the priority order is long, short, and minimum. Of course, the above is merely an example, in practical applications, the first priority, the second priority, the third priority, etc. may also be directly characterized, or the first priority, the second priority, the third priority, etc. may also be characterized, and the expression of the priority levels is not limited herein, and in addition, the three priority levels in fig. 2 are only illustrative, and the priority levels may be set in various types, such as 5-level, 10-level, etc., according to the requirements, and are not limited herein. Fig. 2 illustrates that, when performing master-slave switching, the master slave switches the master slave in the three slave banks in priority order. The mode of performing master-slave switching based on the priority order can also be understood as a legacy switching mode provided in this embodiment, and compared with the existing election switching mode, the mode not only saves the time required by election and improves the master-slave switching efficiency, but also better meets the user's will.
When the target slave server with the highest priority is selected from the plurality of slave servers based on the preset priority order, the slave server with the highest priority can be searched in the plurality of slave servers according to the information of each server recorded in the cluster list, and if the service state identifier of the searched slave server represents that the service can be performed, the searched slave server is used as the target slave server. In this embodiment, the server information includes a master-slave status identifier, a priority level identifier, and a service status identifier. The master-slave state identifier is also used for representing whether the server is in a master state (i.e. leader) or a slave state (i.e. follower), the priority level identifier is used for representing the level of the server in a preset priority order, and the service state identifier is used for representing whether the server is in a normal service state (serviceable) or an abnormal state (non-serviceable). The management server can determine a plurality of slave servers based on the master-slave state identification, search the slave server with the highest priority from the plurality of slave servers based on the priority level identification, determine the slave server as the target slave server to be switched if the service state identification of the slave server indicates that the slave server can provide normal service, and change the master-slave state identification of the target slave server to realize master-slave switching. When the client finds that the data can not be read/edited normally from the original master library, the new master server can be determined through the master-slave state identification of the servers in the cluster list, and the data can be automatically switched to the database on the new master server for data reading/editing.
In practical application, if the slave servers with the same priority level and the highest level exist in the plurality of slave servers, one of the slave servers may be selected randomly, or the slave servers with the same priority level may be selected according to the order of information records in the cluster list, which is not limited herein.
Considering that there may be a state of network anomaly, such as the primary server anomaly may be caused by network flash, but not by the failure of the primary server itself, the method further includes: verifying whether the new main server operates normally; if not, determining the network is abnormal, and recovering the new main server to be the slave server. If the network is abnormal, the original master server has no problem, so the original state can be recovered, the master server can be changed back again, and a new master server (namely the target slave server) can be recovered to be the slave server. The mode of firstly switching and then judging is an asynchronous mode, so that the master-slave switching process cannot be delayed, and the operation of a master server cannot be influenced. When the network is normal, the mode is only checking, and the server cluster is not influenced, and when the network is abnormal, the original master-slave switching strategy can be confirmed to be improper through the mode, and then the original state is recovered.
When verifying whether the new main server operates normally, a consensus algorithm may be used to verify whether the new main server operates normally. The core idea of the consensus algorithm (consensus algorithm) is to finally make multiple nodes agree with a certain event, the consensus algorithm includes, but is not limited to, a raft algorithm, and the above-mentioned manner of verifying whether a new master server operates normally by using the consensus algorithm may also be referred to as an election verification manner, that is, determining that most slave servers accept a new master server, so as to ensure the validity of the master-slave switching result.
For convenience of understanding, the present embodiment provides a main way for verifying whether a new primary server operates normally by using a consensus algorithm, which specifically includes: counting the response numbers of the information packets sent out by other slave servers aiming at the new master server; and if the number of the answers is less than half of the number of the information packets, determining that the new main server is abnormally operated. Whether other slave servers already reach a consensus as a new master server for the target slave server is judged according to the number of the answers. It can be understood that, under the condition that the new master server is known to be normal, if the number of responses is less than half of the number of packets, or even no response is found, it indicates that the network is abnormal, and a split brain or an islanding phenomenon caused by the network abnormality exists currently, so that the original state needs to be restored, and it is ensured that only one master server exists in the server cluster.
Referring to a flowchart of a master-slave library switching method shown in fig. 3, the method is executed by a management node, and mainly includes the following steps S302 to S312:
step S302: and if the current master library is detected to be abnormal, reading the cluster list, and selecting the slave library corresponding to the available IP address with the highest priority. In the method, a priority order is set according to the geographical position (IP address) of a host where the database is located.
And step S304, modifying the slave library state identifier of the selected slave library into the master library state identifier, and taking the selected slave library as a new master library. At this time, the master library state flag of the original master library is changed to the slave library state flag. In this step, master-slave bank switching is achieved.
Step S306, the response number of the outgoing information packet of the host of the new master library from the host of the other slave libraries is obtained.
Step S308, determine whether the number of replies is less than half of the number of packets. If yes, go to step S310; if not, step S314 is performed.
Step S310, determining the network abnormity, confirming the invalid switching of the master library and the slave library, and recovering the original state. That is, the master library state identifier of the new master library is changed back to the slave library state identifier, and the slave library state identifier after the original master library is changed back to the master library state identifier, so that the original state is recovered. If the number of responses is less than half of the number of the information packets, even no response is found, the network is abnormal, and split brain or isolated island phenomenon occurs.
Step S312, determining that the network is normal, and maintaining the switching result of the master library and the slave library.
Since the method of performing master-slave handover based on priority may be referred to as a relay-accepted handover method, and the method of verifying the master-slave handover result by using the consensus algorithm may be referred to as an election verification method, the scheme provided by this embodiment may be summarized as follows: relaying a master-slave switching scheme in which master is elected as slave. On one hand, the scheme can select the slave server (slave library) with the highest priority according to the requirements of users, reduces the master-slave switching time, improves the switching efficiency, and can reduce the master-slave switching time to be less than 1ms in practical application, thereby ensuring the cluster stability. And asynchronous election verification mode can not delay the master-slave switching process and influence the operation of the server, and the original master-slave switching strategy can be restored to the original state only when the original master-slave switching strategy can be verified and confirmed to be improper when the network is abnormal.
Corresponding to the foregoing master-slave switching method for a server, this embodiment further provides a master-slave switching apparatus for a server, where the apparatus is applied to a management server in a server cluster, and refer to a structural block diagram of the master-slave switching apparatus for a server shown in fig. 4, where the structural block diagram includes:
a selecting module 42, configured to select a target slave server with a highest priority from the multiple slave servers based on a preset priority order if it is monitored that the current master server is in an abnormal state; each slave server is preset with a corresponding priority;
and a switching module 44, configured to switch the target slave server to become a new master server.
In the master-slave switching device for the server provided by the embodiment, each slave server is preset with a corresponding priority, and when the current master server is abnormal, the slave server is directly selected as a new master server based on the priority sequence, so that the slave server with the highest priority can be selected according to the user requirement, the multiple communication time required in the existing election process is saved, and the master-slave switching efficiency is improved.
In one embodiment, the selecting module 42 is further configured to: searching a slave server with the highest priority from a plurality of slave servers according to the information of each slave server recorded in the cluster list; the server information comprises a master-slave state identifier, a priority level identifier and a service state identifier; and if the service state identifier of the searched slave server represents normal service, taking the searched slave server as a target slave server.
In one embodiment, referring to fig. 5, the apparatus further includes a verification module and a recovery module, the verification module 52 is configured to verify whether the new primary server is operating normally; and a recovery module 54, configured to determine that the network is abnormal and recover the new master server as the slave server if the verification result of the verification module is negative.
In one embodiment, the verification module 52 is further configured to: and verifying whether the new main server operates normally or not by adopting a consensus algorithm.
In one embodiment, the verification module 52 is further configured to: counting the response numbers of the information packets sent out by other slave servers aiming at the new master server; and if the number of the answers is less than half of the number of the information packets, determining that the new main server is abnormally operated.
In one embodiment, the priority order is associated with a server locale.
In one embodiment, a master database is arranged in the master server, and a slave database is arranged in the slave server; the main database is used for the client to read and/or edit.
The embodiment of the invention also provides a server, which comprises a memory and a processor, wherein the memory is stored with a computer program capable of running on the processor, and the processor realizes the steps of the master-slave switching method of the server when executing the computer program. The present embodiment provides a specific structure of a server, and referring to fig. 6, the server includes a processor 61 and a memory 60, the memory 60 stores machine executable instructions capable of being executed by the processor 61, and the processor 61 executes the machine executable instructions to implement the method for determining the maximum bearer traffic of the service or the method for deploying the service.
Further, the server shown in fig. 6 further includes a bus 62 and a communication interface 63, and the processor 61, the communication interface 63 and the memory 60 are connected through the bus 62.
The Memory 60 may include a high-speed Random Access Memory (RAM) and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 63 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, and the like can be used. The bus 62 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 6, but that does not indicate only one bus or one type of bus.
The processor 61 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 61. The Processor 61 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 60, and the processor 61 reads the information in the memory 60 and, in combination with its hardware, performs the steps of the method of the previous embodiment.
The embodiment of the present invention further provides a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the master-slave switching method of the server.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the apparatus and/or the electronic device described above may refer to corresponding processes in the foregoing method embodiments, and are not described herein again.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (10)

1. A master-slave switching method of a server is applied to a management server in a server cluster, and comprises the following steps:
if the current master server is monitored to be in an abnormal state, selecting a target slave server with the highest priority from a plurality of slave servers based on a preset priority sequence; each slave server is preset with a corresponding priority;
and switching the target slave server into a new master server.
2. The method according to claim 1, wherein the step of selecting a target slave server with the highest priority from the plurality of slave servers based on a preset priority order comprises:
searching a slave server with the highest priority from a plurality of slave servers according to the information of each slave server recorded in the cluster list; the server information comprises a master-slave state identifier, a priority level identifier and a service state identifier;
and if the service state identifier of the searched slave server represents normal service, taking the searched slave server as a target slave server.
3. The method of claim 1, further comprising:
verifying whether the new main server operates normally;
if not, determining that the network is abnormal, and recovering the new main server to be the slave server.
4. The method of claim 3, wherein the step of verifying whether the new primary server is operating properly comprises:
and verifying whether the new main server operates normally or not by adopting a consensus algorithm.
5. The method of claim 4, wherein the step of verifying whether the new primary server is operating normally using a consensus algorithm comprises:
counting the response numbers of the information packets sent out by other slave servers aiming at the new master server;
and if the number of the answers is less than half of the number of the information packets, determining that the new main server is abnormally operated.
6. The method according to any one of claims 1 to 5, wherein a master database is provided in the master server, and a slave database is provided in the slave server; the main database is used for the client to read and/or edit.
7. A master-slave switching device of a server, which is applied to a management server in a server cluster, comprises:
the selecting module is used for selecting a target slave server with the highest priority from the plurality of slave servers based on a preset priority sequence if the current master server is monitored to be in an abnormal state; each slave server is preset with a corresponding priority;
and the switching module is used for switching the target slave server into a new master server.
8. The apparatus of claim 7, wherein the selecting module is further configured to:
searching a slave server with the highest priority from a plurality of slave servers according to the information of each slave server recorded in the cluster list; the server information comprises a master-slave state identifier, a priority level identifier and a service state identifier;
and if the service state identifier of the searched slave server represents normal service, taking the searched slave server as a target slave server.
9. A server comprising a memory, a processor, and a computer program stored in the memory and operable on the processor, wherein the processor implements the steps of the method of any of claims 1 to 6 when executing the computer program.
10. A machine readable storage medium having stored thereon machine executable instructions which, when invoked and executed by a processor, cause the processor to execute the method of any of claims 1 to 6.
CN202011167180.4A 2020-10-27 2020-10-27 Master-slave switching method and device of server and server Active CN112422320B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011167180.4A CN112422320B (en) 2020-10-27 2020-10-27 Master-slave switching method and device of server and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011167180.4A CN112422320B (en) 2020-10-27 2020-10-27 Master-slave switching method and device of server and server

Publications (2)

Publication Number Publication Date
CN112422320A true CN112422320A (en) 2021-02-26
CN112422320B CN112422320B (en) 2022-11-11

Family

ID=74841791

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011167180.4A Active CN112422320B (en) 2020-10-27 2020-10-27 Master-slave switching method and device of server and server

Country Status (1)

Country Link
CN (1) CN112422320B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114039976A (en) * 2021-10-29 2022-02-11 深圳市科思科技股份有限公司 Server cluster master-slave machine management method and system
CN114338727A (en) * 2022-01-05 2022-04-12 中国建设银行股份有限公司 Service cluster construction method and related device
CN114363156A (en) * 2022-01-25 2022-04-15 南瑞集团有限公司 Hydropower station computer monitoring system deployment method based on cluster technology
CN114531373A (en) * 2022-02-25 2022-05-24 苏州浪潮智能科技有限公司 Node state detection method, node state detection device, equipment and medium
CN115567395A (en) * 2022-11-10 2023-01-03 苏州浪潮智能科技有限公司 Master-slave node determination 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
CN104765889A (en) * 2015-04-30 2015-07-08 北京奇虎科技有限公司 Switching method and device of high-availability frame based on database
CN108040108A (en) * 2017-12-11 2018-05-15 杭州电魂网络科技股份有限公司 Communication handover method, device, coordination service device and readable storage medium storing program for executing
CN110413685A (en) * 2019-04-12 2019-11-05 财付通支付科技有限公司 Database service switching method, device, readable storage medium storing program for executing and computer equipment
CN110908801A (en) * 2019-11-12 2020-03-24 金蝶软件(中国)有限公司 Data processing method and device based on block chain, computer equipment and storage medium
CN111277645A (en) * 2020-01-16 2020-06-12 深圳市网心科技有限公司 Hot switching method for main and standby nodes, block chain system, block chain node and medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104765889A (en) * 2015-04-30 2015-07-08 北京奇虎科技有限公司 Switching method and device of high-availability frame based on database
CN108040108A (en) * 2017-12-11 2018-05-15 杭州电魂网络科技股份有限公司 Communication handover method, device, coordination service device and readable storage medium storing program for executing
CN110413685A (en) * 2019-04-12 2019-11-05 财付通支付科技有限公司 Database service switching method, device, readable storage medium storing program for executing and computer equipment
CN110908801A (en) * 2019-11-12 2020-03-24 金蝶软件(中国)有限公司 Data processing method and device based on block chain, computer equipment and storage medium
CN111277645A (en) * 2020-01-16 2020-06-12 深圳市网心科技有限公司 Hot switching method for main and standby nodes, block chain system, block chain node and medium

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114039976A (en) * 2021-10-29 2022-02-11 深圳市科思科技股份有限公司 Server cluster master-slave machine management method and system
CN114039976B (en) * 2021-10-29 2024-01-09 深圳市科思科技股份有限公司 Master-slave management method and system for server cluster
CN114338727A (en) * 2022-01-05 2022-04-12 中国建设银行股份有限公司 Service cluster construction method and related device
CN114338727B (en) * 2022-01-05 2024-03-12 中国建设银行股份有限公司 Service cluster construction method and related device
CN114363156A (en) * 2022-01-25 2022-04-15 南瑞集团有限公司 Hydropower station computer monitoring system deployment method based on cluster technology
CN114531373A (en) * 2022-02-25 2022-05-24 苏州浪潮智能科技有限公司 Node state detection method, node state detection device, equipment and medium
CN115567395A (en) * 2022-11-10 2023-01-03 苏州浪潮智能科技有限公司 Master-slave node determination method and device, electronic equipment and storage medium
CN115567395B (en) * 2022-11-10 2023-03-07 苏州浪潮智能科技有限公司 Master-slave node determination method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112422320B (en) 2022-11-11

Similar Documents

Publication Publication Date Title
CN112422320B (en) Master-slave switching method and device of server and server
CN109462502B (en) Control method and device for configuration information storage instruction and SDN controller
US20110010560A1 (en) Failover Procedure for Server System
EP3528431B1 (en) Paxos protocol-based methods and apparatuses for online capacity expansion of distributed consistency system
CN107508694B (en) Node management method and node equipment in cluster
CN111163173B (en) Cluster configuration method and device, server and readable storage medium
CN111104282B (en) Node processing method and device based on block chain
CN110635941A (en) Database node cluster fault migration method and device
CN109756382B (en) Fault positioning method and device
CN111752488B (en) Management method and device of storage cluster, management node and storage medium
CN113515531A (en) Data access method, device, client and storage medium
CN113625945A (en) Distributed storage slow disk processing method, system, terminal and storage medium
CN112398692A (en) Consensus process processing method and device and electronic equipment
CN113132176B (en) Method for controlling edge node, node and edge computing system
CN111385359A (en) Load processing method and device of object gateway
CN114554593A (en) Data processing method and device
CN107181608B (en) Method for recovering service and improving performance and operation and maintenance management system
CN109587218B (en) Cluster election method and device
CN113055203B (en) Method and device for recovering exception of SDN control plane
CN113127266A (en) Distributed database-based multi-copy disaster recovery method and device
CN115878450A (en) Method and device for executing test task
CN112083888A (en) File storage method and device and electronic equipment
CN110502460B (en) Data processing method and node
CN111669452A (en) High-availability method and device based on multi-master DNS (Domain name System) architecture
CN115277379B (en) Distributed lock disaster recovery processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant