WO2014067254A1 - 一种检测数据库数据一致性的方法、装置及数据库系统 - Google Patents

一种检测数据库数据一致性的方法、装置及数据库系统 Download PDF

Info

Publication number
WO2014067254A1
WO2014067254A1 PCT/CN2013/073476 CN2013073476W WO2014067254A1 WO 2014067254 A1 WO2014067254 A1 WO 2014067254A1 CN 2013073476 W CN2013073476 W CN 2013073476W WO 2014067254 A1 WO2014067254 A1 WO 2014067254A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
data table
data
update
standby
Prior art date
Application number
PCT/CN2013/073476
Other languages
English (en)
French (fr)
Inventor
彭正元
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2014067254A1 publication Critical patent/WO2014067254A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Definitions

  • the database system In order to ensure the normal operation of the system, the database system uses two sets of primary and backup databases. At the same time, in order to ensure the efficiency of database access, the database system caches the data in the database to achieve fast access to the data, and the cached data is consistent with the database in real time.
  • the primary database and the standby database perform periodic or real-time data synchronization.
  • the standby database takes over the data to provide the data service.
  • the database system does not function properly.
  • each application of the database system independently detects the switching of the primary database and the standby database, and after each application detects the primary database and the standby database switching, each application All the cached data in the memory corresponding to the application is compared with the corresponding data in the standby database, and the inconsistent data is persisted to the backup database. In this way, there is no unified method for detecting the primary database and the standby database switching.
  • each application compares all the cached data corresponding to the application with the corresponding data in the standby database, so that the database system handles the database switching cost. Time, inefficiency, and high consumption of resources. Summary of the invention
  • Embodiments of the present invention provide a method, apparatus, and database system for detecting database data consistency, which can improve the efficiency of database system processing database switching and reduce resource consumption of the database system.
  • the embodiment of the present invention uses the following technical solutions:
  • an embodiment of the present invention provides an apparatus for detecting database data consistency, the apparatus comprising an update unit, an obtaining unit, and a processing unit, where the updating unit is configured to update the primary database accessed by each application. a first update identifier of the data table and a second update identifier, the first update identifier indicating an update status of a data table in a cache corresponding to the data table, the second update identifier indicating a correspondence with the data table The update status of the data table in the standby database; the obtaining unit, configured to compare the first update identifier and the second update identifier of each of the data tables after the primary database and the standby database are switched, Obtaining a first data table in which the first update identifier and the second update identifier are inconsistent; the processing unit is configured to perform consistency processing on the data table corresponding to the first data table in the standby database and the cache, to Synchronizing the data in the standby database with the cache.
  • an embodiment of the present invention provides a database system, where the database system includes: at least one primary database, a standby database corresponding to the primary database, a database access device, a switching monitoring device, and a database data consistency check.
  • the primary database is configured to store data that the application needs to access;
  • the standby database is configured to provide data for the application by the standby database when the primary database fails;
  • the database access device And receiving an access request of the application to the primary database or the standby database, and acquiring corresponding data from the primary database or the standby database according to the access request;
  • the switching monitoring device Monitoring whether the primary database and the standby database are switched, and after the primary database and the standby database are switched, notifying the device that detects database data consistency to perform data consistency processing; and the device for detecting database data consistency, Used to update each application's access a first update identifier and a second update identifier of a data table of the primary database, the first update identifier indicating an update status of a data table in a cache
  • the database system After the switching, the database system only compares the first update identifier and the second update identifier of the data accessed by the application, and does not need to compare all the data in the database in turn, thereby improving the database system processing database switching.
  • the efficiency of the database system reduces the consumption of resources.
  • FIG. 1 is a schematic flowchart of a method for detecting consistency of database data according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of another method for detecting consistency of database data according to an embodiment of the present invention
  • FIG. 3 is a schematic flowchart of another method for detecting consistency of database data according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of another apparatus for detecting consistency of database data according to an embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a database system according to an embodiment of the present invention
  • FIG. 7 is a schematic diagram of interaction of a database system for detecting database data consistency according to an embodiment of the present invention.
  • Embodiment 1 The embodiment of the present invention provides a method for detecting consistency of database data.
  • the method is applied to a database system.
  • the database of the database system includes at least one primary database and a standby database corresponding to the primary database, and the database is At least one application is accessible. Each application needs to access a data table in the primary database at runtime.
  • the application typically pre-caches the data table in the primary database to be cached in the device running the application. in.
  • the data in the database should be consistent with the cached data in real time.
  • the primary database also sends the data of the primary database to the standby database periodically or in real time, so that the primary database synchronizes with the data of the standby database, but the primary database and the standby database data are completely synchronized in real time due to network instability or delay.
  • the method specifically includes:
  • Update a first update identifier and a second update identifier of a data table of the primary database accessed by each application where the first update identifier indicates an update status of a data table in a cache corresponding to the data table.
  • the second update identifier indicates an update status of the data table in the standby database corresponding to the data table.
  • the update status includes at least one of the following information: information indicating that the data table has been updated and indicating the number of times the data table was updated.
  • the change operation may be an operation of deleting, adding, or the like of the data, but does not include a query operation on the data.
  • the second update identifier is updated to the first update identifier, and is used to indicate that the data of the standby database and the data of the primary database and the data in the cache are synchronized.
  • the second update identifier maintains the original state value.
  • the first update identifier of each data table is compared with the second update identifier, and the first data that is inconsistent with the first update identifier and the second update identifier is obtained.
  • the database system can perform switching monitoring on the primary database and the standby database. After the database system detects that the primary database and the standby database are switched, the database system compares the first update identifier of each data table with the second update identifier to obtain the first update identifier.
  • the first data table is a data table that is inconsistent with data in the standby database, and the database system needs to perform consistency processing on the data table corresponding to the first data table in the cache database.
  • the embodiment of the present invention provides a method for detecting consistency of database data, where the database system updates a first update identifier and a second update identifier of a data table of the primary database accessed by each application, where the primary After the database is exchanged with the standby database, the database system compares the first update identifier of each of the data tables with the second update identifier, and obtains a first data table in which the first update identifier and the second update identifier are inconsistent, and Performing consistency processing on the standby database and the data table corresponding to the first data table in the cache to synchronize the data in the standby database and the cache.
  • Embodiment 2 The embodiment of the present invention provides a method for detecting database consistency, and the method is applied to a database system.
  • Each of the applications registers the identity of the application with the database system, the name of the database that the application needs to access, and the name of the data table in each database that the application needs to access.
  • the database system stores a first feature table corresponding to each application, where the first feature table includes at least an identifier of the corresponding application, a name of a database accessed by the application, and a database accessed by the application. a name of the data table, a first update identifier of each data table accessed by the application, and a second update identifier, such that the first update identifier and the second update identifier of each data table are included in the corresponding application In the first feature table.
  • the application caches the accessed data to the cache of the device running the application, and the application accesses the data in the corresponding database by accessing the cached data.
  • the method for detecting database data consistency specifically includes:
  • the first update identifier indicating an update of a data table in a cache corresponding to the data table a status
  • the second update identifier indicating an update status of a data table in the standby database corresponding to the data table.
  • the update status includes at least one of the following information: information indicating that the data table has been updated and indicating the number of times the data table was updated.
  • the primary database may synchronize only the data table whose third update identifier has changed to the standby database, and update the second update identifier to the third update. Identification, which improves the synchronization rate of the primary and secondary databases.
  • the database system can monitor the primary database and the standby database.
  • the switching monitoring of the primary database and the standby database by the database system may be a monitoring application in the database system or an independent monitoring device.
  • the monitoring application or the monitoring device performs unified monitoring and management on the devices of the primary database and the standby database. After the primary database fails, the monitoring application or monitoring device is performed after the database system switches the primary database and the standby database.
  • the database system may be based on the obtained first data table and the a first database, the content of the data table corresponding to the first data table of the first standby database may be updated to the content of the data table corresponding to the first data table in the cache; of course, the database system may also The content of the data table corresponding to the first data table in the cache is updated to the content of the data table corresponding to the first data table in the first standby database, and of course, the first data table may be correspondingly matched in other manners.
  • the data table is processed, and the embodiment of the present invention is not specifically limited herein.
  • performing consistency processing on the data table corresponding to the first data table in the first standby database and the cache is processed by an application corresponding to the first data table in the database system, where the database system is A consistency processing message is sent to each application accessing the first data table, the consistency processing message including the first data table and information of the first database.
  • the corresponding application After receiving the consistency processing message, the corresponding application performs consistency processing on the data table corresponding to the first data table in the cache in the first standby database.
  • the consistency process is different for different database systems. Specific treatment For the process, refer to the process of the consistency processing of the data table corresponding to the first data table in the first standby database and the cache.
  • the embodiment of the present invention is only an exemplary description, which is not specifically limited. .
  • the embodiment of the present invention provides a method for detecting consistency of database data, where the database system updates a first update identifier and a second update identifier of a data table of the primary database accessed by each application, if the database The system detects that the primary database and the standby database are switched, and the database system compares the first update identifier and the second update identifier of each data table, and obtains a first inconsistency between the first update identifier and the second update identifier. a data table, and performing consistency processing on the data table corresponding to the first data table in the standby database and the cache, so that the data in the standby database and the cache are synchronized.
  • Embodiment 3 The embodiment of the present invention provides a method for detecting consistency of database data, and the method is applied to a database system.
  • Each of the applications registers the identity of the application with the database system, the name of the database that the application needs to access, and the name of the data table in each database that the application needs to access.
  • the database system stores a first feature table and a second feature table corresponding to each application, where the first feature table includes at least an identifier of the corresponding application, a name of a database accessed by the application, and the application. a name of each data table in the accessed database, a first update identifier of each data table accessed by the application, the second feature table including at least an identifier of the corresponding application, a name of a database accessed by the application, The application accesses the name of each data table in the database and the second update identifier for each data table accessed by the application.
  • the application typically caches the accessed data into the cache of the device running the application, and the application accesses the corresponding number. According to the data in the library is achieved by accessing the cached data.
  • the method for detecting database data consistency specifically includes:
  • the first update identifier indicating an update of a data table in a cache corresponding to the data table a status
  • the second update identifier indicating an update status of a data table in the standby database corresponding to the data table.
  • the update status includes at least one of the following information: information indicating that the data table has been updated and indicating the number of times the data table was updated.
  • the change operation may be a change operation such as deleting, adding, etc. of the data, but does not include a query operation on the data.
  • the second update identifier in the second feature table is updated to a first update identifier in the first feature table, to represent data and a master of the standby database.
  • the data in the database and the data in the cache remain in sync.
  • the second update identifier in the second feature table maintains the original state value.
  • the database system may further establish a third feature table, where the third feature table includes at least an identifier of the corresponding application, and a database accessed by the application.
  • the third update identifier is used to indicate an update status of the corresponding data table in the primary database.
  • the third feature table may also be stored in the database system. When each application changes the data in the corresponding cache, the database system updates the first update identifier and the third update identifier accordingly.
  • the second feature table can also be directly stored in the standby database, and the third feature table can also be stored in the primary database.
  • the database system may only The third update identifier in the third feature table in the primary database may be synchronized to the standby database, and the second feature table may be updated to the third feature table.
  • the first update identifier and the second update identifier of the data table accessed by each application For comparison, the name of the data table in which the first update identifier and the second update identifier are inconsistent is the first data table, and the name of the database storing the first data table is the first database.
  • the database system monitors the primary database and the standby database.
  • the switching monitoring of the primary database and the standby database by the database system may be a monitoring application in the database system, or may be an independent monitoring device. According to different database systems, the primary database and the standby database can be established on the same device or different independent devices.
  • the monitoring application or the monitoring device performs unified monitoring and management on the devices of the primary database and the standby database. After the primary database fails, the monitoring application or monitoring device is performed after the database system switches the primary database and the standby database. After monitoring the switch between the primary database and the standby database, the database system is notified The unified monitoring application or monitoring device monitors the primary database and the backup database included in the database system uniformly. Compared with the database system in the prior art, each application separately monitors the accessed primary database and backup. The technical solution of database switching can improve the working efficiency of the database system and save system resources.
  • the database system After the database system detects the primary database and the standby database switching, the database system compares the first update identifier corresponding to each data table in the first specific table with the second update in the second specific table. The identifier is compared to obtain a first data table in which the first update identifier in the first specific table and the second update identifier in the second feature table are inconsistent.
  • the first data table is a data table of the primary database corresponding to a data table that is inconsistent with the standby database data, and the database system needs to perform consistency processing on the data table corresponding to the first data table in the cache and the standby database. .
  • the second feature table when the second feature table is stored in the standby database, the data table accessed by each application according to the first feature table and the second feature table of each application in the database system Before the first update identifier and the second update identifier are compared, the second feature table needs to be acquired from the standby database.
  • the database system may be based on the obtained first data table and the a first database, the content of the data table corresponding to the first data table of the first standby database may be updated to the content of the data table corresponding to the first data table in the cache; Updating the content of the data table corresponding to a data table to the first in the first standby database
  • the content of the data table corresponding to the data table may be processed in other manners, which is not limited herein.
  • performing consistency processing on the data table corresponding to the first data table in the first standby database and the cache is processed by an application corresponding to the first data table in the database system, where the database system is A consistency processing message is sent to each application accessing the first data table, the consistency processing message including the first data table and information of the first database.
  • the corresponding application After receiving the consistency processing message, the corresponding application performs consistency processing on the data table corresponding to the first data table in the cache in the first standby database.
  • the consistency process is different for different database systems.
  • For the specific processing refer to the process of performing consistency processing on the data table corresponding to the first data table in the first standby database and the cache in the foregoing database system.
  • the embodiment of the present invention is only an exemplary description, and the specific description is not specific thereto. limited.
  • An embodiment of the present invention provides a method for detecting consistency of database data, the database system updating a first update identifier and a second update identifier of a data table of the primary database accessed by each application, and detecting in the database system After the primary database and the standby database are switched, the database system compares the first update identifier and the second update identifier of each data table, and obtains a first inconsistency between the first update identifier and the second update identifier. And a data table, and performing consistency processing on the data table corresponding to the first data table in the standby database and the cache, so that the data in the standby database and the cache are synchronized.
  • Embodiment 4 The embodiment of the present invention provides a device for detecting consistency of database data, as shown in FIG. 4 .
  • the apparatus is configured to detect data consistency of at least one primary database and a standby database corresponding to the primary database, the primary database being accessed by at least one application.
  • Each application needs to access a data table in the primary database at runtime.
  • the application will access the data table in the primary database and pre-cached in the cache of the device running the application. .
  • the data in the database should be consistent with the cached data in real time. For example, when the primary and standby databases are not swapped, the cached data is consistent with the primary database data in real time.
  • the primary database also sends the data of the primary database to the standby database periodically or in real time, so that the data of the primary database and the standby database are synchronized, but the primary database and the standby database data are completely synchronized in real time due to network instability or delay.
  • the device 40 includes: an update unit 4 1 , an acquisition unit 4 2 , and a processing unit 43 .
  • the updating unit 4 1 is configured to update a first update identifier and a second update identifier of a data table of the primary database accessed by each application, where the first update identifier indicates a cache corresponding to the data table.
  • An update status of the data table, the second update identifier indicating an update status of the data table in the standby database corresponding to the data table.
  • the update status includes at least one of the following information: information indicating that the data table has been updated and indicating the number of times the data table was updated.
  • the update unit 41 updates the first update identifier of the data table corresponding to the data to record the change operation.
  • the change operation may be an operation of deleting, adding, or the like of the data, but does not include a query operation on the data.
  • the updating unit 4 1 updates the second update identifier to the first update identifier, which is used to represent the data of the standby database and the data of the primary database, and the cache.
  • the data in the state is kept in sync.
  • the second update identifier maintains the original state value.
  • the primary database and the standby database can be established on the same device or different independent devices.
  • the monitoring application or the monitoring device performs unified monitoring and management on the devices of the primary database and the standby database. After the primary database fails, the monitoring application or monitoring device is performed after the database system switches the primary database and the standby database. After monitoring the primary database and the standby database switch, the database system is notified.
  • the obtaining unit 42 is configured to compare the first update identifier and the second update identifier of each data table after the primary database and the standby database are switched, to obtain a first update identifier and a second update. Identify the first data table that is inconsistent. After the primary database and the standby database are switched, the obtaining unit 42 compares the first update identifier and the second update identifier of each data table to obtain the first update identifier and the second update identifier. Inconsistent first data table.
  • the first data table is a data table of the primary database corresponding to a data table in the cache that is inconsistent with data in the standby database, and the processing unit 43 needs a data table corresponding to the first data table in the cache and the standby database. Perform consistency processing.
  • the processing unit 43 may be specifically configured to update the content of the data table corresponding to the first data table in the standby database to the first data in the cache, according to different principles of the consistency processing of the database system. The contents of the table. The processing unit 43 may be further configured to update the content of the data table corresponding to the first data table in the cache to the content of the first data table in the standby database.
  • the first update identifier and the second update identifier of each data table are included in a first feature table corresponding to an application, where the first feature table includes at least an identifier of the application, The name of the primary database accessed by the application, the name of each data table in the primary database accessed by the application, the first update identifier and the second update identifier of each data table accessed by the application;
  • the memory 40 also includes a storage unit 44.
  • the storage unit 44 is configured to store the first feature table.
  • the update unit 41 updates the first update identifier of each corresponding data table in the first specific table, Record this change.
  • the primary database may synchronize only the data table whose third update identifier has changed to the standby database, and update the second update identifier to the third update.
  • the identification can improve the synchronization rate of the primary and secondary databases.
  • the obtaining unit 42 is specifically configured to: after the primary database and the standby database are switched, according to the first feature table and the second feature table of each application, the first data table accessed by each application The update identifier and the second update identifier are compared and obtained.
  • the name of the data table in which the first update identifier and the second update identifier are inconsistent is the first data table
  • the name of the database storing the first data table is the first database.
  • the obtaining unit 42 compares the first update identifier and the second update identifier corresponding to each data table in the first specific table to obtain a first data table.
  • the first data table is a name of a data table in which the first update identifier and the second update identifier in the first specific table are inconsistent.
  • the first data table is a data table in the cache that is inconsistent with the data in the standby database, and the processing unit 43 needs to perform consistency processing on the data table corresponding to the first data table in the cache and the standby database.
  • the processing unit 43 is specifically configured to: in the first standby database corresponding to the first database, a data table corresponding to the first data table and a cache corresponding to the first database, and the first The data table corresponding to the data table is processed consistently.
  • different database system consistency handling principles are different. For a specific process, refer to the description in the second embodiment, and details are not described herein again.
  • the first update identifier and the second update identifier are respectively included in a first feature table and a second feature table corresponding to the application, where the first feature table includes at least the identifier of the application, a name of a primary database accessed by the application, a name of each data table in the primary database accessed by the application, and a first update identifier of each data table accessed by the application, the second feature table being at least Include an identification of the application, a name of a primary database accessed by the application, a name of each data table in a primary database accessed by the application, and a second update of each data table accessed by the application Logo.
  • the storage unit 44 is further configured to store the first feature table and the second feature table.
  • the update unit 41 updates the first update identifier of the corresponding data table in the first specific table for recording.
  • This change operation may be an operation of deleting, adding, or the like of the data, but does not include a query operation on the data.
  • the update unit 4 1 The second update identifier in the second feature table is updated to be the first update identifier in the first feature table, and is used to indicate that the data of the standby database and the data of the primary database and the data in the cache are synchronized.
  • the storage unit 44 further stores a third feature table, where the third feature table includes at least an identifier of the corresponding application, and a database accessed by the application.
  • the third update identifier is used to indicate an update status of each of the data tables in the primary database.
  • the update unit 4 1 updates the first update identifier and the third update identifier when each application performs a change operation on the data in the corresponding cache.
  • the second update identifier in the second feature table maintains the original state value.
  • the update unit 4 1 updates the second feature table to the third feature table.
  • the obtaining unit 42 is specifically configured to: after the primary database and the standby database perform the switching, according to the first feature table and the second feature table of each application, the first data table accessed by each application The update identifier and the second update identifier are compared, the name of the data table in which the first update identifier and the second update identifier are inconsistent is the first data table, and the name of the database storing the first data table is the first database.
  • the obtaining unit 42 compares the first update identifier corresponding to each data table in the first specific table with the second update identifier in the second specific table, to obtain a first data table in which the first update identifier in the first specific table and the second update identifier in the second feature table are inconsistent.
  • the first data table is a data table of the primary database corresponding to a data table that is inconsistent with the standby database, and the processing unit 43 needs to perform the same data table corresponding to the first data table in the cache database. Sexual treatment.
  • the processing unit 43 is specifically configured to: in the first standby database corresponding to the first database, a data table corresponding to the first data table and the first database pair Consistency processing is performed on the data table corresponding to the first data table in the cache.
  • Consistency processing is performed on the data table corresponding to the first data table in the cache.
  • An embodiment of the present invention provides an apparatus for detecting consistency of database data, where the update unit updates a first update identifier and a second update identifier of a data table of the primary database accessed by each application, in the primary database and After the standby database performs the switching, the obtaining unit compares the first update identifier of each data table with the second update identifier, and obtains a first data table in which the first update identifier and the second update identifier are inconsistent, and the processing is performed. The unit performs consistency processing on the data table corresponding to the first data table in the standby database and the cache to synchronize the data in the standby database and the cache.
  • Embodiment 5 The embodiment of the present invention provides an apparatus for detecting consistency of database data.
  • the apparatus 70 includes a memory 71 and a processor 72.
  • the memory 7 1 stores at least one primary database and a standby database corresponding to the primary database, and the database is accessed by at least one application. Each application needs to access the data table in the primary database at runtime.
  • the application will pre-cache the data table in the primary database in the cache.
  • the data in the database should be consistent with the cached data in real time.
  • the primary database also sends the data of the primary database to the standby database periodically or in real time, so that the data of the primary database and the standby database are synchronized, but the primary database and the standby database data are completely synchronized in real time due to network instability or delay. So, after the primary database and the standby database are switched, in order to ensure the normal operation of the system, database data is needed.
  • the consistency is checked so that the cached data is consistent with the data of the standby database.
  • the processor 7 2 is configured to update a first update identifier and a second update identifier of a data table of the primary database accessed by each application, where the first update identifier indicates a cache corresponding to the data table.
  • An update status of the data table, the second update identifier indicating an update status of the data table in the standby database corresponding to the data table.
  • the update status includes at least one of the following information: information indicating that the data table has been updated and indicating the number of times the data table was updated.
  • the change operation may be an operation of deleting, adding, or the like of the data, but does not include a query operation on the data.
  • the processor 72 updates the second update identifier to the first update identifier, to represent the data of the standby database and the data of the primary database, in the cache. The data remains in sync.
  • the second update identifier maintains the original state value.
  • the primary database and the standby database can be established on the same device or different independent devices.
  • the monitoring application or the monitoring device performs unified monitoring and management on the devices of the primary database and the standby database.
  • the processor 72 is further configured to compare the first update identifier and the second update identifier of each data table after the primary database and the standby database are switched, to obtain a first update identifier and a second update. Identify the first data table that is inconsistent.
  • the obtained processor 72 compares the first update identifier of each of the data tables with the second update identifier to obtain the first update identifier and the second update. Identify the first data table that is inconsistent.
  • the first data table is a data table in the cache that is inconsistent with the data in the standby database, and the processor 72 needs to perform consistency processing on the data table corresponding to the first data table in the cache and the standby database.
  • the processor 72 is further configured to perform consistency processing on the standby database and the data table corresponding to the first data table in the cache, so that the standby database and the data in the cache are synchronized.
  • the processor 72 may be specifically configured to update the content of the first data table in the standby database to the content of the first data table in the cache, according to different principles of the consistency processing of the database system; or Specifically, the content of the first data table in the cache is updated to the content of the first data table in the standby database.
  • the memory 71 is also used to store programs that the processor 72 needs to execute or intermediate results in the execution of the program by the processor 72, and the like. It should be noted that the memory 71 shown in FIG. 5 is directly connected to the processor 72. In other embodiments of the present invention, the memory 71 and the processor 72 and other modules of the device 70 can also be connected through a bus.
  • the bus may be one or more physical lines, and when it is a plurality of physical lines, it may be divided into an address bus, a data bus, a control bus, and the like.
  • ISA Industry Standard Architecture
  • PCI Peripheral Component
  • EISA Extended Industry Standard Architecture
  • the embodiment of the present invention provides an apparatus for detecting consistency of database data, where the processor updates a first update identifier and a second update identifier of a data table of the primary database accessed by each application, where the primary After the database and the standby database are switched, the processor compares the first update identifier of each data table with the second update identifier, and obtains a first data table in which the first update identifier and the second update identifier are inconsistent. The processor performs consistency processing on the data table corresponding to the first data table in the standby database and the cache, so that the data in the standby database and the cache are synchronized.
  • the obtaining unit compares and detects only the first update identifier and the second update identifier of the data accessed by the application, it is not necessary to sequentially compare all the data in the database, thereby The efficiency of the database system to handle database switching is improved, and the resource consumption of the database system is reduced.
  • Embodiment 6 The embodiment of the present invention provides a database system.
  • the database system 5 includes: at least one primary database 51, a standby database 52 corresponding to the primary database, a database access device 53, a switching monitoring device 54, and a device for detecting database data consistency. 5 5.
  • the primary database 5 1 is used to store data that an application needs to access.
  • the standby database 52 when the primary database fails, provides data for the application by the standby database.
  • the database accessing device 5 3 is configured to receive an access request of the application to the primary database or the standby database, and obtain corresponding data from the primary database or the standby database according to the access request.
  • the switching monitoring device 54 is configured to monitor whether the primary database and the standby database are switched, and after the primary database and the standby database are switched, notify the device that detects database data consistency to perform data consistency processing.
  • the device 55 is configured to: when the application performs an update operation on the accessed data table by using the database access device, update the first update identifier; when the primary database After the synchronization with the standby database 5 2, the second update identifier is updated; and after the switching monitoring device 54 monitors that the primary database 51 and the standby database 52 are switched, the first update identifier and the second update are obtained.
  • the device 55 can directly access the standby database 52 and the cache
  • the data table corresponding to the first data table is subjected to consistency processing, and the consistency processing message may also be sent to the application corresponding to the first data table, so that the corresponding application is in the standby database 52 and the cache
  • the data table corresponding to the first data table is processed consistently.
  • the database access device 5, the switching monitoring device 54, and the device 55 may be integrated on the same hardware, and may be one or more application modules in the database access device, or may be independent devices.
  • the working process between the primary database 5 1 , the standby database 5 2 , the database access device 5 3 , the switching monitoring device 54 , and the device 55 for detecting database data consistency in the database system is as shown in FIG. 7 .
  • Each of the applications registers an identifier of the application with the database access device 539, a name of a data table accessed by the application, and a name of a database storing the data table.
  • the application sends an access request to the database access device 53 to request a data table of the primary database.
  • the database access device 530 receives the access request, and the data table for obtaining the access request from the primary database is sent to the application.
  • the application typically caches data accessed from the primary database into the cache.
  • the application performs a change operation on the accessed data.
  • the application program instructs the device 55 to update a first update identifier of a data table corresponding to the data, where the first update identifier indicates that the data table is in a cache update status.
  • the primary database 5 1 and the standby database 52 are synchronized.
  • the backup database 52 instructs the device 55 to update the second update identifier, the second update identifier indicating an update status of the data table in the standby database.
  • the update status in the above steps 6 06 and 6 07 includes at least one of the following information: information indicating that the data table has been updated and indicating the number of times the data table is updated.
  • the detecting database data consistency device 5 5 stores a first feature table, where the first feature table includes at least an identifier of a corresponding application, a name of a database accessed by the application, and a database accessed by the application. a name of the data table, a first update identifier and a second update identifier of each data table accessed by the application, such that the first update identifier and the second update identifier of each data table are included in the corresponding application In a feature table.
  • the first feature table further includes a third update identifier, where the third update identifier is used to indicate an update status of the data table storing the corresponding data in the primary database 51.
  • the primary database 5 1 may synchronize only the data table in which the third update identifier is changed to the standby database 52, while the second update is The identifier is updated to the third update identifier, thereby increasing the synchronization rate of the primary and secondary databases.
  • the device 55 for detecting database data consistency stores a first feature table and a second feature table, where the first feature table includes at least an identifier of the corresponding application, a name of a database accessed by the application, and a name of each data table in the database accessed by the application, a first update identifier of each data table accessed by the application, the second feature table including at least an identifier of the corresponding application, and a database accessed by the application The name, the name of each data table in the database accessed by the application, and the second update identifier for each data table accessed by the application.
  • the device 55 for detecting database data consistency further stores a third feature table, where the third feature table includes at least a corresponding application. Identifying, a name of a database accessed by the application, a name of each data table in the database accessed by the application, and a third update identifier, the third update identifier being used to indicate that the corresponding data is in the primary database 51 update status.
  • device 55 updates the first update identification and the third update identification in the primary database accordingly.
  • the second update identifier in the second feature table maintains the original state value.
  • the primary database 51 may synchronize only the data whose third update identifier has changed to the standby database 5 2 while updating the second feature table. For the third feature table.
  • the application caches the accessed data to the cache of the database system, and the application accesses the data in the corresponding database by accessing the cached data.
  • the means 55 for detecting database data consistency updates the data table of each corresponding data stored in the first specific table.
  • the first update identifier is used to record the change operation.
  • the device 55 updates the second update identifier to a first update identifier in the first feature table to represent the standby database 52.
  • the data is synchronized with the data of the primary database 5 1 and the data in the cache.
  • the second update identifier maintains the original state value.
  • the means 55 for detecting database data consistency updates the second update identifier.
  • the switching monitoring device 54 monitors that the primary database 5 1 and the standby database 52 are switched. 609. The switching monitoring device 54 notifies the device 55 that detects database data consistency to perform consistency processing of the standby database 52 and the cache data. The switching monitoring device 54 performs unified monitoring and management on the devices of the primary database 51 and the standby database 52. After the primary database 51 fails, the database system switches the primary database 51 and the standby database 52, and the switching monitoring The device 54 monitors the device 55 that detects database data consistency after the master database 5 1 and the standby database 52 are switched. The primary database 51 and the backup database 52 included in the database system are uniformly monitored by the independent switching monitoring device 54. Compared with the database system in the prior art, each application separately monitors the accessed primary database 5 1 and The backup solution 52 performs the technical solution of switching, which can improve the working efficiency of the database system and save system resources.
  • the switching monitoring means 54 When the switching monitoring means 54 detects that the primary database 51 and the standby database 52 are switched, the switching monitoring means 54 notifies the means 55 for detecting database data consistency to perform the consistency processing of the standby database 52 and the cached data.
  • the device 55 for detecting database data consistency performs consistency processing on the standby database 52 and the cached data. Specifically, the device 55 for detecting the consistency of the database data compares the first update identifier and the second update identifier, and obtains a first data table in which the first update identifier and the second update identifier are inconsistent, and the first The first database corresponding to the data table, and the identifier of the application corresponding to the first data table.
  • the device 55 for detecting database data consistency performs consistency processing on the standby database 52 and the data table corresponding to the first data table in the cache.
  • the device 55 for detecting database data consistency will use the standby database 52. Updating the content of the data table corresponding to the first data table in the first database to the The content of the data table corresponding to the first data table in the first database.
  • the device 55 for detecting database data consistency may also update the content of the data table corresponding to the first data table in the first database in the cache to be the same as in the standby database 5 2 The content of the data table corresponding to the first data table in a database.
  • the device 55 for detecting database data consistency compares the first update identifier and the second update identifier, acquiring a first data table in which the first update identifier and the second update identifier are inconsistent, the first After the first database corresponding to the data table and the identifier of the application corresponding to the first data table, the device 55 for detecting database data consistency may identify the corresponding application to the application corresponding to the first data table. Sending a first data table and a first database corresponding to the first data table. The application performs consistency processing on the standby database and the data table corresponding to the first data table in the cache to synchronize the data in the standby database 52 with the cache.
  • the application updates the content of the data table corresponding to the first data table in the first database in the standby database 52 to the first data table in the first database in the cache.
  • the application may also update the content of the data table corresponding to the first data table in the first database in the cache to the first data in the standby database 52 and the first database.
  • An embodiment of the present invention provides a database system, where each application registers an identifier of the application, a name of a data table accessed by the application, and a name of a database storing the data table to the database access device.
  • the device for detecting database data consistency updates a first update identifier of the data table corresponding to the data, when the primary database and the standby database are synchronized And the device for detecting database data consistency updates the second update identifier; when the switch monitoring device monitors the primary database and the standby database switching, notifying the device that detects database data consistency to perform standby database and cache Consistency processing of data; comparison of devices for detecting database data consistency And acquiring, by the first update identifier and the second update identifier, a first data table in which the first update identifier and the second update identifier are inconsistent, a first database corresponding to the first data table, and the first data table The identifier of the application is detected; the device for detecting database data consistency performs consistency processing on the data table corresponding to the first data table in the standby database and the cache.
  • the device that detects the consistency of the database data only compares the first update identifier and the second update identifier of the data accessed by the application, and does not need to sequentially perform all the data in the database.
  • the efficiency of the database system to handle database switching is improved, and the resource consumption of the database system is reduced.
  • the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as the cells may or may not be physical. Units can be located in one place, or they can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • connection relationship between the modules indicates that there is a communication connection between them, and specifically may be implemented as one or more communication buses or signal lines.
  • the present invention can be implemented by means of software plus necessary general hardware, and of course, it can also include dedicated integrated circuit, dedicated CP U, dedicated memory through dedicated hardware. , special components and so on.
  • functions performed by computer programs can be easily implemented with the corresponding hardware.
  • the specific hardware structure used to implement the same function can be various, such as analog circuits, digital circuits, or dedicated circuits. Circuits, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明实施例公开了一种检测数据库数据一致性的方法、装置及数据库系统,能够提高数据库系统处理数据库倒换的效率、减小数据库系统对资源的消耗。该方法包括:所述数据库系统更新每个应用程序访问的所述主数据库的数据表的第一更新标识和第二更新标识;在所述主数据库和备用数据库进行倒换后,所述数据库系统将每个所述数据表的第一更新标识和第二更新标识进行比较,获得第一更新标识和第二更新标识不一致的第一数据表;所述数据库系统对所述备用数据库和缓存中的与所述第一数据表对应的数据表进行一致性处理,以使得所述备用数据库和缓存中的数据同步。本发明适用于计算机应用领域。

