Summary of the invention
The present invention provides a kind of server backup method and device, to solve standby server in the prior art and main serviceThe problem of standby server wasting of resources caused by device role corresponds.
According to a first aspect of the embodiments of the present invention, a kind of server backup method is provided, the method is applied to active and standbyWith server, which comprises
The heartbeat established between the multiple primary server connects, and obtains the multiple main clothes by heartbeat connectionThe configuration information of business device, wherein role's software of the multiple primary server is provided in the standby usage server;
When any one primary server in the multiple primary server breaks down, according to the main service broken downThe hardware asset information of device judges whether the standby usage server meets backup condition;
If it is satisfied, then the role's software of primary server to break down described in operation, and broken down according to describedThe configuration information of primary server, the service of the primary server to break down described in operation.
According to a second aspect of the embodiments of the present invention, a kind of server backup method is provided, the method is applied to occurThe primary server of failure, which comprises
According to fault message, judging whether to degenerate is standby server;
If so, obtaining the address information of any one standby server from the information list of standby server;
According to the address information, communication connection is established, between corresponding standby server the spare clothes are addedBackup server cluster where business device, wherein the communication connection is TCP (Transmission ControlProtocol, transmission control protocol) connection or UDP (User Datagram Protocol, User Datagram Protocol) connection.
According to a third aspect of the embodiments of the present invention, a kind of server backup device is provided, described device is applied to active and standbyWith server, described device includes:
Connection establishment unit, the heartbeat connection for establishing between the multiple primary server;
Acquiring unit, for obtaining the configuration information of the multiple primary server by heartbeat connection, wherein describedRole's software of the multiple primary server is set in standby usage server;
Backup units, for when any one primary server in the multiple primary server breaks down, according to hairThe hardware asset information of the primary server of raw failure judges whether the standby usage server meets backup condition, if it is satisfied,Role's software of the primary server then to break down described in operation, and confidence is matched according to the primary server to break downIt ceases, the service of the primary server to break down described in operation.
According to a fourth aspect of the embodiments of the present invention, described device is applied to the primary server to break down, described deviceInclude:
Judging unit is standby server for according to fault message, judging whether to degenerate;
Acquiring unit, for if so, obtaining any one standby server from the information list of standby serverAddress information;
Degeneration, for establishing communication connection, between corresponding standby server to add according to the address informationEnter the backup server cluster where the standby server, wherein the communication connection is TCP connection or UDP connection.
Using the embodiment of the present invention, it is provided with role's software of multiple primary servers in standby usage server, and establishesHeartbeat between multiple primary servers is connect, and the configuration information of multiple primary servers is obtained by heartbeat connection;When multipleWhen any one primary server in primary server breaks down, sentenced according to the hardware asset information of the primary server to break downWhether the standby usage server that breaks meets backup condition, if it is satisfied, then the angle of the primary server to break down described in operationColor software, and according to the configuration information of the primary server to break down, the clothes of the primary server to break down described in operationBusiness.In addition, the primary server to break down can also be according to fault message, it is determined whether can degenerate for standby server, such asBackup server cluster can be then added for backing up in fruit.The role of multiple primary servers can be different in the embodiment of the present invention,The role of standby server and primary server can also be different, and thus solve standby server in the prior art and primary serverThe problem of standby server wasting of resources caused by role corresponds, and it is standby that the server to break down, which is also possible to degenerate,With server for reducing the cost of system group network the problem of backing up, further solve the standby server wasting of resources.
Specific embodiment
The role mentioned in present specification is defined with the function of server in systems, as that can have number in systemAccording to management server, transcoding server, video management server, exchange of media server etc., transported in the server of every kind of roleRow has corresponding role's software, according to configuration information and the corresponding function of role's software realization.Present specification is with video monitoringTechnical solution of the present invention is described for system, but is not limited the scope of protection of the present invention with this, and the present invention program can also answerFor in the other systems such as video on-demand system.It is the application scenarios schematic diagram of the embodiment of the present invention referring to Fig. 1:
In Fig. 1, video management server VM is connected to the primary servers such as MS, DM, BM, DA, and MS is connected to TS, and DM is connected toIP-SAN (IP Storage Area Network, storage area network) equipment, BM are also connected to IP-SAN equipment;Spare clothesIt is engaged in including standby server 1, standby server 2, standby server 3 in device cluster, it is standby server 1, standby server 2, standbyIt can all be VM server with server 3, also may respectively be different role servers, it is standby server 1, standby server 2, standbyWith roles' softwares such as VM, MS, DM, BM, DA are arranged in server 3, standby server 1 is main standby server.Standby server 1It establishes heartbeat between primary server to connect, when some primary server breaks down, standby server 1 can be provided according to hardwareSource information judges whether the standby usage server meets backup condition, if it is satisfied, then the primary server that operation is broken downRole's software run the service of the primary server to break down and according to the configuration information of the primary server to break down.ExampleAs the hardware resource consumption of DA server be mainly CPU (Central Processing Unit, central processing unit) consumption and it is interiorDeposit resource consumption, and the hardware resource consumption of MS server is in addition to CPU consumption and memory source consumption, there are also network interface card consumption, becauseThe hardware resource consumption of this DA server server lower with respect to the hardware resource consumption of MS server, if a failure occursFor DA server, and standby server 1 is VM server, since the hardware consumption of DA server is not above the hard of VM serverPart consumption, therefore standby server 1 meets backup condition, can directly run role's software of DA server, and is serviced according to DAThe configuration information of device runs the service of DA server.Wherein, server if a failure occurs is MS server, and MS is servicedThe hardware resource consumption of device is higher with respect to VM server, therefore standby server 1 can disappear according to MS server hardware resourceThe difference of consumption determines and selects standby server 2 in backup server cluster, common by standby server 1 and standby server 2Run the service of MS server.In addition, if also can be used, can also degenerate for other for the server that partial fault occursThe standby server of role, for backing up.Thus the present invention can solve standby server and primary server role one-to-one correspondence is ledThe problem of standby server wasting of resources of cause, and the primary server to break down can also degenerate for the spare clothes of other rolesBusiness device, greatly reduces networking cost.
In present specification, the hardware resource of all kinds of role servers can obtain empirical value, various servers according to testThe difference of the hardware resource of role can be showed in the form of weight, for example, if the hardware resource of a DM can support a VM'sHardware resource, but 2 hardware resource VM could can support a VM's to the hardware resource of a DM, the hardware resource of a TSHardware resource, but 3 hardware resource VM could then can behave as 1VM=1/2DM=1/3TS to the hardware resource of a TS.When backup server cluster is added in standby server, the hardware asset information of oneself can be reported.
The present invention program is described in detail below by specific embodiment.
Referring to fig. 2, it is server backup method flow diagram in one embodiment of the present invention:
Step 201: backup server cluster is added in each standby server.
Separate unit standby server is added backup server cluster and can be added without any configuration, subsequent standby serverIt may specify the IP address of existing any one standby server in backup server cluster, spare clothes when backup server clusterBusiness device 2 can establish backup pool relationship with standby server 1 by communication connection.Standby server 1 and standby server 2 can basesPreset condition elects a standby usage server, such as can elect a standby usage server according to IP address size, if IPLocation is then main standby server greatly.Certain standby server can also elect standby usage server, the application according to MAC Address sizeThe content of preset condition is not limited.
When backup server cluster is added in standby server N (N is greater than 2), existing is specified in backup server clusterIt anticipates the IP address of a standby server, such as standby server 2.
Standby server N, which attempts to establish with standby server 2, to be communicated to connect, but if standby server 2 is not standby usageThe IP address of standby usage server can then be informed standby server N by server.
Standby server N and standby usage server establish communication connection.After establishing communication connection, standby server N can be withStandby usage server is compared according to preset condition, if standby server N meets preset condition, may replace standby usage clothesBusiness device upgrades to new standby usage server.Former standby usage server notifies the address information of new standby usage server spareExisting standby server in server cluster, so that existing standby server and new standby server establish communication linkIt connects.
Several standby servers can be added to backup server cluster by repeating the above process, and elect standby usage serviceDevice.
After electing standby usage server, the address information of each standby server can be notified remaining by standby usage serverThe address information of standby server.
Wherein, role's software of various role servers is provided in each standby server.
Step 202: the heartbeat that standby usage server is established between multiple primary servers connects.
Step 203: standby usage server obtains the configuration information of multiple primary servers by heartbeat connection.
The configuration information of primary server can include: the current user list of primary server, the main service such as management equipment listThe service of device operation.For example, configuration information may include the current user list of VM and management if primary server is VM serverList of devices, the list of devices of management includes IPC (IP Camera, web camera), the NVR (Network for being registered to VMVideo Recorder, network video recorder) equipment, DVR (Digital Video Recorder, hard disk video recorder), MS,The information such as DM, BM, DA.Other role servers also have the configuration information of oneself, in standby usage server and each main serviceDevice is established heartbeat and is connected to, and each primary server can give the configuration information real-time synchronization of itself to standby usage server.
Step 204: standby usage server sends each main clothes by established communication connection, to other standby serversThe configuration information of business device.
Step 205: when some primary server breaks down, standby usage server can be according to the primary server to break downHardware asset information judge whether the standby usage server meets backup condition.
It is connect since standby usage server establishes heartbeat with each primary server, being verified by heartbeat can be detected generationThe server of failure.Standby usage server detects the hardware asset information of itself, and according to the hard of the server to break downPart resource information judges that can standby usage server meet backup condition, if the hardware resource of standby usage server is not less than hairThe primary server of raw failure, then meet backup condition, be otherwise unsatisfactory for.If it is satisfied, then step 206 is executed, if be unsatisfactory forThen follow the steps 207.
Step 206: role's software of the primary server to break down described in operation, and according to the main clothes to break downIt is engaged in the configuration information of device, the service of the primary server to break down described in operation.
Role's software of the primary server of standby usage server fail, and according to the master to break down currently savedThe configuration information of server runs corresponding service, completes the process that standby server upgrades to primary server.
Step 207: determining the number of units N for meeting the standby server of backup condition needs, and according to the standby serverNumber of units N, in backup server cluster select N-1 platform standby server, the generation is operated together by N platform standby serverThe service of the primary server of failure.
Standby usage server is according to itself hardware asset information, and the hardware asset information of server to break downIt determines and needs how many standby servers that can meet backup condition, according to the number of units N of required standby server, in active serviceN-1 platform standby server is selected in device cluster, and the clothes of the primary server to break down are operated together by N platform standby serverBusiness.For example, if standby usage server is VM server, and the server to break down is MS server, then can determine needsTwo standby servers meet backup condition, and standby usage server can select a spare clothes in backup server cluster at this timeBusiness device, and according to the configuration information of the MS server currently saved, what will be run is divided into two parts, on two standby serversIt is separately operable MS role server software, and loads a configuration information, You Liangtai standby server backs up the master to break downServer.
Step 208: the communication connection between release and other standby servers, and discharge between other primary serversHeartbeat connection.
While standby usage server updating is primary server, the heartbeat connection between other primary servers is disconnected, andAlso the communication connection between other standby servers is disconnected.
After disconnecting the communication connection between other standby servers, other standby servers can be according to the behaviour of step 201Make election standby usage server, new standby usage server executes the operation of original standby usage server, establishes with primary serverHeartbeat connection.
Step 209: it is standby server that the server to break down, which can judge whether to degenerate according to fault message,.
Certain hardware resources also can be used after some server fails, in this case can be true according to fault messageWhether the server to break down surely can degenerate for standby server.For example, if the failure of MS server is single network interface cardIt breaks down, according to the fault message, MS server can not provide enough bandwidth and carry out resource forwarding, but its cpu resourceIt still can be used, MS server can be degenerated to the standby server of single VM role at this time.If so, thening follow the steps 210.
Step 210: if so, obtaining the address letter of any one standby server from the information list of standby serverBreath.
Each main service is sent by the information list of standby server since standby usage server can be connected by heartbeatDevice, therefore the information list of the standby server can be stored in the primary server to break down.
The primary server to break down can obtain the ground of each standby server from the information list of the standby serverLocation information.
Step 211: according to the address information, establish with the communication connection between corresponding standby server, to be addedBackup server cluster where the standby server.
The process that standby server is added in the primary server to break down can refer to step 201, i.e., if address information pairThe standby server answered is the standby usage server in backup server cluster, then establishes and communicate to connect with standby usage serverAfterwards, it identifies the primary server to break down and backup server cluster is added;If the corresponding standby server of address information is notStandby usage server in backup server cluster, then the corresponding standby server of address information is to the primary server to break downThe address information of standby usage server is sent, so that the primary server to break down establishes the communication between standby usage serverBackup server cluster is added in connection.
The primary server to break down is added after the backup server cluster, pre- according to certain with standby usage serverIf condition is compared, primary server if a failure occurs meets preset condition, then the primary server to break down upgrades toStandby usage server in server cluster after upgrading to standby usage server, can be established between other standby serversCommunication connection, and establish and other primary servers between heartbeat connect, and by heartbeat connection acquisition other main servicesThe configuration information of device.
Embodiment as shown in connection with fig. 2, can it is found that be provided with role's software of multiple primary servers in standby usage serverThe heartbeat established between multiple primary servers connects, and the configuration information of multiple primary servers is obtained by heartbeat connection;WhenWhen any one primary server in multiple primary servers breaks down, believed according to the hardware resource of the primary server to break downBreath judges whether standby usage server meets backup condition, if it is satisfied, then the role for the primary server that operation is broken down is softPart, and according to the configuration information of the primary server to break down, run the service of the primary server to break down.In addition, occurringThe primary server of failure can also be according to fault message, it is determined whether can degenerate for standby server, if can if be addedBackup server cluster is for backing up.The role of multiple primary servers can be different in the embodiment of the present invention, standby server andThe role of primary server can also be different, and thus solves standby server in the prior art and primary server role correspondsThe problem of caused standby server wasting of resources, and the server to break down is also possible to degenerate and be used for for standby serverThe problem of backing up, further solving the standby server wasting of resources, reduces the cost of system group network.
It is the hardware environment architecture diagram of server backup device operation in one embodiment of the present invention referring to Fig. 3:
The embodiment of server backup device of the present invention can be applied on standby usage server.Installation practice can lead toSoftware realization is crossed, can also be realized by way of hardware or software and hardware combining.Taking software implementation as an example, as a logicDevice in meaning is to be read computer program instructions corresponding in nonvolatile memory by the CPU of equipment where itInto memory, operation is formed.For hardware view, as shown in figure 3, for server backup in one embodiment of the present inventionDevice operation hardware environment architecture diagram, in addition to CPU shown in Fig. 3, memory, network interface and nonvolatile memory itOutside, the equipment in embodiment where device usually can also include other hardware.
Referring to fig. 4, it is the hardware environment architecture diagram of server backup device operation in one embodiment of the present invention:
The embodiment of server backup device of the present invention can be applied on the primary server to break down.Installation practiceIt can also be realized by way of hardware or software and hardware combining by software realization.Taking software implementation as an example, as oneDevice on a logical meaning is to be referred to computer program corresponding in nonvolatile memory by the CPU of equipment where itIt enables and is read into memory what operation was formed.For hardware view, as shown in figure 4, to be serviced in one embodiment of the present inventionThe hardware environment architecture diagram of device back-up device operation, in addition to CPU shown in Fig. 4, memory, network interface and non-volatile is depositedExcept reservoir, the equipment in embodiment where device usually can also include other hardware.
It is server backup device block diagram in one embodiment of the present invention referring to Fig. 5, which takes applied to standby usageBusiness device.
Described device includes: connection establishment unit 510, acquiring unit 520, backup units 530.
Wherein, connection establishment unit 510, the heartbeat connection for establishing between the multiple primary server;
Acquiring unit 520, for obtaining the configuration information of the multiple primary server by heartbeat connection, whereinRole's software of the multiple primary server is set in the standby usage server;
Backup units 530, for when any one primary server in the multiple primary server breaks down, according toThe hardware asset information of the primary server to break down judges whether the standby usage server meets backup condition, if fullFoot, then role's software of the primary server to break down described in operation, and according to the configuration of the primary server to break downInformation, the service of the primary server to break down described in operation.
Optionally, the connection establishment unit 510, it may also be used for the transmission established between other standby servers controlsProtocol communication connection.
Described device further include: transmission unit 540 (is not shown) in Fig. 5, for sending to other described standby serversThe configuration information of the multiple primary server.Transmission unit 540, it may also be used for connected by the heartbeat, to the multiple masterServer sends the information list of standby server, and the information list of the standby server includes the ground of all standby serversLocation information.
Optionally, the backup units 530 comprise determining that subelement 531 (being not shown in Fig. 5), if being used for the masterStandby server is unsatisfactory for backup condition, determines the number of units N for meeting the standby server of backup condition needs;Select subelement532 (being not shown in Fig. 5) select N-1 platform standby for the number of units N according to the standby server in backup server clusterWith server, the service of the primary server to break down is operated together by N platform standby server.
Described device further include: releasing unit 550 (is not shown) in Fig. 5, for discharging and other described standby serversBetween communication connection, and discharge and other primary servers between heartbeat connect.
The function of each unit and the realization process of effect are specifically detailed in the above method and correspond to step in above-mentioned apparatusRealization process, details are not described herein.
It is server backup device block diagram in one embodiment of the present invention referring to Fig. 6.
Described device includes: judging unit 610, acquiring unit 620, degeneration 630.
Wherein, judging unit 610 are standby server for according to fault message, judging whether to degenerate;
Acquiring unit 620, for if so, obtaining any one standby server from the information list of standby serverAddress information;
Degeneration 630, for establishing and the communication link between corresponding standby server according to the address informationIt connects, the backup server cluster where the standby server is added.
Optionally, the degeneration 630 is specifically used for: if the corresponding standby server of the address information is describedStandby usage server in backup server cluster after then establishing the communication connection with the standby usage server, identifies instituteIt states the primary server to break down and the standby server collection is added;If the corresponding standby server of the address information is notStandby usage server in the backup server cluster, then the corresponding standby server of the address information is former to the generationThe primary server of barrier sends the address information of standby usage server, so that the primary server to break down is established and the masterThe backup server cluster is added in communication connection between standby server.
Optionally, the degeneration further include: upgrading subelement 640 (being not shown in Fig. 6) is used for and the standby usageServer is compared according to certain preset condition, if the primary server to break down meets the preset condition,The primary server to break down upgrades to the standby usage server in the server cluster.
The degeneration further include: bullet member 650 (being not shown in Fig. 6) is established in connection, spare with other for establishingCommunication connection between server, and the heartbeat established between other primary servers connects;Subelement 660 is configured (in Fig. 6It is not shown), it is also used to connect the configuration information for obtaining other primary servers by the heartbeat.
The function of each unit and the realization process of effect are specifically detailed in the above method and correspond to step in above-mentioned apparatusRealization process, details are not described herein.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to of the invention itsIts embodiment.This application is intended to cover any variations, uses, or adaptations of the invention, these modifications, purposes orPerson's adaptive change follows general principle of the invention and including the undocumented common knowledge in the art of the present inventionOr conventional techniques.The description and examples are only to be considered as illustrative, and true scope and spirit of the invention are by followingClaim is pointed out.
It should be understood that the present invention is not limited to the precise structure already described above and shown in the accompanying drawings, andAnd various modifications and changes may be made without departing from the scope thereof.The scope of the present invention is limited only by the attached claims.