The conforming asynchronous method that collects of a kind of maintenance data base duplicate
Technical field
The present invention relates to a kind ofly based on collecting thought, the asynchronous method of data consistency between maintenance data base otherness duplicate belongs to electric power system data library management technical field.
Background technology
In the large-scale supervisory system of Fen Saning, model data is distributed in disparate databases more geographically.Common Distribution Strategy has: centralized: data centralization is deposited; Partition type: data disperse to deposit, but can not repeat between data; Redundance type: each node is all deposited complete data duplicate; Hybrid: above-mentioned three kinds mixing, this is the most complicated, flexible way, i.e. the database otherness duplicate that the present invention is suitable for.
Can be divided into two classes for this class otherness duplicate consistency maintaining method: offline synchronization and online synchronous.
Simple offline synchronization method normally exports to dump file with all objects of source database, dump file is imported the consistance of target database with maintenance and source database again.This method for synchronous is extended to indifference opposite sex duplicate with the otherness duplicate according to its extension, and is simple and reliable, but is not suitable for the application of the concurrent modification of a plurality of databases.
Improved offline synchronization method is divided into sliver on demand with all tuples in the source database, to need the tuple place sliver of maintaining coherency to export to dump file in the source database, again dump file is imported to the original corresponding sliver of covering in the target database.This method has remedied the defective that simple offline synchronization is not supported the concurrent modification of multiple database, but conforming maintenance need increase maintenance difficulties by means of copy, transmission and the merging of a plurality of files of operating system aspect between the storehouse.If can not effectively manage to file, very easily cause the version error of file, increase the inconsistent risk of data.
Online is application software synchronously after local data base is carried out the write operation success, directly revises other databases by network mode again; Or send the message packet that comprises synchronizing information to other database servers.The online problem that has well solved the existence of offline synchronization method synchronously, data consistency is safeguarded and is realized by application software system, can satisfy the demand of using data so flexibly.It is comparatively harsh that but online method for synchronous requires network environment, in case the concurrent modification of multiple database has taken place when network congestion, be easy to cause data inconsistent, even network recovery afterwards, also possibly can't return to consistent state, thereby cause nonvolatil error in data.Then carrying out data modification in the inconsistent database, involve key word in the table, index, and trigger all multi-constraint conditions such as relation between table, also may cause the inconsistent expanded range of data.This catastrophic consequence is that system developer and engineering construction person least wish to see.
Summary of the invention
Technical matters to be solved by this invention is that the consistance of realization service data tuple between the otherness duplicate handled the problem of the concurrent modification of multiple database well, and alleviated the degree of dependence of maintenance work to network quality.
For solving the problems of the technologies described above, the invention provides the conforming asynchronous method that collects of a kind of maintenance data base duplicate, it is characterized in that, may further comprise the steps:
1) database otherness duplicate is divided into complete duplicate and local copy two classes, according to the requirement of using data is divided into sliver and leaves in the two class data duplicates;
2) relatively find out variance data in complete duplicate and the local copy by data-base content, before revising local data, carry out and upgrade operation, from complete duplicate to the local copy synchrodata;
3) finish back execution submit operation revising local data, from local copy to complete duplicate synchrodata.
Described complete duplicate comprises the overall situation, and all are centralized, the partition type data of redundance type data and this node; Local copy comprises the partition type data of redundance type data and this node;
Described submit operation is meant to be carried out the data modification of local local copy fully on the duplicate;
Described renewal behaviour is meant the data modification of complete duplicate is carried out on local local copy.
The conforming asynchronous method that collects of aforesaid maintenance data base duplicate is characterized in that: in described step 3), local copy is only revised at local node, after modification is finished local copy is committed to complete duplicate.
The conforming asynchronous method that collects of aforesaid maintenance data base duplicate is characterized in that: in described step 2) in, duplicate is only revised at local node fully, need not submit to after modification is finished.
The conforming asynchronous method that collects of aforesaid maintenance data base duplicate, it is characterized in that: submitting to complete duplicate and when complete duplicate upgrades, carry out data check, if find to exist conflicting data to stop and the current submit operation of rollback or renewal operation, pop-up window notification operator simultaneously.
The conforming asynchronous method that collects of aforesaid maintenance data base duplicate is characterized in that: in described step 2) and step 3) in, optimize the triggering logical relation in the database, make the triggering logical equivalence of insert, update, delete unified.
The conforming asynchronous method that collects of aforesaid maintenance data base duplicate, it is characterized in that: in described step 2) and step 3) in, increasing the attribute that is used for the data of description version change in the relation that produces by using, comprising: tuple creation-time, tuple are created node, tuple modification time, tuple modification node, tuple deleted marker, tuple deletion time and tuple deletion node.
The conforming asynchronous method that collects of aforesaid maintenance data base duplicate, it is characterized in that: non-0 this tuple of expression of tuple deleted marker attribute is deleted, the tuple deleted marker is as the associating major key of relation, if the value of intrafascicular approximately other row of major key is identical, then delete flag adds up since 1.
The conforming asynchronous method that collects of aforesaid maintenance data base duplicate is characterized in that: the data difference opposite sex of relatively more complete copy and local copy when upgrading operation and submit operation, and in conjunction with the processing that conflicts of tuple running time.
The conforming asynchronous method that collects of aforesaid maintenance data base duplicate, it is characterized in that: in described step 3), local copy was updated to earlier before revising local data and the complete the same versions of data of duplicate, and local copy is submitted to complete duplicate after finishing and revising in time.
The present invention proposes the notion of data duplicate grade:, the data duplicate is divided into two kinds of complete duplicate and local copy according to the coverage of data duplicate to total data.Fully comprised the overall situation all are centralized, the partition type data of redundance type data and this node for duplicate; Local copy comprises the partition type data of redundance type data and this node.
Local copy is only revised at local node, after modification is finished local copy is committed to complete duplicate, and other nodes can upgrade the data of having submitted to from complete duplicate.Merge from the redundance type data of local copy submission and the redundance type data the complete duplicate; The partition type data are not submitted to.
Duplicate is only revised at local node fully, after finishing, modification need not submit to, redundance type data wherein can be updated directly into local copy when needed, local copy should be before once revising beginning from complete duplicate new data more, and after finishing modification, in time be committed to complete duplicate.
Submitting to complete duplicate and when complete duplicate upgrades, doing data check, in case find to exist conflicting data just to stop and the current submission of rollback or upgrade operation, pop-up window notification operator simultaneously.
The beneficial effect that the present invention reached:
Than the offline synchronization method, the asynchronous method of collecting that the present invention proposes can be supported the concurrent modification of multiple database, has overcome its dependence to dump file simultaneously.Than the online method for synchronous of realizing by application software, the asynchronous method of collecting that the present invention proposes greatly reduces the dependence to network stabilization, all the time all stablize from requiring network, be reduced to and only require and before revising beginning, upgrade and modification is stablized when finishing the back submission, and can in time detect the inconsistent situation of the data that existed and notify at once to the operator, prevent that effectively the inconsistent scope of data from continuing to enlarge.
Description of drawings
Fig. 1 is the conforming asynchronous process flow diagram that collects method of maintenance data base duplicate of the present invention.
Embodiment
The asynchronous realization that collects method that the present invention proposes mainly comprises 6 steps:
Step 1: the data in the database are cut apart, according to demands of applications, model data is carried out relative degree/tuple level by following 4 kinds, perhaps horizontal/vertical/compound cutting apart:
1. only be stored in the data in the complete duplicate, this part data is referred to as centralized data;
2. only be stored in a certain local copy, this part data is only preserved portion in the overall situation, and this part data is referred to as the partition type data;
3. be stored in complete duplicate and each part local copy, and all require the data that are consistent in all above-mentioned duplicates, this part data is referred to as the redundance type data;
4. be stored in the data in local local copy and the complete duplicate.
First kind of data only has requirements for access at complete duplicate place node, second kind of data only has requirements for access at this local copy place node, so these two kinds of data do not need to carry out consistency maintenance, the third data all have requirements for access at complete duplicate and all local copy place nodes, it promptly may be certain common data commonly used, this is the part the highest to coherence request, the 4th kind of data are common in during the have hub-and-spoke configuration engineering of (being center-minute site type structure) uses, data are in local local copy and in the duplicate requirements for access is arranged fully, do not need visit at other local copy place nodes, but other local nodes are duplicated in this part data commentaries on classics also can not produce any influence the data consistance, so can conclude in the redundance type data, adopt identical disposal route.
Step 2: definition submit operation and renewal operation:
Submit operation: the data modification of local local copy is being carried out on the duplicate fully;
Upgrade operation: the data modification of complete duplicate is carried out on local local copy.
Step 3: the content difference of more local local copy and the complete duplicate of far-end:
Because submission and renewal operation are all carried out on the node of local copy place, so local copy is local, duplicate is a far-end fully.Successively the identical relation in the complete duplicate of local local copy and far-end is compared, 4 kinds of results may occur: " coupling ", " disappearance ", " exceeding ", " difference ", as table 1:
The table as a result that table 1 data-base content relatively may occur
? |
The local copy Major key |
Complete duplicate Major key |
The record attribute row |
Coupling |
Exist |
Exist |
Consistent |
Disappearance |
Exist |
There is not (or having deleted) |
? |
Exceed |
There is not (or having deleted) |
Exist |
? |
Difference |
Exist |
Exist |
Inconsistent |
Step 4: the triggering logic between optimum relations
In the database of real application systems, can there be the logical relation of some between relation and the relation, this relation generally realizes by the triggering logic of database.This step is to optimize these to trigger logical relation, and the triggering unified logic of insert, update, delete is got up.For example when update concerns the record of A, can trigger and in concern B, insert new record if a certain Column Properties is put 1, in concerning A, just must detect whether these row are 1 during one of insert so, 1 also in concerning B, insert respective record if be; In like manner, the deletion action for update causes also will take in when carrying out insert and delete, makes being kept perfectly property of logic and the consistance of Insert, update, delete.
Step 5: in relation, increase the control information attribute:
In order to have described the state of tuple in the relation, need additionally add some attributes in the relation that produce by using, these attributes comprise: the tuple creation-time, tuple is created node, the tuple modification time, and tuple is revised node, the tuple deleted marker, tuple deletion time, tuple deletion node.Wherein, it is to carry out in the node at that duplicate place that tuple establishment/modification/deletion node is used for recording operation.Non-0 this tuple of expression of tuple deleted marker attribute is deleted, and the tuple deleted marker is as the associating major key of relation, if the value of intrafascicular approximately other row of major key is identical, then delete flag adds up since 1.For example: alternately carry out repeatedly and insert and sweep equipment number is 100 tuple 3 times, then the delete flag attribute of 3 tuples is respectively 1,2,3.Owing to when carrying out deletion action, being not really tuple to be deleted, be changed to non-0 value but will delete first group mark, so can produce unnecessary tuple in the relation, these tuples can be unified deletion behind once overall consistency maintenance EO.
Step 6: the conflict when submission and renewal is handled:
Carrying out submit operation and upgrading in the process of operation, can skip for the tuple of having mated; For lack, exceed, the situation of difference needs to be treated differently as follows.
During renewal: for " disappearance ", the deletion time of more complete duplicate and the access time in the local copy (creation-time or recently modification time) are if the deletion time gap current time is nearer then delete tuple in the local copy (is non-0 value with the deleted marker position).For " exceeding ", access time in the more complete duplicate and the deletion time in the local copy are if the access time is nearer then increase respective tuple in local copy apart from the current time.For " difference ", in the more complete duplicate and the access time in the local copy, if the access time fully in the duplicate is nearer then with the tuple in the replacement of the tuple in the complete duplicate local copy apart from the current time.If above-mentioned condition does not satisfy then keeps present situation, do not change the data in the local copy.
During submit operation: for " disappearance ", deletion time in the more complete duplicate and the access time in the local copy (creation-time or recently modification time) are if the access time is nearer then adding respective tuple in the duplicate fully apart from the current time.For " exceeding ", access time in the more complete duplicate and the deletion time in the local copy are if the deletion time gap current time is nearer then delete tuple in the complete duplicate.For " difference ", in the more complete duplicate and the access time in the local copy, if the access time in the local copy is nearer then replace tuple in the complete duplicate with the tuple in the local copy apart from the current time.Submit failure to if above-mentioned condition does not satisfy, the versions of data in the pop-up window prompting local copy is too outmoded, need be updated to latest edition and carry out data modification again.
The asynchronous method that collects that the present invention proposes, in the concrete process of implementing, all local copy should be updated to earlier before revising local data and the complete the same versions of data of duplicate, same, after local copy is finished modification, also should submit to complete duplicate in time, can reduce like this and submit unsuccessful occurrence probability to.
Recommended flowsheet when local copy is carried out data modification each time is: carry out and upgrade the data à that versions of data à revises local local copy and submit the data of revising to complete duplicate to; Carrying out data modification at complete duplicate does not need to upgrade and submit to.
In addition to the implementation, all employings are equal to the technical scheme that form obtained of replacement or equivalent transformation, all drop within protection scope of the present invention.