Description

一种检测数据库数据一致性的方法、 装置及数据库系统 本申请要求于 2 0 1 2年 1 1月 1 日 提交中 国 专利局、 申请号为 2 0 1 2 1 04 3 0 7 5 8 . X , 发明名称为 "一种检测数据库数据一致性的方法、 装置及数据库系统" 的中国专利申请的优先权, 其全部内容通过引 用结合在本申请中。
技术领域
本发明涉及计算机应用领域,尤其涉及一种检测数据库数据一 致性的方法、 装置及数据库系统。
背景技术
对于大型且可靠性要求高的数据库系统,为了保证系统的正常 运行, 数据库系统釆用建立主、 备两套数据库的方式。 同时, 为了 保证数据库访问的效率,数据库系统会緩存数据库中的数据以实现 数据的快速访问, 并且緩存数据与数据库实时保持一致。 在数据库系统运行过程中,主数据库和备用数据库进行周期或 者实时的数据同步, 但是, 由于网络不稳定或者延时等原因, 难以 保证主数据库和备用数据库的一致性。 当主数据库失效, 由备用数 据库接管数据提供数据服务, 但是, 由于主数据库和备用数据库的 不一致性, 使得数据库系统不能正常运行。
现有技术中, 为了保证数据库系统的正常运行, 数据库系统的 每个应用程序独立检测主数据库和备用数据库的倒换,并在每个应 用程序检测到主数据库和备用数据库倒换后,每个应用程序都将该 应用程序对应的内存中的多份緩存数据与备用数据库中对应的数 据进行比较, 并将不一致的数据持久化到备份数据库中。 这样的处 理方式,没有统一的检测主数据库和备用数据库倒换的方法,同时, 每个应用程序将该应用程序对应的所有緩存数据与备用数据库中 对应的数据进行比较, 使得数据库系统处理数据库倒换耗时长、 效 率低, 并且对资源的消耗较大。 发明内容
本发明的实施例提供一种检测数据库数据一致性的方法、装置 及数据库系统, 可以提高数据库系统处理数据库倒换的效率、 减少 数据库系统对资源的消耗。 为达到上述目 的, 本发明的实施例釆用如下技术方案:
一方面, 提供了一种检测数据库数据一致性的方法, 该方法应 用于数据库系统,该数据库系统至少包括一个主数据库和与所述主 数据库对应的备用数据库, 所述数据库被至少一个应用程序访问, 该方法包括所述数据库系统更新每个应用程序访问的所述主数据 库的数据表的第一更新标识和第二更新标识,所述第一更新标识指 示与所述数据表对应的緩存中的数据表的更新状态,所述第二更新 标识指示与所述数据表对应的备用数据库中的数据表的更新状态; 在所述主数据库与备用数据库进行倒换后,将每个所述数据表的第 一更新标识和第二更新标识进行比较,获得第一更新标识和第二更 新标识不一致的第一数据表;对所述备用数据库和緩存中的与所述 第一数据表对应的数据表进行一致性处理,以使得所述备用数据库 和緩存中的数据同步。
第二方面,本发明实施例提供了一种检测数据库数据一致性的 装置, 该装置包括更新单元、获取单元和处理单元; 所述更新单元, 用于更新每个应用程序访问的所述主数据库的数据表的第一更新 标识和第二更新标识,所述第一更新标识指示与所述数据表对应的 緩存中的数据表的更新状态,所述第二更新标识指示与所述数据表 对应的备用数据库中的数据表的更新状态; 所述获取单元, 用于在 所述主数据库与备用数据库进行倒换后,将每个所述数据表的第一 更新标识和第二更新标识进行比较,获得第一更新标识和第二更新 标识不一致的第一数据表; 所述处理单元, 用于对所述备用数据库 和緩存中的与所述第一数据表对应的数据表进行一致性处理,以使 得所述备用数据库和緩存中的数据同步。 第三方面, 本发明实施例提供了一种数据库系统, 所述数据库 系统包括:至少一个主数据库、与所述主数据库对应的备用数据库、 数据库访问装置、 倒换监控装置和检测数据库数据一致性的装置; 所述主数据库, 用于存储应用程序需要访问的数据; 所述备用数据 库, 用于当所述主数据库失效时, 由所述备用数据库为所述应用程 序提供数据; 所述数据库访问装置, 用于接收所述应用程序对所述 主数据库或所述备用数据库的访问请求,根据所述访问请求从所述 主数据库或所述备用数据库中获取对应的数据; 所述倒换监控装 置, 用于监控所述主数据库与备用数据库是否倒换, 并在所述主数 据库与备用数据库倒换后,通知所述检测数据库数据一致性的装置 进行数据一致性处理; 所述检测数据库数据一致性的装置, 用于更 新每个应用程序访问的所述主数据库的数据表的第一更新标识和 第二更新标识,所述第一更新标识指示与所述数据表对应的緩存中 的数据表的更新状态,所述第二更新标识指示与所述数据表对应的 备用数据库中的数据表的更新状态;所述检测数据库数据一致' 1·生的 装置,还用于在所述倒换监控装置监控到所述主数据库与备用数据 库进行倒换后,将每个所述数据表的第一更新标识和第二更新标识 进行比较, 获得第一更新标识和第二更新标识不一致的第一数据 表; 所述检测数据库数据一致性的装置, 还用于对所述备用数据库 和緩存中的与所述第一数据表对应的数据表进行一致性处理,以使 得所述备用数据库和緩存中的数据同步。 可见, 本发明实施例提供一种检测数据库一致性的方法、 装置 及数据库系统, 该方法具体包括: 所述数据库系统更新每个应用程 序访问的所述主数据库的数据表的第一更新标识和第二更新标识, 在所述主数据库与备用数据库进行倒换后,所述数据库系统将每个 所述数据表的第一更新标识和第二更新标识进行比较,获得第一更 新标识和第二更新标识不一致的第一数据表,并对所述备用数据库 和緩存中的与所述第一数据表对应的数据表进行一致性处理,以使 得所述备用数据库和緩存中的数据同步。在主数据库和备用数据库 倒换后, 由于该数据库系统只对应用程序访问的数据的第一更新标 识和第二更新标识进行比较检测,而不需要对数据库中的所有数据 依次进行比较, 从而, 提高了数据库系统处理数据库倒换的效率、 减小了数据库系统对资源的消耗。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下 面将对实施例或现有技术描述中所需要使用的附图作简单地介绍, 显而易见地, 下面描述中的附图仅仅是本发明的一些实施例, 对于 本领域普通技术人员来讲, 在不付出创造性劳动的前提下, 还可以 根据这些附图获得其他的附图。
图 1 为本发明实施例提供的一种检测数据库数据一致性的方 法流程示意图;
图 2 为本发明实施例提供的另一种检测数据库数据一致性的 方法流程示意图;
图 3 为本发明实施例提供的另一种检测数据库数据一致性的 方法流程示意图;
图 4 为本发明实施例提供的一种检测数据库数据一致性的装 置结构示意图;
图 5 为本发明实施例提供的另一种检测数据库数据一致性的 装置结构示意图;
图 6为本发明实施例提供的一种数据库系统的结构示意图; 图 7 为本发明实施例提供的一种数据库系统检测数据库数据 一致性的交互示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术 方案进行清楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明 一部分实施例, 而不是全部的实施例。 基于本发明中的实施例, 本 领域普通技术人员在没有做出创造性劳动前提下所获得的所有其 他实施例, 都属于本发明保护的范围。 实施例一、 本发明实施例提供一种检测数据库数据一致性的方法,该方法 应用于数据库系统,该数据库系统的数据库至少包括一个主数据库 和所述主数据库对应的备用数据库,所述数据库被至少一个应用程 序访问。 所述每个应用程序在运行时需要访问主数据库中数据表, 为了提高应用程序的处理速度,所述应用程序通常将要访问主数据 库中的数据表预先緩存在运行所述应用程序的装置的緩存中。为了 保证系统正常运行,所述数据库中的数据应当与所述緩存数据保持 实时一致。 例如, 在主数据库和备用数据库未倒换时, 緩存中的数 据实时的与主数据库数据保持一致。所述主数据库也会周期或实时 的将主数据库的数据发送给备用数据库,以使得主数据库与备用数 据库的数据进行同步,但是由于网络不稳定或延迟不能保证主数据 库和备用数据库数据完全实时同步,这样在主数据库和备用数据库 倒换后, 为了保证系统正常运行, 需要对数据库数据的一致性进行 检测, 使得緩存数据与备用数据库的数据保持一致。 具体的如图 1 所示, 该方法具体包括:
1 01、 更新每个应用程序访问的所述主数据库的数据表的第一 更新标识和第二更新标识,所述第一更新标识指示与所述数据表对 应的緩存中的数据表的更新状态,所述第二更新标识指示与所述数 据表对应的备用数据库中的数据表的更新状态。 所述更新状态包括以下信息中的至少一种信息:指示该数据表 已更新的信息和指示该数据表被更新的次数。 当所述应用程序在緩存中对访问的主数据库中的数据进行更 改操作时,所述数据表的第一更新标识会根据对应的更改操作来改 变,用以记录此次的更改操作。所述更改操作可以是对数据的删除、 增加等操作, 但不包括对数据的查询操作。 在所述备用数据库与主 数据库数据同步之后, 所述第二更新标识更新为所述第一更新标 识, 用以表示所述备用数据库的数据和主数据库的数据、 緩存中的 数据保持同步的状态。 在所述备用数据库与主数据库没有同步时, 所述第二更新标识维持原有的状态值。
1 02、 在所述主数据库和备用数据库进行倒换后, 将所述每个 数据表的第一更新标识和第二更新标识进行比较,获得第一更新标 识和第二更新标识不一致的第一数据表。 所述数据库系统可以对所述主数据库和备用数据库进行倒换 监控。 当所述数据库系统检测到所述主数据库和所述备用数据库倒 换后,所述数据库系统将所述每个数据表的第一更新标识和第二更 新标识进行比较,获得所述第一更新标识和第二更新标识不一致的 第一数据表。所述第一数据表为緩存与备用数据库中数据不一致的 数据表,所述数据库系统需要对緩存与备用数据库中的第一数据表 对应的数据表进行一致性处理。
1 0 3、 对所述备用数据库和緩存中的与所述第一数据表对应的 数据表进行一致性处理,以使得所述备用数据库和緩存中的数据同 步。
可见, 本发明实施例提供一种检测数据库数据一致性的方法, 所述数据库系统更新每个应用程序访问的所述主数据库的数据表 的第一更新标识和第二更新标识,在所述主数据库与备用数据库进 行倒换后,所述数据库系统将每个所述数据表的第一更新标识和第 二更新标识进行比较,获得第一更新标识和第二更新标识不一致的 第一数据表,并对所述备用数据库和緩存中的与所述第一数据表对 应的数据表进行一致性处理,以使得所述备用数据库和緩存中的数 据同步。 这样在主数据库和备用数据库倒换后, 由于该数据库系统 只对应用程序访问的数据的第一更新标识和第二更新标识进行比 较检测, 而不需要对数据库中的所有数据依次进行比较, 从而, 提 高了数据库系统处理数据库倒换的效率、减小了数据库系统对资源 的消耗。 实施例二、 本发明实施例提供一种检测数据库一致性的方法,该方法应用 于数据库系统。所述每个应用程序向所述数据库系统注册应用程序 的标识、 该应用程序需要访问的数据库的名称、 该应用程序需要访 问的每个数据库中的数据表的名称。所述数据库系统中存储有每个 应用程序对应的第一特征表,所述第一特征表至少包括对应的应用 程序的标识、 该应用程序访问的数据库的名称、 该应用程序访问的 数据库中每个数据表的名称、该应用程序访问的每个数据表的第一 更新标识和第二更新标识,这样每个数据表的所述第一更新标识和 第二更新标识包含于对应的应用程序的第一特征表中。每个应用程 序运行时,应用程序将访问的数据緩存到运行所述应用程序的装置 的緩存中,应用程序访问对应数据库中数据是通过访问緩存数据来 实现的。如图 2所示,所述检测数据库数据一致性的方法具体包括:
2 0 1、 更新每个应用程序访问的所述主数据库的数据表的第一 更新标识和第二更新标识,所述第一更新标识指示与所述数据表对 应的緩存中的数据表的更新状态,所述第二更新标识指示与所述数 据表对应的备用数据库中的数据表的更新状态。 所述更新状态包括以下信息中的至少一种信息:指示该数据表 已更新的信息和指示该数据表被更新的次数。 当所述应用程序在緩存中对访问的主数据库中的数据进行更 改操作时,所述第一特定表中对应的每个数据的数据表的第一更新 标识会根据对应的更改操作来改变, 用以记录此次的更改操作。 所 述更改操作可以是对数据的删除、 增加等操作, 但不包括对数据的 查询操作。 在所述备用数据库与主数据库数据同步之后, 所述第一 特征表中的第二更新标识更新为所述第一特征表中的第一更新标 识, 用以表示所述备用数据库的数据和主数据库的数据、 緩存中的 数据保持同步的状态。 在所述备用数据库与主数据库没有同步时, 所述第一特征表中的第二更新标识维持原有的状态值。 可选的, 所述第一特征表中还可以包括有第三更新标识, 所述 第三更新标识用于指示对应数据的数据表在所述主数据库中的更 新状态。 这样在主数据库和备用数据库同步时, 所述主数据库可以 仅将所述第三更新标识发生变化的数据表同步到所述备用数据库 即可, 同时将所述第二更新标识更新为第三更新标识, 从而提高了 主备数据库的同步速率。
2 02、 在所述主数据库和备用数据库进行倒换后, 对每个应用 程序的第一特征表的第一更新标识和第二更新标识进行比较,获得 第一更新标识和第二更新标识不一致的数据表的名称为第一数据 表, 以及存储该第一数据表的数据库的名称为第一数据库。 所述数据库系统可以对所述主数据库和备用数据库进行监控。 所述数据库系统对所述主数据库和所述备用数据库的倒换监控可 以是数据库系统中的一个监控应用程序,也可以是一个独立的监控 装置。 所述监控应用程序或监控装置对主数据库和备用数据库的设 备进行统一监控管理, 当主数据库出现故障, 所述数据库系统对所 述主数据库和备用数据库进行切换后,所述监控应用程序或监控装 置监控到所述主数据库和备用数据库切换后,会通知所述数据库系 统和应用程序。 釆用独立的监控应用程序或监控装置对该数据库系统包括的 主数据库和备份数据库统一进行监控,相比较于现有技术中的数据 库系统中,每个应用程序分别监控访问的主数据库和备份数据库进 行倒换的技术方案, 能够提高该数据库系统的工作效率, 节省系统 资源。 当所述数据库系统监测到所述主数据库和备用数据库倒换后, 所述数据库系统将所述第一特定表中的每个数据表对应的第一更 新标识和第二更新标识进行比较, 获得第一数据表, 所述第一数据 表为第一特定表中的第一更新标识和第二更新标识不一致的数据 表的名称。所述第一数据表为緩存中与备用数据库中数据不一致的 数据表,所述数据库系统需要进行緩存和备用数据库中的第一数据 表对应的数据表进行一致性处理。
2 03、 对所述第一数据库对应的第一备用数据库中与所述第一 数据表对应的数据表和所述第一数据库对应的緩存中的与所述第 一数据表对应的数据表进行一致性处理。 当然,不同数据库系统对所述第一备用数据库和緩存中的第一 数据表对应的数据表进行一致性处理的原则有所不同。 当对所述第一备用数据库和緩存中的第一数据表对应的数据 表进行一致性处理是由所述数据库系统进行时,所述数据库系统可 以根据获得的所述第一数据表以及所述第一数据库,可以将所述第 一备用数据库的第一数据表对应的数据表的内容更新为所述緩存 中的第一数据表对应的数据表的内容; 当然所述数据库系统也可以 将所述緩存中的第一数据表对应的数据表的内容更新为所述第一 备用数据库中的第一数据表对应的数据表的内容, 当然, 也可以以 其他方式对所述第一数据表对应的数据表进行处理,本发明实施例 在此不作具体限定。 可选的, 当对所述第一备用数据库和緩存中的第一数据表对应 的数据表进行一致性处理是由数据库系统中访问该第一数据表对 应的应用程序处理的,所述数据库系统向访问所述第一数据表的每 个应用程序发送一致性处理消息,所述一致性处理消息包括所述第 一数据表以及所述第一数据库的信息。
所述对应的应用程序接收到所述一致性处理消息后,对所述第 一备用数据库中和所述緩存中的第一数据表对应的数据表进行一 致性处理。 对于不同的数据库系统, 所述一致性处理有所不同。 具体处理 过程可以参见上述数据库系统对所述第一备用数据库和緩存中的 第一数据表对应的数据表进行一致性处理的过程, 当然本发明实施 例仅是示例性的说明, 对此并不作具体限定。 可见, 本发明实施例提供一种检测数据库数据一致性的方法, 所述数据库系统更新每个应用程序访问的所述主数据库的数据表 的第一更新标识和第二更新标识,若所述数据库系统检测到所述主 数据库和备用数据库进行倒换,所述数据库系统将所述每个数据表 的第一更新标识和第二更新标识进行比较,获得第一更新标识和第 二更新标识不一致的第一数据表,并对所述备用数据库和緩存中的 第一数据表对应的数据表进行一致性处理,以使得所述备用数据库 和緩存中的数据同步。 这样在主数据库和备用数据库倒换后, 由于 该数据库系统只对应用程序访问的数据的第一更新标识和第二更 新标识进行比较检测,而不需要对数据库中的所有数据依次进行比 较, 从而, 提高了数据库系统处理数据库倒换的效率、 减小了数据 库系统对资源的消耗。 实施例三、 本发明实施例提供了一种检测数据库数据一致性的方法,该方 法应用于数据库系统。所述每个应用程序向所述数据库系统注册应 用程序的标识、 该应用程序需要访问的数据库的名称、 该应用程序 需要访问的每个数据库中的数据表的名称。所述数据库系统中存储 有每个应用程序对应的第一特征表和第二特征表,所述第一特征表 至少包括对应的应用程序的标识、 该应用程序访问的数据库的名 称、 该应用程序访问的数据库中每个数据表的名称、 该应用程序访 问的每个数据表的第一更新标识,所述第二特征表至少包括对应的 应用程序的标识、 该应用程序访问的数据库的名称、 该应用程序访 问的数据库中每个数据表的名称和该应用程序访问的每个数据表 的第二更新标识。 每个应用程序运行时, 应用程序通常将访问的数 据緩存到运行所述应用程序的装置的緩存中,应用程序访问对应数 据库中数据是通过访问緩存数据来实现的。 如图 3所示, 所述检测 数据库数据一致性的方法具体包括:
3 0 1、 更新每个应用程序访问的所述主数据库的数据表的第一 更新标识和第二更新标识,所述第一更新标识指示与所述数据表对 应的緩存中的数据表的更新状态,所述第二更新标识指示与所述数 据表对应的备用数据库中的数据表的更新状态。 所述更新状态包括以下信息中的至少一种信息:指示该数据表 已更新的信息和指示该数据表被更新的次数。 在当所述应用程序在緩存中对访问的主数据库中的数据进行 更改操作时,所述第一特征表中对应的数据表的第一更新标识会根 据对应的更改操作来改变, 用以记录此次的更改操作。 所述更改操 作可以是对数据的删除、 增加等更改操作, 但不包括对数据的查询 操作。 在所述备用数据库与主数据库数据同步之后, 所述第二特征 表中的第二更新标识更新为所述第一特征表中的第一更新标识,用 以表示所述备用数据库的数据和主数据库的数据、緩存中的数据保 持同步的状态。 在所述备用数据库与主数据库没有同步时, 所述第 二特征表中的第二更新标识维持原有的状态值。 可选的, 为了更方便主数据库和备用数据库进行数据同步, 所 述数据库系统还可以建立第三特征表,所述第三特征表至少包括对 应的应用程序的标识、 该应用程序访问的数据库的名称、 该应用程 序访问的数据库中每个数据表的名称和该应用程序访问的每个数 据表的第三更新标识。所述第三更新标识用于指示对应数据表在所 述主数据库中的更新状态。所述第三特征表也可以存储在所述数据 库系统中。 当每个应用程序更改对应的緩存中的数据时, 数据库系 统相应的更新第一更新标识和第三更新标识。 当所述备用数据库与 主数据库没有同步时,所述第二特征表中的第二更新标识维持原有 的状态值。 当备用数据库与主数据库同步时, 所述数据库系统可以 仅将所述第三更新标识发生变化的数据同步到所述备用数据库即 可, 同时将第二特征表更新为第三特征表。 需要说明的是, 在该数据库系统中, 若执行所述检测数据库数 据一致性的方法的装置、 所述运行应用程序的装置、 主数据库和备 用数据库分别为独立的装置中, 所述第一特征表、 第二特征表和第 三特征表可以存储在所述运行应用程序的装置或所述执行所述检 测数据库数据一致性的方法的装置中。 当然第二特征表还可以直接 存储在所述备用数据库中,所述第三特征表还可以存储在所述主数 据库中。 这样, 在所述第二特征表存储在所述备用数据库中, 所述第三 特征表存储在所述主数据库中时, 当备用数据库与主数据库同步 时,所述数据库系统可以仅将所述主数据库中的第三特征表中的所 述第三更新标识发生变化的数据同步到所述备用数据库即可, 同时 将第二特征表更新为第三特征表。
302、 若所述主数据库和备用数据库进行倒换后, 根据所述每 个应用程序第一特征表和第二特征表,对每个应用程序访问的数据 表的第一更新标识和第二更新标识进行比较,获得第一更新标识和 第二更新标识不一致的数据表的名称为第一数据表,以及存储该第 一数据表的数据库的名称为第一数据库。 所述数据库系统对所述主数据库和备用数据库进行监控。所述 数据库系统对所述主数据库和所述备用数据库的倒换监控可以是 数据库系统中的一个监控应用程序, 也可以是一个独立的监控装 置。 根据不同的数据库系统,主数据库和备用数据库可以建立在同 一设备上, 也可以是不同的独立设备。 所述监控应用程序或监控装置对主数据库和备用数据库的设 备进行统一监控管理, 当主数据库出现故障, 所述数据库系统对所 述主数据库和备用数据库进行切换后,所述监控应用程序或监控装 置监控到所述主数据库和备用数据库切换后,会通知所述数据库系 统 釆用独立的监控应用程序或监控装置对该数据库系统包括的 主数据库和备份数据库统一进行监控,相比较于现有技术中的数据 库系统中,每个应用程序分别监控访问的主数据库和备份数据库进 行倒换的技术方案, 能够提高该数据库系统的工作效率, 节省系统 资源。
当所述数据库系统监测到所述主数据库和备用数据库倒换后, 所述数据库系统将所述第一特定表中的每个数据表对应的第一更 新标识和第二特定表中的第二更新标识进行比较,获得所述第一特 定表中的第一更新标识和第二特征表中的第二更新标识不一致的 第一数据表。所述第一数据表为緩存与备用数据库数据不一致的数 据表对应的所述主数据库的数据表,所述数据库系统需要对緩存和 备用数据库中的第一数据表对应的数据表进行一致性处理。
当然, 当所述第二特征表存储在备用数据库中时, 在所述数据 库系统中的根据所述每个应用程序第一特征表和第二特征表,对每 个应用程序访问的数据表的第一更新标识和第二更新标识进行比 较之前, 还需要从备用数据库中获取所述第二特征表。
303、 对所述第一数据库对应的第一备用数据库中与所述第一 数据表对应的数据表和所述第一数据库对应的緩存中的与所述第 一数据表对应的数据表进行一致性处理。 当然,不同数据库系统对所述第一备用数据库和緩存中的第一 数据表对应的数据表进行一致性处理的原则有所不同。
当对所述第一备用数据库和緩存中的第一数据表对应的数据 表进行一致性处理是由所述数据库系统进行时,所述数据库系统可 以根据获得的所述第一数据表以及所述第一数据库,可以将所述第 一备用数据库的第一数据表对应的数据表的内容更新为所述緩存 中的第一数据表对应的数据表的内容;也可以将所述緩存中的第一 数据表对应的数据表的内容更新为所述第一备用数据库中的第一 数据表对应的数据表的内容, 当然, 也可以以其他方式对所述第一 数据表对应的数据表进行处理, 本发明实施例在此不作具体限定。
可选的, 当对所述第一备用数据库和緩存中的第一数据表对应 的数据表进行一致性处理是由数据库系统中访问该第一数据表对 应的应用程序处理的,所述数据库系统向访问所述第一数据表的每 个应用程序发送一致性处理消息,所述一致性处理消息包括所述第 一数据表以及所述第一数据库的信息。
所述对应的应用程序接收到所述一致性处理消息后,对所述第 一备用数据库中和所述緩存中的第一数据表对应的数据表进行一 致性处理。 对于不同的数据库系统, 所述一致性处理有所不同。 具体处理 过程参见上述数据库系统对所述第一备用数据库和緩存中的第一 数据表对应的数据表进行一致性处理的过程, 当然本发明实施例仅 是示例性的说明, 对此并不作具体限定。 本发明实施例提供一种检测数据库数据一致性的方法,所述数 据库系统更新每个应用程序访问的所述主数据库的数据表的第一 更新标识和第二更新标识,在所述数据库系统检测到所述主数据库 和备用数据库进行倒换后,所述数据库系统将所述每个数据表的第 一更新标识和第二更新标识进行比较,获得第一更新标识和第二更 新标识不一致的第一数据表,并对所述备用数据库和緩存中的第一 数据表对应的数据表进行一致性处理,以使得所述备用数据库和緩 存中的数据同步。 这样在主数据库和备用数据库倒换后, 由于该数 据库系统只对应用程序访问的数据的第一更新标识和第二更新标 识进行比较检测, 而不需要对数据库中的所有数据依次进行比较, 从而, 提高了数据库系统处理数据库倒换的效率、 减小了数据库系 统对资源的消耗。
实施例四、 本发明实施例提供一种检测数据库数据一致性的装置, 如图 4 所示,该装置用于检测至少一个主数据库和所述主数据库对应的备 用数据库的数据一致性, 所述主数据库被至少一个应用程序访问。 所述每个应用程序在运行时需要访问主数据库中数据表,为了提高 应用程序的处理速度,所述应用程序将要访问主数据库中的数据表 预先緩存在运行所述应用程序的装置的緩存中。为了保证系统正常 运行, 所述数据库中的数据应当与所述緩存数据保持实时一致。 例 如, 在主数据库和备用数据库未倒换时, 緩存数据实时的与主数据 库数据保持一致。所述主数据库也会周期或实时的将主数据库的数 据发送给备用数据库,以使得主数据库与备用数据库的数据进行同 步, 但是由于网络不稳定或延迟不能保证主数据库、 备用数据库数 据完全实时同步, 这样在主数据库和备用数据库倒换后, 为了保证 系统正常运行, 需要对数据库数据的一致性进行检测, 使得緩存数 据与备用数据库的数据保持一致。 具体的, 该装置 4 0 包括: 更新 单元 4 1、 获取单元 4 2和处理单元 4 3。 所述更新单元 4 1 , 用于更新每个应用程序访问的所述主数据 库的数据表的第一更新标识和第二更新标识,所述第一更新标识指 示与所述数据表对应的緩存中的数据表的更新状态,所述第二更新 标识指示与所述数据表对应的备用数据库中的数据表的更新状态。 所述更新状态包括以下信息中的至少一种信息:指示该数据表 已更新的信息和指示该数据表被更新的次数。
在所述应用程序在緩存中对访问的主数据库中的数据进行更 改操作时, 所述更新单元 4 1 更新对应数据的数据表的第一更新标 识,用以记录此次的更改操作。所述更改操作可以是对数据的删除、 增加等操作, 但不包括对数据的查询操作。 在所述备用数据库与主 数据库数据同步之后, 所述更新单元 4 1 将所述第二更新标识更新 为所述第一更新标识,用以表示所述备用数据库的数据和主数据库 的数据、 緩存中的数据保持同步的状态。 在所述备用数据库与主数 据库没有同步时, 所述第二更新标识维持原有的状态值。 根据不同的数据库系统,主数据库和备用数据库可以建立在同 一设备上, 也可以是不同的独立设备。 所述监控应用程序或监控装置对主数据库和备用数据库的设 备进行统一监控管理, 当主数据库出现故障, 所述数据库系统对所 述主数据库和备用数据库进行切换后,所述监控应用程序或监控装 置监控到所述主数据库和备用数据库切换后,会通知所述数据库系 统。
釆用独立的监控应用程序或监控装置对该数据库系统包括的 主数据库和备份数据库统一进行监控,相比较于现有技术中的数据 库系统中,每个应用程序分别监控访问的主数据库和备份数据库进 行倒换的技术方案, 能够提高该数据库系统的工作效率, 节省系统 资源。
所述获取单元 4 2 , 用于在所述主数据库和备用数据库进行倒 换后, 将所述每个数据表的第一更新标识和第二更新标识进行比 较, 获得第一更新标识和第二更新标识不一致的第一数据表。 在所述主数据库和所述备用数据库倒换后, 所述获取单元 42 将所述每个数据表的第一更新标识和第二更新标识进行比较,获得 所述第一更新标识和第二更新标识不一致的第一数据表。所述第一 数据表为緩存中与备用数据库中数据不一致的数据表对应的所述 主数据库的数据表, 所述处理单元 4 3 需要对緩存和备用数据库中 的第一数据表对应的数据表进行一致性处理。
所述处理单元 4 3 , 用于对所述备用数据库和緩存中与所述第 一数据表对应的数据表进行一致性处理,以使得所述备用数据库和 緩存中的数据同步。
根据不同数据库系统的一致性处理的原则不同,所述处理单元 4 3 , 可以具体用于将所述备用数据库中的第一数据表对应的数据表 的内容更新为所述緩存中的第一数据表的内容。 所述处理单元 4 3 , 还可以具体用于将所述緩存中的第一数据 表对应的数据表的内容更新为所述备用数据库中的第一数据表的 内容。
可选的,每个数据表的所述第一更新标识和第二更新标识包含 于与应用程序对应的第一特征表中,所述第一特征表至少包括所述 应用程序的标识、 所述应用程序访问的主数据库的名称、 所述应用 程序访问的主数据库中的每个数据表的名称、所述应用程序访问的 每个数据表的第一更新标识和第二更新标识; 所述装置 4 0还包括 存储单元 44。 所述存储单元 44 , 用于存储所述第一特征表。 此时,当所述应用程序在緩存中对访问的主数据库中的数据进 行更改操作时, 所述更新单元 4 1 更新第一特定表中对应的每个数 据表的第一更新标识, 用以记录此次的更改操作。 所述更改操作可 以是对数据的删除、 增加等操作, 但不包括对数据的查询操作。 在 所述备用数据库与主数据库数据同步之后, 所述更新单元 4 1 将所 述第一特征表中的第二更新标识更新为所述第一更新标识,用以表 示所述备用数据库的数据和主数据库的数据、緩存中的数据保持同 步的状态。 在所述备用数据库与主数据库没有同步时, 所述第一特 征表中的第二更新标识维持原有的状态值。 可选的, 所述第一特征表中还包括有第三更新标识, 所述第三 更新标识用于指示对应数据的数据表在所述主数据库中的更新状 态。 这样在主数据库和备用数据库同步时, 所述主数据库可以仅将 所述第三更新标识发生变化的数据表同步到所述备用数据库即可, 同时将所述第二更新标识更新为第三更新标识,从能提高了主备数 据库的同步速率。
所述获取单元 4 2 , 具体用于在所述主数据库和备用数据库倒 换后, 根据所述每个应用程序第一特征表和第二特征表, 对每个应 用程序访问的数据表的第一更新标识和第二更新标识进行比较,获 得第一更新标识和第二更新标识不一致的数据表的名称为第一数 据表, 以及存储该第一数据表的数据库的名称为第一数据库。 在所述主数据库和备用数据库倒换后, 所述获取单元 42将所 述第一特定表中的每个数据表对应的第一更新标识和第二更新标 识进行比较, 获得第一数据表, 所述第一数据表为第一特定表中的 第一更新标识和第二更新标识不一致的数据表的名称。所述第一数 据表为緩存中与备用数据库中数据不一致的数据表,所述处理单元 4 3 需要进行緩存和备用数据库中的第一数据表对应的数据表进行 一致性处理。 所述处理单元 4 3 , 具体用于对所述第一数据库对应的第一备 用数据库中与所述第一数据表对应的数据表和所述第一数据库对 应的緩存中的与所述第一数据表对应的数据表进行一致性处理。 当然, 不同的数据库系统一致性处理原则有所不同。 具体的处 理过程参见实施例二所述的描述, 本发明实施例在此不再赘述。 可选的,所述第一更新标识和第二更新标识分别包含于与应用 程序对应的第一特征表和第二特征表中,所述第一特征表至少包括 所述应用程序的标识、 所述应用程序访问的主数据库的名称、 所述 应用程序访问的主数据库中的每个数据表的名称和所述应用程序 访问的每个数据表的第一更新标识,所述第二特征表至少包括所述 应用程序的标识、 所述应用程序访问的主数据库的名称、 所述应用 程序访问的主数据库中的每个数据表的名称和所述应用程序访问 的每个数据表的第二更新标识。 所述存储单元 44 , 还用于存储所 述第一特征表和第二特征表。
此时,在当所述应用程序在緩存中对访问的主数据库中的数据 进行更改操作时, 所述更新单元 4 1 更新第一特定表中对应的数据 表的第一更新标识, 用以记录此次的更改操作。 所述更改操作可以 是对数据的删除、 增加等操作, 但不包括对数据的查询操作。 在所 述备用数据库与主数据库数据同步之后, 所述更新单元 4 1 将所述 第二特征表中的第二更新标识更新为所述第一特征表中的第一更 新标识, 用以表示所述备用数据库的数据和主数据库的数据、 緩存 中的数据保持同步的状态。在所述备用数据库与主数据库没有同步 时, 所述第二特征表中的第二更新标识维持原有的状态值。 可选的, 为了更方便主数据库和备用数据库进行数据同步, 所 述存储单元 44还存储有第三特征表, 所述第三特征表至少包括对 应的应用程序的标识、 该应用程序访问的数据库的名称、 该应用程 序访问的数据库中每个数据表的名称和该应用程序访问的每个数 据表的第三更新标识。所述第三更新标识用于指示所述每个数据表 在所述主数据库中的更新状态。 当每个应用程序对对应的緩存中的 数据进行更改操作时, 所述更新单元 4 1 更新第一更新标识和第三 更新标识。 当所述备用数据库与主数据库没有同步时, 所述第二特 征表中的第二更新标识维持原有的状态值。 当备用数据库与主数据 库同步时, 所述更新单元 4 1 将第二特征表更新为第三特征表。 所 述获取单元 42 , 具体用于在所述主数据库和备用数据库进行倒换 后, 根据所述每个应用程序第一特征表和第二特征表, 对每个应用 程序访问的数据表的第一更新标识和第二更新标识进行比较,获得 第一更新标识和第二更新标识不一致的数据表的名称为第一数据 表, 以及存储该第一数据表的数据库的名称为第一数据库。 在所述主数据库和备用数据库倒换后, 所述获取单元 42将所 述第一特定表中的每个数据表对应的第一更新标识和第二特定表 中的第二更新标识进行比较,获得所述第一特定表中的第一更新标 识和第二特征表中的第二更新标识不一致的第一数据表。所述第一 数据表为緩存与备用数据库中不一致的数据表对应的所述主数据 库的数据表, 所述处理单元 4 3 需要进行緩存和备用数据库中的第 一数据表对应的数据表进行一致性处理。 所述处理单元 4 3 , 具体用于对所述第一数据库对应的第一备 用数据库中与所述第一数据表对应的数据表和所述第一数据库对 应的緩存中的与所述第一数据表对应的数据表进行一致性处理。 当然, 不同的数据库系统一致性处理原则有所不同。 具体的处 理过程参见实施例三所述的描述, 本发明实施例在此不再赘述。 本发明实施例提供一种检测数据库数据一致性的装置,所述更 新单元更新每个应用程序访问的所述主数据库的数据表的第一更 新标识和第二更新标识, 在所述主数据库和备用数据库进行倒换 后,所述获取单元将所述每个数据表的第一更新标识和第二更新标 识进行比较,获得第一更新标识和第二更新标识不一致的第一数据 表,所述处理单元对所述备用数据库和緩存中的第一数据表对应的 数据表进行一致性处理,以使得所述备用数据库和緩存中的数据同 步。 这样在主数据库和备用数据库倒换后, 由于该获取单元只对应 用程序访问的数据的第一更新标识和第二更新标识进行比较检测, 而不需要对数据库中的所有数据依次进行比较, 从而, 提高了数据 库系统处理数据库倒换的效率、 减小了数据库系统对资源的消耗。 实施例五、 本发明实施例提供一种检测数据库数据一致性的装置, 如图 5 所示, 该装置 70 包括存储器 7 1和处理器 72。 其中, 所述存储器 7 1 至少存储一个主数据库和所述主数据库 对应的备用数据库, 所述数据库被至少一个应用程序访问。 所述每 个应用程序在运行时需要访问主数据库中数据表,为了提高应用程 序的处理速度,所述应用程序将要访问主数据库中的数据表预先緩 存在緩存中。 为了保证系统正常运行, 所述数据库中的数据应当与 所述緩存数据保持实时一致。 例如, 在主数据库和备用数据库未倒 换时, 緩存数据实时的与主数据库数据保持一致。 所述主数据库也 会周期或实时的将主数据库的数据发送给备用数据库,以使得主数 据库与备用数据库的数据进行同步,但是由于网络不稳定或延迟不 能保证主数据库、 备用数据库数据完全实时同步, 这样在主数据库 和备用数据库倒换后, 为了保证系统正常运行, 需要对数据库数据 的一致性进行检测, 使得緩存数据与备用数据库的数据保持一致。 所述处理器 7 2 , 用于更新每个应用程序访问的所述主数据库 的数据表的第一更新标识和第二更新标识,所述第一更新标识指示 与所述数据表对应的緩存中的数据表的更新状态,所述第二更新标 识指示与所述数据表对应的备用数据库中的数据表的更新状态。 所述更新状态包括以下信息中的至少一种信息:指示该数据表 已更新的信息和指示该数据表被更新的次数。 在当所述应用程序要对访问的数据库进行更改操作时,所述处 理器 72 更新对应数据的数据表的第一更新标识, 用以记录此次的 更改操作。 所述更改操作可以是对数据的删除、 增加等操作, 但不 包括对数据的查询操作。在所述备用数据库与主数据库数据同步之 后,所述处理器 72将所述第二更新标识更新为所述第一更新标识, 用以表示所述备用数据库的数据和主数据库的数据、緩存中的数据 保持同步的状态。 在所述备用数据库与主数据库没有同步时, 所述 第二更新标识维持原有的状态值。 根据不同的数据库系统,主数据库和备用数据库可以建立在同 一设备上, 也可以是不同的独立设备。 所述监控应用程序或监控装置对主数据库和备用数据库的设 备进行统一监控管理, 当主数据库出现故障, 所述数据库系统对所 述主数据库和备用数据库进行切换后,所述监控应用程序或监控装 置监控到所述主数据库和备用数据库切换后,会通知所述数据库系 统。 釆用独立的监控应用程序或监控装置对该数据库系统包括的 主数据库和备份数据库统一进行监控,相比较于现有技术中的数据 库系统中,每个应用程序分别监控访问的主数据库和备份数据库进 行倒换的技术方案, 能够提高该数据库系统的工作效率, 节省系统 资源。 所述处理器 72, 还用于在所述主数据库和备用数据库进行倒 换后, 将所述每个数据表的第一更新标识和第二更新标识进行比 较, 获得第一更新标识和第二更新标识不一致的第一数据表。 在所述主数据库和所述备用数据库倒换后, 所述获处理器 72 将所述每个数据表的第一更新标识和第二更新标识进行比较,获得 所述第一更新标识和第二更新标识不一致的第一数据表。所述第一 数据表为緩存中与备用数据库中数据不一致的数据表,所述处理器 72 需要对緩存和备用数据库中的第一数据表对应的数据表进行一 致性处理。 所述处理器 72, 还用于对所述备用数据库和緩存中与所述第 一数据表对应的数据表进行一致性处理,以使得所述备用数据库和 緩存中的数据同步。 根据不同数据库系统的一致性处理的原则不同, 所述处理器 72,可以具体用于将所述备用数据库中的第一数据表的内容更新为 所述緩存中的第一数据表的内容; 或者, 具体用于将所述緩存中的 第一数据表的内容更新为所述备用数据库中的第一数据表的内容。 存储器 71 还用于存储处理器 72 需要执行的程序或处理器 72 执行程序过程中的中间结果等。 需说明的是, 图 5所示存储器 71 与处理器 72直接连接, 在本 发明其它一些实施例中, 存储器 71 与处理器 72 以及该装置 70的 其它模块还可以通过总线进行连接, 该总线可以是 ISA ( Industry Standard Architecture , 工 业 标 准体 系 结 构 ) 总 线 、 PCI ( Peripheral Component , 夕卜部设备互连 ) 总线或 EISA ( Extended Industry Standard Architecture, 扩展工业标准体系结构) 总线 等。 所述总线可以是一条或多条物理线路, 当是多条物理线路时可 以分为地址总线、 数据总线、 控制总线等。 另外, 对于本领域普通技术人员而言, 处理器 72和存储器 71 的具体实现可以参考前述实施例所述, 在此不再赘述。 可见, 本发明实施例提供一种检测数据库数据一致性的装置, 所述处理器更新每个应用程序访问的所述主数据库的数据表的第 一更新标识和第二更新标识,在所述主数据库和备用数据库进行倒 换后,所述处理器将所述每个数据表的第一更新标识和第二更新标 识进行比较,获得第一更新标识和第二更新标识不一致的第一数据 表,所述处理器对所述备用数据库和緩存中的第一数据表对应的数 据表进行一致性处理, 以使得所述备用数据库和緩存中的数据同 步。 这样在主数据库和备用数据库倒换后, 由于该获取单元只对应 用程序访问的数据的第一更新标识和第二更新标识进行比较检测, 而不需要对数据库中的所有数据依次进行比较, 从而, 提高了数据 库系统处理数据库倒换的效率、 减小了数据库系统对资源的消耗。
实施例六、 本发明实施例提供一种数据库系统。 如图 6所示, 所述数据库 系统 5 0 包括: 至少一个主数据库 5 1、 与所述主数据库对应的备用 数据库 52、 数据库访问装置 5 3、 倒换监控装置 54、 检测数据库数 据一致性的装置 5 5。 所述主数据库 5 1 , 用于存储应用程序需要访问的数据。 所述备用数据库 52 , 当所述主数据库失效时, 由所述备用数 据库为所述应用程序提供数据。
所述数据库访问装置 5 3 , 用于接收所述应用程序对所述主数 据库或所述备用数据库的访问请求,根据所述访问请求从所述主数 据库或所述备用数据库中获取对应的数据。 所述倒换监控装置 54 , 用于监控所述主数据库与备用数据库 是否倒换, 并在所述主数据库与备用数据库倒换后, 通知所述检测 数据库数据一致性的装置进行数据一致性处理。
所述装置 55 用于当所述应用程序通过数据库访问装置对访问 的数据表进行更新操作时, 更新第一更新标识; 当所述主数据库 5 1和备用数据库 5 2 同步后, 更新第二更新标识; 并当所述倒换监 控装置 54监控到所述主数据库 5 1和备用数据库 5 2进行倒换后, 获取第一更新标识和第二更新标识不一致的第一数据表、存储所述 第一数据表的第一数据库、 所述第一数据表对应的应用程序的标 识; 然后, 所述装置 55可以直接对备用数据库 52和緩存中与所述 第一数据表对应的数据表进行一致性处理,也可以向所述第一数据 表对应的应用程序发送一致性处理消息,使得所述对应的应用程序 对备用数据库 52 和緩存中与所述第一数据表对应的数据表进行一 致性处理。 所述数据库访问装置 5 3、 倒换监控装置 54、 装置 55可以是集 成在同一硬件上, 当然也可以是数据库访问装置中的一个或多个应 用模块, 也可以是独立的装置。
具体的, 所述数据库系统中的主数据库 5 1、 备用数据库 5 2、 数据库访问装置 5 3、 倒换监控装置 54、 检测数据库数据一致性的 装置 55之间的工作过程如图 7所示, 具体包括:
6 01、所述每个应用程序向所述数据库访问装置 5 3注册所述应 用程序的标识、 所述应用程序访问的数据表的名称、 存储所述数据 表的数据库的名称。
6 02、 所述应用程序向所述数据库访问装置 5 3发送访问请求, 请求所述主数据库的数据表。
6 03、 所述数据库访问装置 5 3接收所述访问请求, 从所述主数 据库中获取所述访问请求的数据表发送给所述应用程序。
所述应用程序将从所述主数据库访问的数据通常緩存到緩存 中。
6 04、 所述应用程序对访问的数据进行更改操作。
6 05、所述应用程序指示所述装置 5 5更新所述数据对应的数据 表的第一更新标识,所述第一更新标识指示所述数据表在緩存中的 更新状态。
6 06、 所述主数据库 5 1和备用数据库 52 同步。
6 07、所述备用数据库 52指示所述装置 55更新第二更新标识, 所述第二更新标识指示所述数据表在所述备用数据库中的更新状 态。
具体的,上述步骤 6 06和 6 07 中的所述更新状态包括以下信息 中的至少一种信息:指示该数据表已更新的信息和指示该数据表被 更新的次数。 所述检测数据库数据一致性装置 5 5 中存储第一特征表, 所述 第一特征表至少包括对应的应用程序的标识、该应用程序访问的数 据库的名称、 该应用程序访问的数据库中每个数据表的名称、 该应 用程序访问的每个数据表的第一更新标识和第二更新标识,这样每 个数据表的所述第一更新标识和第二更新标识包含于对应的应用 程序的第一特征表中。 进一步的, 所述第一特征表中还包括有第三更新标识, 所述第 三更新标识用于指示存储对应数据的数据表在所述主数据库 5 1 中 的更新状态。 这样在主数据库 5 1和备用数据库 52 同步时, 所述主 数据库 5 1 可以仅将所述第三更新标识发生变化的数据表同步到所 述备用数据库 52 即可, 同时将所述第二更新标识更新为第三更新 标识, 从而提高了主备数据库的同步速率。
可选的, 所述检测数据库数据一致性的装置 55存储第一特征 表和第二特征表, 所述第一特征表至少包括对应的应用程序的标 识、 该应用程序访问的数据库的名称、 该应用程序访问的数据库中 每个数据表的名称、 该应用程序访问的每个数据表的第一更新标 识, 所述第二特征表至少包括对应的应用程序的标识、 该应用程序 访问的数据库的名称、该应用程序访问的数据库中每个数据表的名 称和该应用程序访问的每个数据表的第二更新标识。 进一步的,为了更方便主数据库 5 1和备用数据库 5 2进行数据 同步,所述检测数据库数据一致性的装置 55还存储有第三特征表, 所述第三特征表至少包括对应的应用程序的标识、该应用程序访问 的数据库的名称、该应用程序访问的数据库中每个数据表的名称和 第三更新标识,所述第三更新标识用于指示对应数据在所述主数据 库 5 1 中的更新状态。 当每个应用程序对访问的数据进行更改时, 装置 55相应的更新第一更新标识和主数据库中的第三更新标识。 当所述备用数据库 52与主数据库 5 1没有同步时,所述第二特征表 中的第二更新标识维持原有的状态值。 当备用数据库 5 2 与主数据 库 5 1 同步时,所述主数据库 5 1可以仅将所述第三更新标识发生变 化的数据同步到所述备用数据库 5 2 即可, 同时将第二特征表更新 为第三特征表。 每个应用程序运行时,应用程序将访问的数据緩存到该数据库 系统的緩存中,应用程序访问对应数据库中数据是通过访问緩存数 据来实现的。
当所述应用程序在緩存中对访问的主数据库中的数据进行更 改操作时, 所述检测数据库数据一致性的装置 55 更新所述第一特 定表中存储的对应的每个数据的数据表的第一更新标识,用以记录 此次的更改操作。 在所述备用数据库 52与主数据库 5 1数据同步之后,所述装置 55 将所述第二更新标识更新为所述第一特征表中的第一更新标 识, 用以表示所述备用数据库 5 2 的数据和主数据库 5 1 的数据、 緩 存中的数据保持同步的状态。 在所述备用数据库 52与主数据库 5 1 没有同步时, 所述第二更新标识维持原有的状态值。 当主数据库 5 1和备用数据库 5 2进行实时或周期更新时,所述 检测数据库数据一致性的装置 55更新第二更新标识。
6 08、 所述倒换监控装置 54监控到所述主数据库 5 1 和备用数 据库 52倒换。 609、所述倒换监控装置 54通知所述检测数据库数据一致性的 装置 55进行备用数据库 52和緩存数据的一致性处理。 所述倒换监控装置 54对主数据库 51和备用数据库 52 的设备 进行统一监控管理, 当主数据库 5 1 出现故障, 所述数据库系统对 所述主数据库 51和备用数据库 52进行切换后,所述倒换监控装置 54监控到所述主数据库 5 1 和备用数据库 52 切换后, 会通知所述 检测数据库数据一致性的装置 55。 釆用独立的倒换监控装置 54对该数据库系统包括的主数据库 51和备份数据库 52统一进行监控, 相比较于现有技术中的数据库 系统中, 每个应用程序分别监控访问的主数据库 5 1 和备份数据库 52 进行倒换的技术方案, 能够提高该数据库系统的工作效率, 节 省系统资源。
当所述倒换监控装置 54检测到所述主数据库 51和备用数据库 52倒换时, 所述倒换监控装置 54通知所述检测数据库数据一致性 的装置 55进行备用数据库 52和緩存数据的一致性处理。
61 0、 所述检测数据库数据一致性的装置 55 对备用数据库 52 和緩存数据进行一致性处理。 具体的, 首先所述检测数据库数据一致性的装置 55 比较所述 第一更新标识和第二更新标识,获取所述第一更新标识和第二更新 标识不一致的第一数据表、 所述第一数据表对应的第一数据库、 所 述第一数据表对应的应用程序的标识。
然后, 所述检测数据库数据一致性的装置 55对所述备用数据 库 52和緩存中的第一数据表对应的数据表进行一致性处理。 所述检测数据库数据一致性的装置 55 对所述备用数据库 52 和緩存中的第一数据表对应的数据表进行一致性处理时,所述检测 数据库数据一致性的装置 55将所述备用数据库 52中与所述第一数 据库中的第一数据表对应的数据表的内容更新为所述緩存中的与 所述第一数据库中的第一数据表对应的数据表的内容。所述检测数 据库数据一致性的装置 55 也可以将所述緩存中的与所述第一数据 库中的第一数据表对应的数据表的内容更新为所述备用数据库 5 2 中的与所述第一数据库中的第一数据表对应的数据表的内容。
可选的, 当所述检测数据库数据一致性的装置 55 比较所述第 一更新标识和第二更新标识,获取所述第一更新标识和第二更新标 识不一致的第一数据表、 所述第一数据表对应的第一数据库、 所述 第一数据表对应的应用程序的标识之后,所述检测数据库数据一致 性的装置 55 可以向所述第一数据表对应的应用程序标识对应的应 用程序发送第一数据表以及所述第一数据表对应的第一数据库。所 述应用程序对所述备用数据库和緩存中与所述第一数据表对应的 数据表进行一致性处理, 以使得所述备用数据库 5 2 和緩存中的数 据同步。
所述应用程序将所述备用数据库 5 2 中与所述第一数据库中的 第一数据表对应的数据表的内容更新为所述緩存中的与所述第一 数据库中的第一数据表对应的数据表的内容。所述应用程序也可以 将所述緩存中的与所述第一数据库中的第一数据表对应的数据表 的内容更新为所述备用数据库 52 中的与所述第一数据库中的第一 数据表对应的数据表的内容。 本发明实施例提供一种数据库系统,所述每个应用程序向所述 数据库访问装置注册所述应用程序的标识、所述应用程序访问的数 据表的名称、 存储所述数据表的数据库的名称; 当所述应用程序对 所述数据库中的数据进行更改操作时,所述检测数据库数据一致性 的装置更新所述数据对应的数据表的第一更新标识, 当所述主数据 库和备用数据库同步时,所述检测数据库数据一致性的装置更新第 二更新标识; 当所述倒换监控装置监控到所述主数据库和备用数据 库倒换时,通知所述检测数据库数据一致性的装置进行备用数据库 和緩存数据的一致性处理; 所述检测数据库数据一致性的装置比较 所述第一更新标识和第二更新标识,获取所述第一更新标识和第二 更新标识不一致的第一数据表、 所述第一数据表对应的第一数据 库、 所述第一数据表对应的应用程序的标识; 所述检测数据库数据 一致性的装置对所述备用数据库和緩存中的第一数据表对应的数 据表进行一致性处理。 这样在主数据库和备用数据库倒换后, 由于 检测数据库数据一致性的装置只对应用程序访问的数据的第一更 新标识和第二更新标识进行比较检测,而不需要对数据库中的所有 数据依次进行比较, 从而, 提高了数据库系统处理数据库倒换的效 率、 减小了数据库系统对资源的消耗。 需说明的是, 以上所描述的装置实施例仅仅是示意性的, 其中 所述作为分离部件说明的单元可以是或者也可以不是物理上分开 的, 作为单元显示的部件可以是或者也可以不是物理单元, 即可以 位于一个地方, 或者也可以分布到多个网络单元上。 可以根据实际 的需要选择其中的部分或者全部模块来实现本实施例方案的目 的。 另外, 本发明提供的装置实施例附图中, 模块之间的连接关系表示 它们之间具有通信连接,具体可以实现为一条或多条通信总线或信 号线。 本领域普通技术人员在不付出创造性劳动的情况下, 即可以 理解并实施。 通过以上的实施方式的描述,所属领域的技术人员可以清楚地 了解到本发明可借助软件加必需的通用硬件的方式来实现, 当然也 可以通过专用硬件包括专用集成电路、 专用 CP U、 专用存储器、 专 用元器件等来实现。 一般情况下, 凡由计算机程序完成的功能都可 以很容易地用相应的硬件来实现, 而且, 用来实现同一功能的具体 硬件结构也可以是多种多样的, 例如模拟电路、 数字电路或专用电 路等。 但是, 对本发明而言更多情况下软件程序实现是更佳的实施 方式。 基于这样的理解, 本发明的技术方案本质上或者说对现有技 术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件 产品存储在可读取的存储介质中, 如计算机的软盘, U盘、 移动硬 盘、 只读存储器( ROM , R e a d- On l y Memo r y ) , 随机存取存储器( RAM , Random Access Memory ), 磁碟或者光盘等, 包括若干指令用以使 得一台计算机设备(可以是个人计算机, 服务器, 或者网络设备等) 执行本发明各个实施例所述的方法。
以上所述, 仅为本发明的具体实施方式, 但本发明的保护范围 并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技 术范围内, 可轻易想到变化或替换, 都应涵盖在本发明的保护范围 之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。

Claims

权 利 要 求 书
1、 一种检测数据库数据一致性的方法, 该方法应用于数据库系 统, 该数据库系统至少包括一个主数据库和与所述主数据库对应的 备用数据库, 所述数据库被至少一个应用程序访问, 其特征在于, 该方法包括:
更新每个应用程序访问的所述主数据库的数据表的第一更新标 识和第二更新标识, 所述第一更新标识指示与所述数据表对应的緩 存中的数据表的更新状态, 所述第二更新标识指示与所述数据表对 应的备用数据库中的数据表的更新状态; 在所述主数据库与备用数据库进行倒换后, 将每个所述数据表 的第一更新标识和第二更新标识进行比较, 获得第一更新标识和第 二更新标识不一致的第一数据表; 对所述备用数据库和緩存中的与所述第一数据表对应的数据表 进行一致性处理, 以使得所述备用数据库和緩存中的数据同步。
2、 根据权利要求 1所述的方法, 其特征在于, 每个数据表的所 述第一更新标识和第二更新标识包含于与应用程序对应的第一特征 表中, 所述第一特征表至少包括所述应用程序的标识、 所述应用程 序访问的主数据库的名称、 所述应用程序访问的主数据库中的每个 数据表的名称、 所述应用程序访问的每个数据表的第一更新标识和 第二更新标识; 所述将所述每个数据表的第一更新标识和第二更新标识进行比 较, 获得第一更新标识和第二更新标识不一致的第一数据表具体包 括:
对每个应用程序的第一特征表的第一更新标识和第二更新标识 进行比较, 获得第一更新标识和第二更新标识不一致的数据表为第 一数据表, 以及存储该第一数据表的数据库为第一数据库;
所述对所述备用数据库和緩存中的与所述第一数据表对应的数 据表进行一致性处理, 以使得所述备用数据库和緩存中的数据同步 具体包括:
对所述第一数据库对应的第一备用数据库中与所述第一数据表 对应的数据表和所述第一数据库对应的緩存中的与所述第一数据表 对应的数据表进行一致性处理。
3、 根据权利要求 1所述的方法, 其特征在于, 所述第一更新标 识和第二更新标识分别包含于与应用程序对应的第一特征表和第二 特征表中, 所述第一特征表至少包括所述应用程序的标识、 所述应 用程序访问的主数据库的名称、 所述应用程序访问的主数据库中的 每个数据表的名称和所述应用程序访问的每个数据表的第一更新标 识, 所述第二特征表至少包括所述应用程序的标识、 所述应用程序 访问的主数据库的名称、 所述应用程序访问的主数据库中的每个数 据表的名称和所述应用程序访问的每个数据表的第二更新标识; 所述将所述每个数据表的第一更新标识和第二更新标识进行比 较, 获得第一更新标识和第二更新标识不一致的第一数据表具体包 括:
根据所述每个应用程序的第一特征表和第二特征表, 对每个应 用程序访问的数据表的第一更新标识和第二更新标识进行比较, 获 得第一更新标识和第二更新标识不一致的数据表为第一数据表, 以 及存储该第一数据表的数据库为第一数据库;
所述对所述备用数据库和緩存中的与所述第一数据表对应的数 据表进行一致性处理, 以使得所述备用数据库和緩存中的数据同步 具体包括:
对所述第一数据库对应的第一备用数据库中与所述第一数据表 对应的数据表和所述第一数据库对应的緩存中的与所述第一数据表 对应的数据表进行一致性处理。
4、 根据权利要求 1 - 3 任一项所述的方法, 其特征在于, 所述 更新状态包括以下信息中的至少一种信息: 指示该数据表已更新的 信息和指示该数据表被更新的次数。
5、 根据权利要求 4所述的方法, 其特征在于, 所述对所述备用 数据库和緩存中的与所述第一数据表对应的数据表进行一致性处 理, 以使得所述备用数据库和緩存中的数据同步具体包括: 将所述备用数据库中与所述第一数据表对应的数据表的内容更 新为所述緩存中的与所述第一数据表对应的数据表的内容; 或 将所述緩存中的与所述第一数据表对应的数据表的内容更新为 所述备用数据库中的与所述第一数据表对应的数据表的内容。
6、 一种检测数据库数据一致性的装置, 其特征在于, 所述数据 库系统至少包括一个主数据库和与所述主数据库对应的备用数据 库, 所述数据库被至少一个应用程序访问, 该装置包括: 更新单元、 获取单元和处理单元; 所述更新单元, 用于更新每个应用程序访问的所述主数据库的 数据表的第一更新标识和第二更新标识, 所述第一更新标识指示与 所述数据表对应的緩存中的数据表的更新状态, 所述第二更新标识 指示与所述数据表对应的备用数据库中的数据表的更新状态; 所述获取单元,用于在所述主数据库与备用数据库进行倒换后, 将每个所述数据表的第一更新标识和第二更新标识进行比较, 获得 第一更新标识和第二更新标识不一致的第一数据表; 所述处理单元, 用于对所述备用数据库和緩存中的与所述第一 数据表对应的数据表进行一致性处理, 以使得所述备用数据库和緩 存中的数据同步。
7、 根据权利要求 6所述的装置, 其特征在于, 每个数据表的所 述第一更新标识和第二更新标识包含于与应用程序对应的第一特征 表中, 所述第一特征表至少包括所述应用程序的标识、 所述应用程 序访问的主数据库的名称、 所述应用程序访问的主数据库中的每个 数据表的名称、 所述应用程序访问的每个数据表的第一更新标识和 第二更新标识; 所述装置还包括: 存储单元; 所述存储单元, 用于存储所述第一特征表; 所述获取单元, 具体用于对每个应用程序的第一特征表的第一 更新标识和第二更新标识进行比较, 获得第一更新标识和第二更新 标识不一致的数据表为第一数据表, 以及存储该第一数据表的数据 库为第一数据库; 所述处理单元, 具体用于对所述第一数据库对应的第一备用数 据库中与所述第一数据表对应的数据表和所述第一数据库对应的緩 存中的与所述第一数据表对应的数据表进行一致性处理。
8、 根据权利要求 6所述的装置, 其特征在于, 所述第一更新标 识和第二更新标识分别包含于与应用程序对应的第一特征表和第二 特征表中, 所述第一特征表至少包括所述应用程序的标识、 所述应 用程序访问的主数据库的名称、 所述应用程序访问的主数据库中的 每个数据表的名称和所述应用程序访问的每个数据表的第一更新标 识, 所述第二特征表至少包括所述应用程序的标识、 所述应用程序 访问的主数据库的名称、 所述应用程序访问的主数据库中的每个数 据表的名称和所述应用程序访问的每个数据表的第二更新标识; 所 述装置还包括: 存储单元; 所述存储单元, 用于存储所述第一特征表和第二特征表; 所述获取单元, 具体用于根据所述每个应用程序的第一特征表 和第二特征表, 对每个应用程序访问的数据表的第一更新标识和第 二更新标识进行比较, 获得第一更新标识和第二更新标识不一致的 数据表为第一数据表, 以及存储该第一数据表的数据库为第一数据 库; 所述处理单元, 具体用于对所述第一数据库对应的第一备用数 据库中与所述第一数据表对应的数据表和所述第一数据库对应的緩 存中的与所述第一数据表对应的数据表进行一致性处理。
9、 根据权利要求 6 - 8 任一项所述的装置, 其特征在于, 所述 更新状态包括以下信息中的至少一种信息: 指示该数据表已更新的 信息和指示该数据表被更新的次数。
1 0、 根据权利要求 9所述的装置, 其特征在于, 所述处理单元, 具体用于 将所述备用数据库中与所述第一数据表对应的数据表的内容更 新为所述緩存中的与所述第一数据表对应的数据表的内容; 或 将所述緩存中的与所述第一数据表对应的数据表的内容更新为 所述备用数据库中的与所述第一数据表对应的数据表的内容。
1 1、 一种数据库系统, 其特征在于, 所述数据库系统包括: 至 少一个主数据库、 与所述主数据库对应的备用数据库、 数据库访问 装置、 倒换监控装置和检测数据库数据一致性的装置;
所述主数据库, 用于存储应用程序需要访问的数据;
所述备用数据库, 用于当所述主数据库失效时, 由所述备用数 据库为所述应用程序提供数据;
所述数据库访问装置, 用于接收所述应用程序对所述主数据库 或所述备用数据库的访问请求, 根据所述访问请求从所述主数据库 或所述备用数据库中获取对应的数据;
所述倒换监控装置, 用于监控所述主数据库与备用数据库是否 倒换, 并在所述主数据库与备用数据库倒换后, 通知所述检测数据 库数据一致性的装置进行数据一致性处理;
所述检测数据库数据一致性的装置, 用于更新每个应用程序访 问的所述主数据库的数据表的第一更新标识和第二更新标识, 所述 第一更新标识指示与所述数据表对应的緩存中的数据表的更新状 态, 所述第二更新标识指示与所述数据表对应的备用数据库中的数 据表的更新状态;
所述检测数据库数据一致性的装置, 还用于在所述倒换监控装 置监控到所述主数据库与备用数据库进行倒换后, 将每个所述数据 表的第一更新标识和第二更新标识进行比较, 获得第一更新标识和 第二更新标识不一致的第一数据表;
所述检测数据库数据一致性的装置, 还用于对所述备用数据库 和緩存中的与所述第一数据表对应的数据表进行一致性处理, 以使 得所述备用数据库和緩存中的数据同步。
PCT/CN2013/073476 2012-11-01 2013-03-29 一种检测数据库数据一致性的方法、装置及数据库系统 WO2014067254A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210430758.X 2012-11-01
CN201210430758.XA CN102982087B (zh) 2012-11-01 2012-11-01 一种检测数据库数据一致性的方法、装置及数据库系统

