Specific embodiment
In order to make those skilled in the art more fully understand the technical solution in this specification, below in conjunction with this explanation
Attached drawing in book embodiment is clearly and completely described the technical solution in this specification embodiment, it is clear that described
Embodiment be only this specification a part of the embodiment, instead of all the embodiments.The embodiment of base in this manual, this
This all should belong in field those of ordinary skill every other embodiment obtained without making creative work
The range of specification protection.
This specification embodiment provides a kind of verification of data method and device.
The some concepts being related in this specification embodiment are explained first below.
Record: database is made of tables of data, and the column of tables of data are known as " field " or " field ", and the row of tables of data is known as
" record " generally comprises a plurality of record in database.The data for including in every record belong to state type data.
State type data: refer to that data only have a and can dynamically update, such as the balance information of account, transaction, which occurs, then to be needed
It updates.
Verification: a kind of comparing means refer to and are compared between two parts of data, it is ensured that data consistency.
Off-line data: referring to that data are synchronized to off-line files or offline warehouse by certain technology, this data be called from
Line number evidence.
Synchronization delay: data, which synchronize, can not accomplish 100% Perfect Time, for state type data, due to data one
Directly changing, therefore there may be inconsistent situations for more parts of data of synchronizing moment.
Next a kind of verification of data method provided this specification embodiment is introduced.
Fig. 1 is the flow chart of the verification of data method of one embodiment of this specification, as shown in Figure 1, this method can be with
The following steps are included: step 102, step 104, step 106 and step 108, wherein
In a step 102, according to prefixed time interval, the record of primary database and the record of standby database is synchronous respectively
To offline memory device.
In this specification embodiment, primary database and standby database are master-slave relationship.
In this specification embodiment, online service equipment where primary database is two differences with offline memory device
Equipment;Online service equipment where standby database is two different equipment from offline memory device.
In this specification embodiment, prefixed time interval can be 1 hour, 1 day, 12 hours, 30 minutes, 5 minutes or 1 point
Clock.To take into account synchronizing frequency and checking the balance of frequency, it is preferable that prefixed time interval is 1 hour.
It, can be according to prefixed time interval, by the whole records and standby database of primary database in this specification embodiment
Whole records be synchronized to offline memory device respectively.
In one example, prefixed time interval is 1 hour, every 1 hour, by whole recording synchronisms in primary database
To corresponding offline memory device, by whole recording synchronisms in standby database to corresponding offline memory device.
It, can be according to prefixed time interval, by main number in order to reduce the synchronous workload of data in this specification embodiment
The note that the record and standby database having differences according to library relative to previous interval have differences relative to previous interval
Record is synchronized to offline memory device respectively.
In one example, prefixed time interval be 1 hour, every 1 hour, by primary database from upper one hour to
Changed recording synchronism is to corresponding offline memory device between hour, will be in standby database from upper one hour to this hour
Between changed recording synchronism to corresponding offline memory device.
In this specification embodiment, offline memory device be used for the record of primary database and standby database synchronization (i.e. from
Line number evidence) it is stored.For storing the offline memory device of the synchronous recording of primary database, and for storing standby database
The offline memory device of synchronous recording can be same storage equipment, or two different storage equipment.
At step 104, respectively to the primary database in time interval same in offline memory device and for database
Record carries out comparison in difference.
In this specification embodiment, records for each of every hyposynchronous primary database and standby database, carry out
Comparison in difference.It is recorded for every, each time comparison in difference, the comparison in difference result that can all generate the record is (i.e. consistent
Or inconsistent).
In this specification embodiment, according to prefixed time interval, whole by primary database are recorded and for database
All record the master data that will be spaced at the same time in offline memory device in the case where being synchronized to offline memory device respectively
Whole records of library and standby database carry out comparison in difference.
In one example, prefixed time interval is 1 hour, there is 3 records in primary database and standby database, every
Include the transactions balances information of an account in record, on 2 24th, 2,018 16 points, 3 in primary database records are same
Offline memory device is walked, by 3 recording synchronisms in standby database to offline memory device, correspondingly, offline memory device
3 records of middle primary database are as shown in table 1:
Record number |
Account |
Remaining sum |
Time |
Remarks |
Account state |
1 |
20880001 |
100 |
2018-02-24 15:00:01 |
Deposit |
OK |
2 |
20880002 |
111 |
2018-02-24 15:00:01 |
Deposit |
OK |
3 |
20880003 |
112 |
2018-02-24 15:00:01 |
Deposit |
OK |
Table 1
3 records of standby database are as shown in table 2 in offline memory device:
Record number |
Account |
Remaining sum |
Time |
Remarks |
Account state |
1 |
20880001 |
100 |
2018-02-24 15:00:01 |
Deposit |
OK |
2 |
20880002 |
110 |
2018-02-24 15:00:02 |
Deposit |
OK |
3 |
20880003 |
111 |
2018-02-24 15:00:02 |
Deposit |
OK |
Table 2
While the reason of generating the above difference is primary database and standby database in phase, transaction is also occurring, account
Number Transaction Information modified always, can not accomplish real-time update.
3 records of 3 records of primary database in offline memory device and standby database are subjected to comparison in difference, are obtained
Comparison result such as table 3:
Table 3
For this record of account " 20880001 ", comparison result is " consistent ", that is, difference is not present;For account
" 20880002 " this record, comparison result is " inconsistent ", that is, is had differences;For account " 20880003 ", this is recorded,
Comparison result is " inconsistent ", that is, is had differences.Similarly, by hour next in offline memory device (i.e. on 2 24th, 2018
16. -17 points) 3 records in interior primary database are compared with for 3 records in database.
In this specification embodiment, according to prefixed time interval, primary database is existed relative to previous interval
The record that the record of difference and standby database have differences relative to previous interval is synchronized to offline memory device respectively
In the case of, by the record of primary database in offline memory device and standby database being had differences relative to previous interval into
Row comparison in difference.
In step 106, it is based on comparison in difference situation, determines the differentiation count of record, wherein the differentiation count is used for table
Show that the number of comparing difference continuously occurs in corresponding record.
In this specification embodiment, following differentiation count mode can be used:
Exist if the same of primary database and standby database in offline memory device in same time interval records
Difference then carries out the differentiation count of the record to add 1;
If the same record of primary database and standby database in offline memory device in same time interval is not present
Difference, then the differentiation count of the record remains unchanged.
In one example, using above-mentioned differentiation count mode, differentiation count is carried out to the comparison result of table 3, if 3
The differentiation count initial value of account is 0, then comparison result is " consistent ", poor for this record of account " 20880001 "
Different counting remains unchanged, and differentiation count is still 0;For this record of account " 20880002 ", comparison result is " inconsistent ", poor
Different counting carries out adding 1, and differentiation count becomes 1;For this record of account " 20880003 ", comparison result is " inconsistent ", poor
Different counting carries out adding 1, and differentiation count becomes 1;This relatively obtains differentiation count result as shown in table 4.
Table 4
In this specification embodiment, the comparison in difference of every record can be counted as a result, according to the comparison in difference knot of the record
Fruit determines the differentiation count of the record.
For example, being recorded for one, if the first time comparison in difference result of the record is consistent, second of comparison in difference
As a result to be inconsistent, then its differentiation count is 1;If the first time comparison in difference result of the record be it is inconsistent, second
Comparison in difference result is consistent, then its differentiation count is 1;If the first time comparison in difference result of the record be it is inconsistent,
Second of comparison in difference result is inconsistent, then its differentiation count is 2.
In step 108, the record that differentiation count is greater than preset threshold is determined as synchronous abnormality record, wherein this is pre-
If threshold value is positive integer.
In this specification embodiment, preset threshold can be 1,2,3 or 4 etc..
In one example, preset threshold 1, if this record of account " 20880002 ", twice in succession all than less
Unanimously, i.e., its differentiation count is 2, then this record is determined as synchronous abnormality record by account " 20880002 ".
In this specification embodiment, the problem of finding synchronous abnormality in time for the ease of operation maintenance personnel, in above-mentioned steps 108
Following steps can also be increased later:
Export message notifying, wherein the message notifying is for prompting synchronous abnormality to record.
In this specification embodiment, the sides such as desktop prompting message, transmission short message, mail, sending alarm sound can be passed through
Formula prompts the record of operation maintenance personnel synchronous abnormality, so that operation maintenance personnel takes corresponding processing strategie in time.
Understand for the ease of the technical solution on the whole to this specification embodiment, from the angle of database, knot
It closes Fig. 2 above step 102 to 108 is described, as shown in Fig. 2, at interval of prefixed time interval, by the note in primary database
Record is synchronized to corresponding offline storehouse,, will when being checked by the recording synchronism in standby database to corresponding offline storehouse
The record of primary database and the record of database standby in offline storehouse carry out comparison in difference in offline storehouse, obtain final checked result.
From the angle of executing subject, above step 102 to 108 is described in conjunction with Fig. 3, as shown in figure 3, the applied field
It include: online service equipment 310, online service equipment 320, offline memory device 330, offline memory device 340 and core in scape
To equipment 350, wherein be stored with primary database in online service equipment 310, standby data are stored in online service equipment 320
Library, offline memory device 330 are used to store the off-line data (i.e. the synchronous record of primary database) of primary database, and offline storage is set
Standby 340 for storing the off-line data (i.e. for the record of database synchronization) of standby database, and checking apparatus 350 is used for from depositing offline
The off-line data of the off-line data that primary database is read in equipment 330 and offline memory device 340 and standby database is stored up, and to it
Comparison in difference is carried out, checked result is obtained.
As seen from the above-described embodiment, in the embodiment, by being spaced at regular intervals, periodically by the record of primary database
Recording synchronism with standby database is to offline memory device, to realize that verification of data in the decoupling of line service, avoids data core
It is impacted to in line service;Diversity ratio is carried out by the record to primary database in offline memory device and standby database
Compared with, comparison in difference result is accumulated, when there is comparing difference in a record continuous several times, really its there are synchronous abnormalities, keep away
Exempt from data synchronization delay problem during verification of data, reduces rate of false alarm.
Fig. 4 is the structural schematic diagram of the verification of data device of one embodiment of this specification, as shown in figure 4, in one kind
In Software Implementation, verification of data device 400 may include: synchronization module 401, comparison module 402, count determining module
403 and exception record determining module 404, wherein
Synchronization module 401, for according to prefixed time interval, the record of the record of primary database and standby database to be distinguished
It is synchronized to offline memory device;
Comparison module 402, for respectively to primary database in same time interval in the offline memory device and standby
The record of database carries out comparison in difference;
Determining module 403 is counted, for being based on comparison in difference situation, determines the differentiation count of record, the differentiation count
For indicating that the number of comparing difference continuously occurs in corresponding record;
Exception record determining module 404, the record for differentiation count to be greater than preset threshold are determined as synchronous abnormality note
Record, the preset threshold are positive integer.
As seen from the above-described embodiment, in the embodiment, by being spaced at regular intervals, periodically by the record of primary database
Recording synchronism with standby database is to offline memory device, to realize that verification of data in the decoupling of line service, avoids data core
It is impacted to in line service;Diversity ratio is carried out by the record to primary database in offline memory device and standby database
Compared with, comparison in difference result is accumulated, when there is comparing difference in a record continuous several times, really its there are synchronous abnormalities, keep away
Exempt from data synchronization delay problem during verification of data, reduces rate of false alarm.
Optionally, as one embodiment, the synchronization module 401 may include:
Recording synchronism submodule, for according to prefixed time interval, primary database to be existed relative to previous interval
The record that the record of difference and standby database have differences relative to previous interval is synchronized to offline memory device respectively.
Optionally, as one embodiment, the counting determining module 403 may include:
Counting submodule, if for primary database and standby data in same time interval in the offline memory device
The same record in library has differences, then carries out adding 1 to the differentiation count of the record;
If the same record of primary database and standby database in the offline memory device in same time interval is not
It has differences, then the differentiation count of the record remains unchanged.
Optionally, as one embodiment, verification of data device 400 can also include:
Output module, for exporting message notifying, the message notifying is for prompting the synchronous abnormality to record.
Optionally, as one embodiment, the prefixed time interval is 1 hour, 1 day, 12 hours, 30 minutes, 5 minutes
Or 1 minute.
Fig. 5 is the structural schematic diagram of the electronic equipment of one embodiment of this specification, as shown in figure 5, in hardware view,
The electronic equipment includes processor, optionally further comprising internal bus, network interface, memory.Wherein, memory may include
Memory, such as high-speed random access memory (Random-Access Memory, RAM), it is also possible to further include non-volatile deposit
Reservoir (non-volatile memory), for example, at least 1 magnetic disk storage etc..Certainly, which is also possible that it
Hardware required for his business.
Processor, network interface and memory can be connected with each other by internal bus, which can be ISA
(Industry Standard Architecture, industry standard architecture) bus, PCI (Peripheral
Component Interconnect, Peripheral Component Interconnect standard) bus or EISA (Extended Industry Standard
Architecture, expanding the industrial standard structure) bus etc..The bus can be divided into address bus, data/address bus, control always
Line etc..Only to be indicated with a four-headed arrow in Fig. 5, it is not intended that an only bus or a type of convenient for indicating
Bus.
Memory, for storing program.Specifically, program may include program code, and said program code includes calculating
Machine operational order.Memory may include memory and nonvolatile memory, and provide instruction and data to processor.
Processor is from the then operation into memory of corresponding computer program is read in nonvolatile memory, in logical layer
Verification of data device is formed on face.Processor executes the program that memory is stored, and is specifically used for executing following operation:
According to prefixed time interval, the record of the record of primary database and standby database is synchronized to offline storage respectively and is set
It is standby;
The record of primary database and standby database in same time interval in the offline memory device is carried out respectively
Comparison in difference;
Based on comparison in difference situation, the differentiation count of record is determined, the differentiation count is for indicating that corresponding record connects
It is continuous the number of comparing difference occur;
The record that differentiation count is greater than preset threshold is determined as synchronous abnormality record, the preset threshold is positive integer.
Optionally, described according to prefixed time interval as one embodiment, by the record of primary database and standby database
Record be synchronized to offline memory device respectively, comprising:
According to prefixed time interval, the record and standby database that primary database is had differences relative to previous interval
The record having differences relative to previous interval is synchronized to offline memory device respectively.
Optionally, described to be based on comparison in difference situation as one embodiment, determine the differentiation count of record, comprising:
If the same of primary database and standby database in the offline memory device in same time interval records
It has differences, then the differentiation count of the record is carried out adding 1;
If the same record of primary database and standby database in the offline memory device in same time interval is not
It has differences, then the differentiation count of the record remains unchanged.
Optionally, as one embodiment, it is determined as synchronous different in the record that differentiation count is greater than preset threshold
Often after the step of record, further includes:
Message notifying is exported, the message notifying is for prompting the synchronous abnormality to record.
Optionally, as one embodiment, the prefixed time interval is 1 hour, 1 day, 12 hours, 30 minutes, 5 minutes
Or 1 minute.
The method that verification of data device disclosed in the above-mentioned embodiment illustrated in fig. 5 such as this specification executes can be applied to handle
In device, or realized by processor.Processor may be a kind of IC chip, the processing capacity with signal.It is realizing
In the process, each step of the above method can pass through the integrated logic circuit of the hardware in processor or the instruction of software form
It completes.Above-mentioned processor can be general processor, including central processing unit (Central Processing Unit,
CPU), network processing unit (Network Processor, NP) etc.;It can also be digital signal processor (Digital Signal
Processor, DSP), it is specific integrated circuit (Application Specific Integrated Circuit, ASIC), existing
Field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device are divided
Vertical door or transistor logic, discrete hardware components.It may be implemented or execute and is in this specification embodiment disclosed
Each method, step and logic diagram.General processor can be microprocessor or the processor be also possible to it is any conventional
Processor etc..The step of method in conjunction with disclosed in this specification embodiment, can be embodied directly in hardware decoding processor execution
Complete, or in decoding processor hardware and software module combine execute completion.Software module can be located at random storage
Device, flash memory, read-only memory, this fields such as programmable read only memory or electrically erasable programmable memory, register at
In ripe storage medium.The storage medium is located at memory, and processor reads the information in memory, completes in conjunction with its hardware
The step of stating method.
The method that the electronic equipment can also carry out Fig. 1, and realize the function of verification of data device embodiment shown in Fig. 1,
Details are not described herein for this specification embodiment.
This specification embodiment additionally provides a kind of computer readable storage medium, the computer-readable recording medium storage
One or more programs, the one or more program include instruction, and the instruction is when by the portable electric including multiple application programs
When sub- equipment executes, the method that the portable electronic device can be made to execute embodiment illustrated in fig. 1, and be specifically used for executing following
Method:
According to prefixed time interval, the record of the record of primary database and standby database is synchronized to offline storage respectively and is set
It is standby;
The record of primary database and standby database in same time interval in the offline memory device is carried out respectively
Comparison in difference;
Based on comparison in difference situation, the differentiation count of record is determined, the differentiation count is for indicating that corresponding record connects
It is continuous the number of comparing difference occur;
The record that differentiation count is greater than preset threshold is determined as synchronous abnormality record, the preset threshold is positive integer.
In short, being not intended to limit the protection of this specification the foregoing is merely the preferred embodiment of this specification
Range.For all spirit in this specification within principle, any modification, equivalent replacement, improvement and so on should be included in this
Within the protection scope of specification.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.It is a kind of typically to realize that equipment is computer.Specifically, computer for example may be used
Think personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
It is any in device, navigation equipment, electronic mail equipment, game console, tablet computer, wearable device or these equipment
The combination of equipment.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including described want
There is also other identical elements in the process, method of element, commodity or equipment.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for system reality
For applying example, since it is substantially similar to the method embodiment, so being described relatively simple, related place is referring to embodiment of the method
Part explanation.