CN109245908A - A kind of method and apparatus of principal and subordinate's cluster switching - Google Patents

A kind of method and apparatus of principal and subordinate's cluster switching Download PDF

Info

Publication number
CN109245908A
CN109245908A CN201710555869.6A CN201710555869A CN109245908A CN 109245908 A CN109245908 A CN 109245908A CN 201710555869 A CN201710555869 A CN 201710555869A CN 109245908 A CN109245908 A CN 109245908A
Authority
CN
China
Prior art keywords
cluster
back end
nodal value
configuration information
client
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
CN201710555869.6A
Other languages
Chinese (zh)
Other versions
CN109245908B (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 Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information 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 Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710555869.6A priority Critical patent/CN109245908B/en
Publication of CN109245908A publication Critical patent/CN109245908A/en
Application granted granted Critical
Publication of CN109245908B publication Critical patent/CN109245908B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0876Aspects of the degree of configuration automation
    • H04L41/0886Fully automatic configuration
    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1044Group management mechanisms 

Abstract

The embodiment of the present invention provides a kind of method and apparatus of principal and subordinate's cluster switching, is related to field of computer technology.The method of the embodiment of the present invention includes: creation back end, the configuration information of main cluster is written in the nodal value of corresponding back end;When needing to carry out the switching of principal and subordinate's cluster, the nodal value of the back end is revised as the to be switched configuration information from cluster;Whether the nodal value for monitoring the back end changes, after monitoring that the nodal value changes, the to be switched configuration information from cluster is obtained, the client is modified according to the configuration information got and is directed toward the link of cluster to realize the switching of principal and subordinate's cluster.By configuration information being written in the nodal value of back end in the embodiment of the present invention, the nodal value of client monitors back end changes, after monitoring that nodal value changes, obtains the configuration information from cluster and modify the link of client to cluster, realize the online switching of principal and subordinate's cluster.

Description

A kind of method and apparatus of principal and subordinate's cluster switching
Technical field
The present invention relates to the method and apparatus that computer field more particularly to a kind of principal and subordinate's cluster switch.
Background technique
Currently, more and more Internet companies start using large-scale cluster come supporting business, in order to guarantee cluster High Availabitity, many companies all use principal and subordinate's cluster across computer room disaster tolerance as solution.The switching of principal and subordinate's cluster at present There are mainly two types of schemes: scheme one: modification configuration is restarted.Client prepares two sets of configurations, and main cluster is directed toward in a set of configuration, another Set configuration is directed toward from cluster, and when main clustering fault, client restarts application, and modification is configured to be directed toward from cluster.Scheme two: double It is living.Two sets of clients are run simultaneously, and a set of client accesses main cluster, and another set of client access is from cluster, when main cluster event When barrier, accesses and remain to normally access from the application of cluster.
In realizing process of the present invention, at least there are the following problems in the prior art for inventor's discovery:
(1) it services unavailable.Restart client mean to service it is unavailable, this in line service often can not Tolerance.
(2) time-consuming.When client scale is when thousands of even more big, it is very long to restart client time-consuming.
(3) at high cost.The scheme of dual-active means to expend more resources, needs higher maintenance cost.
(4) data consistency.The scheme of dual-active needs the data consistency of client oneself guarantee principal and subordinate's cluster, when a set of After the fault recovery of client, complement is generally required.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method and apparatus of principal and subordinate's cluster switching.In the embodiment of the present invention By configuration information being written in the nodal value of back end, the nodal value of client monitors back end changes, when monitoring After nodal value changes, obtains the configuration information from cluster and modify the link of client to cluster, realize principal and subordinate's cluster Online switching.
To achieve the above object, according to an aspect of an embodiment of the present invention, a kind of side of principal and subordinate's cluster switching is provided Method.
A kind of method of principal and subordinate's cluster switching of the embodiment of the present invention, comprising: creation back end, by the configuration of main cluster Information is written in the nodal value of corresponding back end;When needing to carry out the switching of principal and subordinate's cluster, by the section of the back end Point value is revised as the to be switched configuration information from cluster;Whether the nodal value for monitoring the back end changes, and works as prison It measures after the nodal value changes, obtains the to be switched configuration information from cluster, confidence is matched according to getting Breath modifies the client and is directed toward the link of cluster to realize the switching of principal and subordinate's cluster.
Optionally, back end is created, comprising: the back end is created in ZooKeeper.
Optionally, whether the nodal value for monitoring the back end changes, comprising: is arranged to the back end and supervises Listen whether device is changed with the nodal value of back end described in real-time monitoring.
Optionally, whether the nodal value for monitoring the back end changes, comprising: institute is inquired in timing or not timing State the nodal value of back end, more adjacent nodal value twice it is whether identical with monitor the back end nodal value whether It changes.
Optionally, the method also includes: in client terminal start-up, the configuration information of the main cluster is obtained, according to institute It states configuration information and creates the link that the client is directed toward cluster.
To achieve the above object, according to another aspect of an embodiment of the present invention, a kind of dress of principal and subordinate's cluster switching is provided It sets.
A kind of device of principal and subordinate's cluster switching of the embodiment of the present invention, comprising: creation and writing module, for creating data Node the configuration information of main cluster is written in the nodal value of corresponding back end;Modified module is led for working as When switching from cluster, the nodal value of the back end is revised as the to be switched configuration information from cluster;Monitoring and modification Whether link module, the nodal value for monitoring the back end change, when monitoring that the nodal value changes Afterwards, the to be switched configuration information from cluster is obtained, the client is modified according to the configuration information got and is directed toward collection The link of group is to realize the switching of principal and subordinate's cluster.
Optionally, the creation and writing module, are also used to: the back end is created in ZooKeeper.
Optionally, the monitoring and modification link module, are also used to: to back end setting monitor to supervise in real time Whether the nodal value for surveying the back end changes.
Optionally, the monitoring and modification link module, be also used to: the back end is inquired in timing or not timing Nodal value, whether more adjacent nodal value twice is identical is changed with the nodal value for monitoring the back end.
Optionally, described device further include: creation link module, for obtaining the main cluster in client terminal start-up Configuration information, the link that the client is directed toward cluster is created according to the configuration information.
To achieve the above object, according to an embodiment of the present invention in another aspect, providing a kind of electronic equipment.
The a kind of electronic equipment of the embodiment of the present invention, comprising: one or more processors;Storage device, for storing one A or multiple programs, when one or more of programs are executed by one or more of processors, so that one or more The method that a processor realizes a kind of principal and subordinate's cluster switching of the embodiment of the present invention.
To achieve the above object, according to an embodiment of the present invention in another aspect, providing a kind of computer-readable medium.
A kind of computer-readable medium of the embodiment of the present invention, is stored thereon with computer program, and described program is processed A kind of method of principal and subordinate's cluster switching of the embodiment of the present invention is realized when device executes.
One embodiment in foregoing invention has the following advantages that or the utility model has the advantages that by the way that configuration information is maintained into data Node, the nodal value variation of client monitors back end obtain configuration information and repair after monitoring that nodal value changes Change the link of client to cluster, the online switching of principal and subordinate's cluster is only achieved that with a set of client.By by configuration information It is maintained into ZooKeeper, and monitors nodal value variation in real time with monitor, it is ingenious to have used ZooKeeper that pass through monitoring The characteristics of device is monitored in real time is rapidly completed the switching of principal and subordinate's cluster, switching can still be rapidly completed when client terminal quantity is huge.
Further effect possessed by above-mentioned non-usual optional way adds hereinafter in conjunction with specific embodiment With explanation.
Detailed description of the invention
Attached drawing for a better understanding of the present invention, does not constitute an undue limitation on the present invention.Wherein:
Fig. 1 is the schematic diagram of the key step of the method for principal and subordinate's cluster switching according to an embodiment of the present invention;
Fig. 2 is the flow chart of the method for principal and subordinate's cluster switching according to an embodiment of the present invention;
Fig. 3 is the architecture diagram of principal and subordinate's cluster switching system before cluster switching according to an embodiment of the present invention;
Fig. 4 is the architecture diagram of principal and subordinate's cluster switching system after cluster switching according to an embodiment of the present invention;
Fig. 5 is the schematic diagram of back end in ZooKeeper before cluster according to an embodiment of the present invention switches;
Fig. 6 is the schematic diagram of back end in ZooKeeper after modification according to an embodiment of the present invention;
Fig. 7 is the schematic diagram of the main modular of the device of principal and subordinate's cluster switching according to an embodiment of the present invention;
Fig. 8 is that the embodiment of the present invention can be applied to exemplary system architecture figure therein;
Fig. 9 is the structural schematic diagram for being suitable for the computer installation of the electronic equipment to realize the embodiment of the present invention.
Specific embodiment
Below in conjunction with attached drawing, an exemplary embodiment of the present invention will be described, including the various of the embodiment of the present invention Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize It arrives, it can be with various changes and modifications are made to the embodiments described herein, without departing from scope and spirit of the present invention.Together Sample, for clarity and conciseness, descriptions of well-known functions and structures are omitted from the following description.
Fig. 1 is the schematic diagram of the key step of the method for principal and subordinate's cluster switching according to an embodiment of the present invention.Such as Fig. 1 institute Show, the method for principal and subordinate's cluster switching of the embodiment of the present invention mainly includes the following steps:
Step S101: creation back end the configuration information of main cluster is written in the nodal value of corresponding back end. Configuration information is uniformly maintained into back end by this step, and back end here can be in distributed application services It is created in ZooKeeper or in Consul.One back end generally corresponds to the specific service application of user.Configuration Information can be written in the nodal value of back end, know whether configuration information has occurred subsequently through the variation of monitoring node value Change.
Step S102: when needing to carry out the switching of principal and subordinate's cluster, the nodal value of the back end is revised as to be switched Slave cluster configuration information.When main clustering fault or main cluster need to carry out upgrade maintenance, need to carry out principal and subordinate's cluster Switching.Here two kinds of scenes are considered, one is nodal value is revised as to be switched matching from cluster manually by maintenance personnel Confidence breath, triggering cluster switching.Another kind is that main clustering fault is observed from cluster, automatically by itself configurable write ingress value In, triggering cluster switching.
Step S103: whether the nodal value for monitoring the back end changes, when monitoring that the nodal value occurs After variation, the to be switched configuration information from cluster is obtained, the client is modified according to the configuration information got and is referred to To the link of cluster to realize the switching of principal and subordinate's cluster.Client is by monitor process come the variation of real-time monitoring nodal value. After server end triggers monitoring event, it can send and notify to client, it is to be switched from cluster that acquisition is executed by client Configuration information readjustment logic.The link of cluster is directed toward so that client refers to according to the configuration information modification client got To be switched from cluster, the online switching of principal and subordinate's cluster is so far completed.After the completion of switching, monitor process continues monitoring modification Whether nodal value afterwards changes.
Wherein, whether the nodal value that the back end is monitored in step 103 changes, and mentions in the embodiment of the present invention Two kinds of implementations are supplied.Mode one: to back end setting monitor with the node of back end described in real-time monitoring Whether value changes.Mode two: the nodal value of the back end, more adjacent section twice are inquired in timing or not timing Whether whether point value is identical is changed with the nodal value for monitoring the back end.Mode one can be monitored in real time, mode two It can not real-time monitoring.
When using the configuration information of ZooKeeper maintenance cluster, client can pass through Watcher process real-time monitoring number Whether change according to the nodal value of node.Specific implementation are as follows: client is to ZooKeeper server registration Watcher, together When, Watcher object is stored in the management of monitor device (WatchManager) of client.When ZooKeeper server touches After sending out Watcher event, the notice that Watcher event occurs for which back end can be sent to client, client again from Corresponding Watcher object is taken out in WatchManager to execute readjustment logic.Wherein, Watcher is that ZooKeeper is realized The main means of the applications such as distributed lock, decentralized configuration, distributed queue can monitor the nodal value variation of arbitrary node.
In addition, between step 101 and step 102, the method for principal and subordinate's cluster switching of the embodiment of the present invention further include: When client terminal start-up, the configuration information of the main cluster is obtained, the client is created according to the configuration information and is directed toward cluster Link.Below by taking the configuration information using ZooKeeper maintenance cluster as an example, which is described in detail:
(1) configuration information of cluster: starting client is obtained, client obtains the back end being locally configured, access ZooKeeper simultaneously inquires the data in corresponding data node, parses the data to obtain the configuration information of main cluster;
(2) creation link: client constructs configuration parameter according to the configuration information of acquisition, uses configuration parameter create chain It connects.
Below to safeguard configuration information, the main cluster that cluster A is accessed as client, cluster B conduct in ZooKeeper For to be switched slave cluster, principal and subordinate's cluster switching method of the invention is illustrated.
Each cluster includes multiple servers, one or more server in cluster constitutes server-side.Client Access request is initiated to server-side, the final access request can be transferred to the specific service device of server-side.Before the switching of principal and subordinate's cluster Afterwards, it need to guarantee that data/table of client request exists in another cluster, therefore the data between cluster A and cluster B are answered When being mutually synchronized.By taking cluster A is HBase cluster (cluster is a distributed column storage system) as an example, synchronous specific reality Existing mode can be with are as follows: cluster A is by included duplication (Replication) function by write-ahead log (Write-Ahead Logging, WAL) it is sent to cluster B, cluster B plays back WAL log after receiving, daily record data is written in this cluster.
Fig. 2 is the flow chart of the method for principal and subordinate's cluster switching according to an embodiment of the present invention.As shown in Fig. 2, the present invention is real The method for applying principal and subordinate's cluster switching of example, includes the following steps:
Step S201: creating corresponding back end in ZooKeeper, and the configuration information write-in of cluster A is corresponding In back end;It is corresponding with client for creating the correspondence in corresponding back end.Usually created in ZooKeeper cluster Back end, the back end are used to the configuration information of storage cluster, are the entities of client access ZooKeeper.
Step S202: starting client obtains the configuration information of the cluster A of corresponding data node in ZooKeeper;Client It can configure which back end it monitors in the configuration file at end.
Step S203: client creates its link for being directed toward cluster according to the configuration information of the cluster A of acquisition, meanwhile, wound Build a monitor process (Watcher process);
Step S204: when needing to switch over, the manual/auto nodal value by corresponding data node in ZooKeeper It is revised as the configuration information of to be switched cluster B;
Step S205: client is by the variation of Watcher process real-time monitoring nodal value, when monitoring nodal value After variation, the configuration information of cluster B is reacquired;
Step S206: client modifies its link for being directed toward cluster according to the configuration information of the cluster B got.
After step S206 is finished, cluster B is switched as main cluster.Later, client repeat step S205 and S206 by Watcher process to continue to monitor whether modified nodal value changes, after monitoring nodal value variation, The configuration information of new cluster is reacquired, new cluster is directed toward in modification link.
Fig. 3 is the architecture diagram of principal and subordinate's cluster switching system before cluster switching according to an embodiment of the present invention.Such as Fig. 3 institute Show, the master-slave swap system of the embodiment of the present invention includes client 1 to client N, cluster A, cluster B and ZooKeeper, cluster Before switching, cluster A is client 1 to the main cluster of client N, passes through step S201 to step S203, client 1 to client N obtains the configuration information of cluster A from the corresponding data node of ZooKeeper, then creates client 1 to client N direction The link of cluster A so that client 1 to client N access cluster A.
Fig. 4 is the architecture diagram of principal and subordinate's cluster switching system after cluster switching according to an embodiment of the present invention.Such as Fig. 4 institute Show, after cluster switching, cluster B is switched to the main cluster of client 1 to client N.Pass through step S205, step S206, visitor In corresponding data node of the family end 1 to client N from ZooKeeper obtain cluster B configuration information, then by client 1 to Client N be directed toward cluster A link be modified to point to cluster B so that client 1 to client N access cluster B.
Fig. 5 is the schematic diagram of back end in ZooKeeper before cluster according to an embodiment of the present invention switches.Such as Fig. 5 institute Show, before cluster switching, creation corresponds to the back end 1 of client to back end N in ZooKeeper.Back end 1 to The nodename of back end N corresponds to/SL100000000001 to/SL10000000000N;Back end 1 is to back end The nodal value of N is the configuration information of cluster A.Certainly, here back end 1 to back end N configuration information be cluster A also It is that cluster B can be customized by the user, for example set the nodal value of back end 1 to the configuration information of cluster A, back end 2 nodal value is set as the configuration information of cluster B, is only a schematic diagram in figure.
Fig. 6 is the schematic diagram of back end in ZooKeeper after modification according to an embodiment of the present invention.As shown in fig. 6, working as When needing main cluster being switched to cluster B by cluster A, the nodal value of back end 1 to back end N is revised as cluster B Configuration information.Equally, back end 1 to the modified nodal value of back end N can also be customized by the user here.
The method of principal and subordinate's cluster switching through the embodiment of the present invention can be seen that by the way that configuration information is maintained into data Node, the nodal value variation of client monitors back end obtain configuration information and repair after monitoring that nodal value changes Change the link of client to cluster, the online switching of principal and subordinate's cluster is only achieved that with a set of client.By by configuration information It is maintained into ZooKeeper, and monitors nodal value variation in real time with monitor, it is ingenious to have used ZooKeeper that pass through monitoring The characteristics of device is monitored in real time is rapidly completed the switching of principal and subordinate's cluster, switching can still be rapidly completed when client terminal quantity is huge.
Fig. 7 is the schematic diagram of the main modular of the device of principal and subordinate's cluster switching according to an embodiment of the present invention.Such as Fig. 7 institute Show, the device of principal and subordinate's cluster switching of the embodiment of the present invention includes:
For creating back end corresponding data section is written in the configuration information of main cluster by creation and writing module 701 In the nodal value of point.Configuration information is uniformly maintained into the back end created in ZooKeeper in embodiment.
Modified module 702, for when needing to carry out the switching of principal and subordinate's cluster, the nodal value of the back end to be revised as The configuration information of to be switched slave cluster.When main clustering fault or main cluster need to carry out upgrade maintenance, led Switch from cluster.Here two kinds of scenes are considered, it is to be switched from collection one is manually nodal value is revised as by maintenance personnel The configuration information of group, triggering cluster switching.Another kind is that main clustering fault is observed from cluster, itself will configure write-in section automatically In point value, triggering cluster switching.
Whether monitoring and modification link module 703, the nodal value for monitoring the back end change, and work as monitoring After changing to the nodal value, the to be switched configuration information from cluster is obtained, according to the configuration information got It modifies the client and is directed toward the link of cluster to realize the switching of principal and subordinate's cluster.It can be with ZooKeeper in embodiment The characteristics of being monitored in real time by Watcher, client is by the variation of Watcher monitoring the process nodal value, when monitoring node After value changes, modification client is directed toward the link of cluster, the principal and subordinate's cluster switching being automatically performed.After the completion of switching, monitor Process continues to monitor whether modified nodal value changes.
From the above, it can be seen that by the way that configuration information is maintained into back end, client monitors back end Nodal value variation obtains configuration information and modifies the link of client to cluster, only use after monitoring that nodal value changes A set of client is achieved that the online switching of principal and subordinate's cluster.By the way that configuration information is maintained into ZooKeeper, and with monitor Device monitors nodal value variation in real time, ingenious the characteristics of having used ZooKeeper that can monitor in real time by monitor, master is rapidly completed Switch from cluster, switching can still be rapidly completed when client terminal quantity is huge.
Fig. 8 is shown can be using the device for the method or the switching of principal and subordinate's cluster that principal and subordinate's cluster of the embodiment of the present invention switches Exemplary system architecture 800.
As shown in figure 8, system architecture 800 may include terminal device 801,802,803, network 804 and server 805. Network 804 between terminal device 801,802,803 and server 805 to provide the medium of communication link.Network 804 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 801,802,803 and be interacted by network 804 with server 805, to receive or send out Send message etc..Various telecommunication customer end applications, such as the application of shopping class, net can be installed on terminal device 801,802,803 (merely illustrative) such as the application of page browsing device, searching class application, instant messaging tools, mailbox client, social platform softwares.
Terminal device 801,802,803 can be the various electronic equipments with display screen and supported web page browsing, packet Include but be not limited to smart phone, tablet computer, pocket computer on knee and desktop computer etc..
Server 805 can be to provide the server of various services, such as utilize terminal device 801,802,803 to user Generated click event provides the back-stage management server (merely illustrative) supported.Back-stage management server can be to receiving The data such as click data, content of text analyze etc. processing, and (such as target push information, product are believed by processing result Breath -- merely illustrative) feed back to terminal device.
It should be noted that the method for the switching of principal and subordinate's cluster provided by the embodiment of the present application is generally by 805 He of server Terminal device 801,802,803 executes, and correspondingly, the device of principal and subordinate's cluster switching is generally positioned at server 805 and terminal is set In standby 801,802,803.
It should be understood that the number of terminal device, network and server in Fig. 8 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.
According to an embodiment of the invention, the present invention also provides a kind of electronic equipment and a kind of computer-readable medium.
Electronic equipment of the invention includes: one or more processors;Storage device, for storing one or more journeys Sequence, when one or more of programs are executed by one or more of processors, so that one or more of processors are real A kind of method of principal and subordinate's cluster switching of the existing embodiment of the present invention.
Computer-readable medium of the invention is stored thereon with computer program, real when described program is executed by processor A kind of method of principal and subordinate's cluster switching of the existing embodiment of the present invention.
Below with reference to Fig. 9, it illustrates the computer systems 900 for the terminal device for being suitable for being used to realize the embodiment of the present invention Structural schematic diagram.Terminal device shown in Fig. 9 is only an example, function to the embodiment of the present invention and should not use model Shroud carrys out any restrictions.
As shown in figure 9, computer system 900 includes central processing unit (CPU) 901, it can be read-only according to being stored in Program in memory (ROM) 902 or be loaded into the program in random access storage device (RAM) 903 from storage section 908 and Execute various movements appropriate and processing.In RAM 903, also it is stored with system 900 and operates required various programs and data. CPU 901, ROM 902 and RAM 903 are connected with each other by bus 904.Input/output (I/O) interface 905 is also connected to always Line 904.
I/O interface 905 is connected to lower component: the importation 906 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 907 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 908 including hard disk etc.; And the communications portion 909 of the network interface card including LAN card, modem etc..Communications portion 909 via such as because The network of spy's net executes communication process.Driver 910 is also connected to I/O interface 905 as needed.Detachable media 911, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 910, in order to read from thereon Computer program be mounted into storage section 908 as needed.
Particularly, disclosed embodiment, the process of key step figure description above may be implemented as counting according to the present invention Calculation machine software program.For example, embodiment disclosed by the invention includes a kind of computer program product comprising be carried on computer Computer program on readable medium, the computer program include the program code for method shown in execution flow chart.? In such embodiment, which can be downloaded and installed from network by communications portion 909, and/or from can Medium 911 is dismantled to be mounted.When the computer program is executed by central processing unit (CPU) 901, system of the invention is executed The above-mentioned function of middle restriction.
It should be noted that computer-readable medium shown in the present invention can be computer-readable signal media or meter Calculation machine readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example can be --- but not Be limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.Meter The more specific example of calculation machine readable storage medium storing program for executing can include but is not limited to: have the electrical connection, just of one or more conducting wires Taking formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only storage Device (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device, Or above-mentioned any appropriate combination.In the present invention, computer readable storage medium can be it is any include or storage journey The tangible medium of sequence, the program can be commanded execution system, device or device use or in connection.And at this In invention, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal, Wherein carry computer-readable program code.The data-signal of this propagation can take various forms, including but unlimited In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for By the use of instruction execution system, device or device or program in connection.Include on computer-readable medium Program code can transmit with any suitable medium, including but not limited to: wireless, electric wire, optical cable, RF etc. are above-mentioned Any appropriate combination.
Key step figure and block diagram in attached drawing, illustrate the system, method and calculating according to various embodiments of the invention The architecture, function and operation in the cards of machine program product.In this regard, each box in flowchart or block diagram can To represent a part of a module, program segment or code, a part of above-mentioned module, program segment or code include one or Multiple executable instructions for implementing the specified logical function.It should also be noted that in some implementations as replacements, box Middle marked function can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated It can actually be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved. It, can be with holding it is also noted that the combination of each box in block diagram or flow chart and the box in block diagram or flow chart The dedicated hardware based system of functions or operations as defined in row is realized, or can use specialized hardware and computer instruction Combination realize.
Being described in module involved in the embodiment of the present invention can be realized by way of software, can also be by hard The mode of part is realized.Described module also can be set in the processor, for example, can be described as: a kind of processor packet Include creation and writing module, modified module and monitoring and modification link module.Wherein, the title of these units is under certain conditions The restriction to the unit itself is not constituted, " creation back end, will for example, dependence packet generation module is also described as The module in the nodal value of corresponding back end is written in the configuration information of main cluster ".
As on the other hand, the present invention also provides a kind of computer-readable medium, which be can be Included in equipment described in above-described embodiment;It is also possible to individualism, and without in the supplying equipment.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the equipment, makes Obtaining the equipment includes: creation back end, the configuration information of main cluster is written in the nodal value of corresponding back end;When need When carrying out the switching of principal and subordinate's cluster, the nodal value of the back end is revised as the to be switched configuration information from cluster;Prison Whether the nodal value for surveying the back end changes, and after monitoring that the nodal value changes, obtains to be switched From the configuration information of cluster, the client is modified according to the configuration information got and is directed toward the link of cluster to realize The switching of principal and subordinate cluster.
From the above, it can be seen that by the way that configuration information is maintained into back end, client monitors back end Nodal value variation obtains configuration information and modifies the link of client to cluster, only use after monitoring that nodal value changes A set of client is achieved that the online switching of principal and subordinate's cluster.By the way that configuration information is maintained into ZooKeeper, and with monitor Device monitors nodal value variation in real time, ingenious the characteristics of having used ZooKeeper that can monitor in real time by monitor, master is rapidly completed Switch from cluster, switching can still be rapidly completed when client terminal quantity is huge.
Method provided by the embodiment of the present invention can be performed in the said goods, has the corresponding functional module of execution method and has Beneficial effect.The not technical detail of detailed description in the present embodiment, reference can be made to method provided by the embodiment of the present invention.
Above-mentioned specific embodiment, does not constitute a limitation on the scope of protection of the present invention.Those skilled in the art should be bright It is white, design requirement and other factors are depended on, various modifications, combination, sub-portfolio and substitution can occur.It is any Made modifications, equivalent substitutions and improvements etc. within the spirit and principles in the present invention, should be included in the scope of the present invention Within.

Claims (12)

1. a kind of method of principal and subordinate's cluster switching characterized by comprising
Back end is created, the configuration information of main cluster is written in the nodal value of corresponding back end;
When needing to carry out the switching of principal and subordinate's cluster, the nodal value of the back end is revised as the to be switched configuration from cluster Information;
Whether the nodal value for monitoring the back end changes, after monitoring that the nodal value changes, obtain to The configuration information of the slave cluster of switching, according to the configuration information got modify the client be directed toward the link of cluster from And realize the switching of principal and subordinate's cluster.
2. the method according to claim 1, wherein creation back end, comprising: created in ZooKeeper The back end.
3. method according to claim 1 or 2, which is characterized in that whether the nodal value for monitoring the back end occurs Variation, comprising: whether changed to back end setting monitor with the nodal value of back end described in real-time monitoring.
4. method according to claim 1 or 2, which is characterized in that whether the nodal value for monitoring the back end occurs Variation, comprising: the nodal value of the back end is inquired in timing or not timing, and whether more adjacent nodal value twice is identical To monitor whether the nodal value of the back end changes.
5. the method according to claim 1, wherein the method also includes: in client terminal start-up, obtain institute The configuration information for stating main cluster creates the link that the client is directed toward cluster according to the configuration information.
6. a kind of device of principal and subordinate's cluster switching characterized by comprising
For creating back end the section of corresponding back end is written in the configuration information of main cluster by creation and writing module In point value;
Modified module, for the nodal value of the back end being revised as to be switched when needing to carry out the switching of principal and subordinate's cluster Slave cluster configuration information;
Whether monitoring and modification link module, the nodal value for monitoring the back end change, described when monitoring After nodal value changes, the to be switched configuration information from cluster is obtained, institute is modified according to the configuration information got It states client and is directed toward the link of cluster to realize the switching of principal and subordinate's cluster.
7. device according to claim 6, which is characterized in that the creation and writing module are also used to: The back end is created in ZooKeeper.
8. device according to claim 6 or 7, which is characterized in that the monitoring and modification link module are also used to: right Whether the back end setting monitor is changed with the nodal value of back end described in real-time monitoring.
9. device according to claim 6 or 7, which is characterized in that the monitoring and modification link module are also used to: fixed When or not timing inquire the nodal value of the back end, whether more adjacent nodal value twice identical to monitor the number Whether change according to the nodal value of node.
10. device according to claim 6, which is characterized in that described device further include: creation link module is used for When client terminal start-up, the configuration information of the main cluster is obtained, the client is created according to the configuration information and is directed toward cluster Link.
11. a kind of electronic equipment characterized by comprising
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real Now such as method as claimed in any one of claims 1 to 5.
12. a kind of computer-readable medium, is stored thereon with computer program, which is characterized in that
Such as method as claimed in any one of claims 1 to 5 is realized when described program is executed by processor.
CN201710555869.6A 2017-07-10 2017-07-10 Method and device for switching master cluster and slave cluster Active CN109245908B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710555869.6A CN109245908B (en) 2017-07-10 2017-07-10 Method and device for switching master cluster and slave cluster

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710555869.6A CN109245908B (en) 2017-07-10 2017-07-10 Method and device for switching master cluster and slave cluster

Publications (2)

Publication Number Publication Date
CN109245908A true CN109245908A (en) 2019-01-18
CN109245908B CN109245908B (en) 2022-04-26

Family

ID=65082964

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710555869.6A Active CN109245908B (en) 2017-07-10 2017-07-10 Method and device for switching master cluster and slave cluster

Country Status (1)

Country Link
CN (1) CN109245908B (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111277632A (en) * 2020-01-13 2020-06-12 中国建设银行股份有限公司 Method and device for managing applications in system cluster
CN111371865A (en) * 2020-02-26 2020-07-03 上海达梦数据库有限公司 Client connection relation adjusting method, system and node
CN111901395A (en) * 2020-07-07 2020-11-06 青岛海尔科技有限公司 Multi-cluster switching method and device
CN111917846A (en) * 2020-07-19 2020-11-10 中信银行股份有限公司 Kafka cluster switching method, device and system, electronic equipment and readable storage medium
WO2021072967A1 (en) * 2019-10-17 2021-04-22 厦门网宿有限公司 Method and device for managing configuration information
CN113765690A (en) * 2021-01-07 2021-12-07 北京沃东天骏信息技术有限公司 Cluster switching method, system, device, terminal, server and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1716227A (en) * 2004-06-30 2006-01-04 富士通株式会社 Operating means and operation apparatus control method, program and computer-readable medium
CN103546914A (en) * 2013-10-21 2014-01-29 大唐移动通信设备有限公司 HSS (home subscriber server) master-slave management method and HSS master-slave management device
CN104394142A (en) * 2014-11-24 2015-03-04 北京京东尚科信息技术有限公司 Method and device for achieving automatic Redis master-slave conversion
CN105721200A (en) * 2016-01-21 2016-06-29 北京乐动卓越科技有限公司 Master-slave server system application method and system thereof
US20160381127A1 (en) * 2012-09-10 2016-12-29 William James Gibson Systems and methods for dynamic networked peer-to-peer content distribution
CN106557399A (en) * 2015-09-25 2017-04-05 伊姆西公司 Method and apparatus for the state of storage cluster is presented
CN106681861A (en) * 2016-12-08 2017-05-17 杭州销冠网络科技有限公司 New environment isolation configuration data management method and system
EP3188409A1 (en) * 2015-12-30 2017-07-05 Juniper Networks, Inc. Oam mechanisms for evpn active-active services

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1716227A (en) * 2004-06-30 2006-01-04 富士通株式会社 Operating means and operation apparatus control method, program and computer-readable medium
US20160381127A1 (en) * 2012-09-10 2016-12-29 William James Gibson Systems and methods for dynamic networked peer-to-peer content distribution
CN103546914A (en) * 2013-10-21 2014-01-29 大唐移动通信设备有限公司 HSS (home subscriber server) master-slave management method and HSS master-slave management device
CN104394142A (en) * 2014-11-24 2015-03-04 北京京东尚科信息技术有限公司 Method and device for achieving automatic Redis master-slave conversion
CN106557399A (en) * 2015-09-25 2017-04-05 伊姆西公司 Method and apparatus for the state of storage cluster is presented
EP3188409A1 (en) * 2015-12-30 2017-07-05 Juniper Networks, Inc. Oam mechanisms for evpn active-active services
CN105721200A (en) * 2016-01-21 2016-06-29 北京乐动卓越科技有限公司 Master-slave server system application method and system thereof
CN106681861A (en) * 2016-12-08 2017-05-17 杭州销冠网络科技有限公司 New environment isolation configuration data management method and system

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021072967A1 (en) * 2019-10-17 2021-04-22 厦门网宿有限公司 Method and device for managing configuration information
CN111277632A (en) * 2020-01-13 2020-06-12 中国建设银行股份有限公司 Method and device for managing applications in system cluster
CN111277632B (en) * 2020-01-13 2022-05-06 中国建设银行股份有限公司 Method and device for managing applications in system cluster
CN111371865A (en) * 2020-02-26 2020-07-03 上海达梦数据库有限公司 Client connection relation adjusting method, system and node
CN111371865B (en) * 2020-02-26 2023-02-24 上海达梦数据库有限公司 Client connection relation adjusting method, system and node
CN111901395A (en) * 2020-07-07 2020-11-06 青岛海尔科技有限公司 Multi-cluster switching method and device
CN111901395B (en) * 2020-07-07 2024-03-22 青岛海尔科技有限公司 Multi-cluster switching method and device
CN111917846A (en) * 2020-07-19 2020-11-10 中信银行股份有限公司 Kafka cluster switching method, device and system, electronic equipment and readable storage medium
CN113765690A (en) * 2021-01-07 2021-12-07 北京沃东天骏信息技术有限公司 Cluster switching method, system, device, terminal, server and storage medium

Also Published As

Publication number Publication date
CN109245908B (en) 2022-04-26

Similar Documents

Publication Publication Date Title
CN109245908A (en) A kind of method and apparatus of principal and subordinate's cluster switching
CN109905286A (en) A kind of method and system of monitoring device operating status
CN104115142B (en) For the file specific to equipment of bookmark synchronization
CN111190888A (en) Method and device for managing graph database cluster
CN109783151B (en) Method and device for rule change
CN108874828A (en) The method and apparatus of Data Migration
CN110019346A (en) A kind of data processing method and device based on double primary databases
US9727117B2 (en) Validating power paths to it equipment
CN113742031A (en) Node state information acquisition method and device, electronic equipment and readable storage medium
CN109241033A (en) The method and apparatus for creating real-time data warehouse
CN108984544A (en) A kind of method and apparatus of distributed system modification configuration information
CN110019158A (en) A kind of method and apparatus of monitoring data quality
CN112612467A (en) Method and device for processing micro front-end architecture based on qiankun
CN104167817A (en) Power equipment real-time information integration system and method
CN112860744A (en) Business process processing method and device
CN112817562A (en) Service processing method and device
CN111178849A (en) Linear process engine implementation method, device, equipment and storage medium
CN110661851A (en) Data exchange method and device
CN110119279A (en) A kind of method and apparatus applied and its upgrade
CN112398669B (en) Hadoop deployment method and device
CN110347654A (en) A kind of method and apparatus of online cluster features
CN105871659A (en) Monitoring method and device of newly added server
CN114756301A (en) Log processing method, device and system
CN110309157A (en) A kind of data synchronization updating method and apparatus
CN110019525A (en) A kind of method and apparatus of data-base capacity-enlarging

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