A kind of active/standby server switching method and deviceTechnical field
The present invention relates to computer communication technology fields, more particularly to a kind of active/standby server switching method and device.
Background technique
The effect of Keepalived is the state of detection service device, if there is a web server delay machine, or work occurFailure, Keepalived will test, and faulty server is rejected from system, while be replaced using other server generationsThe work of the server, server is added in server zone by Keepalived automatically after server is working properly, theseWork is all automatically performed, and does not need artificial interference, and need manually to do only repairs the server of failure.
In order to improve reliability, be provided between LAN (Local Area Network, local area network) parallel two orMultiple bridges, still, this configuration cause other problem, because producing circuit in topological structure, may causeInfinite Cyclic.Spanning tree (spanningtree) algorithm generallyd use at present.The method for solving the problems, such as Infinite Cyclic is to allow netBridge is in communication with each other, and the spanning tree for reaching each LAN with one covers actual topological structure.Use spanning tree, it can be ensured thatThere was only unique paths between any two LAN.Once bridge agrees upon spanning tree, this life is all deferred in all transmission between LANCheng Shu.Due to there was only unique path from each source to each destination, therefore there can not be again circulation.
In order to build spanning tree it may first have to select root of the bridge as spanning tree.The method of realization is each netBridge broadcasts its sequence number (sequence number is arranged by producer and is guaranteed global unique), selects the smallest bridge of sequence number as root.It connects, spanning tree is constructed to the shortest path of each bridge by root.If some bridge or LAN failure, are recalculated.Keepalived effect is that have a primary server and Duo Tai backup server, is disposed on primary server and backup serverIdentical service configuration externally provides service using a virtual ip address, when primary server breaks down, virtual ip addressAutomatic drift is understood to backup server.Keepalived trustship is some existing services for having port, so we can be withPort is configured in the configuration file of keepalived, such keepalived can be whether there is by port to judgeWhether service is normal, and then to switch over active/standby server.But there is no such ports for bridge services, at this moment IJust need to know other marks of bridge services, such as the status information of bridge.Spanning tree (spanningtree) algorithm is realIt is now and excessively complicated.
Summary of the invention
The present invention provides a kind of active/standby server switching method and devices, in the prior art can not be according to bridge with solutionState carries out switch between master and slave machines, and the problem of can not also stop the bridge services for the equipment not used.
To solve the above-mentioned problems, the present invention is implemented as follows:
In a first aspect, the embodiment of the invention provides a kind of active/standby server switching methods, comprising: starting firstKeepalived service;Start the first bridge services, to judge the first Bridge States of the machine bridge;In the first bridge shapeIn the case that state is in running order, the first bridge of starting checks thread;Check that thread checks the machine using first bridgeSecond Bridge States of bridge generate the first Bridge States file;Utilize described in the first Keepalived service inspectionOne Bridge States file;In the case where determining that the machine bridge is in off working state according to inspection result, stop described firstKeepalived service, and execute active-standby switch process.
Preferably, after the step of the first Keepalived of the starting is serviced, further includes: the first host-standby communication of startingThread;Host-initiated status message is sent to standby server by the first host-standby communication thread;It receives by described spareThe standby host status information that server returns;Determining that the standby server is in running order according to the standby host status informationIn the case where, Xiang Suoshu standby server send bridge services stop message, with by the standby server according to the bridgeService stoppage message stops bridge services;Determining that the standby server is in inoperative shape according to the standby host status informationIn the case where state, the first bridge services of the starting are executed, the step of the first Bridge States to judge the machine bridge.
Preferably, the step of execution active-standby switch process, comprising: obtain this using the first host-standby communication threadThe corresponding Bridge States value of machine bridge;The Bridge States value is sent to the standby server, is executed by the main serviceDevice switches to the process of the standby server.
Preferably, stop the first Keepalived service described, and after the step of executing active-standby switch process,Further include: after the state of the machine bridge restores normal, by the first host-standby communication thread to the standby serverServer normal operating condition information is sent, and executes the process for switching to the primary server by the standby server.
Second aspect, the embodiment of the invention provides a kind of active/standby server switching methods, comprising: starting secondKeepalived service;Start the second host-standby communication thread;It is received using the second host-standby communication thread and is sent out by primary serverThe first main machine status information sent;When determining the master server exception according to first main machine status information, Xiang SuoshuPrimary server sends bridge services halt instruction;Start the second bridge services, to judge the second Bridge States of the machine bridge;?In the case that second Bridge States are in running order, the second bridge of starting checks thread;It is active and standby logical using described secondLetter thread receives the second main machine status information sent by primary server;Described in being determined according to second main machine status informationWhen primary server restores normal condition, stop second bridge services and the 2nd Keepalived service, and to describedPrimary server sends service stopping status information.
Preferably, after the second bridge services of the starting the step of, further includes: judge whether the machine bridge is in workMake state;In the case where the machine bridge is in off working state, then second bridge services are again started up;Repeat instituteIt states and judges whether the machine bridge is in running order and described in the case where the machine bridge is not at working condition, then againThe step of starting second bridge services.
The third aspect, the embodiment of the invention provides a kind of active/standby server switching devices, comprising: the first KeepalivedStarting module, for starting the first Keepalived service;First Bridge States judgment module, for starting the first bridge clothesBusiness, to judge the first Bridge States of the machine bridge;First bridge thread starting module, at first Bridge StatesIn the case where working condition, the first bridge of starting checks thread;First bridge file generating module, for utilizing described firstBridge checks that thread checks the second Bridge States of the machine bridge, generates the first Bridge States file;First bridge file checkingModule, for utilizing the first Bridge States file described in the first Keepalived service inspection;Active-standby switch execution module,In the case where determining that the machine bridge is in off working state according to inspection result, stop the first Keepalived clothesBusiness, and execute active-standby switch process.
Preferably, further includes: the first active and standby thread starting module, for starting the first host-standby communication thread;Host StatusMessage transmission module, for sending host-initiated status message to standby server by the first host-standby communication thread;It is standbyMachine status information receiving module, for receiving the standby host status information returned by the standby server;Bridge judgment module is heldRow module, for holding in the case where determining that the standby server is in off working state according to the standby host status informationRow the first Bridge States judgment module.
Preferably, the active-standby switch execution module includes: Bridge States value acquisition submodule, for utilizing described firstHost-standby communication thread obtains the corresponding Bridge States value of the machine bridge;Active-standby switch implementation sub-module is used for the bridge shapeState value is sent to the standby server, executes the process that the standby server is switched to by the primary server.
Preferably, further includes: standby primary server switching module, for leading to after the state of the machine bridge restores normalIt crosses the first host-standby communication thread and sends bridge normal state information to the standby server, and execute by the spare clothesBusiness device switches to the process of the primary server.
Fourth aspect, the embodiment of the invention provides a kind of active/standby server switching devices, comprising: the 2nd KeepalivedStarting module, for starting the 2nd Keepalived service;Second active and standby thread starting module, for starting the second host-standby communicationThread;First Host Status receiving module, for receiving sent by primary server the using the second host-standby communication threadOne main machine status information;Bridge halt instruction sending module, for determining the master according to first main machine status informationWhen server exception, Xiang Suoshu primary server sends bridge services halt instruction;Second Bridge States judgment module, for startingSecond bridge services, to judge the second Bridge States of the machine bridge;Second bridge thread starting module, for described secondIn the case that Bridge States are in running order, the second bridge of starting checks thread;Second Host Status receiving module, for benefitThe second main machine status information sent by primary server is received with the second host-standby communication thread;Second bridge services andKeepalived stopping modular, for determining that the primary server restores normal condition according to second main machine status informationWhen, stop second bridge services and the 2nd Keepalived service, and send service stopping to the primary serverStatus information.
Preferably, further includes: Bridge States judgment module, for judging whether the machine bridge is in running order;SecondBridge services are again started up module, in the case where the machine bridge is in off working state, being then again started up described secondBridge services;Module is repeated, for repeating the Bridge States judgment module and second bridge services againStarting module.
5th aspect, the embodiment of the invention provides a kind of terminals, comprising: memory, processor and is stored in described depositOn reservoir and the computer program that can run on the processor, the computer program are realized when being executed by the processorThe step of active/standby server switching method described in any of the above embodiments.
6th aspect, it is described computer-readable to deposit the embodiment of the invention also provides a kind of computer readable storage mediumComputer program is stored on storage media, the computer program is realized described in any of the above embodiments active and standby when being executed by processorStep in server switching method.
Compared with prior art, the present invention includes the following advantages:
In embodiments of the present invention, by starting the first Keepalived service, start the first bridge services, to judge thisFirst Bridge States of machine bridge, in the case where the first Bridge States are in running order, the first bridge of starting checks thread,It checks that thread checks the second Bridge States of the machine bridge using the first bridge, generates the first Bridge States file, utilize firstKeepalived service inspection the first Bridge States file determines that the machine bridge is in the feelings of off working state according to inspection resultUnder condition, stop the first Keepalived service, and execute active-standby switch process.The embodiment of the present invention can solve bridge and make parallelThe problem of at circuit, also, provide status mechanism for the service of keepalived trustship to no port and carry out active-standby switchMode, implementation is fairly simple, and can achieve the purpose that multiplexing.
Detailed description of the invention
Fig. 1 shows a kind of step flow chart of active/standby server switching method provided in an embodiment of the present invention;
Fig. 2 shows a kind of step flow charts of active/standby server switching method provided in an embodiment of the present invention;
Fig. 3 shows a kind of structural schematic diagram of active/standby server switching device provided in an embodiment of the present invention;
Fig. 4 shows a kind of structural schematic diagram of active/standby server switching device provided in an embodiment of the present invention.
Specific embodiment
In order to make the foregoing objectives, features and advantages of the present invention clearer and more comprehensible, with reference to the accompanying drawing and specific realApplying mode, the present invention is described in further detail.
Explanation of technical terms employed in the embodiment of the present invention is as follows:
The effect of Keepalived:Keepalived is the state of detection service device, if there is a web server is delayedMachine, or work are broken down, and Keepalived will test, and faulty server is rejected from system, use simultaneouslyOther server generations replace the work of the server, and server is added to clothes automatically by Keepalived after server is working properlyIt is engaged in device group, these work are all automatically performed, and do not need artificial interference, and need manually to do only repairs the service of failureDevice.
Bridge: bridge is to be connected to the network two, and be managed to the circulation of network data.It works in dataLink layer forwards data according to MAC Address.It plays data receiver, address filtering and data forwarding in the network interconnectionEffect, for realizing the data exchange between multiple network systems.
Embodiment one
Referring to Fig.1, a kind of step flow chart of active/standby server switching method provided in an embodiment of the present invention is shown, it shouldActive/standby server switching method can be applied to primary server, can specifically include following steps:
Step 101: starting the first Keepalived service.
In kind of the embodiment of the present invention, the first Keepalived service refers to the Keepalived service of primary server side.
It can be added in advance in the Keepalived service configuration item of primary server and check oneself function, this checks oneself function can be withIt is convenient to carry out active-standby switch in Bridge States exception for subsequent examination the machine Bridge States file.
After the first Keepalived service of starting primary server side, the first Keepalived service pair can usePrimary server carries out trustship, whether there is failure with the state of real-time monitoring primary server, such as primary server.
After starting the first Keepalived service, step 102 is executed.
Step 102: the first bridge services of starting, to judge the first Bridge States of the machine bridge.
First bridge services refer to the bridge services of primary server side.First Bridge States refer to the bridge of primary server sideState, may include working condition and off working state two states.
First bridge services can judge the state of the machine bridge, i.e., judge the machine net using the first bridge servicesWhether bridge is in running order.
In embodiments of the present invention, after starting the first Keepalived service, host-standby communication thread can also be started,To realize the communication between primary server and standby server by host-standby communication thread, specifically, with embodiments discussed belowIt carries out detailed further below.
In a preferred embodiment of an embodiment of the present invention, after above-mentioned steps 101, can also include:
Step A1: the first host-standby communication thread of starting.
In embodiments of the present invention, the first host-standby communication thread refers to the line that primary server is communicated with standby serverJourney.
Host-standby communication thread, which refers to, mutually reports Bridge States between host (i.e. primary server) and standby host (i.e. standby server)Thread, and according to the Bridge States of opposite end, to determine the start and stop of the machine bridge.
After starting the first Keepalived service, the first host-standby communication thread can star, to realize main serviceCommunication between device and standby server mutually reports Bridge States to realize between primary server and standby server.
After starting the first host-standby communication thread, step A2 is executed.
Step A2: host-initiated status message is sent to standby server by the first host-standby communication thread.
Host-initiated status message refers to the message restarted after host-initiated or fault restoration.
After starting the first host-standby communication thread, primary server can send host by the first host-standby communication thread and openDynamic status message can pass through the host-initiated state if current standby server is carrying out service to standby serverMessage is serviced by the Keepalived that standby server stops bridge and standby server side, avoids the presence of parallel operation bridgeThe problem of causing circuit.
After sending host-initiated status message to standby server by the first host-standby communication thread, step is executedA3。
Step A3: the standby host status information returned by the standby server is received.
By the first host-standby communication thread send host-initiated status message to standby server after, can receive byThe standby host status information that standby server returns, namely received by the first host-standby communication thread returned by standby server it is standbyMachine status information, and execute step A4 and step A5.
Step A4: in the case where determining that the standby server is in running order according to the standby host status information,Bridge services are sent to the standby server and stop message, to be disappeared by the standby server according to bridge services stoppingBreath stops bridge services.
The standby host status information that primary server receives is intended to describe standby server standby server side whether it has stoppedBridge services and the status information of Keepalived service, are determining that standby server is in work shape by standby host status informationIn the case where state, then bridge services is sent to standby server by the first host-standby communication thread from primary server and stops message,Standby server is after the bridge services for receiving primary server transmission stop message, then standby server is needed according to the netBridge service stoppage message cuts off the bridge services of standby server side, and after cutting off bridge services, continues to primary serverStandby host status information is sent, to prompt primary server to stop the bridge services of standby server side.
Step A5: the case where standby server is in off working state is being determined according to the standby host status informationUnder, the first bridge services of the starting are executed, the step of the first Bridge States to judge the machine bridge.
Primary server received standby host status information is intended to describe standby server standby server side whether it has stoppedBridge services and the status information of Keepalived service.It is determined in the standby host status information returned according to standby server spareIn the case that server is in off working state, then above-mentioned steps 102 are executed.
After judging the first Bridge States of the machine bridge, step 103 is executed.
Step 103: in the case where first Bridge States are in running order, the first bridge of starting checks thread.
Bridge checks that thread refers to circulation acquisition Bridge States thread, and by Bridge States write state file,Facilitate the state value of keepalived inspection state file.
First bridge checks that thread refers to that the bridge of primary server side checks thread.
In the case where judging that the machine bridge is in running order using the first bridge services, then start the inspection of the first bridgeLine inspection journey, and execute step 104.
Step 104: checking that thread checks the second Bridge States of the machine bridge using first bridge, generate the first netBridge status file.
Second Bridge States refer to the Bridge States of the primary server side detected by the first bridge inspection thread.
After starting the first bridge and checking thread, it can check that thread checks the second of the machine bridge by the first bridgeBridge States can will check obtained state recording to bridge shape after the Bridge States to the machine bridge checkIn state file, to generate the first Bridge States file.
After generating the first Bridge States file, step 105 is executed.
Step 105: utilizing the first Bridge States file described in the first Keepalived service inspection.
After generating the first Bridge States file, it can use the first the first Bridge States of Keepalived service inspectionFile, to judge the state of the machine bridge according to the value in the first Bridge States file.
After using the first Keepalived service inspection the first Bridge States file, step 106 is executed.
Step 106: in the case where determining that the machine bridge is in off working state according to inspection result, stopping described firstKeepalived service, and execute active-standby switch process.
In the case where determining that the machine bridge is in off working state according to inspection result, then stop the first KeepalivedService, and execute active-standby switch process, i.e., standby server is switched to by primary server, provides service by standby server.
Active-standby switch process is described in detail with embodiments discussed below.
In a preferred embodiment of an embodiment of the present invention, above-mentioned steps 106 may include:
Sub-step B1: the corresponding Bridge States value of the machine bridge is obtained using the first host-standby communication thread;
Sub-step B2: the Bridge States value is sent to the standby server, execution is switched by the primary serverTo the process of the standby server.
In embodiments of the present invention, primary server can use the first host-standby communication thread and obtain the corresponding net of the machine bridgeBridge like state value, and Bridge States value is sent to the standby server, when Bridge States value sends failure, then recording equipmentWork intention, the first Keepalived service give configuration in the configuration file that Keepalived is serviced according to this state valueMailbox sends alarm email, with by personnel intervention standby server, i.e., the bridge of stopping standby server side andKeepalived service.
When sending successfully, then stop the net of standby server side according to the Bridge States value of host computer side by standby serverBridge and Keepalived service.
After the Bridge States of primary server side restore normal, the recovery of the machine bridge can also be sent to standby serverThe information of normal condition is specifically carried out detailed further below with embodiments discussed below.
In a preferred embodiment of an embodiment of the present invention, after above-mentioned steps 106, can also include:
Sub-step C1: after the state of the machine bridge restores normal, by the first host-standby communication thread to describedStandby server sends server normal operating condition information, and executes and switch to the primary server by the standby serverProcess.
In embodiments of the present invention, server normal operating condition information refers to that primary server is in normal operating conditionInformation.
After the state of the machine bridge restores normal, primary server can be by the first host-standby communication thread to spare clothesBusiness device sends server normal operating condition information, and server normal operating condition information can be used for describing primary server extensiveIt answers to working condition, and then stops the net of standby server side according to the server normal operating condition information by standby serverBridge service and Keepalived service to avoid there is the problem of parallel bridge causes circuit, and then are executed by standby serverThe process of primary server is switched to, i.e., offer service is continued by primary server.
Active/standby server switching method provided in an embodiment of the present invention passes through starting the first Keepalived service, startingFirst bridge services, to judge the first Bridge States of the machine bridge, in the case where the first Bridge States are in running order,Start the first bridge and check thread, checks that thread checks the second Bridge States of the machine bridge using the first bridge, generate firstBridge States file determines the machine according to inspection result using the first Keepalived service inspection the first Bridge States fileIn the case that bridge is in off working state, stop the first Keepalived service, and execute active-standby switch process.The present invention is realApplying example can solve the problem of bridge causes circuit parallel, also, the service to no port for keepalived trustship providesStatus mechanism carries out the mode of active-standby switch, and implementation is fairly simple, and can achieve the purpose that multiplexing.
Embodiment two
Referring to Fig. 2, a kind of step flow chart of active/standby server switching method provided in an embodiment of the present invention is shown, it shouldActive/standby server switching method can be applied to standby server, can specifically include following steps:
Step 201: starting the 2nd Keepalived service.
The embodiment of the present invention can be applied to standby server.
2nd Keepalived service refers to the Keepalived service of active service side.
Start the 2nd Keepalived service, after carrying out trustship to standby server, executes step 202.
Step 202: the second host-standby communication thread of starting.
Second host-standby communication thread refers to the thread communicated for standby server and primary server, main by secondStandby communication thread, standby server and primary server can mutually report Bridge States, and determine the machine according to the Bridge States of opposite endThe start and stop of bridge.
After starting the 2nd Keepalived service, the second host-standby communication thread can star, and execute step 203.
Step 203: the first main machine status information sent by primary server is received using the second host-standby communication thread.
First main machine status information refers to the information for being used to indicate primary server current state, may include that primary server is differentThe status informations such as normal or failure.
After starting the second host-standby communication thread, standby server can be received by the second host-standby communication thread by leadingThe first main machine status information that server is sent, and execute step 204.
Step 204: when determining the master server exception according to first main machine status information, to the main serviceDevice sends bridge services halt instruction.
After standby server receives the first main machine status information sent by primary server, the first host shape can be passed throughState information judges the state of primary server, i.e., whether exception or normal condition etc..
When standby server determines master server exception according to the first main machine status information, then net is sent to primary serverThe instruction of bridge service stopping, bridge services halt instruction are used to indicate primary server and stop bridge services.
When sending bridge services halt instruction to primary server, step 205 is executed.
Step 205: the second bridge services of starting, to judge the second Bridge States of the machine bridge.
After sending bridge services halt instruction to primary server, primary server can stop referring to by the bridge servicesThe bridge services for stopping primary server side are enabled, and net is sent to standby server by the second host-standby communication thread from primary serverBridge services stopped message.
In a preferred embodiment of an embodiment of the present invention, after above-mentioned steps 205, can also include:
Sub-step D1: judge whether the machine bridge is in running order;
Sub-step D2: in the case where the machine bridge is in off working state, then second bridge services are again started up;
Sub-step D3: repeat it is described judge the machine bridge it is whether in running order and it is described the machine bridge notIn the case where in running order, then the step of being again started up second bridge services.
It in a preferred embodiment of an embodiment of the present invention, can also be using the after starting the second bridge servicesTwo bridge services judge the machine Bridge States judge whether the machine bridge is in running order, judging the machineBridge is in the case of inoperative filling, then is again started up the second bridge services, to carry out sentencing again to the machine Bridge StatesIt is disconnected, above-mentioned steps D1 and above-mentioned steps D2 are repeated, number will be repeated and reach setting number, can be prevented due to netBridge service started erroneous judgement that is slow and causing Bridge States to check thread.
In the stopped message of bridge services that standby server receives primary server side, then standby server startsSecond bridge services namely the bridge services of standby server local, and the of the machine bridge is judged using the second bridge servicesTwo Bridge States, and then execute step 206.
Step 206: in the case where second Bridge States are in running order, the second bridge of starting checks thread.
In the case where standby server judges that the machine bridge is in running order by the second bridge services, then startSecond bridge checks thread, checked in real time standby host Bridge States, and inspection result is recorded in status file.
Step 207: the second main machine status information sent by primary server is received using the second host-standby communication thread.
It, can also be active and standby by second during being checked in real time using the second bridge services the state of the machine bridgeCommunication thread receives the second main machine status information sent by primary server, and executes step 208.
Step 208: when determining that the primary server restores normal condition according to second main machine status information, stoppingSecond bridge services and the 2nd Keepalived service, and service stopping state letter is sent to the primary serverBreath.
Determine that primary server restores normal shape according to the second main machine status information that primary server is sent in standby serverIn the case where state, then stop the second bridge services and the 2nd Keepalived service, and send service stopping shape to primary serverState information, primary server can carry out standby server cutting to primary server after receiving service stopping status informationChange of current journey provides service by primary server after switching.
Active/standby server switching method provided in an embodiment of the present invention passes through starting the 2nd Keepalived service, startingSecond host-standby communication thread receives the first main machine status information sent by primary server using the second host-standby communication thread,When determining master server exception according to the first main machine status information, bridge services halt instruction, starting the are sent to primary serverTwo bridge services, in the case where the second Bridge States are in running order, are opened with judging the second Bridge States of the machine bridgeDynamic second bridge checks thread, and the second main machine status information sent by primary server is received using the second host-standby communication thread,When determining that primary server restores normal condition according to the second main machine status information, stop the second bridge services and secondKeepalived service, and service stopping status information is sent to primary server.It is parallel that the embodiment of the present invention can solve bridgeThe problem of causing circuit, also, provide status mechanism for the service of keepalived trustship to no port and carry out active and standby cutThe mode changed, implementation is fairly simple, and can achieve the purpose that multiplexing.
Embodiment three
Referring to Fig. 3, a kind of structural schematic diagram of active/standby server switching device provided in an embodiment of the present invention is shown, it shouldActive/standby server switching device can be applied to primary server, can specifically include:
First Keepalived starting module 310, for starting the first Keepalived service;The judgement of first Bridge StatesModule 320, for starting the first bridge services, to judge the first Bridge States of the machine bridge;First bridge thread starts mouldBlock 330, in the case where first Bridge States are in running order, the first bridge of starting to check thread;First netBridge file generating module 340 is generated for checking that thread checks the second Bridge States of the machine bridge using first bridgeFirst Bridge States file;First bridge file checking module 350, for utilizing the first Keepalived service inspection instituteState the first Bridge States file;Active-standby switch execution module 360, for determining that the machine bridge is in inoperative according to inspection resultIn the case where state, stop the first Keepalived service, and execute active-standby switch process.
Preferably, further includes: the first active and standby thread starting module, for starting the first host-standby communication thread;Host StatusMessage transmission module, for sending host-initiated status message to standby server by the first host-standby communication thread;It is standbyMachine status information receiving module, for receiving the standby host status information returned by the standby server;Bridge judgment module is heldRow module, for holding in the case where determining that the standby server is in off working state according to the standby host status informationRow the first Bridge States judgment module.
Preferably, the active-standby switch execution module 360 includes: Bridge States value acquisition submodule, described in utilizingFirst host-standby communication thread obtains the corresponding Bridge States value of the machine bridge;Active-standby switch implementation sub-module is used for the netBridge like state value is sent to the standby server, executes the process that the standby server is switched to by the primary server.
Preferably, further includes: standby primary server switching module, for leading to after the state of the machine bridge restores normalIt crosses the first host-standby communication thread and sends bridge normal state information to the standby server, and execute by the spare clothesBusiness device switches to the process of the primary server.
Active/standby server switching device provided in an embodiment of the present invention passes through starting the first Keepalived service, startingFirst bridge services, to judge the first Bridge States of the machine bridge, in the case where the first Bridge States are in running order,Start the first bridge and check thread, checks that thread checks the second Bridge States of the machine bridge using the first bridge, generate firstBridge States file determines the machine according to inspection result using the first Keepalived service inspection the first Bridge States fileIn the case that bridge is in off working state, stop the first Keepalived service, and execute active-standby switch process.The present invention is realApplying example can solve the problem of bridge causes circuit parallel, also, the service to no port for keepalived trustship providesStatus mechanism carries out the mode of active-standby switch, and implementation is fairly simple, and can achieve the purpose that multiplexing.
Example IV
Referring to Fig. 4, a kind of structural schematic diagram of active/standby server switching device provided in an embodiment of the present invention is shown, it shouldActive/standby server switching device can be applied to standby server, can specifically include:
2nd Keepalived starting module 410, for starting the 2nd Keepalived service;Second active and standby thread startingModule 420, for starting the second host-standby communication thread;First Host Status receiving module 430, for active and standby using described secondCommunication thread receives the first main machine status information sent by primary server;Bridge halt instruction sending module 440, for according toWhen determining the master server exception according to first main machine status information, Xiang Suoshu primary server sends bridge services stopping and refers toIt enables;Second Bridge States judgment module 450, for starting the second bridge services, to judge the second Bridge States of the machine bridge;Second bridge thread starting module 460, for starting the second net in the case where second Bridge States are in running orderBridge checks thread;Second Host Status receiving module 470, for being received using the second host-standby communication thread by primary serverThe second main machine status information sent;Second bridge services and Keepalived stopping modular 480, for according to described secondWhen main machine status information determines that the primary server restores normal condition, stop second bridge services and described secondKeepalived service, and service stopping status information is sent to the primary server.
Preferably, further includes: Bridge States judgment module, for judging whether the machine bridge is in running order;SecondBridge services are again started up module, in the case where the machine bridge is in off working state, being then again started up described secondBridge services;Module is repeated, for repeating the Bridge States judgment module and second bridge services againStarting module.
Active/standby server switching device provided in an embodiment of the present invention passes through starting the 2nd Keepalived service, startingSecond host-standby communication thread receives the first main machine status information sent by primary server using the second host-standby communication thread,When determining master server exception according to the first main machine status information, bridge services halt instruction, starting the are sent to primary serverTwo bridge services, in the case where the second Bridge States are in running order, are opened with judging the second Bridge States of the machine bridgeDynamic second bridge checks thread, and the second main machine status information sent by primary server is received using the second host-standby communication thread,When determining that primary server restores normal condition according to the second main machine status information, stop the second bridge services and secondKeepalived service, and service stopping status information is sent to primary server.It is parallel that the embodiment of the present invention can solve bridgeThe problem of causing circuit, also, provide status mechanism for the service of keepalived trustship to no port and carry out active and standby cutThe mode changed, implementation is fairly simple, and can achieve the purpose that multiplexing.
It should be noted that for simple description, therefore, it is stated as a series of action groups for embodiment of the methodIt closes, but those skilled in the art should understand that, embodiment of that present invention are not limited by the describe sequence of actions, because according toAccording to the embodiment of the present invention, some steps may be performed in other sequences or simultaneously.Secondly, those skilled in the art also shouldKnow, the embodiments described in the specification are all preferred embodiments, and the related movement not necessarily present invention is implementedNecessary to example.
For device embodiment, since it is basically similar to the method embodiment, related so being described relatively simplePlace illustrates referring to the part of embodiment of the method.
Preferably, the embodiment of the present invention also provides a kind of terminal, including processor, and memory stores on a memory simultaneouslyThe computer program that can be run on the processor, the computer program realize above-mentioned active/standby server when being executed by processorEach process of switching method embodiment, and identical technical effect can be reached, to avoid repeating, which is not described herein again.
The embodiment of the present invention also provides a kind of computer readable storage medium, and meter is stored on computer readable storage mediumCalculation machine program, the computer program realize each mistake of above-mentioned active/standby server switching method embodiment when being executed by processorJourney, and identical technical effect can be reached, to avoid repeating, which is not described herein again.Wherein, the computer-readable storage mediumMatter, such as read-only memory (Read-Only Memory, abbreviation ROM), random access memory (Random AccessMemory, abbreviation RAM), magnetic or disk etc..
All the embodiments in this specification are described in a progressive manner, the highlights of each of the examples are withThe difference of other embodiments, the same or similar parts between the embodiments can be referred to each other.
It should be understood by those skilled in the art that, the embodiment of the embodiment of the present invention can provide as method, system or calculateMachine program product.Therefore, the embodiment of the present invention can be used complete hardware embodiment, complete software embodiment or combine software andThe form of the embodiment of hardware aspect.Moreover, the embodiment of the present invention can be used one or more wherein include computer canWith in the computer-usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) of program codeThe form of the computer program product of implementation.
The embodiment of the present invention be referring to according to the method for the embodiment of the present invention, terminal (system) and computer program productFlowchart and/or the block diagram describe.It should be understood that can be realized by computer program instructions in flowchart and/or the block diagramThe combination of process and/or box in each flow and/or block and flowchart and/or the block diagram.It can provide these calculatingProcessing of the machine program instruction to general purpose computer, special purpose computer, Embedded Processor or other programmable data processing terminalsDevice is to generate a machine, so that being generated by the instruction that the processor of computer or other programmable data processing terminals executesFor realizing the function of being specified in one or more flows of the flowchart and/or one or more blocks of the block diagramSystem.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing terminals with spyDetermine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,Enable the manufacture of system, the instruction system realize in one box of one or more flows of the flowchart and/or block diagram orThe function of being specified in multiple boxes.
These computer program instructions can also be loaded on computer or other programmable data processing terminals, so that countingSeries of operation steps are executed on calculation machine or other programmable terminals to generate computer implemented processing, thus in computer orThe instruction executed on other programmable terminals is provided for realizing in one or more flows of the flowchart and/or block diagram oneThe step of function of being specified in a box or multiple boxes.
Although the preferred embodiment of the embodiment of the present invention has been described, once a person skilled in the art knows basesThis creative concept, then additional changes and modifications can be made to these embodiments.So the following claims are intended to be interpreted asIncluding preferred embodiment and fall into all change and modification of range of embodiment of the invention.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to byOne entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operationBetween there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaningCovering non-exclusive inclusion, so that the process, method, article or the terminal that include a series of elements not only include thatA little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article orThe intrinsic element of terminal.In the absence of more restrictions, the element limited by sentence "including a ...", is not arrangedExcept there is also other identical elements in process, method, article or the terminal for including the element.
Above to a kind of active/standby server switching method provided by the present invention and a kind of active/standby server switching device, intoIt has gone and has been discussed in detail, used herein a specific example illustrates the principle and implementation of the invention, the above implementationThe explanation of example is merely used to help understand method and its core concept of the invention;Meanwhile for the general technology people of this fieldMember, according to the thought of the present invention, there will be changes in the specific implementation manner and application range, in conclusion this explanationBook content should not be construed as limiting the invention.