A kind of memory database fast data recovery method
Technical field
The present invention relates to a kind of memory database fast data recovery method, be used for solving after memory database takes place unusually, internal storage data loses, can pass through this method, restore data from disk file fast guarantees that data do not lose.
Background technology
Along with telecommunications industry, financial circles constantly develop, professional expansion is more and more wider, and various new business emerge in an endless stream, and data volume is also increasing, and is also increasingly high to the response speed requirement of data visit.A large amount of subscriber data data, customer consumption data all need leave in the memory database, but because the perishability of internal memory abends in case the memory database process perhaps belongs to main frame, the data in the internal memory just will all be lost.After memory database restarts, how to guarantee that data can return to unusual state before, become the gordian technique of memory database safety.
At present, general memory database adopts the mode of timed backup internal storage data, such as per hour backing up once; Like this, unusual when the internal storage data generation, can recover from the Backup Data of the last time; But; Backup to system from the last time unusual this section period takes place, the retouching operation that memory database takes place all can be lost, and only depends on the mechanism of memory database self to recover; Can only come restore data through the reform business of that a period of time of concrete business procedure, not only time-consuming but also cause mistake easily.
In addition, the SQL statement of the each operation of memory database meeting real time record that has if system takes place unusually like this, can backup to the SQL statement of unusual this section period of system's generation from the last time through reforming and come restore data.Because SQL statement itself need be resolved, and searches the record that needs operation again in internal memory, in the huge telecommunication service system of data volume, be difficult to recover at short notice total data.
Summary of the invention
Technical matters to be solved by this invention provides a kind of new memory database fast data recovery method; After memory database system abends; Can be in the relatively short time; Memory database is restarted, and make each memory table data can return to the state before unusual, guarantee that data do not lose fully.
The technical scheme that the present invention solves the problems of the technologies described above is following: memory database fast data recovery method comprises the steps:
Step 1: memory database regularly all writes the full dose file with internal storage data when normal operation;
Step 2: external application carries out additions and deletions to memory database at every turn and changes when operation, and the flowing water daily record with operation immediately writes delta file;
Step 3:, when memory database restarts, at first load the last full dose file in internal memory in case abending appears in memory database;
Step 4: and then with all the increment log records after the full dose document time point, be appended to one by one in order in the internal memory, finally make data return to unusual preceding state.
The invention has the beneficial effects as follows: regularly (such as every at a distance from 1 day; Perhaps per hour) internal storage data is all write specified file (full dose file); Can let memory database begin to recover from the last BACKUP TIME point, avoid when recovering need to before all delta files reform.Change when operation memory database being carried out additions and deletions at every turn, all immediately the flowing water daily record of operation is write delta file, can guarantee like this being modified in of internal memory all to be left record on the disk at every turn, can effectively prevent losing suddenly of internal storage data.
Further, in delta file, the modification of each bar record all contains the internal memory coordinate of corresponding record, saves the time loss of resolving SQL like this, can directly navigate to corresponding internal memory record fast according to coordinate, realizes fast quick-recovery.
Further, when reforming delta file, strictness is appended in the internal memory in order one by one, can guarantee finally to make data to return to unusual preceding state.
Description of drawings
Fig. 1 is internal storage data storage mode of the present invention and delta file form synoptic diagram;
Fig. 2 is a concrete processing flow chart of the present invention.
Embodiment
Below in conjunction with accompanying drawing principle of the present invention and characteristic are described, institute gives an actual example and only is used to explain the present invention, is not to be used to limit scope of the present invention.
Memory database fast data recovery method of the present invention comprises the steps:
Step 1: memory database regularly all writes the full dose file with internal storage data when normal operation;
Step 2: external application carries out additions and deletions to memory database at every turn and changes when operation, and the flowing water daily record with operation immediately writes delta file;
Step 3:, when memory database restarts, at first load the last full dose file in internal memory in case abending appears in memory database;
Step 4: and then with all the increment log records after the full dose document time point, be appended to one by one in order in the internal memory, finally make data return to unusual preceding state.
At first, the data organization form in the memory database is as shown in Figure 1, and the internal storage data of each table is a unit with 100000, and every is write down a corresponding unique memory block sequence number and the record number in the specified memory piece.Delta file whenever generated a new file at a distance from 10 minutes, and file designation is ALL.yyyymmddhhmi00, for example ALL.20101021080000, ALL.20101021081000 etc.; Every record format of delta file is as shown in Figure 1, has write down the internal memory coordinate and the action type of every amendment record.
Fig. 2 has provided memory database after abending; Operational flowchart when restarting at first adopts multithreading that the full dose file load of each memory table is arrived internal memory, and the time point from last backup begins then; Read the internal memory coordinate in the delta file one by one; Navigate to after the designated recorder, go to revise corresponding internal memory record according to the value of operation flag and each field again, make internal storage data return to unusual preceding state.
Below for adopting the profile information of the inventive method, the presents configuration be the process operation time essential information used, adopt the ini file form.
The above is merely preferred embodiment of the present invention, and is in order to restriction the present invention, not all within spirit of the present invention and principle, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.