Nothing Special   »   [go: up one dir, main page]

CN100449548C - Method and system for synchronizing data base - Google Patents

Method and system for synchronizing data base Download PDF

Info

Publication number
CN100449548C
CN100449548C CNB2007100738877A CN200710073887A CN100449548C CN 100449548 C CN100449548 C CN 100449548C CN B2007100738877 A CNB2007100738877 A CN B2007100738877A CN 200710073887 A CN200710073887 A CN 200710073887A CN 100449548 C CN100449548 C CN 100449548C
Authority
CN
China
Prior art keywords
server
database
main
sync
backup
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CNB2007100738877A
Other languages
Chinese (zh)
Other versions
CN101038591A (en
Inventor
朱湘毅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CNB2007100738877A priority Critical patent/CN100449548C/en
Publication of CN101038591A publication Critical patent/CN101038591A/en
Application granted granted Critical
Publication of CN100449548C publication Critical patent/CN100449548C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a database synchronization method, in which a synchronous table comprising a synchronous identification numbers and SQL statements is adopted to realize the data synchronization, a database synchronization system is disclosed also, which comprises a primary server having a backup unit, a synchronous table unit and a backup server having a request unit, an acquisition unit and a synchronization unit. The method and system realizes the synchronization of the database and simplifies the modification of the server configuration by use of a synchronous table, thereby the database can be implemented without the restriction of the operation system and the database system which results in an improved efficiency.

Description

Database synchronization method and system
Technical field
The present invention relates to database technology, relate in particular to the method and system of database synchronization.
Background technology
In telecommunication management network, each network element all has an Operation and Maintenance Unit (OMU, Operation ﹠amp; Maintenance Unit), specifically can be the server that OMU Software is installed, be responsible for providing the Operation and Maintenance function of this network element.Be the operate as normal of maintaining network unit, telecom operators are very high to the Operation and Maintenance functional reliability requirement of network element, generally all more than 99.999%.Therefore, in order to guarantee the reliability of OMU Operation and Maintenance function, general two-shipper (Dual System) back mechanism that adopts OMU of telecommunication apparatus supplier.So-called two-shipper by the system that two computing machines are formed, wherein, is main with server (Active Server is hereinafter to be referred as AS) with leading with the OMU corresponding server, and service function externally is provided; With standby OMU corresponding server be standby server (StandbyServer is hereinafter to be referred as SS), backup functionality is provided, service function externally is not provided with server for main.The master can switch under certain condition with server and standby server, and is promptly main with becoming the main usefulness of standby, standby change.Both combinations can externally provide service function continuously.
Adopt dual-host backup mechanism can guarantee the reliability of System Operation, crash for some reason or influence such as human negligence with server main, and can't carry out Operation and Maintenance to OMU the time, standby server can replace main status with server immediately, continues OMU is carried out Operation and Maintenance.Adopt this mechanism, significantly reduce the probability that System Operation pauses,, all provide reliable guarantee no matter to personal user or enterprise customer.In addition, adopt dual-host backup mechanism, user data can pass to two main frames, obtains appropriate backup, has improved the security of information processing.
Realize Operation and Maintenance to network element, server will be handled lot of data, for example configuration data, alarm data, performance statistic etc., these data all are stored in the system of data in server storehouse, meeting installation database system software provides the uniform database access interface on the OMU server.These are stored in data in the Database Systems along with the operation of system, are real time modifyings.Therefore to realize the dual-host backup function, must guarantee main with between data in the server database system and the data in the standby server Database Systems synchronously in real time.In the time of guaranteeing that so just the master breaks down with server, standby server upgrades to main with correct Operation and Maintenance function can be provided behind the server.
In the prior art, realize that the two-shipper database synchronization has following technical scheme:
Scheme one:
Utilize database replication mechanism, duplicate such as SQL.What is called is duplicated, and is the technology that one group of data is copied to a plurality of data sources from a data source.The fundamental element that SQL (Structured Query Language, Structured Query Language (SQL)) duplicates comprises publishes server, Subscriber, Distributor, publication, article.The server at source data place is to publish server, is responsible for delivering data.Publish server the institute's situation that changes copy of the data that will deliver is copied to Distributor, Distributor includes a distribution database, can change from the institute that publishes server reception data, and preserve these changes, again these changes are distributed to Subscriber.
SQL Server Database Systems with Microsoft company are example, and this system provides three kinds of reproduction technologies, are respectively snapshot, transactional replication and merge replication.The general synchronously in real time transactional replication technology that adopts of database between the active/standby server.Adopt transactional replication need carry out following configuration step:
1. dispose a database as distribution database (distribution database can be configured in the master and use server, also can be configured on the standby server), specify which server can use this database;
2. on leading with server, the distribution database that uses with server is led in configuration; Configuration is main with the Subscriber that allows on the server; Configuration is main with tables of data that needs in database that needs on the server to issue and the database to issue and field etc.;
3. on standby server, configuration is to the subscription of publication database;
4. dispose the scheduling and the attribute of each agent process, have snapshot agent process, distribution agent process and daily record to read agent process etc.;
Above-mentioned layoutprocedure is very complicated, make mistakes easily and setup time longer, if a plurality of databases are arranged, each database has many tables of data to carry out synchronously, then layoutprocedure generally needs a few minutes.This layoutprocedure is revised the attribute of database simultaneously, will be restricted the operation of database, be publication database such as certain database of configuration after, just can not delete this database.
After the above-mentioned configuration successful, the master can generate a snapshot (being similar to the data export of tables of data) to the data that need the data in synchronization table in each database automatically with the SQL SERVER on the server, this SNAPSHOT INFO is sent in the distribution database, distribution database is distributed to standby server again, in subscription database, to have finished primary data synchronous for active/standby server like this with the data importing in the snapshot for standby server.After transactional replication configures, finish initial synchronisation earlier, carry out automatically in real time synchronously.When leading with server generation data modification, publication database can be sent to distribution database to the log information of data modification, distribution database is distributed to subscription database with it again, and subscription database is revised data according to log information, guarantees with publication database synchronous.
The defective of this scheme is:
1. must be based on SQL Server Database Systems, corresponding, this system must be installed on the WINDOWS operating system;
2. must be between active/standby server the configuration transaction replication relation, active/standby server is switched and need be reconfigured the transactional replication relation.Because the transactional replication relation is very complicated, and is very complicated to the layoutprocedure of Database Systems.
3. it is long that publisher server and Subscriber are finished the initial database synchronization time.The time that transactional replication generated and used snapshot is directly proportional with the quantity of tables of data, is 500 calculating to need the data in synchronization table in the database, generally needs the time more than 30 minutes just can finish initial synchronisation.And to use snapshot on the Subscriber be that a table connects a table and uses successively, is not to finish in the affairs.Finish initial synchronization and switching of active/standby server can not be taken place as last, otherwise the data on the standby server are chaotic.This time is difficult to receive for telecom operators;
4. this scheme has a lot of restrictions and influence for server.Transactional replication depends on the daily record of database, and daily record is made marks, and the daily record so that sign has been sent to distribution database and has not transmitted guarantees that with this database change is consistent.If the standby server fault, then the master constantly increases with the daily record meeting of data in server storehouse, causes database to move; If the master uses the server restore database, then can cause the daily record confusion, transactional replication can break down.
Scheme two:
SQL Server 2000 enterprise versions with Microsoft company are example, the function that this system provides daily record to transmit, promptly from source database, back up transaction journal incessantly, then they are duplicated and revert to the destination data storehouse, destination data storehouse and source database are kept synchronously.Compare with transactional replication, daily record transmits simple a little.Daily record transmit to guarantee two database synchronization, and transactional replication can make and needs the data in synchronization table to keep not needing the data in synchronization table can not carry out synchronously synchronously.The initial synchronisation aspect, SQL SERVER provides the guide of log shipping job, creates source database on destination server, guarantees the primary data unanimity.
The defective of this scheme is:
1. must be based on Sql Server Database Systems, corresponding, this system must be installed on the WINDOWS operating system;
2. the real-time of daily record transmission is relatively poor, generally is configured in 15 minutes synchronizing cycle in real time, and the server of having relatively high expectations for real-time is improper;
3. daily record transmits reliability not as transactional replication, and the server higher to reliability requirement is improper.
Summary of the invention
In view of this, the subject matter that the embodiment of the invention will solve is, the method and system of database synchronization is provided, and can simplify the modification to server configures, and database synchronization is not subjected to the restriction of operating system and Database Systems, has improved the efficient of data sync.
The method of the database synchronization that one embodiment of the present of invention provided, be used for main initial synchronisation with server database and standby server database, main with being provided with the synchronous meter that comprises sync id number in the server database, this method may further comprise the steps: standby server to main with the request of server transmission initial synchronisation; Main with server according to the initial synchronisation request that receives, in synchronous meter, upgrade sync id number, and the main server database of using of backup, the generation backup file; Standby server obtains sync id number and the backup file after the renewal, recovers the standby server database with backup file.
The method of the database synchronization that an alternative embodiment of the invention provided, be used for main the synchronous in real time of server database and standby server database of using, main with being provided with the synchronous meter that comprises sync id number and SQL statement in the server database, sync id is number according to the database manipulation real-time update, and this method may further comprise the steps: mainly need the SQL statement of data in synchronization storehouse operation in synchronous meter with server replicates; Standby server is directly connected to the master with on the server database, obtains SQL statement from synchronous meter, and visits the standby server database with this SQL statement.
The method of the database synchronization that another embodiment of the present invention provided, be used for main with server database and standby server database synchronously, main with being provided with the synchronous meter that comprises sync id number and SQL statement in the server database, this method comprises:
A, standby server check whether the identification number of its preservation is present in the synchronous meter, if there is no, then execution in step B, C, D, if exist, then execution in step E, F;
B, standby server send the initial synchronisation request to main with server;
C, main with server according to the described initial synchronisation request that receives, in synchronous meter, upgrade sync id number, the main server data library database of using of backup, generation backup file;
D, standby server obtain sync id number and the backup file after the renewal, recover the standby server database with backup file;
E, master need the SQL statement of data in synchronization storehouse operation in synchronous meter with server replicates;
F, standby server obtain this SQL statement from synchronous meter, and visit the standby server database with this SQL statement.
The system of the database synchronization that another embodiment of the present invention provided, comprise and dispose the main main server of using with server database, and the standby server that disposes the standby server database, main with being provided with the synchronous meter that comprises sync id number and SQL statement in the server database.
The master of this system comprises with server: backup units, be used in the initial synchronisation stage, and after receiving the initial synchronisation request that standby server sends, backup is main to generate backup file with server database; The synchronous meter unit was used in the initial synchronisation stage, upgraded sync id number in synchronous meter, also was used at real-time synchronous phase, upgraded the sync id number in the synchronous meter, duplicate need the operation of data in synchronization storehouse SQL statement in synchronous meter;
Standby server comprises: request unit is used for sending the initial synchronisation request to main with server; Acquiring unit was used in the initial synchronisation stage, obtained the backup file that backup units generates, and the sync id of synchronous meter unit after upgrading in synchronous meter number; Lock unit is used for obtaining backup file in the initial synchronisation stage from acquiring unit, and recover the standby server database with this backup file, also be used for from synchronous meter, obtaining SQL statement, and visit the standby server database with this SQL statement at real-time synchronous phase.
The method and system that embodiments of the invention provided, utilize the identification number in the synchronous meter, active/standby server keeps data consistent after need judging whether initial synchronisation and guaranteeing initial synchronisation, adopt standby server to read main mode, directly obtain the master and revise with data in server with the SQL statement in the synchronous meter on the server.Thereby simplify the modification to server configures, database synchronization is not subjected to the restriction of operating system and Database Systems, has improved the efficient of data sync.
Description of drawings
Fig. 1 is in the embodiment of the invention, the synchronous meter structural representation;
Fig. 2 is the method flow diagram of first embodiment of the invention database synchronization;
Fig. 3 is the method flow diagram of second embodiment of the invention database synchronization;
Fig. 4 is the method flow diagram of third embodiment of the invention database synchronization;
Fig. 5 is the system diagram of four embodiment of the invention database synchronization.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer,, technical scheme of the present invention is further described below in conjunction with embodiment and accompanying drawing.
The technical scheme that the embodiment of the invention provides is utilized synchronous meter, and is synchronous at the application layer fulfillment database, simplifies the modification to server configures, and database synchronization can not be subjected to the restriction of operating system and Database Systems, improves the efficient of data sync.
Fig. 1 is in the embodiment of the invention, the synchronous meter structural representation.
As shown in Figure 1, be arranged at the main synchronous meter of using in the server database, comprise two fields: sync id field (identity) and SQL statement field.
The seed attribute that the sync id field generally adopts database to provide increases progressively automatically.This field does not need to safeguard, if the setting of seed attribute is to increase progressively since 1, when inserting article one record, do not need to formulate the value of this field, Database Systems just are changed to 1 automatically, insert second, automatically be changed to 2, if deleted all records of database, next time, the value of this field was that the value before the deletion adds 1 when inserting again.The sync id field is used for representing sync id number.
The SQL statement field is deposited the SQL statement of revising database.SQL almost is the data manipulation language (DML) that all large data servers are all supported, it provides some can carry out the narration of data manipulations such as data query, renewal, deletion fast.With regard to the relation of sign and SQL, sign is a numbering of giving when inserting every SQL record, SQL record of promptly every insertion, and the value of identification field adds 1.
In the embodiment of the invention, by synchronous meter being set on server main, the identification number match ratio of the sync id of synchronous meter number and standby server, whether check needs initial synchronisation.By SQL statement, realize in real time synchronously in real time synchronous process, whether real-time inspection needs initial synchronisation simultaneously.With this, by sign and SQL statement in the synchronous meter, fulfillment database is synchronous.
The identification number of standby server can be kept in the database or be kept in the configuration file.This value initialization is 0, thus during initial start-up, certainly with main be different with identification number minimum in the server sync table, therefore can carry out initial synchronisation.After initial synchronisation was finished, the identification number that standby server is preserved will be present in the synchronous meter.Then enter synchronously in real time, main with every modification one secondary data of server in this process, in synchronous meter, insert the SQL record, increase by one time the synchronous meter record, the corresponding identification number that increases; When synchronous in real time, standby server deletion earlier is main with the record of identification number in the synchronous meter on the server less than the identification number of self preserving, and reads the master then and preserves the record of identification number with identification number in the synchronous meter on the server greater than self.Before record that reads of the every execution of standby server, the identification number of oneself preserving is checked with the identification number of the record that reads, if the identification number of its preservation is continuous with the identification number that reads, illustrate that then standby server keeps synchronous with main with server always, then carry out this record, and upgrade the identification number of preserving, that is, the identification number of up-to-date synchronous mistake is preserved.If discontinuous, illustrate then active and standbyly to have lost data sync that standby server need restart data sync with server.Judge whether identification number that standby server is preserved and the identification number that reads be continuous, judge promptly also whether the identification number that standby server is preserved is present in the synchronous meter.
If standby server is restarted, then restart the sync id number of checking its preservation in the back and whether still exist in the server sync table, if then only need to continue to get final product synchronously in real time main.If standby server has stopped for a long time, cause main synchronous meter being removed with server, then the sync id of standby server preservation number has not existed in synchronous meter, then restarts initial synchronisation.
First embodiment of the present invention relates to the method for database initial synchronisation, be used for main initial synchronisation with server database and standby server database, wherein, main with being provided with the synchronous meter that comprises sync id number in the server database, this method idiographic flow as shown in Figure 2.
Step 201: check by standby server whether the identification number of its preservation is present in the synchronous meter, need to judge whether the beginning initial synchronisation in view of the above;
Such as, under following three kinds of scenes, all need to carry out the judgement of step 201:
(1) as previously mentioned, the seed attribute that identification field adopts database to provide increases progressively automatically, can be provided with since 1.The identification number of standby server can be kept in the database or be kept in the configuration file.This value initialization is 0.So during initial start-up, be different with main identification number with minimum in the server sync table certainly, i.e. the identification number of standby server preservation is not present in the synchronous meter, therefore can carry out initial synchronisation, then carries out subsequent step;
(2) in real-time synchronizing process, standby server is carried out a record, then update the identification number of oneself preserving, before carrying out the identification number of oneself preserving is checked with the identification number of the record that reads, if the identification number of its preservation is continuous with the identification number of the record that reads, then only need to continue to get final product synchronously in real time; If not, illustrate that the master removed the synchronous meter record with server, then restart initial synchronisation, carry out subsequent step;
(3) if standby server restart, then restart the sync id of check preserving the back number main with whether still existing in the synchronous meter, if then only need to continue to get final product synchronously in real time.If standby server has stopped for a long time, cause main synchronous meter being removed with server, then the standby server sync id of preserving number has not existed in synchronous meter, then restarts initial synchronisation, the execution subsequent step.
Step 202: standby server is to the main request message that sends the request initial synchronisation with server;
Step 203: main receive the request message that standby server sends with server after, in synchronous meter, upgrade sync id number, the main server database of use of backup, generation backup file;
In this step, the master before backup database, can empty the data recording in the synchronous meter after receiving the request message of standby server transmission with server.In addition, before backup database, for preventing in the backup procedure have module to revise database data, be to data library locking.Lock and empty data recording in the synchronous meter after the success, mainly insert a null record again after emptying data recording with server, the value of sync id field adds 1 on the basis of the value before the deletion, forms the sync id number after upgrading.Then, the main server backup database of using generates backup file.After finishing backup, remove locking to database, and send carry this new sync id number the backup success message to standby server.
Step 204: standby server obtain backup file and upgrade after sync id number;
After standby server is received the main backup success message that sends with server, can obtain and preserve this sync id number, promptly article one synchronous recording corresponding identification is present in main with in the synchronous meter of server with this identification number that guarantees that standby server is preserved.In addition, the file transmitting function that can provide by FTP or operating system, backup file from main with Server Transport to standby server.Concrete transmission manner both can adopt standby server initiatively to obtain the mode of backup file, also can be main mode with the server active transmission.And adopt standby server initiatively to obtain the mode of backup file, can reduce main complexity with server process.
Step 205: standby server recovers the standby server database with the backup file that receives.
So far, finished the database initial synchronization.
In time from the data library locking to the release, main each module accesses database with server can block.Data total amounts such as the configuration in the general NE database, alarm, performance are between 50M~500M, and the hard disk of OMU server all adopts high performance SCSI hard disk or SAS hard disk, and handling capacity is more than per second 30M, and the SATA hard disk is more than per second 150M.Database is from adding about 0~3 second time that is locked into pinning, and the T.T. that database is lockable is about 3~20 seconds.The data initial synchronization time comprises that also standby server obtains the time of backup file and restore database, generally is the high speed bandwidth of 1000MBits/S between active/standby server, and backup file can be sent to standby server in 10 seconds.The database recovery time, the used time before adding, whole initial synchronisation can be finished within 1 minute, had improved the efficient of initial synchronisation less than the DB Backup time.
In whole initial synchronization,, fail or wait timeout with the server return messages as main if do not complete successfully the situation of certain step, the data library locking failure, DB Backup failure, backup file bust this, or standby database recovery failure etc., all can return step 201.
Because the method for embodiment of the invention database initial synchronisation, utilize the identification number in the synchronous meter, active/standby server keeps data consistent after need judging whether initial synchronisation and guaranteeing initial synchronisation, the concrete method that adopts the DB Backup reduction, simplification is to the modification of server configures, database synchronization is not subjected to the restriction of operating system and Database Systems, has improved the efficient of data initial synchronisation.
From the entire database synchronizing process, main at first synchronously the initial data base of standby server with server; Standby server is finished on the basis of initial synchronisation, and is main synchronously in real time with the data modification in the database on the server.After initial synchronisation was finished, the identification number that standby server is preserved will be present in the synchronous meter.Below in conjunction with accompanying drawing second embodiment of the invention is described.
Second embodiment of the present invention relates to database synchronous method in real time, be used for main the synchronous in real time of server database and standby server database of using, wherein, main with being provided with the synchronous meter that comprises sync id number and SQL statement in the server database, sync id is number according to the database manipulation real-time update, and this method idiographic flow as shown in Figure 3.
Step 301: the master need to have judged whether the operation of real-time data in synchronization storehouse with server, and if desired, then execution in step 302 and 303 if do not need, is then proceeded the judgement of this step;
OMU Software provides the uniform database access interface, and Operation and Maintenance functions such as the configuration that general OMU provides, performance statistics, alarm are realized by different software modules.This database access interface operating database of each calling software module.Database access interface provides optional parameter, and whether indicate this operation needs synchronously.For example, can represent that needs are synchronous with TRUE, FALSE do not need to represent synchronously, and default is TRUE.
Step 302: the master needs the SQL statement of real-time data in synchronization storehouse operation in synchronous meter with server replicates;
This statement is certain module accesses database and statement that the data database data is made amendment.Like this, standby server just can obtain this SQL statement from synchronous meter.
Step 303: standby server obtains this SQL statement from described synchronous meter;
Specifically obtaining the method for SQL statement, can be that standby server obtains main username and password with server database, according to the username and password that obtains, is directly connected to the master with on the database, obtains the SQL statement of synchronous meter.Standby server is by such mode, from leading with reading a batch record the data in server synchronous meter.
Step 304: standby server is visited the standby server database with same SQL.
After obtaining SQL statement, standby server is visited its database by database access interface with same SQL, promptly carries out these records one by one.Because standby server is consistent with main basic data with server, so both data modifications are synchronous, thereby make standby server keep synchronous with the data in server storehouse with main.
In the synchronizing process, main in real time with every modification one secondary data of server, just increase the synchronous meter record one time.When standby server is synchronous in real time, upgrade the identification number of standby server synchronously, the identification number of up-to-date synchronous mistake is preserved, after the execution amendment record was finished, deletion was main with record synchronous in the server sync table.Because when the main synchronously N bar with server of standby server writes down, only can delete main N-1 bar record with front in the synchronous meter, N bar record is retained in the synchronous meter, like this, whether the last item record that standby server can be checked own synchronous mistake at every turn in synchronous meter, need judges whether initial synchronisation.
Standby server can be provided with synchronizing cycle, finish one-period synchronously after, next cycle continues in real time synchronously.Synchronizing cycle, operated by rotary motion was in level second, therefore mainly just can be synchronized to standby server in second in the level with the data modification on the server, accomplished synchronous in real time.
Because the database that the embodiment of the invention provides is synchronous method in real time, adopt standby server to read main mode with the SQL statement in the record of the synchronous meter on the server, directly obtaining the master revises with data in server, simplification is to the modification of server configures, database synchronization is not subjected to the restriction of operating system and Database Systems, has improved the efficient of data sync.
The 3rd embodiment of the present invention relates to the method for database synchronization, be used for main with server database and standby server database synchronously, wherein, main with being provided with the synchronous meter that comprises sync id number and SQL statement in the server database.In the present embodiment, with first initial synchronisation, carry out being synchronously in real time example after finishing, this method idiographic flow as shown in Figure 4.
Step 401: check by standby server whether the identification number of its preservation is present in the synchronous meter, need to judge whether the beginning initial synchronisation in view of the above;
If do not need initial synchronisation, then directly enter step 406; Initial synchronisation if desired, carry out following steps:
Step 402: standby server is to the main request message that sends the request initial synchronisation with server;
Step 403: main with server according to the described request message that receives, in synchronous meter, upgrade sync id number, the main server database of using of backup, generation backup file;
Step 404: standby server obtain backup file and upgrade after sync id number;
Step 405: standby server recovers the standby server database with the backup file that receives.
Idiographic flow in each step of above initial synchronisation, identical with corresponding steps among first embodiment, repeat no more herein.So far, finished the database initial synchronization, because the identification number that this moment, standby server was preserved is present in the synchronous meter, so carry out after initial synchronisation is finished synchronously in real time.
Step 406: the master need to have judged whether the operation of real-time data in synchronization storehouse with server;
If the operation of the data in synchronization of needs storehouse is arranged, carries out following step.
Step 407: the master needs the SQL statement of data in synchronization storehouse operation in synchronous meter with server replicates;
Step 408: standby server obtains this SQL statement from described synchronous meter;
Step 409: standby server is visited the standby server database with same SQL.
More than the real-time synchronously idiographic flow in each step, identical with corresponding steps among second embodiment, repeat no more herein.In in real time synchronous process, standby server upgrades the identification number of standby server synchronously, and the deletion of complete back is main with record synchronous in the server sync table.And record of the every execution of standby server can check all whether identification number is present in the synchronous meter, need to judge whether initial synchronisation.Because data read out from synchronous meter, if judge sign that standby server preserves whether and the sign of the record that reads out whether continuously.
Because the method for this embodiment of the invention database synchronization, utilize synchronous meter, the initial synchronisation of fulfillment database and synchronous is in real time simplified the modification to server configures, database synchronization is not subjected to the restriction of operating system and Database Systems, has improved the efficient of data sync.
The 4th embodiment of the present invention relates to the system of database synchronization, and Fig. 5 is the system diagram of this database synchronization, as shown in Figure 5:
This database synchronous system comprises disposing and main use server with the main of server database, and the standby server that disposes the standby server database, and is main with being provided with the synchronous meter that comprises sync id number and SQL statement in the server database.
Wherein, the master comprises with server:
Backup units 501 was used in the initial synchronisation stage, and after receiving the initial synchronisation request that standby server sends, backup database generates backup file; Synchronous meter unit 502 was used in the initial synchronisation stage, upgraded sync id number at synchronous meter, also was used at real-time synchronous phase, upgraded the sync id number in the synchronous meter, duplicate need the operation of data in synchronization storehouse SQL statement in synchronous meter; Synchronous meter can be arranged in the synchronous meter unit.
Standby server comprises:
Request unit 503 is used for the request message that sends the request initial synchronisation with server to main; Acquiring unit 504 was used in the initial synchronisation stage, obtained the main backup file that generates with backup units in the server, and synchronous meter sign and the preservation of synchronous meter unit 502 after upgrading in synchronous meter; Lock unit 505 is used for obtaining backup file in the initial synchronisation stage from acquiring unit 504, and recover the standby server database with this backup file, also be used for from synchronous meter, obtaining SQL statement, and visit the standby server database with same SQL statement at real-time synchronous phase.
Main backup units with server may further include:
The backup subelement is used for after receiving the initial synchronisation request that standby server sends, and backup database generates backup file; The response subelement is used for sending the backup success message to standby server after the success of backup subelement backup database; Wherein, the backup success message carries the sync id number after initial synchronisation stage synchronous meter unit upgrades in synchronous meter.Accordingly, acquiring unit obtains this sync id number the success message from backup, obtains backup file from the backup subelement.
The master can further include with server: the subelement that locks, be used for before the master is with the server backup database, and lock with server database to main.
This system can also comprise judging unit in real time synchronously, and the parameter that provides according to database access interface is provided, and judges when the operation of the real-time data in synchronization of needs storehouse is arranged, and sends synch command to lock unit; Lock unit obtains SQL statement according to described synch command from synchronous meter, and with same SQL statement visit standby server database, finishes the synchronous in real time of data.
In the data synchronization process, whether the sync id that request unit 503 is preserved according to acquiring unit 504 number is present in the synchronous meter of synchronous meter unit 502, makes the judgement that whether needs initial synchronisation; Initial synchronisation then sends the request message of asking initial synchronisation is used server to the master backup units 501 if desired.After backup units 501 was received the request message of standby server transmission, backup database generated backup file.Synchronous meter unit 502, the sync id after in synchronous meter, form upgrading number.After backing up successfully, acquiring unit 504 obtains this backup file, and obtains this synchronous meter sign and preserve it.And lock unit 505, the backup file that utilizes acquiring unit 504 to obtain recovers the standby server database with this document, has realized the database initial synchronisation.
Main judge when the operation of the real-time data in synchronization of needs storehouse is arranged with server, synchronous meter unit 502 duplicate need the operation of data in synchronization storehouse SQL statement in synchronous meter, upgrade the sync id in the synchronous meter unit.In this process, main with every modification one secondary data of server, just increase the synchronous meter record one time.Lock unit 505 obtains this SQL statement from synchronous meter, and with same SQL visit standby server database, realizes that the modification of data in real time is synchronous.When the main synchronously N bar with server of standby server writes down, only can delete main with N-1 bar record with front in the table, N bar record is retained in the synchronous meter, like this, whether the standby the last item record that at every turn can check own synchronous mistake in synchronous meter, need judges whether initial synchronisation.
And in the present embodiment, need to have judged whether the operation of real-time data in synchronization storehouse, can realize that the parameter that this unit provides according to database access interface need to have judged whether the operation of real-time data in synchronization storehouse by in real time synchronous judging unit.If judged result then sends synch command to lock unit 505 for being, lock unit 505 obtains SQL statement according to this order from described synchronous meter, and visits the standby server database with same SQL statement.
Because this embodiment of the invention database synchronous system, utilize synchronous meter, the initial synchronisation of fulfillment database and synchronous is in real time simplified the modification to server configures, database synchronization is not subjected to the restriction of operating system and Database Systems, has improved the efficient of data sync.
Above-described specific embodiment further describes purpose of the present invention, technical scheme and beneficial effect, it should be understood that the above only is a kind of displaying of inventive concept, but not be used to limit protection scope of the present invention.Within the spirit and principles in the present invention all, any modification of being made, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (16)

1, a kind of database synchronization method is used for main initial synchronisation with server database and standby server database, it is characterized in that, described main with being provided with the synchronous meter that comprises sync id number in the server database, this method may further comprise the steps:
Standby server sends the initial synchronisation request to main with server;
Main with server according to the described initial synchronisation request that receives, in described synchronous meter, upgrade sync id number, and back up the described main server database of using, generation backup file;
Standby server obtains sync id number and the described backup file after the described renewal, with described backup file recovery standby server database.
2, method according to claim 1 is characterized in that, described main with server according to the described initial synchronisation request that receives, the step of renewal sync id number comprises in described synchronous meter:
Main receive described initial synchronisation request with server after, empty the data recording in the synchronous meter and insert null record, form the sync id number after upgrading.
3, method according to claim 2 is characterized in that, described master with after the server database success, sends the backup success message of the sync id number after carrying described renewal with the server backup master to standby server;
The step that described standby server obtains the sync id number after the described renewal is:
Standby server obtains and preserves the sync id number after the described renewal from described backup success message.
4, according to each described method of claim 1 to 3, it is characterized in that, further be included in and lead with the server backup master with before the server database, to the main step that locks with server database.
5, the main seed attribute that increases progressively automatically that provides with server database of sync id in the described synchronous meter number employing according to each described method of claim 1 to 3, is provided.
6, a kind of database synchronization method, be used for main the synchronous in real time of server database and standby server database of using, described main with being provided with the synchronous meter that comprises sync id number and SQL statement in the server database, described sync id is number according to the database manipulation real-time update, it is characterized in that this method may further comprise the steps:
The master needs the SQL statement of data in synchronization storehouse operation in described synchronous meter with server replicates;
Standby server is directly connected to the master with on the server database, obtains described SQL statement from described synchronous meter, and visits the standby server database with described SQL statement.
7, method according to claim 6 is characterized in that, before described master needs data in synchronization storehouse operation with server replicates SQL statement was in the described synchronous meter, described method also comprised the steps:
The master according to the parameter that database access interface provides, need to have judged whether the operation of real-time data in synchronization storehouse with server.
8, method according to claim 7 is characterized in that, described standby server obtains described SQL statement from described synchronous meter step comprises:
Described standby server obtains main username and password with server database;
Be connected to the master according to the described username and password that obtains and use server, obtain the described SQL statement of synchronous meter.
9, a kind of database synchronization method, be used for main with server database and standby server database synchronously, described main with being provided with the synchronous meter that comprises sync id number and SQL statement in the server database, it is characterized in that this method comprises:
A, standby server check whether the identification number of its preservation is present in the described synchronous meter, if there is no, then execution in step B, C, D, if exist, then execution in step E, F;
B, standby server send the initial synchronisation request to main with server;
C, main with server according to the described initial synchronisation request that receives, in described synchronous meter, upgrade sync id number, back up described master and uses server database, the generation backup file;
D, standby server obtain sync id number and the described backup file after the described renewal, recover the standby server database with described backup file;
E, master need the SQL statement of data in synchronization storehouse operation in described synchronous meter with server replicates;
F, standby server obtain described SQL statement from described synchronous meter, and visit the standby server database with described SQL statement.
10, method according to claim 9 is characterized in that, described main with server according to the described initial synchronisation request that receives, the step of renewal sync id number comprises in described synchronous meter:
Main receive described initial synchronisation request with server after, empty the data recording in the synchronous meter and insert null record, form the sync id number after upgrading;
Main with the server backup master with the server database success after, send the backup success message of the sync id number after carrying described renewal to standby server.
11, method according to claim 9 is characterized in that, also comprises before step e:
The main parameter that provides according to database access interface with server, judging has the operation of the real-time data in synchronization of needs storehouse.
12, method according to claim 9 is characterized in that, described standby server obtains described SQL statement from described synchronous meter step comprises:
Standby server obtains main username and password with server database, is connected to the master with on the server according to described username and password, obtains the described SQL statement of synchronous meter.
13, a kind of database synchronous system comprises that disposing main master with server database uses server, and the standby server that disposes the standby server database, it is characterized in that,
Described main with being provided with the synchronous meter that comprises sync id number and SQL statement in the server database;
Described master comprises with server:
Backup units was used in the initial synchronisation stage, and after receiving the initial synchronisation request that standby server sends, backup is main to generate backup file with server database;
The synchronous meter unit was used in the initial synchronisation stage, upgraded sync id number in described synchronous meter, also was used at real-time synchronous phase, upgraded the sync id number in the described synchronous meter, duplicate need the operation of data in synchronization storehouse SQL statement in synchronous meter;
Described standby server comprises:
Request unit is used for sending the initial synchronisation request to main with server;
Acquiring unit was used in the initial synchronisation stage, obtained the backup file that described backup units generates, and the sync id of synchronous meter unit after upgrading in described synchronous meter number;
Lock unit, be used in the initial synchronisation stage, obtain described backup file from described acquiring unit, and recover the standby server database with this backup file, also be used at real-time synchronous phase, from described synchronous meter, obtain described SQL statement, and visit the standby server database with described SQL statement.
14, system according to claim 13 is characterized in that, described main backup units with server further comprises:
The backup subelement is used for after receiving the initial synchronisation request that standby server sends, and backup is main to generate backup file with server database;
The response subelement is used for sending the backup success message to standby server after described backup subelement backup master is with the server database success;
Described backup success message carries the sync id number after initial synchronisation stage described synchronous meter unit upgrades in described synchronous meter;
Described acquiring unit obtains the sync id number after the described renewal from described backup success message, obtain described backup file from described backup subelement.
15, system according to claim 13 is characterized in that, described master further comprises with server:
The subelement that locks, be used for main with the server backup master with before the server database, lock with server database to main.
16, system according to claim 13, it is characterized in that this system also comprises main with the in real time synchronous judging unit in the server, and the parameter that provides according to database access interface is provided, judge when the operation of the real-time data in synchronization of needs storehouse is arranged, send synch command to described lock unit;
Described lock unit obtains described SQL statement according to described synch command from described synchronous meter, and visits the standby server database with described SQL statement.
CNB2007100738877A 2007-04-11 2007-04-11 Method and system for synchronizing data base Active CN100449548C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2007100738877A CN100449548C (en) 2007-04-11 2007-04-11 Method and system for synchronizing data base

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2007100738877A CN100449548C (en) 2007-04-11 2007-04-11 Method and system for synchronizing data base

Publications (2)

Publication Number Publication Date
CN101038591A CN101038591A (en) 2007-09-19
CN100449548C true CN100449548C (en) 2009-01-07

Family

ID=38889494

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2007100738877A Active CN100449548C (en) 2007-04-11 2007-04-11 Method and system for synchronizing data base

Country Status (1)

Country Link
CN (1) CN100449548C (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110096389A (en) * 2019-04-30 2019-08-06 上海达梦数据库有限公司 A kind of starting method, apparatus, equipment and the storage medium of database

Families Citing this family (52)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8121979B2 (en) * 2007-09-28 2012-02-21 Nokia Siemens Networks Oy System and method for replication and synchronisation
CN100574220C (en) * 2007-12-11 2009-12-23 华为技术有限公司 Data back up method and application processing system
CN101489074B (en) * 2009-01-14 2013-11-27 深圳市龙视传媒有限公司 Collaborative recording system and method
CN101826073B (en) * 2009-03-06 2013-08-28 华为技术有限公司 Synchronous method, apparatus and system for distributed database
CN102006611B (en) * 2009-09-03 2014-03-19 中兴通讯股份有限公司 Method for realizing data uniqueness conversion and mobile switching center servers
CN101706795B (en) * 2009-11-30 2012-05-09 上海世范软件技术有限公司 Method for synchronizing data of database in active/standby server
CN102193841B (en) * 2010-03-04 2013-07-31 阿里巴巴集团控股有限公司 Backup method and device of Subversion configuration database
CN101854400B (en) * 2010-06-09 2015-04-01 中兴通讯股份有限公司 Database synchronization deployment and monitoring method and device
CN102299904B (en) * 2010-06-23 2014-03-19 阿里巴巴集团控股有限公司 System and method for realizing service data backup
CN102118247A (en) * 2011-01-04 2011-07-06 中兴通讯股份有限公司 System and method for password management
CN102843395B (en) * 2011-06-22 2015-08-19 阿里巴巴集团控股有限公司 A kind of method of data synchronization and device
CN102662793A (en) * 2012-03-07 2012-09-12 江苏引跑网络科技有限公司 Hot backup and recovery method of distributed database with guarantee of data consistency
CN102801789B (en) * 2012-07-17 2015-09-02 浙江中烟工业有限责任公司 A kind of number of cigarette combined test stand adopts networked system
CN103580906B (en) * 2012-08-09 2018-02-27 腾讯科技(深圳)有限公司 A kind of method of data backup, system and server
CN108280239B (en) * 2013-02-15 2023-01-17 直观外科手术操作公司 System and method for synchronizing nodes of a robotic system
CN104066107A (en) * 2013-03-22 2014-09-24 中兴通讯股份有限公司 Method and system for business disaster tolerance
CN103365979A (en) * 2013-07-03 2013-10-23 交通银行股份有限公司 Long-distance double-center online processing method and system based on open database
CN103605740B (en) * 2013-11-19 2016-10-05 北京国双科技有限公司 Data import treating method and apparatus
CN103886091B (en) * 2014-04-01 2017-08-01 无锡科技职业学院 A kind of database synchronization method based on recording mark
CN104503868B (en) * 2014-12-29 2017-10-27 成都致云科技有限公司 Method of data synchronization, device and system
CN105988893A (en) * 2015-02-10 2016-10-05 北京中科同向信息技术有限公司 Technique based on data replication
CN104809199B (en) * 2015-04-24 2018-11-16 联动优势科技有限公司 A kind of method and apparatus of database synchronization
CN104834694A (en) * 2015-04-24 2015-08-12 同程网络科技股份有限公司 OTA-based quick and intelligent report form processing method
CN105045678B (en) * 2015-07-09 2018-10-26 小米科技有限责任公司 Database restoring method and device
CN105069059A (en) * 2015-07-28 2015-11-18 小米科技有限责任公司 Database synchronization method and apparatus
CN104965935B (en) * 2015-08-06 2018-10-12 上海携程商务有限公司 The update method of network monitoring daily record
CN105117441A (en) * 2015-08-11 2015-12-02 北京思特奇信息技术股份有限公司 Data work order processing method and system
CN106802895B (en) * 2015-11-26 2020-06-02 阿里巴巴集团控股有限公司 Method and device for repairing database backup data
CN106855860A (en) * 2015-12-08 2017-06-16 阿里巴巴集团控股有限公司 Method and apparatus for creating master/slave data storehouse
CN106919496B (en) * 2015-12-28 2020-09-08 华为技术有限公司 Method, device and system for testing service continuity of database
US10545990B2 (en) * 2016-03-31 2020-01-28 Veritas Technologies Llc Replication between heterogeneous storage systems
CN106301967B (en) * 2016-10-25 2019-10-15 杭州华为数字技术有限公司 A kind of method of data synchronization and outband management equipment
CN106779993A (en) * 2016-11-29 2017-05-31 南京信息工程大学 A kind of stateless Financial information processing and standby system and method
CN107066480B (en) * 2016-12-20 2020-08-11 创新先进技术有限公司 Method, system and equipment for managing main and standby databases
CN108733699A (en) * 2017-04-19 2018-11-02 北京京东尚科信息技术有限公司 Database leader follower replication system, method and apparatus
CN107229541B (en) * 2017-06-20 2019-11-26 携程旅游信息技术(上海)有限公司 Backup method, standby system and the server of Transaction Information
CN107741950A (en) * 2017-09-05 2018-02-27 北京趣拿软件科技有限公司 Processing method, device, processor and the service end of data syn-chronization task
CN108038028B (en) * 2017-12-13 2021-03-23 北信源系统集成有限公司 File backup method and device and file restoration method and device
CN108200220B (en) * 2018-04-08 2021-07-23 武汉斗鱼网络科技有限公司 Data synchronization method, server and storage medium
CN108573060A (en) * 2018-04-26 2018-09-25 北京恒华伟业科技股份有限公司 A kind of method of data synchronization and system based on spring boot plug-in units
CN108900497B (en) * 2018-06-25 2021-11-02 江苏欧软信息科技有限公司 Data synchronization method and system between heterogeneous systems
CN110766371A (en) * 2018-07-27 2020-02-07 视联动力信息技术股份有限公司 Office automation data synchronization method and system
CN109885622B (en) * 2019-01-18 2021-07-16 广州虎牙信息科技有限公司 Data processing equipment, system and multi-node data processing method
CN109933630B (en) * 2019-03-19 2021-11-23 武汉达梦数据库股份有限公司 Real-time database data synchronization method and device
CN110442643A (en) * 2019-07-05 2019-11-12 苏州浪潮智能科技有限公司 A kind of file synchronisation method and device for two-node cluster hot backup
CN110851527B (en) * 2019-09-24 2022-12-06 福建星网智慧科技有限公司 Data synchronization method for main and standby servers
CN110727733B (en) * 2019-09-25 2023-07-14 许昌许继软件技术有限公司 Master-slave server system and data synchronization method
CN111241198B (en) * 2020-01-02 2024-02-27 广州虎牙科技有限公司 Data synchronization method and device and data processing equipment
CN111831661A (en) * 2020-07-20 2020-10-27 江苏云柜网络技术有限公司 Database filing method based on express business logic
CN112307054B (en) * 2020-11-18 2023-02-28 太原理工大学 Reading and writing method for active and standby servers of double active databases
CN114531394B (en) * 2020-11-20 2023-11-17 华为技术有限公司 Data synchronization method and device
CN113609232B (en) * 2021-10-08 2021-12-03 武汉四通信息服务有限公司 Data management method, data management system, and computer-readable storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1437348A (en) * 2002-02-04 2003-08-20 深圳市中兴通讯股份有限公司 Real-time synchronizing method for data in both main and spare board in communication system
US20040153624A1 (en) * 2002-10-29 2004-08-05 Brocade Communications Systems, Inc. High availability synchronization architecture
CN1561022A (en) * 2004-03-04 2005-01-05 中兴通讯股份有限公司 Method of internal data base main-spare synchronous
CN1851657A (en) * 2005-07-21 2006-10-25 上海华为技术有限公司 Dual-machine back-up realizing method and system
US20060271813A1 (en) * 2005-05-26 2006-11-30 David Horton Systems and methods for message handling among redunant application servers

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1437348A (en) * 2002-02-04 2003-08-20 深圳市中兴通讯股份有限公司 Real-time synchronizing method for data in both main and spare board in communication system
US20040153624A1 (en) * 2002-10-29 2004-08-05 Brocade Communications Systems, Inc. High availability synchronization architecture
CN1561022A (en) * 2004-03-04 2005-01-05 中兴通讯股份有限公司 Method of internal data base main-spare synchronous
US20060271813A1 (en) * 2005-05-26 2006-11-30 David Horton Systems and methods for message handling among redunant application servers
CN1851657A (en) * 2005-07-21 2006-10-25 上海华为技术有限公司 Dual-machine back-up realizing method and system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110096389A (en) * 2019-04-30 2019-08-06 上海达梦数据库有限公司 A kind of starting method, apparatus, equipment and the storage medium of database

Also Published As

Publication number Publication date
CN101038591A (en) 2007-09-19

Similar Documents

Publication Publication Date Title
CN100449548C (en) Method and system for synchronizing data base
US6748381B1 (en) Apparatus and method for maintaining consistency of shared data resources in a cluster environment
WO2019154394A1 (en) Distributed database cluster system, data synchronization method and storage medium
JP4397385B2 (en) Method implemented as computer processor instructions stored in computer and storage medium readable by computer
US9286368B2 (en) Linking framework for information technology management
US8121978B2 (en) Database system providing improved methods for data replication
CN113396407A (en) System and method for augmenting database applications using blockchain techniques
US11010267B2 (en) Method and system for automatic maintenance of standby databases for non-logged workloads
CN106991035A (en) A kind of Host Supervision System based on micro services framework
WO2021103499A1 (en) Multi-active data center-based traffic switching method and device
US20060123098A1 (en) Multi-system auto-failure web-based system with dynamic session recovery
CN104252500A (en) Method and device for carrying out fault repairing on database management platform
CN106294741B (en) A kind of automated data inquiry synchronization storage system
US11194769B2 (en) System and method for re-synchronizing a portion of or an entire source database and a target database
CN106657169A (en) Main and slave node data synchronization method in Redis
US11698917B1 (en) Method for replacing a currently operating data replication engine in a bidirectional data replication environment without application downtime and while preserving target database consistency, and by using audit trail tokens that provide a list of active transactions
CN108762982B (en) A kind of database restoring method, apparatus and system
US20200125667A1 (en) Real-time masking in a standby database
JP2024026143A (en) Finally consistent switch to database clone
CN111181775A (en) Integrated operation and maintenance management alarm method based on automatic host asset discovery
US20220413971A1 (en) System and Method for Blockchain Based Backup and Recovery
CA2619778A1 (en) Method and apparatus for sequencing transactions globally in a distributed database cluster with collision monitoring
JPH07114495A (en) Multiplexing file managing system
CN105955830B (en) Communication means and system between a kind of application module
US7644306B2 (en) Method and system for synchronous operation of an application by a purality of processing units

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant