A kind of method and device for ensureing data consistency and availability
Technical field
The application is related to field of computer technology, more particularly to a kind of method and dress for ensureing data consistency and availability
Put.
Background technology
Website or application server in internet cause disabled situation to occur in order to avoid computer room failure, generally
Multiple computer rooms can be built.So in a computer room because network, power supply, fire etc. are unexpected when causing whole computer room unavailable can be with
Ongoing service is switched to another computer room, so as to continue to provide the user service.
After computer room switching, the data that usual data can be produced in the computer room of subregion, i.e., two are asynchronous, and under normal circumstances two
Data in individual computer room are all identical and are newest, can now run into and how ensure asking for data consistency and availability
Topic.
Current distributed data base (such as oceanbase) can accomplish computer room switching when and meanwhile ensure data consistency and
Availability, but on condition that need majority to reach an agreement.In order to meet this precondition, it usually needs 3 and the above
Computer room.For example, there are 3 computer rooms, when fire, which occurs, for one of computer room causes computer room unavailable, computer room can be used due to remaining
Quantity 2 is more than the quantity 1 of unavailable computer room, it is possible to meet the condition that majority reaches an agreement.But it is due to computer room construction
And the cost safeguarded is higher, and two-shipper room may can be only used in many cases.
, in the prior art, can be by a computer room in order to meet above-mentioned precondition in the case of only 2 computer rooms
Majority's node is set, and another computer room sets minority's node, so when minority's node computer room breaks down unavailable,
The condition that majority reaches an agreement can just only be met by majority's node computer room itself.For example, a computer room is provided with 2
Node device a, computer room is provided with 1 node device;When the computer room of 1 node device is unavailable, remaining computer room due to
It is more than 1 node device of unavailable computer room with 2 node devices, can have still reached the consistent condition of majority.So
And, when majority's node computer room is unavailable, the consistent condition of majority only can not be met by minority's node computer room, also
Data consistency and availability can not be ensured.
In summary, in the prior art in the presence of under double building environments, it is impossible to the problem of ensureing data consistency and availability.
The content of the invention
A kind of guarantee data consistency and the method and device of availability that the application is provided, it is double in the prior art to solve
Under building environment, it is impossible to the problem of ensureing data consistency and availability.
A kind of guarantee data consistency and the method for availability provided according to the embodiment of the present application, methods described includes:
In the case of any one node device is disabled, judge whether enabled node number of devices exceedes all nodes
The half of number of devices;
In the case of half of the enabled node number of devices no more than all node device quantity, available node is changed
Configuration file interior joint facility information and the node device sum of equipment so that available node device no longer recognize it is described not
Available node device;
In the case where receiving affairs submission request, according to the amended configuration file, to the available section
Point device initiates to operate for the submission of the affairs;
Judge the half for successfully submitting the quantity of the node device of the affairs whether to exceed modification deutomerite point device sum;
In the case of the half for successfully submitting the quantity of node device of the affairs to exceed modification deutomerite point device sum,
Then determine that the affairs are submitted successfully, and the successful information of submission is returned to the affairs submission side.
A kind of guarantee data consistency and the method for availability provided according to the embodiment of the present application, methods described is applied to
Two-shipper room, methods described includes:
In the case of all node devices are disabled in the first computer room, another available second computer room interior joint is changed
Configuration file interior joint facility information and the node device sum of equipment so that the second computer room interior joint equipment is no longer known
Not described first computer room interior joint equipment;
In the case where receiving affairs submission request, according to the amended configuration file, to second computer room
Interior joint equipment is initiated to operate for the submission of the affairs;
Judge that successfully submitting the quantity of the node device of the affairs whether to exceed modification posterior nodal point in second computer room sets
The half of standby sum;
The quantity of the node device of the affairs is successfully submitted to exceed modification deutomerite point device sum in second computer room
Half in the case of, determine that the affairs are submitted successfully, and returned to the affairs submission side and submit successful information.
A kind of guarantee data consistency and the method for availability provided according to the embodiment of the present application, methods described is applied to
Two-shipper room, methods described includes:
Between two-shipper room in the case of interrupted communication link, the configuration file interior joint of main equipment room interior joint equipment is changed
Facility information and node device sum so that main equipment room interior joint equipment no longer recognizes standby computer room interior joint equipment;
In the case where receiving affairs submission request, according to the amended configuration file, to main equipment room interior joint
Equipment is initiated to operate for the submission of the affairs;
Judge successfully to submit whether the quantity of the node device of the affairs exceedes modification deutomerite point device in the main equipment room
The half of sum;
The quantity of the node device of the affairs is successfully submitted to exceed modification deutomerite point device sum in the main equipment room
In the case of half, determine that the affairs are submitted successfully, and the successful information of submission is returned to the affairs submission side.
A kind of guarantee data consistency and the device of availability provided according to the embodiment of the present application, described device includes:
First judging unit, in the case of any one node device is disabled, judges that enabled node number of devices is
The no half more than all node device quantity;
Unit is changed, in the case of half of the enabled node number of devices no more than all node device quantity, modification
Configuration file interior joint facility information and the node device sum of available node device so that available node device is no longer
Recognize the disabled node device;
Unit is initiated, is being received in the case that affairs submit request, according to the amended configuration file, to described
Available node device initiates to operate for the submission of the affairs;
Second judging unit, judges successfully to submit whether the quantity of the node device of the affairs exceedes modification deutomerite point device
The half of sum;
Determining unit, exceedes the half of modification deutomerite point device sum successfully submitting the quantity of the node device of the affairs
In the case of, it is determined that the affairs are submitted successfully, and return to the successful information of submission to the affairs submission side.
A kind of guarantee data consistency and the device of availability provided according to the embodiment of the present application, described device is applied to
Two-shipper room, described device includes:
Change unit, in the case of all node devices are disabled in the first computer room, change another available second
Configuration file interior joint facility information and the node device sum of computer room interior joint equipment so that the second computer room interior joint
Equipment no longer recognizes the first computer room interior joint equipment;
Unit is initiated, is being received in the case that affairs submit request, according to the amended configuration file, to described
Second computer room interior joint equipment is initiated to operate for the submission of the affairs;
Judging unit, judges successfully to submit whether the quantity of the node device of the affairs exceedes modification in second computer room
The half of deutomerite point device sum;
Determining unit, successfully submits the quantity of the node device of the affairs to exceed modification posterior nodal point in second computer room
In the case of the half of equipment sum, determine that the affairs are submitted successfully, and submission successfully letter is returned to the affairs submission side
Breath.
A kind of guarantee data consistency and the device of availability provided according to the embodiment of the present application, described device is applied to
Two-shipper room, described device includes:
Unit is changed, between two-shipper room in the case of interrupted communication link, the configuration of main equipment room interior joint equipment is changed
File interior joint facility information and node device sum so that main equipment room interior joint equipment no longer recognizes standby computer room interior joint
Equipment;
Unit is initiated, in the case where receiving affairs submission request, according to the amended configuration file, to main frame
Room interior joint equipment is initiated to operate for the submission of the affairs;
Judging unit, judges successfully to submit whether the quantity of the node device of the affairs exceedes after modification in the main equipment room
The half of node device sum;
Determining unit, successfully submits the quantity of the node device of the affairs to exceed modification posterior nodal point in the main equipment room and sets
In the case of the half of standby sum, determine that the affairs are submitted successfully, and the successful information of submission is returned to the affairs submission side.
In the embodiment of the present application, any node device occur it is disabled in the case of, by automatically change it is other can
Configuration file interior joint facility information and the node device sum of node device, so that available node device is not
The disabled node device is recognized again.In this way, when carrying out affairs submission, half is exceeded in remaining available node device
Count when successfully submitting, the consistent condition of majority can be just met, so as to ensure data consistency and availability.
For two-shipper room after disaster tolerance switching, the configuration file interior joint of computer room interior joint equipment can be used by changing automatically
Facility information and node device sum, so that described can no longer be recognized with computer room interior joint equipment in unavailable computer room is saved
Point device.In this way, carry out affairs submission when, it is only necessary to it is described can with successfully submitted in computer room the affairs node device quantity surpass
When more than half (modification deutomerite point device sum), it is possible to meet the consistent condition of majority, thus ensure data consistency and
Availability.For example, each 2 node devices of computer room A and computer room B, when 2 node devices are all unavailable in computer room A, change computer room
Configuration file interior joint facility information and the node device sum of B interior joint equipment, when carrying out affairs submission, due to modification
Node device sum afterwards is 2, and now the quantity of majority is 2, so 2 node devices are successfully carried in the computer room B
In the case of handing over the affairs, it is possible to meet the consistent condition of majority, submitted so as to the successfully affairs, it is ensured that data one
Cause property and availability, solve the problem of can not ensureing data consistency and availability under two-shipper room.For leading between two-shipper room
It is identical with time in the case of letter link down, main equipment room can be considered as to available computer room, standby computer room is considered as unavailable computer room.
Brief description of the drawings
Fig. 1 is the flow chart of the method for the guarantee data consistency that the embodiment of the application one is provided and availability;
Fig. 2 is the node device cluster schematic diagram that the embodiment of the application one is provided;
Fig. 3 a, 3b are the two-shipper room schematic diagrames that the embodiment of the application one is provided;
Fig. 4 is the flow chart of the method for the guarantee data consistency that the embodiment of the application one is provided and availability;
Fig. 5 is the schematic diagram in the two-shipper room that the embodiment of the application one is provided;
Fig. 6 is the flow chart of the method for the guarantee data consistency that the embodiment of the application one is provided and availability;
Fig. 7 is a kind of hardware configuration of equipment where the device of the guarantee data consistency that the application is provided and availability
Figure;
Fig. 8 is the module diagram of the device of the guarantee data consistency that the embodiment of the application one is provided and availability;
Fig. 9 is a kind of hardware configuration of equipment where the device of the guarantee data consistency that the application is provided and availability
Figure;
Figure 10 is the module diagram of the device of the guarantee data consistency that the embodiment of the application one is provided and availability;
Figure 11 is a kind of hardware configuration of equipment where the device of the guarantee data consistency that the application is provided and availability
Figure;
Figure 12 is the module diagram of the device of the guarantee data consistency that the embodiment of the application one is provided and availability.
Embodiment
Here exemplary embodiment will be illustrated in detail, its example is illustrated in the accompanying drawings.Following description is related to
During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous key element.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended
The example of the consistent apparatus and method of some aspects be described in detail in claims, the application.
It is the purpose only merely for description specific embodiment in term used in this application, and is not intended to be limiting the application.
" one kind ", " described " and "the" of singulative used in the application and appended claims are also intended to including majority
Form, unless context clearly shows that other implications.It is also understood that term "and/or" used herein refers to and wrapped
It may be combined containing one or more associated any or all of project listed.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the application
A little information should not necessarily be limited by these terms.These terms are only used for same type of information being distinguished from each other out.For example, not departing from
In the case of the application scope, the first information can also be referred to as the second information, similarly, and the second information can also be referred to as
One information.Depending on linguistic context, word as used in this " if " can be construed to " ... when " or " when ...
When " or " in response to determining ".
In correlation technique, data consistency is represented, the data in all node devices are all newest and identicals.
For example, for user account remaining sum, data consistency is extremely important.Assuming that in the presence of two record users
The node device of account balance, certain user account remaining sum is 100 yuan, has at a time been transferred to 100 yuan by node device 1,
Then the user account remaining sum is changed into 200 yuan in node device 1;In order to ensure data consistency, node device 1 is also needed to data
Another node device 2 is synchronized to, it is also 200 yuan to make the user account remaining sum in node device 2.If node device 1 does not have
Synchronous user account remaining sum, then when the user is queried the balance or paid by node device 2, account balance is only
For 100 yuan.Therefore, data consistency is extremely important.
Availability represents that data have high availability.For example, when some node device breaks down, then the node device
The service of offer needs to be switched on other available node devices, so as to ensure availability.For another example when some computer room occurs
Failure so that all node devices are all unavailable in the computer room, then need the node device being switched in other computer room to continue to carry
For service.
General, the node device of each computer room, which can be provided with to record in a configuration file, the configuration file, to be had
Node device information in this computer room and other computer rooms, and node device sum (including this computer room interior joint number of devices
With other computer room interior joint number of devices).
Fig. 1 is referred to, the guarantee data consistency and the flow chart of the method for availability provided for the embodiment of the application one,
It the described method comprises the following steps:
Step 110:In the case of any one node device is disabled, judge whether enabled node number of devices exceedes
The half of all node device quantity.
Step 120:In the case of half of the enabled node number of devices no more than all node device quantity, modification can
Configuration file interior joint facility information and the node device sum of node device so that available node device is no longer known
Not described disabled node device.
In the present embodiment, the node device information can include the IP address of node device.
In the case of half of the enabled node number of devices no more than all node device quantity, illustrate according only to residue
Enabled node equipment can not reach the condition of majority.Accordingly, it would be desirable to be handled, that is, change the configuration of available node device
File interior joint facility information and node device sum so that available node device no longer recognizes the disabled node
Equipment.The configuration file interior joint facility information and node device sum of the available node device of modification, are specifically included:
The IP address of the disabled node device recorded in the configuration file of available node device is deleted, and
The node device sum of record is subtracted 1.In this manner it is possible to which so that available node device no longer recognizes the disabled node
Equipment.
Step 130:Receiving in the case that affairs submit request, according to the amended configuration file, to described
Available node device initiates to operate for the submission of the affairs.
In the present embodiment, due to having deleted the IP address of disabled node device in amended configuration file,
Therefore, receive affairs submit request after, only need into configuration file remaining node device, you can node device send out
The submission risen for the affairs is operated.General, it can be write operation to submit operation.
Step 140:Judge successfully to submit whether the quantity of the node device of the affairs exceedes modification deutomerite point device sum
Half.
Step 150:Exceed the half of modification deutomerite point device sum successfully submitting the quantity of the node device of the affairs
In the case of, it is determined that the affairs are submitted successfully, and return to the successful information of submission to the affairs submission side.
For example, in node device cluster schematic diagram as shown in Figure 2:
The node device cluster can be the node in the node device cluster of some node device compositions, the cluster
Equipment can adhere to different computer rooms separately.As in Fig. 2, there is node device 1 and 2 in computer room A, computer room B has node device 3 and 4,
Computer room C has node device 5 and 6.Under normal circumstances, the configuration file interior joint facility information of each computer room interior joint equipment is
The IP address of node device 1,2,3,4,5,6, and node device sum is 6.Assuming that node device 1,2,3 is unavailable, then may be used
It is 3 with node device quantity, and the half of all node device quantity is also 3;Now due to enabled node number of devices whether
All or fewer than the half of node device quantity, then the configuration file of available node device 4,5,6 is changed automatically.Specifically, will
The IP address of the node device 1,2,3 recorded in configuration file is deleted, and node device sum is revised as into 3.Receiving thing
It is engaged in after the affairs submission request of initiator's initiation, according to amended configuration file, can be initiated to enabled node equipment 4,5,6
For the submission operation of the affairs.Because configuration file interior joint equipment sum is 3 after modification, therefore the quantity of majority is 2
(half of node device sum), i.e., in the case where at least two node device is reached an agreement, can just meet majority consistent
Condition.In view of the situation, can be with only in the case where successfully submitting the quantity of node device of the affairs more than 2
Determine that the affairs are submitted successfully, it is possible to returned to affairs submission side and submit successful information.
The embodiment of the present application, enabled node number of devices whether all or fewer than node device quantity half situation
Under, by automatically changing the configuration file interior joint facility information and node device sum of other available node devices,
So that available node device no longer recognizes the disabled node device.In this way, when carrying out affairs submission, surplus
When successfully being submitted more than half in remaining available node device, the consistent condition of majority can be just met, so as to ensure data
Uniformity and availability.
Still it is based on the basis of embodiment described in Fig. 1, this method embodiment can also comprise the following steps:
After any disabled node device x recovers normal, it will add in the configuration file of other available node devices
Plus the IP address of the node device x, and node device sum Jia 1 so that other available node devices re-recognize institute
State node device x;
By the data syn-chronization of other all available node devices to the node device x, until the node device x with
Data are identical in other all available node devices.
In the present embodiment, after recovering normal for disabled node device x, due in the node device x unavailable phases
Between, data may change in other node devices, in order to ensure data consistency, it is necessary to be counted in synchronous node device x
According to so that data are identical in all available node devices (including node device x and other all available node devices).
Continue to use Fig. 2, it is assumed that, then can be by the configuration file of other available node devices after node device 1 recovers normal
The middle IP address for adding the node device 1, and node device is total because 3 are revised as 6, so that other available nodes
Equipment 4,5,6 can recognize the node device 1 again.Afterwards, by node device 1 from other all available node devices 4,5,
Data supplementing write operation is carried out at 6, until node device 1 is identical with data in node device 4,5,6, so as to ensure that data one
Cause property.Likewise, if node device 2 or 3 also recovers normally, processing procedure is identical with the processing procedure of above-mentioned node device 1.
In the two-shipper room schematic diagram shown in Fig. 3 a, with computer room A and computer room B.Wherein, in computer room A there are 2 nodes to set
It is standby, there is 1 node device in computer room B.Because node device sum is 3, therefore the quantity of majority is 2, i.e., at least two
When node device is reached an agreement, the consistent condition of majority is met.
If minority's computer room is computer room, B interior joint equipment is unavailable, and affairs submission side such as App servers are into computer room A
Node device initiates affairs and submits request, it is assumed that the responsible affairs that handle of node device 1 submit request.Now, node device 1 is removed
Outside the write operation for carrying out affairs, in addition it is also necessary to node device information in configuration file, as shown in the dotted line in Fig. 3 a to
The data that node device 3 in node device 2 and computer room B is synchronously written;Because the quantity of majority is 2, as long as therefore computer room A
Interior joint equipment 1 and 2 all successfully submits affairs, even if computer room B is because unavailable cause node device 3 to submit affairs not successfully,
The consistent condition of majority can also be met, the App servers submit affairs be just counted as work(, it is ensured that data consistency and can use
Property.
However, if majority's computer room is that computer room A interior joints equipment 1,2 is all unavailable as shown in Figure 3 b, App servers to
Computer room B interior joints equipment initiates affairs and submits request, it is assumed that the responsible affairs that handle of node device 3 submit request.Now, node
Equipment 3 is in addition to carrying out the write operation of affairs, in addition it is also necessary to the dotted line in the node device information in configuration file, such as Fig. 3 b
The data that node device 1 and 2 in shown from the A to computer room is synchronously written;Because the quantity of majority is 2, and computer room A interior joints
Equipment 1,2 is unavailable to be caused all to submit affairs not successfully, even if therefore node device 3 successfully submits affairs, can not also meet many
Number sends consistent condition, also can not just ensure data consistency and availability.
In the present embodiment, the communication between the two-shipper room can be based on distributed consensus agreement.Such as Paxos agreements
Or the improved protocol of the Paxos agreements.
As long as the Paxos agreements, which propose that f+1 node in middle 2f+1 node is available, (exceedes the section of more than half
Point, i.e. majority), then ensure that data consistency and availability.Here availability be not represent 100% can
With the codomain of availability can be defined as the continuum of 0 to 100% (i.e. 1) in general sense.Because distributed system reaches
In availability less than 100%, such as two-shipper room, a computer room failure needs to carry out computer room switching, and now, failure computer room is
It is unavailable, and be not switched to also in this period of normal computer room, whole system is at down state.
Assuming that the availability of single node is P, then the f+1 being combined in 2f+1 node normally might be used with last node
The property usedAgain assume P=0.99, f=2, then P (total)=
0.9999901494, now availability will be from 29 liftings after single node decimal point to 59, it means that system is annual
Downtime can be dropped to 0.086 hour from 87.6 hours.Such system can substantially meet the demand of all applications
.
In order to solve the above problems, Fig. 4 is referred to, the guarantee data consistency that provides for the embodiment of the application one and available
The flow chart of the method for property, methods described can apply to two-shipper room, the described method comprises the following steps:
Step 210:In the case of all node devices are disabled in any one computer room A, another is changed available
Configuration file interior joint facility information and the node device sum of computer room B interior joint equipment so that the computer room B interior joints are set
It is standby no longer to recognize the computer room A interior joint equipment.
In the present embodiment, the node device information can include the IP address of node device.
The disabled situation, can include all node device failures in such as any one computer room A.
In the present embodiment, the configuration file interior joint equipment letter for changing another available computer room B interior joint equipment
Breath and node device sum, are specifically included:
All node devices in the computer room A that will be recorded in the configuration file of another available computer room B interior joint equipment
IP address is deleted, and node device sum is revised as to the quantity of the computer room B interior joint equipment.
Illustrate, it is assumed that computer room A and computer room B node device quantity is all 2, in computer room A interior joints equipment not
In the case of available, all node device information are deleted in the computer room A that will can be recorded in the configuration file of computer room B interior joint equipment
Remove, and node device is total because original 4 are revised as 2.
Step 220:Receiving in the case that affairs submit request, according to the amended configuration file, to described
Computer room B interior joints equipment is initiated to operate for the submission of the affairs.
In the present embodiment, in the case where receiving affairs submission request, because amended configuration file only remains computer room B
In node device information so that computer room B interior joints equipment no longer recognizes computer room A interior joint equipment, therefore, only to the computer room
B interior joints equipment is initiated to operate for the submission of the affairs.
Step 230:Judge successfully to submit whether the quantity of the node device of the affairs exceedes modification deutomerite in the computer room B
The half of point device sum.
Step 240:The quantity of the node device of the affairs is successfully submitted to exceed modification deutomerite point device in the computer room B
In the case of the half of sum, determine that the affairs are submitted successfully, and the successful information of submission is returned to the affairs submission side.
For above-mentioned Fig. 3 b, because computer room A interior joints equipment 1,2 is unavailable, the configuration text of computer room B interior joint equipment is changed
Part, i.e., delete the IP address of the node device 1,2 recorded in configuration file, and node device sum is revised as into 1 by 3.Such as
This, as long as computer room B interior joints equipment 3 successfully submits affairs, it is possible to meet the condition of majority's uniformity, and then ensure data
Uniformity and availability.
It is noted that generally each computer room can have the node device of identical quantity in two-shipper room, node is set
Standby sum is the sum of the two-shipper room interior joint equipment.
For example, in two-shipper room schematic diagram as shown in Figure 5, with computer room A and computer room B.Wherein, computer room A has 2
Node device, computer room B has 2 node devices.Node device sum is 2+2=4, therefore the quantity of majority is 3, that is, is existed
When 3 node devices are reached an agreement, the consistent condition of majority is met.
In the case of computer room A interior joints equipment 3,4 is disabled, computer room B can be switched offer service is provided, now can be with
Change computer room B interior joint equipment configuration file, i.e., by the node device 1 recorded in the configuration file of computer room B interior joint equipment,
2nd, 3,4, it is revised as only remaining the node device 1,2 (deleting computer room A interior joints equipment 3,4) of the computer room B, and node is set
Standby sum is revised as 2 from 4.After computer room B is switched to, App servers, can be to computer room if necessary to carry out affairs submission
B interior joints equipment initiates affairs and submits request, according to the node device information recorded in amended configuration file, is set to node
Initiate to operate for the submission of the affairs for 1 and node device 2.If node device 1 and node device 2 all successfully submit the thing
Business, because present majority is 2 (half of node device sum), can meet the consistent condition of majority.So,
It ensure that data consistency and availability.
In the embodiment of the present application, for two-shipper room after disaster tolerance switching, computer room interior joint equipment can be used by changing automatically
Configuration file interior joint facility information and node device sum so that it is described with computer room B interior joints equipment no longer
Recognize unavailable computer room A interior joint equipment.In this way, when carrying out affairs submission, it is only necessary to successfully submit the affairs in the computer room B
Node device quantity when exceeding half (modification deutomerite point device sum), it is possible to meet the consistent condition of majority so that
Ensure data consistency and availability.For example, each 2 node devices of computer room A and computer room B, 2 node devices are all in computer room A
When unavailable, the configuration file interior joint facility information and node device sum of computer room B interior joint equipment are changed, is entering to act
When business is submitted, because amended node device sum is 2, now the quantity of majority is 2, so 2 in the computer room B
In the case that node device successfully submits the affairs, it is possible to meet the consistent condition of majority, so as to the successfully thing
Business is submitted, it is ensured that data consistency and availability, solves the problem of can not ensureing data consistency and availability under two-shipper room.
In actual applications, it is assumed that any one node device recovers normal in computer room A, due to the computer room A unavailable phases
Between, it may increase many data newly in computer room B interior joint equipment, therefore, there are data in node device in computer room A and computer room B
In the case of inconsistent, in order to ensure data consistency, it is necessary to recover the data of normal node device in synchronous computer room A, make
Obtain data in all available node devices identical.Therefore, on the basis of embodiment illustrated in fig. 4, also comprise the following steps:
After all node devices recover normal in the computer room A, one by one by data in the computer room A interior joint equipment
Synchronize, specifically include with computer room B interior joint device datas:
A1:It is node device to be synchronized that a node device is chosen from recovered normal node device;
A2:The IP address of the node device to be synchronized will be added in the configuration file of the computer room B interior joint equipment, and
Node device sum Jia 1;
A3:By the data syn-chronization of enabled node equipment to the node device to be synchronized;
A4:In the node device to be synchronized and enabled node equipment in the case of data identical, A1 is repeated, directly
Into the computer room A, all node devices are identical with data in enabled node equipment
Still it is illustrated with the schematic diagram shown in Fig. 5, after all node devices recover normal in computer room A, it is assumed that be
Node device 3 be have chosen for node device to be synchronized;Now, institute will be added in the configuration file of the computer room B interior joint equipment
The IP address of node device 3 is stated, and node device sum Jia 1.
Then, the node device 3 is subjected to data supplementing write operation at the computer room B interior joints equipment 1,2, until
The node device 3 is identical with the data of all node devices in computer room B.
After the completion of the synchrodata of node device 3, node device 4 is chosen for node device to be synchronized;Computer room B is changed again
The configuration information of interior joint equipment, the IP address of the node device 1,2,3 of record is revised as to the IP of node device 1,2,3,4
Location so that node device 1,2,3 can be with recognition node equipment 4.And node device sum is also revised as 4 from 3.
Then, node device 4 is gone out to carry out data supplementing write operation from node device 1,2,3.
In actual applications, except in computer room all node devices it is unavailable in addition to, it is also possible to occur to lead between two-shipper room
Believe the situation of link down.General, one computer room can be set to main equipment room when two-shipper room is set, another is set to standby
Computer room.When interrupted communication link between two-shipper room, the just only main equipment room of service can be provided, and in standby computer room
Although node device is normal, but due to interrupted communication link, for main equipment room, and standby computer room is equivalent to can not in fact
With.Therefore, such case is also required to ensure data consistency and availability.Fig. 6 is referred to for this, is that the embodiment of the application one is carried
The flow chart of the guarantee data consistency of confession and the method for availability, methods described can apply to two-shipper room, methods described bag
Include following steps:
Step 310:Between two-shipper room in the case of interrupted communication link, the configuration text of main equipment room interior joint equipment is changed
Part interior joint facility information and node device sum so that main equipment room interior joint equipment no longer recognizes that standby computer room interior joint is set
It is standby.
In the present embodiment, the node device information can include the IP address of node device.
It should be noted that the main equipment room can be an artificially pre-defined computer room;Or, it is affairs submission side
The computer room that for example App servers are determined.
Because one is main equipment room in two-shipper room, one is standby computer room.As it was previously stated, between two-shipper room in communication link
It is disconnected that the just only main equipment room of service can be provided;Accordingly, it would be desirable to which the configuration file interior joint for changing main equipment room interior joint equipment is set
Standby information and node device sum, are specifically included:
The IP address of all node devices is deleted in the standby computer room that will be recorded in the configuration file of main equipment room interior joint equipment
Remove, and node device sum is revised as to the quantity of the main equipment room interior joint equipment.
This step is similar to the above embodiments, and here is omitted.
Step 320:In the case where receiving affairs submission request, according to the amended configuration file, to main frame
Room interior joint equipment is initiated to operate for the submission of the affairs.
This step is similar to the above embodiments, and here is omitted.
Step 330:Judge successfully to submit whether the quantity of the node device of the affairs exceedes after modification in the main equipment room
The half of node device sum.
This step is similar to the above embodiments, and here is omitted.
Step 340:Successfully submit the quantity of the node device of the affairs to exceed modification posterior nodal point in the main equipment room to set
In the case of the half of standby sum, determine that the affairs are submitted successfully, and the successful information of submission is returned to the affairs submission side.
This step is similar to the above embodiments, and here is omitted.
Similar, each computer room can have the node device of identical quantity in usual two-shipper room.
Similar, on the basis of embodiment illustrated in fig. 6, it can also include:
After communication link recovers normal between two-shipper room, one by one by standby the computer room interior joint device data and main frame
Room interior joint device data is synchronized, and is specifically included:
B1:It is node device to be synchronized that a node device is chosen from the standby computer room;
B2:The IP address of the node device to be synchronized will be added in the configuration file of the main equipment room interior joint equipment,
And node device sum Jia 1;
B3:By the data syn-chronization of enabled node equipment to the node device to be synchronized;
B4:In the node device to be synchronized and enabled node equipment in the case of data identical, B1 is repeated, directly
Into the standby computer room, all node devices are identical with data in enabled node equipment.
The present embodiment is similar with previous embodiment, and here is omitted.
It is corresponding with ensureing the embodiment of the method for data consistency and availability described in earlier figures 1, present invention also provides
A kind of embodiment for the device for ensureing data consistency and availability.Described device embodiment can be realized by software, also may be used
To be realized by way of hardware or software and hardware combining.Exemplified by implemented in software, as the device on a logical meaning, it is
Corresponding computer program instructions in nonvolatile memory are read in internal memory by the processor of equipment where it and run
Formed.For hardware view, as shown in fig. 7, equipment where ensureing the device of data consistency and availability for the application
A kind of hardware structure diagram, in addition to the processor shown in Fig. 7, network interface, internal memory and nonvolatile memory, implement
Equipment in example where device can also include other hard generally according to the actual functional capability of the guarantee data consistency and availability
Part, is repeated no more to this.
Referring to Fig. 8, the guarantee data consistency and the module map of the device of availability provided for the embodiment of the application one, institute
Stating device includes:First judging unit 410, modification unit 420, initiation unit 430, second judge into unit 440 and determined single
Member 450.
Wherein, the first judging unit 410, in the case of any one node device is disabled, judges that enabled node is set
Whether standby quantity exceedes the half of all node device quantity;
Unit 420 is changed, in the case of half of the enabled node number of devices no more than all node device quantity, is repaiied
Change the configuration file interior joint facility information and node device sum of available node device so that available node device is not
The disabled node device is recognized again;
Unit 430 is initiated, is being received in the case that affairs submit request, according to the amended configuration file, to
The available node device initiates to operate for the submission of the affairs;
Second judging unit 440, judges successfully to submit whether the quantity of the node device of the affairs exceedes modification posterior nodal point
The half of equipment sum;
Determining unit 450, exceedes modification deutomerite point device sum successfully submitting the quantity of the node device of the affairs
In the case of half, it is determined that the affairs are submitted successfully, and the successful information of submission is returned to the affairs submission side.
In an optional embodiment:
The node device information includes the IP address of node device.
In an optional embodiment:
The modification unit 420, is specifically included:
In the case of half of the enabled node number of devices no more than all node device quantity, available node is set
The IP address of the disabled node device recorded in standby configuration file is deleted, and the node device sum of record is repaiied
It is changed to available node device quantity so that available node device no longer recognizes the disabled node device.
In an optional embodiment:
Described device also includes:
Recover processing unit, after any disabled node device x recovers normal, by other available node devices
The IP address of the node device x is added in configuration file, and node device sum Jia 1 so that other available nodes are set
It is standby to re-recognize the node device x;
Synchronous data hierarchy, by the data syn-chronization of other all available node devices to the node device x.
It is corresponding with ensureing the embodiment of the method for data consistency and availability described in earlier figures 4, present invention also provides
A kind of embodiment for the device for ensureing data consistency and availability, applied to two-shipper room.Described device embodiment can pass through
Software is realized, can also be realized by way of hardware or software and hardware combining.Exemplified by implemented in software, anticipated as a logic
Device in justice, is to be read corresponding computer program instructions in nonvolatile memory by the processor of equipment where it
Into internal memory, operation is formed.For hardware view, as shown in figure 9, ensureing data consistency and availability for the application
A kind of hardware structure diagram of equipment where device, except the processor shown in Fig. 9, network interface, internal memory and non-volatile is deposited
Outside reservoir, the equipment in embodiment where device is gone back generally according to the actual functional capability of the guarantee data consistency and availability
Other hardware can be included, this is repeated no more.
Referring to Figure 10, the guarantee data consistency and the module map of the device of availability provided for the embodiment of the application one,
Described device includes:Unit 510 is changed, unit 520 is initiated, judges into unit 530 and determining unit 540.
Wherein, unit 510 is changed, in the case of all node devices are disabled in the first computer room, changing another can
Configuration file interior joint facility information and the node device sum of second computer room interior joint equipment so that second machine
Room interior joint equipment no longer recognizes the first computer room interior joint equipment;
Unit 520 is initiated, is being received in the case that affairs submit request, according to the amended configuration file, to
The second computer room interior joint equipment is initiated to operate for the submission of the affairs;
Judging unit 530, judges successfully to submit whether the quantity of the node device of the affairs exceedes in second computer room
Change the half of deutomerite point device sum;
Determining unit 540, successfully submits the quantity of the node device of the affairs to exceed after modification in second computer room
In the case of the half of node device sum, determine that the affairs are submitted successfully, and submitted successfully to affairs submission side return
Information.
In an optional embodiment:
The node device information includes the IP address of node device.
In an optional embodiment:
The modification unit 510, is specifically included:
In the case of all node devices are disabled in the first computer room, another available second computer room interior joint is set
The IP address of all node devices is deleted in the first computer room A recorded in standby configuration file, and node device sum is changed
For the quantity of the computer room B interior joint equipment so that the second computer room interior joint equipment is no longer recognized in first computer room
Node device.
In an optional embodiment:
There is the node device of identical quantity in the two-shipper room in each computer room.
In an optional embodiment:
Described device also includes:
Recover processing unit, after all node devices recover normal in first computer room, one by one by described first
Computer room interior joint device data is synchronized with the second computer room interior joint device data.
In an optional embodiment:
The recovery processing unit, is specifically included:
Subelement is chosen, it is node device to be synchronized that a node device is chosen from recovered normal node device;
Subelement is added, the node device to be synchronized will be added in the configuration file of the second computer room interior joint equipment
IP address, and by node device sum Jia 1;
Synchronous subelement, by the data syn-chronization of enabled node equipment to the node device to be synchronized;
Subelement is controlled, in the node device to be synchronized and enabled node equipment in the case of data identical, is repeated
The selection subelement is performed, until all node devices are identical with data in enabled node equipment in first computer room.
In an optional embodiment:
Communication between the two-shipper room is based on distributed consensus agreement.
It is corresponding with ensureing the embodiment of the method for data consistency and availability described in earlier figures 6, present invention also provides
A kind of embodiment for the device for ensureing data consistency and availability, applied to two-shipper room.Described device embodiment can pass through
Software is realized, can also be realized by way of hardware or software and hardware combining.Exemplified by implemented in software, anticipated as a logic
Device in justice, is to be read corresponding computer program instructions in nonvolatile memory by the processor of equipment where it
Into internal memory, operation is formed.It is that the application ensures data consistency and availability as shown in figure 11 for hardware view
A kind of hardware structure diagram of equipment where device, except the processor shown in Figure 11, network interface, internal memory and non-volatile is deposited
Outside reservoir, the equipment in embodiment where device is gone back generally according to the actual functional capability of the guarantee data consistency and availability
Other hardware can be included, this is repeated no more.
Referring to Figure 12, the guarantee data consistency and the module map of the device of availability provided for the embodiment of the application one,
Described device includes:Unit 610 is changed, unit 620 is initiated, judges into unit 630 and determining unit 640.
Unit 610 is changed, between two-shipper room in the case of interrupted communication link, matching somebody with somebody for main equipment room interior joint equipment is changed
Put file interior joint facility information and node device sum so that main equipment room interior joint equipment is no longer recognized in standby computer room and saved
Point device;
Unit 620 is initiated, is being received in the case that affairs submit request, according to the amended configuration file, to
Main equipment room interior joint equipment is initiated to operate for the submission of the affairs;
Judging unit 630, judges that successfully submitting the quantity of the node device of the affairs whether to exceed in the main equipment room repaiies
Change the half of deutomerite point device sum;
Determining unit 640, successfully submits the quantity of the node device of the affairs to exceed modification deutomerite in the main equipment room
In the case of the half of point device sum, determine that the affairs are submitted successfully, and submission is returned to successfully to the affairs submission side
Information.
In an optional embodiment:
The node device information includes the IP address of node device.
In an optional embodiment:
The modification unit 610, is specifically included:
Between two-shipper room in the case of interrupted communication link, by what is recorded in the configuration file of main equipment room interior joint equipment
The IP address of all node devices is deleted in standby computer room, and node device sum is revised as into the main equipment room interior joint equipment
Quantity so that main equipment room interior joint equipment no longer recognizes standby computer room interior joint equipment.
In an optional embodiment:
There is the node device of identical quantity in the two-shipper room in each computer room.
In an optional embodiment:
Described device also includes:
Recover processing unit, after communication link recovers normal between two-shipper room, one by one by the standby computer room interior joint
Device data is synchronized with main equipment room interior joint device data.
In an optional embodiment:
The recovery processing unit, is specifically included:
Subelement is chosen, it is node device to be synchronized that a node device is chosen from the standby computer room;
Subelement is added, the node device to be synchronized will be added in the configuration file of the main equipment room interior joint equipment
IP address, and node device sum Jia 1;
Synchronous subelement, by the data syn-chronization of enabled node equipment to the node device to be synchronized;
Subelement is controlled, in the node device to be synchronized and enabled node equipment in the case of data identical, is repeated
The selection subelement is performed, until all node devices are identical with data in enabled node equipment in the standby computer room.
In an optional embodiment:
Communication between the two-shipper room is based on distributed consensus agreement.
System, device, module or unit that above-described embodiment is illustrated, can specifically be realized by computer chip or entity,
Or realized by the product with certain function.A kind of typically to realize that equipment is computer, the concrete form of computer can
To be personal computer, laptop computer, cell phone, camera phone, smart phone, personal digital assistant, media play
In device, navigation equipment, E-mail receiver/send equipment, game console, tablet PC, wearable device or these equipment
The combination of any several equipment.
The function of unit and the implementation process of effect specifically refer to correspondence step in the above method in said apparatus
Implementation process, will not be repeated here.
For device embodiment, because it corresponds essentially to embodiment of the method, so related part is real referring to method
Apply the part explanation of example.Device embodiment described above is only schematical, wherein described be used as separating component
The unit of explanation can be or may not be physically separate, and the part shown as unit can be or can also
It is not physical location, you can with positioned at a place, or can also be distributed on multiple NEs.Can be according to reality
Selection some or all of module therein is needed to realize the purpose of application scheme.Those of ordinary skill in the art are not paying
In the case of going out creative work, you can to understand and implement.
Those skilled in the art will readily occur to its of the application after considering specification and putting into practice invention disclosed herein
Its embodiment.The application is intended to any modification, purposes or the adaptations of the application, these modifications, purposes or
Person's adaptations follow the general principle of the application and including the undocumented common knowledge in the art of the application
Or conventional techniques.Description and embodiments are considered only as exemplary, and the true scope of the application and spirit are by following
Claim is pointed out.
It should be appreciated that the precision architecture that the application is not limited to be described above and is shown in the drawings, and
And various modifications and changes can be being carried out without departing from the scope.Scope of the present application is only limited by appended claim.