Publications (1)

Publication Number Publication Date
WO2014067254A1 true WO2014067254A1 (zh) 2014-05-08

Family

ID=47856107

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/073476 WO2014067254A1 (zh) 2012-11-01 2013-03-29 一种检测数据库数据一致性的方法、装置及数据库系统

Country Status (2)

Country Link
CN (1) CN102982087B (zh)
WO (1) WO2014067254A1 (zh)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102982087B (zh) * 2012-11-01 2016-05-25 华为技术有限公司 一种检测数据库数据一致性的方法、装置及数据库系统
CN103324679B (zh) * 2013-05-28 2017-03-08 杭州朗和科技有限公司 一种缓存服务器中数据更新的控制方法和设备
CN103605776B (zh) * 2013-11-28 2017-04-12 北京国双科技有限公司 信息数据库的数据处理方法和装置
CN104021192A (zh) * 2014-06-13 2014-09-03 北京联时空网络通信设备有限公司 一种数据库更新方法及装置
CN104317737A (zh) * 2014-10-10 2015-01-28 浪潮集团有限公司 一种不需要硬件支持实现基于程序同步点高速缓存一致性的方法
CN105338078B (zh) * 2015-10-26 2019-01-01 北京百度网讯科技有限公司 用于存储系统的数据存储方法和装置
CN106802892B (zh) * 2015-11-26 2021-12-28 阿里巴巴集团控股有限公司 用于主备数据一致性校验的方法和设备
CN107193821B (zh) * 2016-03-14 2021-07-13 创新先进技术有限公司 监控方法和系统
CN107784043B (zh) * 2016-08-31 2022-04-12 北京京东尚科信息技术有限公司 数据仓库数据表的监控方法、装置及系统
CN109710688B (zh) * 2018-11-26 2021-10-08 福建天泉教育科技有限公司 一种数据实时比对校验方法及消息中间件
CN109547269B (zh) * 2019-01-04 2021-12-14 烽火通信科技股份有限公司 一种ip ran设备实现lsp保护的方法及装置
CN111988155A (zh) * 2019-05-22 2020-11-24 烽火通信科技股份有限公司 一种集群设备的主备框间配置同步方法及系统
CN113672639B (zh) * 2021-08-27 2024-04-26 成都长城开发科技股份有限公司 多类型数据库表结构对比方法、系统、设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101409614A (zh) * 2007-10-12 2009-04-15 华为技术有限公司 一种数据同步方法、系统和设备
CN102194009A (zh) * 2011-06-09 2011-09-21 北京新媒传信科技有限公司 一种数据库托管方法和一种数据库托管平台系统
CN102402562A (zh) * 2010-09-14 2012-04-04 中兴通讯股份有限公司 数据库异地容灾方法及系统
CN102541927A (zh) * 2010-12-30 2012-07-04 北京新媒传信科技有限公司 一种实现数据缓存的方法和装置
CN102982087A (zh) * 2012-11-01 2013-03-20 华为技术有限公司 一种检测数据库数据一致性的方法、装置及数据库系统

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5689697A (en) * 1994-06-27 1997-11-18 International Business Machines Corporation System and method for asynchronous database command processing

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101409614A (zh) * 2007-10-12 2009-04-15 华为技术有限公司 一种数据同步方法、系统和设备
CN102402562A (zh) * 2010-09-14 2012-04-04 中兴通讯股份有限公司 数据库异地容灾方法及系统
CN102541927A (zh) * 2010-12-30 2012-07-04 北京新媒传信科技有限公司 一种实现数据缓存的方法和装置
CN102194009A (zh) * 2011-06-09 2011-09-21 北京新媒传信科技有限公司 一种数据库托管方法和一种数据库托管平台系统
CN102982087A (zh) * 2012-11-01 2013-03-20 华为技术有限公司 一种检测数据库数据一致性的方法、装置及数据库系统

Also Published As

Publication number Publication date
CN102982087A (zh) 2013-03-20
CN102982087B (zh) 2016-05-25

Similar Documents

Publication Publication Date Title
WO2014067254A1 (zh) 一种检测数据库数据一致性的方法、装置及数据库系统
EP3493471B1 (en) Data disaster recovery method, apparatus and system
US8954391B2 (en) System and method for supporting transient partition consistency in a distributed data grid
CN108418900B (zh) 一种服务器集群系统中的缓存方法、写入点客户端和读客户端
WO2019061720A1 (zh) 一种数据同步的方法和系统
US9367261B2 (en) Computer system, data management method and data management program
CN111200532A (zh) 数据库集群节点主从切换的方法、装置、设备和介质
CN110120961B (zh) 一种分布式服务集群及其路由同步的方法
CN107368369B (zh) 分布式容器管理方法及系统
WO2021184587A1 (zh) 基于Prometheus的私有云监控方法、装置、计算机设备及存储介质
CN105069152B (zh) 数据处理方法及装置
CN112506702B (zh) 数据中心容灾方法、装置、设备及存储介质
CN111049928A (zh) 数据同步方法、系统、电子设备及计算机可读存储介质
CN111181765A (zh) 一种任务处理方法和装置
CN111600794B (zh) 服务器切换方法、终端、服务器及存储介质
CN105373563B (zh) 数据库切换方法及装置
WO2024104073A1 (zh) 一种元数据访问方法、装置和存储介质
CN105323271B (zh) 一种云计算系统以及云计算系统的处理方法和装置
WO2018010603A1 (zh) 基于视频云存储系统的存储模式升级方法、装置和系统
KR20210044281A (ko) 클라우드 저하 모드에서 지속적인 디바이스 동작 안정성을 보장하기 위한 방법 및 장치
CN114363356B (zh) 数据同步方法、系统、装置、计算机设备和存储介质
CN112711466B (zh) 悬挂事务巡检方法和装置、电子设备和存储介质
US9798633B2 (en) Access point controller failover system
CN109992384B (zh) 服务注册发现协调系统及其方法
CN107483257A (zh) 一种基于x86和arm混合环境的应用系统部署方法及架构

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13850557

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 13850557

Country of ref document: EP

Kind code of ref document: A1