WO2016127557A1 - 重建备机数据库的方法及其装置 - Google Patents

重建备机数据库的方法及其装置 Download PDF

Info

Publication number
WO2016127557A1
WO2016127557A1 PCT/CN2015/083536 CN2015083536W WO2016127557A1 WO 2016127557 A1 WO2016127557 A1 WO 2016127557A1 CN 2015083536 W CN2015083536 W CN 2015083536W WO 2016127557 A1 WO2016127557 A1 WO 2016127557A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
page
page structure
information
database
Prior art date
Application number
PCT/CN2015/083536
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 华为技术有限公司
Priority to RU2017102476A priority Critical patent/RU2665884C2/ru
Priority to EP15881718.9A priority patent/EP3147789B1/en
Priority to JP2017501381A priority patent/JP6470391B2/ja
Publication of WO2016127557A1 publication Critical patent/WO2016127557A1/zh
Priority to US15/377,683 priority patent/US10585895B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1464Management of the backup or restore process for networked environments
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • G06F11/1451Management of the data involved in backup or backup restore by selection of backup contents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1469Backup restoration techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/2053Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant
    • G06F11/2056Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant by mirroring
    • G06F11/2082Data synchronisation
    • 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/21Design, administration or maintenance of databases
    • G06F16/217Database tuning
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/84Using snapshots, i.e. a logical point-in-time copy of the data

Definitions

  • the present invention relates to the field of communications and, more particularly, to a method and apparatus for reconstructing a standby database.
  • a Data Base is an associated structured collection of data that is reasonably stored on a storage device of a computer.
  • the database is dual-system hot standby, it is usually implemented by redo log stream replication technology: the host database sends the continuously generated redo log stream to the standby database, and the standby database is played back to recover the data. Hot Standby.
  • the log files retained in the host database are limited.
  • the standby database replication speed is too slow, the playback is slow, or the network is broken, the standby database cannot copy the required log files from the host database, and the stream replication mechanism stops. At this point, you need to rebuild the standby database to continue streaming replication.
  • the existing method of rebuilding the standby database is to copy all the data files and all the log files in the host database to the standby database at one time, so that the flow replication can be continued after the standby database is restarted.
  • this method of reconstructing the standby database may take a long time and cause a large loss of network resources.
  • the embodiment of the invention provides a method and a device for reconstructing a standby database, which can shorten the time for rebuilding the standby database.
  • a method for reestablishing a standby database includes: obtaining file information of a first page structure file of a host database and file information of a second page structure file in a standby database, wherein the first The page structure file and the second page structure file are data files having a corresponding relationship; comparing the file information of the first page structure file and the file information of the second page structure file to obtain a file Whether the information is the same as the comparison result; according to the file letter The comparison result of whether the information is the same is used to reconstruct the standby database.
  • the re-establishing the standby database according to whether the file information is the same comparison result includes: when the file information is the same, the comparison result is When the file information of the first page structure file and the file information of the second page structure file are different, the second page structure file is replaced with the first page structure file.
  • the re-establishing the standby database according to whether the file information is the same comparison result includes: when the file information is When the same comparison result is that the file information of the first page structure file and the file information of the second page structure file are different, the second page structure file is replaced with the first page structure file.
  • the file information includes a file size, the file information of the first page structure file, and the second page
  • the file information of the structure file is compared by comparing the file size of the first page structure file with the file size of the second page structure file.
  • the re-establishing the standby database is specifically: All pages of the first page structure file replace all pages of the second page structure file.
  • the file information includes a number of pages
  • the file information and the The file information of the two-page structure file is compared by comparing the number of pages in the first page structure file with the number of pages in the second page structure file.
  • the re-establishing the standby database is specifically: All pages of the first page structure file are replaced with all pages of the second page structure file.
  • the re-establishing the standby database is specifically: The version information of each page in the one-page structure file and the version information of each page of the page in the second page structure file are compared one by one; for pages with different version information of the page, The page of the first page structure file replaces the corresponding page of the second page structure file.
  • the version information of the page includes a location of a log file or a logical system time ⁇ .
  • the determining, before the re-establishing the standby database, according to whether the file information is the same comparison result determining the host
  • the database supports replication relationships and the processes of the standby database have been shut down gracefully.
  • an apparatus for reconstructing a standby database comprising: an obtaining unit, configured to acquire file information of a first page structure file of a host database and a second page structure file in a standby database a file information, wherein the first page structure file and the second page structure file are data files having a corresponding relationship; and a comparison unit, configured to acquire the first page structure file obtained by the acquiring unit The file information is compared with the file information of the second page structure file to obtain a comparison result of whether the file information is the same; the reconstruction unit is configured to compare whether the text information obtained by the comparison unit is the same The standby machine database is reconstructed.
  • the reconstruction unit is specifically configured to: when the file information is the same, the comparison result is the file information of the first page structure file and the first When the file information of the two-page structure file is different, the second page structure file is replaced with the first page structure file.
  • the file information includes a file size
  • the comparing unit is specifically configured to use a file size of the first page structure file and The file size of the second page structure file is compared.
  • the reconstructing unit when the comparing result of the file size obtained by the comparing unit is different, is specifically configured to use the All pages of the first page structure file replace all pages of the second page structure file.
  • the file information includes a number of pages
  • the comparing unit is specifically configured to use the first page structure file The number of pages in the middle page is compared with the number of pages in the second page structure file.
  • the reconstruction unit when the comparison result of the number of the file pages obtained by the comparing unit is different, the reconstruction unit is specifically used to All pages of the first page structure file are replaced with all pages of the second page structure file.
  • the reconstruction unit when the comparison result of the file information is the same, is specifically configured to: use the first page structure file The version information of each page in the page and the version information of each page of the page in the second page structure file are compared one by one; for the page with different version information of the page, the page of the first page structure file is replaced with the page of the first page structure file The corresponding page of the second page structure file.
  • the version information of the page includes a location of a log file or a logical system time ⁇ .
  • the apparatus further includes a determining unit, where the determining unit is configured to compare, according to whether the file information is the same according to the reconstruction unit As a result, before the standby database is reconstructed, it is also determined that the host database supports the replication relationship and the process of the standby database has been normally closed.
  • the reconstruction unit is configured to not modify the second page structure file.
  • the file information of the first page structure file of the host database and the file information of the second page structure file in the standby database are obtained by comparing and comparing the file information according to the comparison result.
  • the database is rebuilt, which can avoid the large network resource loss caused by the full-scale reconstruction of the standby database when the amount of data in the host database is large, and can shorten the time for rebuilding the standby database.
  • FIG. 1 is a schematic flowchart of a method for reconstructing a standby database according to an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a method for reconstructing a standby database according to another embodiment of the present invention.
  • FIG. 3 is a schematic diagram of reconstructing a standby database based on page version information in a host database and page version information in a standby database according to an embodiment of the present invention.
  • FIG. 4 is a block diagram of an apparatus for reconstructing a standby database in accordance with an embodiment of the present invention.
  • FIG. 5 is a block diagram of an apparatus for reconstructing a standby database according to another embodiment of the present invention.
  • FIG. 1 is a schematic flowchart of a method for reconstructing a standby database according to an embodiment of the present invention.
  • Step 101 Obtain file information of a first page structure file of a host database and file information of a second page structure file in a standby database, where the first page structure file and the second page structure file have a corresponding relationship Data file.
  • Step 102 Compare file information of the first page structure file with file information of the second page structure file to obtain a comparison result of whether the file information is the same.
  • Step 103 Rebuild the standby database according to whether the file information is the same comparison result.
  • the file information of the first page structure file of the host database and the file information of the second page structure file in the standby database are obtained by comparing and comparing the file information according to the comparison result.
  • the database is rebuilt, which can avoid the large network resource loss caused by the full-scale reconstruction of the standby database when the amount of data in the host database is large, and can shorten the time for rebuilding the standby database.
  • the standby database can obtain the file information of the first page structure file of the host database and the file information of the second page structure file in the standby database.
  • the first page structure file and the second page structure file are data files having a corresponding relationship.
  • the first page structure file can be any page structure file in the data file of the host database.
  • the host database may read the version information of the page structure file from the local data file, and then send the file information of the page structure file to the standby database.
  • the standby database can also read the second page structure file corresponding to the location of the first page structure file in the data file of the host database in the data file of the standby database. Version information.
  • the location correspondence here may be the same location of the file, for example, the location of the first page structure file in the host database and the location of the second page structure file in the standby database are the same.
  • the files in the database include data files and log files.
  • SQL Structured Query Language
  • Data files in the host database or standby database may include both page structure files and non-page structure files.
  • Page structure files are stored in a minimum unit of page storage.
  • the file information in the embodiment of the present invention may be a file size, a number of pages in the file, or version information of a page in the file.
  • the file information is not limited in the embodiment of the present invention.
  • the second page structure file may be replaced with the first page structure file. That is, you can replace the file in the standby database with the corresponding location in the host database with a page structure file. It should be understood that when there is no file corresponding to the page structure file in the host database in the standby database, the file in the host database can be directly copied to the corresponding location of the standby database, and the situation is also protected by the present invention. Within the scope.
  • each file size in the database can be the same. You can compare the file sizes to compare the files for the same. You can also compare files by comparing the number of pages in the file. Or, more specifically, comparing the version information of the pages in the file to compare whether the files are the same.
  • comparing the file information of the first page structure file and the file information of the second page structure file is specifically the file size of the first page structure file and the second page structure file.
  • File size is compared. For example, when the files in the host database and the files in the standby database are the same size (for example, both are 8k), the two files can be considered the same. In this case, the file in the standby database is not made. modify.
  • the files in the host database and the files in the standby database are different in size, you can think that the two files are different. You can replace the corresponding files in the standby database with the files in the host database, that is, all the files in the host database. The page replaces all pages of the corresponding file in the standby database.
  • comparing the file information of the first page structure file and the file information of the second page structure file is specifically the number of pages in the first page structure file and the number of pages
  • the number of pages in the two-page structure file is compared. For example, when the number of pages in a file in the host database is the same as the number of pages in a file in the standby database (for example, the first file of the host database includes six pages, and the second file of the standby database includes four pages.
  • the two files can be considered to be the same. In this case, the file in the standby database is not modified.
  • comparing the file information of the first page structure file and the file information of the second page structure file is specifically the version information and the second page of the page in the first page structure file.
  • the version information of the pages in the structure file is compared.
  • the version information of the page of each page in the two files can be compared with the page structure file in the host database and the page structure file of the corresponding location in the standby database.
  • the two files may be considered to be the same, in this case, the standby database
  • the file in the file is not modified.
  • the page in the standby database can be replaced with the page in the host database. It should be understood that when the number of pages is the same, pages in the standby database can be replaced with pages in the host database for different pages. When the number of pages is different, for example, when the page in the host database does not have a corresponding page in the standby database, the page of the host database can be copied to the corresponding location of the standby database, which is still in the present invention. Within the scope of protection.
  • the content of the first page structure file and the content of the second page structure file may be considered to be the same.
  • the content of the first page structure file and the content of the second page structure file may be considered different.
  • Reconstructing the standby database according to whether the file information is the same or not includes: when the comparison result of the file information is the same as the file information of the first page structure file and the file information of the second page structure file, the first The page structure file replaces the second page structure file.
  • the comparison result of the piece of information is the same, the file information of the first page structure file and the file information of the second page structure file are the same, the second page structure file is not modified, that is, the second in the standby database is retained. Page structure file.
  • Replacing the second file with the first file may be to copy all of the first file, replacing the entire contents of the second file with the entire contents of the first file.
  • the page can be completely replaced by the file.
  • Replacing the second file with the first file may further include comparing the first page of the first file with the first page of the second file in the second file, when the first page of the first file and the second file are When the page is the same, the first page of the second file is not modified. When the first page of the first file is different from the first page of the second file, the first page of the second file is replaced with the first page of the first file. Each page of the first file and the second file are compared, so that the page can no longer be copied when the page is the same, which can reduce the loss of network resources by the reconstructed standby database.
  • the first page of the first file is a page of the page structure file in the data file of the host database
  • the first page of the second file is a page of the page structure file in the standby database.
  • the first page of the first file and the first page of the second file are in the same location in the data files of the two databases.
  • the data file in the database includes at least one file, and the data file may be a page structure file or a non-page structure file.
  • Page structure files are stored in a minimum unit of pages.
  • the page structure file includes version information on the page, and usually, the version information is a location or time stamp in the page change history. The version information can be increased as the page is updated.
  • the version information of the page is the same, and the contents of the page can be considered to be the same.
  • the version information of the page is different, and the contents of the page can be considered different.
  • the first page of the second file may be replaced with the first page of the first file, for example, by copying the first page of the host file To replace the first page of the second file.
  • the first page of the second file may not be modified, and the first page of the first file may no longer be copied, and no longer Replace the second page of the second file with the first page of the host file.
  • the page in the file in the standby database is not modified.
  • the page in the file in the host database is replaced with the page in the file in the standby database. page.
  • the embodiment of the present invention does not limit whether the page is determined to be the same. For example, you can pass the version number of the page The code is judged, but the present invention is not limited to this.
  • replacements in embodiments of the invention may also include additions or deletions.
  • the second file does not exist in the standby database (for example, during the hot standby process, the standby cannot keep up with the host and fails to copy the first file in the host), it is in the standby database and in the host database.
  • the first file is added to the same location in the first file.
  • the standby database has more files than the host database, the redundant files are deleted. All of the above are within the coverage of the embodiments of the present invention.
  • the database of the standby machine is reconstructed by incrementally, and the backup database is reconstructed by comparing the file information of the page structure file of the data file, and only the files in the host database and the standby database need to be copied, and The same file is no longer copied. This can shorten the time to rebuild the standby database and reduce network resource loss.
  • the embodiment of the present invention uses the incremental reconstruction of the standby database, and the host database no longer needs to transmit all the data to the standby database, and the time for rebuilding the standby database can be shortened, and the consumption of the host network resources can be reduced.
  • the version information of the page may include at least one of the following information: a location of the log file and a logical system time ⁇ .
  • the host database is determined to support the replication relationship and the process of the standby database has been normally closed.
  • the host database does not support the replication relationship or the process of the standby database is abnormally closed, the data file of the standby database is overwritten by the data file of the host database.
  • the standby database Before rebuilding the standby database, you can determine whether the host database supports replication relationships. Before rebuilding the standby database, you can also determine whether the process of the standby database is properly shut down. When the host database supports the replication relationship, or when the process of the standby database is normally closed, the standby database may be reconstructed according to the file information of the first page structure file and the file information of the second page structure file, so that Improve the accuracy of rebuilding the standby database. When the host database supports the replication relationship and the standby database is normally shut down, rebuilding the standby database according to the file information of the first page structure file and the file information of the second page structure file can further improve the accuracy of reconstructing the standby database. .
  • the host database When the host database enables the non-logging mode (Nologging) mode or the data file of the standby database is not derived from the host database, it is determined that the host database does not support the replication relationship.
  • the data file of the standby database is not derived from the host database. It can be considered that the standby database does not match the host database, and the host database does not support the replication relationship. For example, the identifier of the host database does not match the identifier of the standby database.
  • the embodiment of the present invention does not limit how to determine that the host database does not support the replication relationship. For example, when the host database does not match the standby database, the host database can be considered as not supporting the replication relationship.
  • the host database may enable the Nologging mode to upgrade the application database. In this way, the standby database cannot know whether the host database has been modified or modified. In this case, the standby database cannot be reconstructed incrementally. When the host database has the Noogog mode enabled, it can be considered that the host database does not support the replication relationship.
  • the standby database also includes a control file, and the control file of the standby database can record the status information of the standby database.
  • the standby database can know whether the standby database is properly shut down according to the status information.
  • the embodiment of the present invention does not limit how to determine whether the standby database is normally closed.
  • the standby database When the standby database is abnormally closed, there may be a page that only writes a partial (partial write). At this time, the version information of the comparison page cannot determine whether the page in the host database is the same as the content of the page in the corresponding standby database. Therefore, when the standby database is abnormally closed, you cannot use the incremental backup database to rebuild. Instead, you need to use full-scale reconstruction of the standby database to copy all data files and all log files in the host database to the standby database. In the middle, the data file of the standby database is overwritten by the data file of the host database, and the log file of the standby database is overwritten by the log file of the host database.
  • Whether the host database supports the replication relationship and whether the standby database is properly closed can be interchanged.
  • the embodiment of the present invention does not limit the order in which the host database supports the replication relationship and whether the standby database is normally closed.
  • the standby database can be incrementally reconstructed.
  • Data files in the host database or standby database may include both page structure files and non-page structure files.
  • the backup database cannot be reconstructed by comparing the version information of the page, and the non-page structure file in the data file of the host database is directly replaced with the data file corresponding to the standby database.
  • the non-page structure file in the data file of the host database is used to replace the non-page type of the data file of the standby database.
  • Structure file The host database also includes log files. When the standby database is rebuilt, you can replace the log files of the standby database with the log files of the host database.
  • the embodiment of the invention provides a high-performance backup database database method, which compares the file information of the first page structure file of the data file of the host database with the second page structure file of the data file of the standby database.
  • the file information of the first page structure file and the file information of the second page structure file are the same, the contents of the two file information may be considered to be the same, and the page structure of the data file of the standby database is The page is not modified, so that the amount of data to be transmitted can be reduced, which can shorten the time for rebuilding the standby database, thereby improving the availability of the database system, thereby improving the reconstruction performance of the standby database.
  • the log file tracks the record of each execution of the Structured Query Language (SQL) to record the update operation of the database.
  • SQL Structured Query Language
  • the log file includes the information needed to recover all transactions in the database.
  • FIG. 2 is a schematic flowchart of a method for reconstructing a standby database according to another embodiment of the present invention.
  • Step 201 Close the process of the standby database, and start to rebuild the standby database.
  • the log files saved by the host database are limited.
  • the standby database replication speed is too slow, the standby database playback is too slow, or the network is broken, the standby database cannot copy the required log files from the host database.
  • the log stream replication mechanism stops, and the standby database needs to be rebuilt. First shut down the process of the standby database to start the number of rebuilds According to the library.
  • Step 202 Determine whether the host database supports the replication relationship.
  • the host database does not support the replication relationship.
  • the host database has the Noogog mode enabled, and the standby database does not match the host database.
  • the host database may enable the Nologging mode to upgrade the application database. In this way, the standby database cannot know whether the host database has been modified or modified. In this case, the incremental standby database cannot be reconstructed.
  • the host database has the Noogog mode enabled, it can be considered that the host database does not support the replication relationship.
  • step 203 the standby database is fully reconstructed.
  • the incremental backup database may not be reconstructed, and the full backup database may be reconstructed.
  • the standby database can be replaced with all the data files and all log files of the host database in the corresponding location of the standby database to reconstruct the standby database.
  • step 204 it is determined whether the process of the standby database is normally closed.
  • step 202 When the judgment result of step 202 is that the host database supports the replication relationship, it is continuously determined whether the standby database is normally closed.
  • the order of the two determining steps of step 202 and step 204 can be interchanged.
  • the embodiment of the present invention does not limit the order in which the host database supports the replication relationship and whether the process of the standby database is normally closed. For example, it is also possible to first determine whether the process of the standby database is normally closed. When the process of determining that the standby database is normally closed, continue to determine whether the host database supports the replication relationship. When the result of the judgment is that the process of the standby database is abnormally closed, the full-scale reconstruction of the standby database is used, that is, the data file and the log file of the corresponding location in the standby database are replaced with the data files and log files in the host database, or the file is re-drawn. Standby the database, and then shut down the process of the standby database normally, and then re-determine whether the standby database is properly shut down and whether the host database supports replication.
  • step 205 a full-scale reconstruction machine database is employed.
  • the comparison file information cannot determine the page format of the data file in the data file of the host database and the data file of the standby database. Whether the contents of the file at the corresponding position of the structure file are the same. Therefore, when the result of the determination in step 204 is that the process of the standby database is abnormally closed, the full-scale reconstruction machine database is used, that is, the data file of the standby database is replaced with the data file of the host database, and the log of the standby database is replaced with the host database log file. file.
  • step 206 the standby database is newly pulled up, and the process of the standby database is normally closed.
  • step 204 When the result of the determination in step 204 is that the standby database is abnormally closed, the standby database may be re-pulled, and then the process of the standby database is normally shut down, and then returning to step 202 to determine whether the host database supports the replication relationship, to continue the subsequent process. .
  • Step 205 and step 206 are different methods used when the judgment result of step 204 is that the standby database is abnormally closed. When it is determined that the standby database is abnormally closed, step 205 and step 206 are not performed at the same time, and step 205 or step 206 may be selectively performed.
  • step 207 the standby database is connected to the host database.
  • the standby database is connected to the host database, and the two replication processes of data files and log files are started to rebuild the standby database.
  • the following step 208 is to start the log file reconstruction process.
  • the data file reconstruction process is started from step 209.
  • the log file reconstruction in step 208 can be performed before the completion of the entire standby database reconstruction, so as to overwrite the log file of the standby database with the log file of the host database in real time. For example, copy the log files from the host database to the standby database and replace the log files in the standby database.
  • step 208 the log file is reconstructed.
  • step 209 it is determined whether there are still unreconstructed data files.
  • the data file in the database includes at least one file.
  • Step 210 Determine whether the first file is a page structure file.
  • step 210 is executed to determine whether the first file is a page structure file, wherein the first file
  • the piece can be any file in the data file of the host database.
  • step 211 it is determined whether the file information is the same.
  • step 211 is executed to determine whether the file information is the same. Assuming that the second file is a file corresponding to the first file in the host database in the standby database, step 211 determines whether the file information of the first file and the file information of the second file are the same.
  • the embodiment of the present invention does not limit how to compare the file information to determine whether the file content is the same.
  • the file information in the embodiment of the present invention may be a file size, a number of pages in the file, or version information of a page in the file.
  • the file information may also be other related information, which is not limited by the embodiment of the present invention.
  • step 212 no modification is made to the second file.
  • step 211 When the result of the determination in step 211 is that the file information of the first file and the file information of the second file are the same, the file content of the first file and the file content of the second file are considered to be the same.
  • the second file can be modified, that is, the second file is reserved in the standby database.
  • step 209 is performed to determine whether there are any unreconstructed files.
  • step 213 the second file is replaced with the first file.
  • step 211 When the result of the determination in step 211 is that the file information of the first file and the file information of the second file are different, the file content of the first file and the file content of the second file may be considered different. At this point, the second file can be replaced with the first file.
  • replacing the second file with the first file may be to copy all of the first file, replacing the entire contents of the second file with the entire contents of the first file.
  • Replacing the second file with the first file may further include comparing the first page of the first file with the first page of the second file in the second file, when the first page of the first file and the second file are When the page is the same, the first page of the second file is not modified. When the first page of the first file is different from the first page of the second file, the first page of the second file is replaced with the first page of the first file. Each page of the first file and the second file are compared, so that the page can no longer be copied when the page is the same, which can reduce the loss of network resources by the reconstructed standby database.
  • the replacement also includes additions or deletions.
  • the second file may be replaced with the first file.
  • the second file does not exist in the standby database (for example, during the hot standby process, the standby cannot keep up with the host and fails to copy the first file in the host), it is in the standby database and in the host database.
  • the first file is added to the same location in the first file. when When the standby database has more files than the host database, delete the redundant files. All of the above are within the coverage of the embodiments of the present invention.
  • step 209 is executed to determine whether there are any unreconstructed files.
  • step 214 the first file is copied to the standby database.
  • the determining step 210 obtains that the first file is a non-page structure file, the first file is copied to a corresponding location in the standby database.
  • step 215 is executed to end the entire process.
  • FIG. 3 is a schematic diagram of reconstructing a standby database based on page version information in a host database and page version information in a standby database according to an embodiment of the present invention.
  • 301 is a file of a page structure in a data file of a host database
  • 302 is a file of a page structure in a data file in the original standby database
  • 303 is a page format in a data file in the reconstructed standby database.
  • Structured file Among them, a rectangular grid represents a page, and consecutive pages connected together represent a file.
  • 301-1, 301-2, 302-1, 302-2, 303-1, and 303-2 in the figure all represent one page.
  • 301-1, 301-2 and two consecutive small cells represent one file.
  • the blank cells in 301 and 302 indicate that the data file of the host database and the version information of the page of the same location of the data file of the standby database are the same, for example, the version information of page 301-1 and page 302-1 in Fig. 3 is the same.
  • the shaded cells in 301 and 302 indicate that the data file of the host database and the version information of the page of the same location of the data file of the standby database are different. For example, the version information of page 301-2 and page 302-2 in FIG. 3 is the same.
  • the file in 301 in FIG. 3 corresponds to the file at the corresponding position in 302.
  • Each file in 301 corresponds to each file in 302.
  • the first line in 301 consists of two files
  • the first file consists of four pages
  • the second file consists of two
  • the second line consists of a seven-page file
  • the third line consists of a two-page file and a four Page file.
  • Each file in 302 corresponds to each file in 301.
  • Each page in 301 of Figure 3 corresponds to each page in each file in 302.
  • page 301-1 corresponds to page 302-1.
  • the standby database can be reconstructed by comparing the data file of the host database with the version information of the page at the same position of the data file of the standby database. If the number of hosts According to the version information of the page in the same position of the data file of the library and the data file of the standby database, the key content of the page can be considered to be the same.
  • the page need not be processed, that is, the page is not processed. Do the processing. If the version information of the page in the same location of the data file of the host database and the data file of the standby database are different, the key content of the page may be considered different.
  • the standby database is rebuilt, the page in the data file of the host database may be replaced. The page in the data file of the standby database.
  • comparing the version information of page 301-1 and page 302-1 can obtain the same version information of page 301-1 and page 302-1, and the standby database no longer copies page 301-1 to replace 302-1, but the page is 302-1 does not process, that is, the page 302-1 is retained in the data file of the standby database, and the page 302-1 is used as the page 303-1 of the page structure file in the reconstructed standby database.
  • the version information of the page 301-2 and the page 302-2 can be different from the version information of the page 301-2 and the page 302-2, and the standby database page 1-1 covers the page 303 of the page structure file of the original machine database.
  • -2 that is, page 301-1 is used as page 303-2 of the page structure file of the reconstructed standby database.
  • the non-page structure file in the data file of the standby database is replaced with the file of the non-page structure.
  • the apparatus 40 of FIG. 4 includes an acquisition unit 41 and a reconstruction unit 42.
  • the obtaining unit 41 is configured to obtain file information of the first page structure file of the host database and file information of the second page structure file in the standby database, where the first page structure file and the second page structure file exist Correspondence data file.
  • the comparing unit 42 is configured to use the file information and the first page of the first page structure file acquired by the obtaining unit The file information of the two-page structure file is compared to obtain a comparison result of whether the file information is the same.
  • the reconstruction unit 43 is configured to reconstruct the standby database according to whether the text information obtained by the comparison unit is the same.
  • the file information of the first page structure file of the host database and the file information of the second page structure file in the standby database are obtained by comparing and comparing the file information according to the comparison result.
  • the database is rebuilt, which can avoid the large network resource loss caused by the full-scale reconstruction of the standby database when the amount of data in the host database is large, and can shorten the time for rebuilding the standby database.
  • the reconstruction unit is specifically configured to: when the comparison result of the file information is the same, the file information of the first page structure file and the file information of the second page structure file are different, The first page structure file replaces the second page structure file.
  • the file information includes a file size.
  • the comparing unit is specifically configured to compare the file size of the first page structure file with the file size of the second page structure file.
  • the reconstruction unit when the comparison result of the file sizes obtained by the comparison unit is different, is specifically configured to replace all pages of the first page structure file with all of the second page structure file. page.
  • the file information includes the number of pages.
  • the comparison unit is specifically used to compare the number of pages in the first page structure file with the number of pages in the second page structure file.
  • the reconstruction unit when the comparison result of the number of file pages obtained by the comparison unit is different, is specifically configured to replace all pages of the first page structure file with the second page structure. All pages of the file.
  • the reconstruction unit when the comparison result of the file information obtained by the comparison unit is the same, is specifically configured to: version information and a second page of each page in the first page structure file.
  • the version information of each page of the page in the structure file is compared one by one. For pages having different page version information, the corresponding page of the second page structure file is replaced with the page of the first page structure file.
  • the version information of the page includes the location of the log file or the logical system time ⁇ .
  • the apparatus further includes a determining unit for reconstructing Before the unit rebuilds the standby database based on the comparison result of the file information, it is also determined that the host database supports the replication relationship and the process of the standby database has been closed normally.
  • the reconstruction unit when the comparison result obtained by the comparison unit is the same, and the comparison result of the version information of the page is also the same, the reconstruction unit is configured to use the second page structure file. Do not make changes.
  • the apparatus 40 of FIG. 4 can perform the various processes of the methods illustrated in FIGS. 1, 2, and 3, and to avoid repetition, it will not be described in detail herein.
  • the device 50 includes a processor 51, a memory 52, and a bus system 53.
  • the processor 51 and the memory 52 are connected by a bus system 53 for storing instructions for executing instructions and data stored by the memory 52.
  • a portion of the memory 52 may also include a Non-Volatile Random Access Memory (NVRAM).
  • NVRAM Non-Volatile Random Access Memory
  • the various components of the apparatus are coupled together by a bus system 53, wherein the bus system 53 includes, in addition to the data bus, a power bus, a control bus, and a status signal bus.
  • various buses are labeled as the bus system 53 in the figure.
  • the method disclosed in the foregoing embodiments of the present invention may be applied to the processor 51 or implemented by the processor 51.
  • each step of the above method may be completed by an integrated logic circuit of hardware in the processor 51 or an instruction in a form of software.
  • the processor 51 can be a general purpose processor, a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, which can be implemented or executed in an embodiment of the invention.
  • a general purpose processor can be a microprocessor or any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present invention may be directly implemented as a hardware processor, or may be performed by a combination of hardware and software modules in the processor.
  • the software module can be located in a conventional storage medium such as random access memory, flash memory, read only memory, programmable read only memory or electrically erasable programmable memory, registers, and the like.
  • the storage medium is located in the memory 52, and the processor 51 reads the information in the memory 52 and performs the steps of the above method in combination with its hardware.
  • the processor 51 may obtain file information of the first page structure file of the host database and file information of the second page structure file in the standby database, where the first page structure file and the second page structure file A data file that has a corresponding relationship. Comparing the file information of the first page structure file acquired by the obtaining unit with the file information of the second page structure file to obtain a file Whether the information is the same as the comparison result. The standby database is reconstructed based on whether the text information is the same as the comparison result.
  • the file information of the first page structure file of the host database and the file information of the second page structure file in the standby database are obtained by comparing and comparing the file information according to the comparison result.
  • the database is rebuilt, which can avoid the large network resource loss caused by the full-scale reconstruction of the standby database when the amount of data in the host database is large, and can shorten the time for rebuilding the standby database.
  • the processor 51 is configured to: when the comparison result of the file information is the same, the file information of the first page structure file and the file information of the second page structure file are different.
  • the one-page structure file replaces the second page structure file.
  • the processor 51 is configured to compare the file size of the first page structure file and the file size of the second page structure file when the file information includes the file size.
  • the processor 51 is configured to replace all pages of the first page structure file with all pages of the second page structure file when the comparison result of the file sizes obtained by the comparison unit is different. page.
  • the processor 51 is configured to: when the file information includes the number of pages, the number of pages in the first page structure file and the pages in the second page structure file The number is compared.
  • the processor 51 is configured to replace all pages of the first page structure file with the second page when the comparison result of the number of file pages obtained by the comparison unit is different. All pages of the structure file.
  • the processor 51 is configured to, when the comparison result of the file information obtained by the comparing unit is the same, specifically used for version information and second information of each page in the first page structure file.
  • the version information of each page of the page in the page structure file is compared one by one. For pages having different page version information, the corresponding page of the second page structure file is replaced with the page of the first page structure file.
  • the version information of the page includes the location of the log file or the logical system time ⁇ .
  • the processor 51 is configured to perform weighting on the standby database when the reconstruction unit performs the comparison result that the text information obtained according to the first comparison unit is the same. Before the establishment, it is determined that the host database supports the replication relationship and the process of the standby database has been closed normally.
  • the processor 51 is configured to: when the comparison result obtained by the comparison unit is the same, and the comparison result of the version information of the page is also the same, the reconstruction unit is used to The two-page structure file is not modified.
  • the device 50 can implement the steps in the foregoing method embodiments, and is not described in detail to avoid repetition.
  • the size of the sequence numbers of the above processes does not mean the order of execution, and the order of execution of each process should be determined by its function and internal logic, and should not be taken to the embodiments of the present invention.
  • the implementation process constitutes any limitation.
  • B corresponding to A means that B is associated with A, and B can be determined according to A.
  • determining B from A does not mean that B is only determined based on A, and that B can also be determined based on A and/or other information.
  • RAM random access memory
  • ROM read only memory
  • electrically programmable ROM electrically erasable programmable ROM
  • registered hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

Landscapes

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

Abstract

一种重建备机数据库的方法和装置,该方法包括:获取主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息,其中,第一页式结构文件与第二页式结构文件为存在对应关系的数据文件(101),对第一页式结构文件的文件信息和第二页式结构文件的文件信息进行比较,得到文件信息是否相同的比较结果(102),根据文件信息是否相同的比较结果对备机数据库进行重建(103)。通过采用增量重建备机数据库,能够缩短重建备机数据库的时间。

Description

重建备机数据库的方法及其装置
本申请要求于2015年2月13日提交中国专利局、申请号为201510082880.6、发明名称为“重建备机数据库的方法及其装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及通信领域,并且更具体地,涉及一种重建备机数据库的方法及其装置。
背景技术
数据库(Data Base)是在计算机的存储设备上合理存放的相关联的有结构的数据集合。数据库进行双机热备时,通常采用重做(redo)日志流复制技术来实现:主机数据库将持续产生的重做日志流发送到备机数据库中,备机数据库进行回放以恢复数据,从而实现热备。然而,主机数据库中保留的日志文件是有限的,当备机数据库复制速度过慢、回放过慢或网络断裂等时,导致备机数据库无法从主机数据库复制所需日志文件,流复制机制停止。此时,需要重建备机数据库以继续进行流复制。
现有重建备机数据库的方法就是把主机数据库中的全部数据文件和全部日志文件一次性复制到备机数据库中,这样,在备机数据库重启后可以继续进行流复制。但是,当主机数据库数据量很大时,这种重建备机数据库的方法可能耗时很长,并且带来很大的网络资源损耗。
发明内容
本发明实施例提供一种重建备机数据库的方法及其装置,能够缩短重建备机数据库的时间。
第一方面,提供了一种重建备机数据库的方法,包括获取主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息,其中,所述第一页式结构文件与所述第二页式结构文件为存在对应关系的数据文件;对所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息进行比较,得到文件信息是否相同的比较结果;根据所述文件信 息是否相同的比较结果对所述备机数据库进行重建。
结合第一方面,在第一方面的一种实现方式中,所述根据所述文件信息是否相同的比较结果对所述备机数据库进行重建包括:当所述文件信息是否相同的比较结果为所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息不同时,用所述第一页式结构文件替换所述第二页式结构文件。
结合第一方面及其上述实现方式,在第一方面的另一种实现方式中,所述根据所述文件信息是否相同的比较结果对所述备机数据库进行重建包括:当所述文件信息是否相同的比较结果为所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息不同时,用所述第一页式结构文件替换所述第二页式结构文件。
结合第一方面及其上述实现方式,在第一方面的另一种实现方式中,所述文件信息包括文件大小;所述对所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息进行比较具体为:对所述第一页式结构文件的文件大小和所述第二页式结构文件的文件大小进行比较。
结合第一方面及其上述实现方式,在第一方面的另一种实现方式中,当所述文件大小的比较结果为不同时,所述对所述备机数据库进行重建具体为:将所述第一页式结构文件的所有页替换所述第二页式结构文件的所有页。
结合第一方面及其上述实现方式,在第一方面的另一种实现方式中,所述文件信息包括页的个数;所述对所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息进行比较具体为:对所述第一页式结构文件中页的个数和所述第二页式结构文件中页的个数进行比较。
结合第一方面及其上述实现方式,在第一方面的另一种实现方式中,当所述文件页的个数的比较结果为不同时,所述对所述备机数据库进行重建具体为:将所述第一页式结构文件的所有页替换所述第二页式结构文件的所有页。
结合第一方面及其上述实现方式,在第一方面的另一种实现方式中,当所述文件信息的比较结果相同时,所述对所述备机数据库进行重建具体为:对所述第一页式结构文件中每一页的版本信息和所述第二页式结构文件中页的每一页的版本信息逐个进行比较;对于页的版本信息不同的页,用所述 第一页式结构文件的页替换所述第二页式结构文件的相应的页。
结合第一方面及其上述实现方式,在第一方面的另一种实现方式中,所述页的版本信息包括日志文件的位置或逻辑系统时间戮。
结合第一方面及其上述实现方式,在第一方面的另一种实现方式中,所述根据所述文件信息是否相同的比较结果对所述备机数据库进行重建之前,还要确定所述主机数据库支持复制关系并且所述备机数据库的进程已经正常关闭。
结合第一方面及其上述实现方式,在第一方面的另一种实现方式中,当所述文件信息是否相同的比较结果为相同,且页的版本信息的比较结果也相同时,对所述第二页式结构文件不做修改。
第二方面,提供了一种重建备机数据库的装置,所述装置包括:获取单元,用于获取主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息,其中,所述第一页式结构文件与所述第二页式结构文件为存在对应关系的数据文件;比较单元,用于对所述获取单元获取的所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息进行比较,得到文件信息是否相同的比较结果;重建单元,用于根据所述比较单元得到的所述文本信息是否相同的比较结果对所述备机数据库进行重建。
结合第二方面,在第二方面的一种实现方式中,所述重建单元具体用于:当所述文件信息是否相同的比较结果为所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息不同时,用所述第一页式结构文件替换所述第二页式结构文件。
结合第二方面及其上述实现方式,在第二方面的另一种实现方式中,所述文件信息包括文件大小;所述比较单元具体用于对所述第一页式结构文件的文件大小和所述第二页式结构文件的文件大小进行比较。
结合第二方面及其上述实现方式,在第二方面的另一种实现方式中,当所述比较单元得到的所述文件大小的比较结果为不同时,所述重建单元具体用于将所述第一页式结构文件的所有页替换所述第二页式结构文件的所有页。
结合第二方面及其上述实现方式,在第二方面的另一种实现方式中,所述文件信息包括页的个数;所述比较单元具体用于对所述第一页式结构文件 中页的个数和所述第二页式结构文件中页的个数进行比较。
结合第二方面及其上述实现方式,在第二方面的另一种实现方式中,当所述比较单元得到的所述文件页的个数的比较结果为不同时,所述重建单元具体用于将所述第一页式结构文件的所有页替换所述第二页式结构文件的所有页。
结合第二方面及其上述实现方式,在第二方面的另一种实现方式中,当所述文件信息的比较结果相同时,所述重建单元具体用于:对所述第一页式结构文件中每一页的版本信息和所述第二页式结构文件中页的每一页的版本信息逐个进行比较;对于页的版本信息不同的页,用所述第一页式结构文件的页替换所述第二页式结构文件的相应的页。
结合第二方面及其上述实现方式,在第二方面的另一种实现方式中,所述页的版本信息包括日志文件的位置或逻辑系统时间戮。
结合第二方面及其上述实现方式,在第二方面的另一种实现方式中,所述装置还包括确定单元,所述确定单元用于在所述重建单元根据所述文件信息是否相同的比较结果对所述备机数据库进行重建之前,还要确定所述主机数据库支持复制关系并且所述备机数据库的进程已经正常关闭。
结合第二方面及其上述实现方式,在第二方面的另一种实现方式中,当所述比较单元得到的文件信息是否相同的比较结果为相同,且页的版本信息的比较结果也相同时,所述重建单元用于对所述第二页式结构文件不做修改。
本发明实施例在重建备机数据库时,通过获取并比较主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息是否相同,根据比较结果对备机数据库进行重建,这样可以避免主机数据库数据量很大时采用全量重建备机数据库的带来很大的网络资源损耗,能够缩短重建备机数据库的时间。
附图说明
为了更清楚地说明本发明实施例的技术方案,下面将对本发明实施例中所需要使用的附图作简单地介绍,显而易见地,下面所描述的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本发明一个实施例的重建备机数据库的方法的示意性流程图。
图2是本发明另一实施例的重建备机数据库的方法的示意性流程图。
图3是本发明一个实施例的基于主机数据库中页版本信息和备机数据库中的页版本信息对备机数据库进行重建的原理图。
图4是本发明一个实施例的重建备机数据库的装置的框图。
图5是本发明另一实施例的重建备机数据库的装置的框图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明的一部分实施例,而不是全部实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都应属于本发明保护的范围。
图1是本发明一个实施例的重建备机数据库的方法的示意性流程图。
步骤101,获取主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息,其中,第一页式结构文件与第二页式结构文件为存在对应关系的数据文件。
步骤102,对第一页式结构文件的文件信息和第二页式结构文件的文件信息进行比较,得到文件信息是否相同的比较结果。
步骤103,根据文件信息是否相同的比较结果对备机数据库进行重建。
本发明实施例在重建备机数据库时,通过获取并比较主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息是否相同,根据比较结果对备机数据库进行重建,这样可以避免主机数据库数据量很大时采用全量重建备机数据库的带来很大的网络资源损耗,能够缩短重建备机数据库的时间。
备机数据库可以获取主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息。其中,第一页式结构文件与第二页式结构文件为存在对应关系的数据文件。第一页式结构文件可以为主机数据库的数据文件中的任意一个页式结构文件。具体地,主机数据库可以从本地数据文件中读取页式结构文件的版本信息,然后将页式结构文件的文件信息发送给备机数据库。备机数据库还可以读取备机数据库的数据文件中与主机数据库的数据文件中第一页式结构文件的位置对应的第二页式结构文件 的版本信息。这里的位置对应可以是文件的位置相同,例如,第一页式结构文件在主机数据库中的位置和第二页式结构文件在备机数据库中的位置相同。
数据库中的文件包括数据文件和日志文件。重建备机数据库时,要完成对数据文件和日志文件的重建。当主机数据库中数据文件和日志文件两部分均完成复制时,表示完成对备机数据库的重建。日志文件对结构化查询语言(Structured Query Language,SQL)每次执行的记录进行跟踪,以记录数据库的更新操作。日志文件包括恢复数据库中的所有事务所需的信息。
主机数据库或备机数据库中的数据文件可能既包括页式结构文件,还包括非页式结构文件。页式结构文件以页为最小单位来存储管理。
应理解,本发明实施例中的文件信息可以为文件大小、文件中页的个数或者文件中页的版本信息。本发明实施例对文件信息不做限定。
当第一页式结构文件的文件信息和第二页式结构文件的文件信息不同时,可以用第一页式结构文件替换第二页式结构文件。即可以用主机数据库中的一个页式结构文件来替换备机数据库中与之相应位置的文件。应理解,当备机数据库中没有与主机数据库中的页式结构文件对应的文件时,可以直接将主机数据库中的该文件复制到备机数据库的相应位置,这种情形也在本发明的保护范围之内。
具体地,数据库中每个文件大小可以相同。可以通过比较文件大小来比价文件是否相同。也可以通过比较文件中页的个数来比较文件是否相同。或者,更具体地,比较文件中页的版本信息来比较文件是否相同。
当文件信息为文件大小时,对第一页式结构文件的文件信息和第二页式结构文件的文件信息进行比较具体为对第一页式结构文件的文件大小和第二页式结构文件的文件大小进行比较。例如,当主机数据库中的文件和备机数据库中的文件大小相同(比如,都为8k)时,可以认为这两个文件相同,在这种情况下,对备机数据库中的该文件不做修改。当主机数据库中的文件和备机数据库中的文件大小不同时,可以认为这两个文件不同,可以用主机数据库中的文件替换备机数据库中的对应文件,即用主机数据库中的文件的所有页替换备机数据库中对应的文件的所有页。
当文件信息为页的个数时,对第一页式结构文件的文件信息和第二页式结构文件的文件信息进行比较具体为对第一页式结构文件中页的个数和第 二页式结构文件中页的个数进行比较。例如,当主机数据库中的文件中页的个数和备机数据库中的文件中页的个数相同(比如,主机数据库的第一文件包括六页,备机数据库的第二文件包括四页。其中,第一文件与第二文件在两个数据库中的位置相同)时,可以认为这两个文件相同,在这种情况下,对备机数据库中的该文件不做修改。当主机数据库中的文件和备机数据库中的页的个数不同时,可以认为这两个文件不同,可以用主机数据库中的文件替换备机数据库中的文件,即用主机数据库中的全部页替换备机数据库的全部页。
当文件信息为页的版本信息时,对第一页式结构文件的文件信息和第二页式结构文件的文件信息进行比较具体为对第一页式结构文件中页的版本信息和第二页式结构文件中页的版本信息进行比较。可以对主机数据库中的页式结构文件和备机数据库中的对应位置的页式结构文件,这两个文件中的每一页的页的版本信息进行比较。当主机数据库中的文件中每一页的版本信息和对应的备机数据库中的文件中每一页的版本信息相同时,可以认为这两个文件相同,在这种情况下,对备机数据库中的该文件不做修改。当主机数据库中的页的版本信息和对应的备机数据库中的文件中页的版本信息不同时,可以用主机数据库中的该页替换备机数据库中的该页。应理解,当页的个数相同时,可以对不同页用主机数据库中的页替换备机数据库中的页。当页的个数不同时,例如,主机数据库中的页在备机数据库中没有对应页时,可以将主机数据库的该页复制到备机数据库的对应位置上,这种情形仍在本发明的保护范围之内。
应理解,上述三种文件信息文件大小、文件中页的个数和文件中页的版本信息可以任意组合来判断主机数据库中的页式结构文件和对应备机数据库中的页式结构文件是否相同。在此不再一一赘述。
当第一页式结构文件的文件信息和第二页式结构文件的文件信息相同时,可以认为第一页式结构文件的内容和第二页式结构文件的内容相同。当第一页式结构文件的文件信息和第二页式结构文件的文件信息不同时,可以认为第一页式结构文件的内容和第二页式结构文件的内容不同。
根据文件信息是否相同的比较结果对备机数据库进行重建包括:当文件信息是否相同的比较结果为第一页式结构文件的文件信息和第二页式结构文件的文件信息不同时,用第一页式结构文件替换第二页式结构文件。当文 件信息是否相同的比较结果为第一页式结构文件的文件信息和第二页式结构文件的文件信息相同时,对第二页式结构文件不做修改,即保留备机数据库中的第二页式结构文件。
用第一文件替换第二文件可以为将第一文件全部复制,用第一文件的全部内容替换第二文件的全部内容。第一文件中页的个数和第二文件中页的个数不同时,页可以这样进行文件的整体替换。
用第一文件替换第二文件还可以包括用第一文件的第一页与第二文件中的替换第二文件中的第一页比较,当第一文件的第一页和第二文件的第一页相同时,对第二文件的第一页不做修改。当第一文件的第一页和第二文件的第一页不同时,用第一文件的第一页替换第二文件的第一页。对第一文件和第二文件两个文件中的每一页都进行比较,这样可以在页相同时,不再对该页进行复制,这样可以减小重建备机数据库对网络资源的损耗。
具体地,第一文件的第一页为主机数据库的数据文件中页式结构文件的一页,第二文件的第一页为备机数据库中页式结构文件的一页。第一文件的第一页和第二文件的第一页在两个数据库的数据文件中的位置相同。数据库中的数据文件包括至少一个文件,数据文件可以为页式结构文件,也可以为非页式结构文件。页式结构文件是以页为最小单位来进行存储管理的。页式结构文件的页上包括版本信息,通常,版本信息为页变化历史中的位置或时刻标识。版本信息可以随着的页的更新而不断增大。一般地,页的版本信息相同,可以认为页的内容相同。页的版本信息不同,可以认为页的内容不同。当第一文件的第一页内容和第二文件的第一页内容不同时,可以用第一文件的第一页替换第二文件的第一页,例如,可以通过复制主机文件的第一页来替换第二文件的第一页。当第一文件的第一页内容和第二文件的第一页内容相同时,可以对第二文件的第一页不做修改,可以不再通过复制第一文件的第一页,也不再用主机文件的第一页替换第二文件的第二页。
例如,当主机数据库中的文件中的页的版本号码和对应备机数据库中对应文件中的对应页的版本号码相同时,对备机数据库中的文件中的该页不做修改。当主机数据库中的文件中的页的版本号码和对应备机数据库中对应文件中的对应页的版本号码不同时,用主机数据库中的文件中的该页替换备机数据库中的文件中的该页。
本发明实施例对判断页是否相同不做限定。例如,可以通过页的版本号 码来判断,但本发明并不限定于此。
应理解,本发明实施例中的替换还可以包括增加或删除。当备机数据库中不存在第二文件,(比如,双机热备过程中,备机跟不上主机,未能复制主机中的第一文件)时,在备机数据库中与主机数据库中的第一文件相同的位置上增加第一文件。当备机数据库比主机数据库中多出文件时,删除该多余的文件。上述情况都在本发明实施例中的覆盖范围之内。
本发明实施例采用增量式对备机数据库进行重建,通过比较数据文件的页式结构文件的文件信息对备机数据库进行重建,仅需要复制主机数据库和备机数据库上有变化的文件,而不再复制相同的文件。这样可以缩短重建备机数据库的时间,能够降低网络资源损耗。
本发明实施例采用增量式重建备机数据库,主机数据库不再需要向备机数据库传输全部数据,在缩短重建备机数据库的时间的同时,还可以减少对主机网络资源的消耗。
可选地,作为本发明的一个实施例,页的版本信息可以包括下列信息中的至少一种:日志文件的位置和逻辑系统时间戮。
可选地,作为本发明的一个实施例,根据文件信息是否相同的比较结果对备机数据库进行重建之前,还要确定主机数据库支持复制关系并且备机数据库的进程已经正常关闭。
可选地,作为本发明的一个实施例,当主机数据库不支持复制关系或备机数据库的进程异常关闭时,用主机数据库的数据文件覆盖备机数据库的数据文件。
在重建备机数据库之前,可以判断主机数据库是否支持复制关系。在重建备机数据库之前,还可以判断备机数据库的进程是否正常关闭。当主机数据库支持复制关系时,或者,当备机数据库的进程正常关闭时,可以根据第一页式结构文件的文件信息和第二页式结构文件的文件信息对备机数据库进行重建,这样可以提高重建备机数据库的准确率。当主机数据库支持复制关系且备机数据库正常关闭时,根据第一页式结构文件的文件信息和第二页式结构文件的文件信息对备机数据库进行重建可以进一步提高重建备机数据库的准确率。当主机数据库不支持复制关系或备机数据库的异常关闭时,采用全量式重建备机数据库,用主机数据库的数据文件覆盖备机数据库的数据文件,用主机数据库的日志文件覆盖备机数据库的日志文件。
当主机数据库启用不记录日志(Nologging)模式或者备机数据库的数据文件不是源自所述主机数据库时,确定主机数据库不支持复制关系。备机数据库的数据文件不是源自主机数据库,可以认为是备机数据库与主机数据库不匹配,那么主机数据库不支持复制关系。例如,主机数据库的标识符与备机数据库的标识符不一致。
应理解,本发明实施例对如何确定主机数据库不支持复制关系不做限制。例如,当主机数据库与备机数据库不匹配时,都可以认为主机数据库不支持复制关系。
主机数据库可能启用Nologging模式进行应用数据库的升级,这样,备机数据库便无法得知主机数据库是否有修改或进行了哪些修改,这时,无法使用增量式重建备机数据库。当主机数据库启用过Nologging模式时,可以认为主机数据库不支持复制关系。
当主机数据库不支持复制关系时,不能采用增量式对备机数据库进行重建,而需要采用全量式对备机数据库进行重建,将主机数据库中的全部数据文件和全部日志文件复制到备机数据库中,即用主机数据库的数据文件覆盖备机数据库的数据文件,用主机数据库的日志文件覆盖备机数据库的日志文件。
备机数据库还包括控制文件,备机数据库的控制文件可以记载备机数据库的状态信息。备机数据库可以根据该状态信息得知备机数据库是否正常关闭。本发明实施例对如何判断备机数据库是否正常关闭不做限制。
当备机数据库异常关闭时,可能存在只写了一部分(partial write)的页,此时比较页的版本信息无法判断主机数据库中的页与对应备机数据库中的页的内容是否相同。所以当备机数据库异常关闭时,不能采用增量式对备机数据库进行重建,而需要采用全量式对备机数据库进行重建,将主机数据库中的全部数据文件和全部日志文件复制到备机数据库中,即用主机数据库的数据文件覆盖备机数据库的数据文件,用主机数据库的日志文件覆盖备机数据库的日志文件。
主机数据库是否支持复制关系和备机数据库是否正常关闭这两个判断步骤的先后顺序可以互换。本发明实施例对判断主机数据库是否支持复制关系和判断备机数据库是否正常关闭的先后顺序不做限定。当主机数据库不支持复制关系或者备机数据库异常关闭时,可以采用全量式对备机数据库进行 重建。当主机数据库支持复制关系时,或者当备机数据库正常关闭时,或者当主机数据库支持复制关系,并且备机数据库正常关闭时,可以采用增量式重建备机数据库。
主机数据库或备机数据库中的数据文件可能既包括页式结构文件,还包括非页式结构文件。对于数据文件中的非页式结构文件,无法通过比较页的版本信息对备机数据库进行重建,而直接将主机数据库的数据文件中的非页式结构文件替换对应备机数据库的数据文件中的对应位置的非页式结构文件。
可选地,作为本发明的一个实施例,主机数据库的数据文件中包括非页式结构文件时,用主机数据库的数据文件中的非页式结构文件替换备机数据库的数据文件的非页式结构文件。主机数据库还包括日志文件,在进行备机数据库重建时,可以用主机数据库的日志文件替换备机数据库的日志文件。
本发明实施例提供了一种高性能的备机数据库的重建方法,通过比较主机数据库的数据文件的第一页式结构文件的文件信息和备机数据库的数据文件的第二页式结构文件的文件信息,第一页式结构文件的文件信息和第二页式结构文件的文件信息相同时,可以认为这两个文件信息的内容相同,对备机数据库的数据文件的页式结构中的该页不做修改,从而可以减少需要传输的数据量,这样可以缩短重建备机数据库的时间,从而提高数据库系统的可用性,进而能够提升备机数据库的重建性能。
重建备机数据库时,当主机数据库中数据文件和日志文件两部分均完成复制时,表示完成对备机数据库的重建。日志文件对结构化查询语言(Structured Query Language,SQL)每次执行的记录进行跟踪,以记录数据库的更新操作。日志文件包括恢复数据库中的所有事务所需的信息。
完成重建备机数据库时,可以将备机数据库拉起,并重新建立主机数据库和备机数据库之间的复制关系,以继续进行数据库双机热备等通信过程。
图2是本发明另一个实施例的重建备机数据库的方法的示意性流程图。
步骤201,关闭备机数据库的进程,开始重建备机数据库。
数据库双机热备过程中,主机数据库保存的日志文件是有限的。当备机数据库复制速度过慢、备机数据库回放过慢或者网络断裂等时,备机数据库无法从主机数据库复制所需日志文件。这时,日志流复制机制停止,此时备机数据库需要进行重建。首先关闭备机数据库的进程,以开始进行重建的数 据库。
步骤202,判断主机数据库是否支持复制关系。
主机数据库不支持复制关系包括主机数据库启用过Nologging模式、备机数据库与主机数据库不匹配。主机数据库可能启用Nologging模式进行应用数据库的升级,这样,备机数据库便无法得知主机数据库是否有修改或进行了哪些修改,这时,无法使用增量式对备机数据库进行重建。当主机数据库启用过Nologging模式时,可以认为主机数据库不支持复制关系。另外,主机数据库与备机数据库可能存在不匹配的情况,例如,备机数据库中的数据不是源自主机数据库,或者主机数据库的标识符与备机数据库的标识符(例如,ID)不一致。
步骤203,全量式重建备机数据库。
当步骤202的判断结果为主机数据库不支持复制关系时,不能采用增量式对备机数据库进行重建,可以采用全量式对备机数据库进行重建。备机数据库可以用主机数据库的全部数据文件和全部日志文件替换在备机数据库对应位置上,以对备机数据库进行重建。
步骤204,判断备机数据库的进程是否正常关闭。
当步骤202的判断结果为主机数据库支持复制关系时,继续判断备机数据库是否正常关闭。
步骤202和步骤204两个判断步骤的先后顺序可以互换。本发明实施例对判断主机数据库是否支持复制关系和判断备机数据库的进程是否正常关闭的先后顺序不做限定。例如,还可以先判断备机数据库的进程是否正常关闭,当判断结果为备机数据库的进程正常关闭时,继续判断主机数据库是否支持复制关系。当判断结果为备机数据库的进程异常关闭时,采用全量式重建备机数据库,即用主机数据库中的数据文件和日志文件替换备机数据库中对应位置的数据文件和日志文件,或者重新拉起备机数据库,然后正常关闭备机数据库的进程,进而重新判断备机数据库是否正常关闭和主机数据库是否支持复制关系。
步骤205,采用全量式重建机数据库。
当备机数据库的进程异常关闭时,可能存在只写了一部分(partial write)的页,此时比较文件信息无法判断主机数据库的数据文件中页式结构文件与备机数据库的数据文件中页式结构文件的对应位置的文件的内容是否相同。 所以当步骤204的判断结果为备机数据库的进程异常关闭时,采用全量式重建机数据库,即用主机数据库的数据文件替换备机数据库的数据文件,用主机数据库日志文件替换备机数据库的日志文件。
步骤206,重新拉起备机数据库,正常关闭备机数据库的进程。
当步骤204的判断结果为备机数据库异常关闭时,还可以重新拉起备机数据库,然后正常关闭备机数据库的进程,进而重新返回步骤202判断主机数据库是否支持复制关系,以继续执行后续流程。
步骤205和步骤206是当步骤204的判断结果为备机数据库异常关闭时所采用的不同方法。当判断备机数据库异常关闭时,步骤205和步骤206不会同时执行,而可以择一选择执行步骤205或步骤206。
步骤207,备机数据库与主机数据库连接。
备机数据库和主机数据库相连接,以开启数据文件和日志文件两条复制流程进行重建备机数据库。下面从步骤208是开启日志文件重建流程。从步骤209开启数据文件重建流程。
应理解,数据文件和日志文件两条重建流程同时进行,互不干扰。步骤208的日志文件重建可以在整个备机数据库重建完成前都在进行,以实时用主机数据库的日志文件覆盖备机数据库的日志文件。例如,将主机数据库中的日志文件复制到备机数据库中,并替换备机数据库中的日志文件。
步骤208,重建日志文件。
重建日志文件,用主机数据库中的日志文件覆盖备机数据库中的日志文件。
步骤209,判断是否还有未重建的数据文件。
数据库中的数据文件包括至少一个文件。当步骤209的判断结果为还有未重建的页时,遍历当前所有的数据文件,继续执行步骤210,继续对其他文件进行重建,对其他文件继续执行不做修改或用主机数据库的文件替换备机数据库中的对应文件。当步骤209的判断结果为没有未重建的数据文件时,即主机数据库中的所有数据文件都已经完成重建,则执行步骤215,结束整个流程。
步骤210,判断第一文件是否为页式结构文件。
当步骤209判断结果为主机数据库中存在未进行备机数据库重建的数据文件时,执行步骤210,判断第一文件是否为页式结构文件,其中,第一文 件可以为主机数据库的数据文件中的任意一个文件。
步骤211,判断文件信息是否相同。
当步骤210的判断结果为第一文件为页式结构文件时,执行步骤211,判断文件信息是否相同。假设第二文件为备机数据库中与主机数据库中第一文件对应的文件,那么步骤211判断第一文件的文件信息和第二文件的文件信息是否相同。
本发明实施例对如何比较文件信息判断得到文件内容是否相同不做限定。本发明实施例中的文件信息可以为文件大小、文件中页的个数或文件中页的版本信息。文件信息还可以为其他的相关信息,本发明实施例对此不做限定。
步骤212,对第二文件不做修改。
当步骤211的判断结果为第一文件的文件信息和第二文件的文件信息相同时,可以认为第一文件的文件内容和第二文件的文件内容相同。此时,可以对第二文件不做修改,即备机数据库中保留第二文件。
步骤211之后,执行步骤209,判断是否还有未重建的文件。
步骤213,用第一文件替换第二文件。
当步骤211的判断结果为第一文件的文件信息和第二文件的文件信息不同时,可以认为第一文件的文件内容和第二文件的文件内容不同。此时,可以用第一文件替换第二文件。
应理解,用第一文件替换第二文件可以为将第一文件全部复制,用第一文件的全部内容替换第二文件的全部内容。
用第一文件替换第二文件还可以包括用第一文件的第一页与第二文件中的替换第二文件中的第一页比较,当第一文件的第一页和第二文件的第一页相同时,对第二文件的第一页不做修改。当第一文件的第一页和第二文件的第一页不同时,用第一文件的第一页替换第二文件的第一页。对第一文件和第二文件两个文件中的每一页都进行比较,这样可以在页相同时,不再对该页进行复制,这样可以减小重建备机数据库对网络资源的损耗。
应理解,替换还包括增加或删除。例如,当第一文件和第二文件内容不同时,可以用第一文件替换第二文件。当备机数据库中不存在第二文件,(比如,双机热备过程中,备机跟不上主机,未能复制主机中的第一文件)时,在备机数据库中与主机数据库中的第一文件相同的位置上增加第一文件。当 备机数据库比主机数据库中多出文件时,删除该多余的文件。上述情况都在本发明实施例中的覆盖范围之内。
步骤213之后,执行步骤209,判断是否还有未重建的文件。
步骤214,复制第一文件到备机数据库。
当判断步骤210得到第一文件为非页式结构文件时,采用将第一文件复制到备机数据库的对应位置上。
步骤215,结束。
当步骤209判断结果为没有为未重建的数据文件时,且已完成步骤208时,执行步骤215,结束整个流程。
流程进行到215时,表示已完成整个重建备机数据库的过程。
图3是本发明一个实施例的基于主机数据库中页版本信息和备机数据库中的页版本信息对备机数据库进行重建的原理图。
图3中301为主机数据库的数据文件中的页式结构的文件,302为原备机数据库中的数据文件中页式结构的文件,303为重建后的备机数据库中的数据文件中页式结构的文件。其中,一个长方形小格表示一页,连续的连在一起的几页表示一个文件。例如,图中301-1,301-2,302-1,302-2,303-1,303-2都表示一页。301-1,301-2和后面连续两个小格表示一个文件。301和302中的空白小格表示主机数据库的数据文件和备机数据库的数据文件的相同位置的页的版本信息相同,例如,图3中页301-1和页302-1的版本信息相同。301和302中的阴影小格表示主机数据库的数据文件和备机数据库的数据文件的相同位置的页的版本信息不同,例如,图3中页301-2和页302-2的版本信息相同。
图3中301中的文件与302中对应位置的文件对应。301中的每个文件与302中的每个文件对应。例如,301中第一行包括两个文件,第一个文件包括四页,第二个文件包括两个,第二行包括一个七页的文件,第三行包括一个两页的文件和一个四页的文件。302中的每一个文件都与301中的每个文件对应。
图3中301每个文件中每一页与302每个文件中每一页对应。例如,页301-1与页302-1对应。
本发明实施例中,可以通过比较主机数据库的数据文件和备机数据库的数据文件相同位置的页的版本信息,来对备机数据库进行重建。如果主机数 据库的数据文件和备机数据库的数据文件的相同位置的页的版本信息相同,则可以认为该页的关键内容相同,重建备机数据库时,无需对该页进行处理,即对该页不做处理。如果主机数据库的数据文件和备机数据库的数据文件相同位置的页的版本信息不同,则可以认为该页的关键内容不同,重建备机数据库时,可以用主机数据库的数据文件中的该页替换备机数据库的数据文件中的页。
例如,比较页301-1和页302-1的版本信息可以得到页301-1和页302-1的版本信息相同,备机数据库不再复制页301-1来替换302-1,而对页302-1不做处理,即备机数据库的数据文件中保留页302-1,将页302-1作为重建后的备机数据库中的页式结构文件的页303-1。比较页301-2和页302-2的版本信息可以得到页301-2和页302-2的版本信息不同,备机数据库用页301-1覆盖原备机数据库的页式结构文件的页303-2,即用页301-1作为重建后的备机数据库的页式结构文件的页303-2。
如此遍历页式结构文件中的每一页,将主机数据库的页式结构文件和对应备机数据库的页式结构文件相比较。如果页的版本信息相同,则对备机数据库的数据文件中的该页不做修改。如果页的版本信息不同,则用主机数据库的数据文件中的页替换备机数据库的数据文件中的页。
如果主机数据库的数据文件中存在非页式结构的文件,则用该非页式结构的文件替换备机数据库的数据文件中的非页式结构文件。
最后,复制所有的日志文件到备机数据库中,即用主机数据库中的日志文件覆盖备机数据库的日志文件,这样,即可以完成对备机数据库的重建。
重建备机数据库完成时,可以将备机数据库拉起,并重新建立主机数据库与备机数据库之间的复制关系,以继续进行数据库双机热备等通信过程。
上面结合图1、图2和图3详细描述了重建备机数据库的方法和原理,下面结合图4和图5详细描述重建备机数据库的装置。
图4是本发明一个实施例的重建备机数据库的装置的框图。图4的装置40包括获取单元41和重建单元42。
获取单元41用于获取主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息,其中,第一页式结构文件与第二页式结构文件为存在对应关系的数据文件。
比较单元42用于对获取单元获取的第一页式结构文件的文件信息和第 二页式结构文件的文件信息进行比较,得到文件信息是否相同的比较结果.
重建单元43用于根据比较单元得到的文本信息是否相同的比较结果对备机数据库进行重建。
本发明实施例在重建备机数据库时,通过获取并比较主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息是否相同,根据比较结果对备机数据库进行重建,这样可以避免主机数据库数据量很大时采用全量重建备机数据库的带来很大的网络资源损耗,能够缩短重建备机数据库的时间。
可选地,作为本发明的一个实施例,重建单元具体用于:当文件信息是否相同的比较结果为第一页式结构文件的文件信息和第二页式结构文件的文件信息不同时,用第一页式结构文件替换第二页式结构文件。
可选地,作为本发明的一个实施例,文件信息包括文件大小。比较单元具体用于对第一页式结构文件的文件大小和第二页式结构文件的文件大小进行比较。
可选地,作为本发明的一个实施例,当比较单元得到的文件大小的比较结果为不同时,重建单元具体用于将第一页式结构文件的所有页替换第二页式结构文件的所有页。
可选地,作为本发明的一个实施例,文件信息包括页的个数。比较单元具体用于述第一页式结构文件中页的个数和第二页式结构文件中页的个数进行比较。
可选地,作为本发明的一个实施例,当比较单元得到的文件页的个数的比较结果为不同时,重建单元具体用于将第一页式结构文件的所有页替换第二页式结构文件的所有页。
可选地,作为本发明的一个实施例,当比较单元得到的文件信息的比较结果相同时,重建单元具体用于:对第一页式结构文件中每一页的版本信息和第二页式结构文件中页的每一页的版本信息逐个进行比较。对于页的版本信息不同的页,用第一页式结构文件的页替换第二页式结构文件的相应的页。
可选地,作为本发明的一个实施例,页的版本信息包括日志文件的位置或逻辑系统时间戮。
可选地,作为本发明的一个实施例,装置还包括确定单元,用于在重建 单元根据文件信息是否相同的比较结果对备机数据库进行重建之前,还要确定主机数据库支持复制关系并且备机数据库的进程已经正常关闭。
可选地,作为本发明的一个实施例,当比较单元得到的文件信息是否相同的比较结果为相同,且页的版本信息的比较结果也相同时,重建单元用于对第二页式结构文件不做修改。
图4的装置40可以执行图1、图2、和图3所示的方法的各个流程,为避免重复,在此不再详细描述。
图5是根据本发明另一实施例的重建备机数据库的装置的框图。该装置50包括处理器51、存储器52和总线系统53。其中,处理器51和存储器52通过总线系统53相连,该存储器52用于存储指令,该处理器51用于执行该存储器52存储的指令和数据。存储器52的一部分还可以包括非易失行随机存取存储器(NVRAM,Non-Volatile Random Access Memory)。装置的各个组件通过总线系统53耦合在一起,其中总线系统53除包括数据总线之外,还包括电源总线、控制总线和状态信号总线。但是为了清楚说明起见,在图中将各种总线都标为总线系统53。
上述本发明实施例揭示的方法可以应用于处理器51中,或者由处理器51实现。在实现过程中,上述方法的各步骤可以通过处理器51中的硬件的集成逻辑电路或者软件形式的指令完成。处理器51可以是通用处理器、数字信号处理器、专用集成电路、现场可编程门阵列或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件,可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者任何常规的处理器等。结合本发明实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器52,处理器51读取存储器52中的信息,结合其硬件完成上述方法的步骤。
具体地,处理器51可以获取主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息,其中,第一页式结构文件与第二页式结构文件为存在对应关系的数据文件。对获取单元获取的第一页式结构文件的文件信息和第二页式结构文件的文件信息进行比较,得到文件 信息是否相同的比较结果。根据文本信息是否相同的比较结果对备机数据库进行重建。
本发明实施例在重建备机数据库时,通过获取并比较主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息是否相同,根据比较结果对备机数据库进行重建,这样可以避免主机数据库数据量很大时采用全量重建备机数据库的带来很大的网络资源损耗,能够缩短重建备机数据库的时间。
可选地,作为本发明的一个实施例,处理器51用于当文件信息是否相同的比较结果为第一页式结构文件的文件信息和第二页式结构文件的文件信息不同时,用第一页式结构文件替换第二页式结构文件。
可选地,作为本发明的一个实施例,处理器51用于当文件信息包括文件大小时,对第一页式结构文件的文件大小和第二页式结构文件的文件大小进行比较。
可选地,作为本发明的一个实施例,处理器51用于当比较单元得到的文件大小的比较结果为不同时,将第一页式结构文件的所有页替换第二页式结构文件的所有页。
可选地,作为本发明的一个实施例,处理器51用于当文件信息包括页的个数时,对第一页式结构文件中页的个数和第二页式结构文件中页的个数进行比较。
可选地,作为本发明的一个实施例,处理器51用于当比较单元得到的文件页的个数的比较结果为不同时,用于将第一页式结构文件的所有页替换第二页式结构文件的所有页。
可选地,作为本发明的一个实施例,处理器51用于当比较单元得到的文件信息的比较结果相同时,具体用于对第一页式结构文件中每一页的版本信息和第二页式结构文件中页的每一页的版本信息逐个进行比较。对于页的版本信息不同的页,用第一页式结构文件的页替换第二页式结构文件的相应的页。
可选地,作为本发明的一个实施例,页的版本信息包括日志文件的位置或逻辑系统时间戮。
可选地,作为本发明的一个实施例,处理器51用于在重建单元执行根据第一比较单元得到的文本信息是否相同的比较结果对备机数据库进行重 建之前确定主机数据库支持复制关系并且备机数据库的进程已经正常关闭。
可选地,作为本发明的一个实施例,处理器51用于当比较单元得到的文件信息是否相同的比较结果为相同,且页的版本信息的比较结果也相同时,重建单元用于对第二页式结构文件不做修改。
装置50能够实现前述方法实施例中的步骤,为避免重复,不再详细描述。
应理解,说明书通篇中提到的“一个实施例”或“一实施例”意味着与实施例有关的特定特征、结构或特性包括在本发明的至少一个实施例中。因此,在整个说明书各处出现的“在一个实施例中”或“在一实施例中”未必一定指相同的实施例。此外,这些特定的特征、结构或特性可以任意适合的方式结合在一个或多个实施例中。
应理解,在本发明的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本发明实施例的实施过程构成任何限定。
应理解,在本发明实施例中,“与A相应的B”表示B与A相关联,根据A可以确定B。但还应理解,根据A确定B并不意味着仅仅根据A确定B,还可以根据A和/或其它信息确定B。
应理解,本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。
本领域普通技术人员可以意识到,结合本文中所公开的实施例中描述的各方法步骤和单元,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各实施例的步骤及组成。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。本领域普通技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。
结合本文中所公开的实施例描述的方法或步骤可以用硬件、处理器执行的软件程序,或者二者的结合来实施。软件程序可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存 器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。
尽管通过参考附图并结合优选实施例的方式对本发明进行了详细描述,但本发明并不限于此。在不脱离本发明的精神和实质的前提下,本领域普通技术人员可以对本发明的实施例进行各种等效的修改或替换,而这些修改或替换都应在本发明的涵盖范围内。

Claims (20)

  1. 一种重建备机数据库的方法,其特征在于,包括:
    获取主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息,其中,所述第一页式结构文件与所述第二页式结构文件为存在对应关系的数据文件;
    对所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息进行比较,得到文件信息是否相同的比较结果;
    根据所述文件信息是否相同的比较结果对所述备机数据库进行重建。
  2. 如权利要求1所述的方法,其特征在于,所述根据所述文件信息是否相同的比较结果对所述备机数据库进行重建包括:
    当所述文件信息是否相同的比较结果为所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息不同时,用所述第一页式结构文件替换所述第二页式结构文件。
  3. 如权利要求1或2所述的方法,其特征在于,所述文件信息包括文件大小;
    所述对所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息进行比较具体为:
    对所述第一页式结构文件的文件大小和所述第二页式结构文件的文件大小进行比较。
  4. 如权利要求3所述的方法,其特征在于,
    当所述文件大小的比较结果为不同时,所述对所述备机数据库进行重建具体为:将所述第一页式结构文件的所有页替换所述第二页式结构文件的所有页。
  5. 如权利要求1或2所述的方法,其特征在于,所述文件信息包括页的个数;
    所述对所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息进行比较具体为:
    对所述第一页式结构文件中页的个数和所述第二页式结构文件中页的个数进行比较。
  6. 如权利要求5所述的方法,其特征在于,
    当所述文件页的个数的比较结果为不同时,所述对所述备机数据库进行重建具体为:将所述第一页式结构文件的所有页替换所述第二页式结构文件的所有页。
  7. 如权利要求3或5所述的方法,其特征在于,当所述文件信息的比较结果相同时,所述对所述备机数据库进行重建具体为:
    对所述第一页式结构文件中每一页的版本信息和所述第二页式结构文件中页的每一页的版本信息逐个进行比较;
    对于页的版本信息不同的页,用所述第一页式结构文件的页替换所述第二页式结构文件的相应的页。
  8. 如权利要求7所述的方法,其特征在于,所述页的版本信息包括日志文件的位置或逻辑系统时间戮。
  9. 如权利要求1至8中任一项所述的方法,其特征在于,所述根据所述文件信息是否相同的比较结果对所述备机数据库进行重建之前,还要确定所述主机数据库支持复制关系并且所述备机数据库的进程已经正常关闭。
  10. 如权利要求7所述的方法,其特征在于,
    当所述文件信息是否相同的比较结果相同,且页的版本信息的比较结果相同时,对所述第二页式结构文件不做修改。
  11. 一种重建备机数据库的装置,其特征在于,包括:
    获取单元,用于获取主机数据库的第一页式结构文件的文件信息和备机数据库中第二页式结构文件的文件信息,其中,所述第一页式结构文件与所述第二页式结构文件为存在对应关系的数据文件;
    比较单元,用于对所述获取单元获取的所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息进行比较,得到文件信息是否相同的比较结果;
    重建单元,用于根据所述比较单元得到的所述文本信息是否相同的比较结果对所述备机数据库进行重建。
  12. 如权利要求10所述的装置,其特征在于,所述重建单元具体用于:
    当所述比较单元得到的所述文件信息是否相同的比较结果为所述第一页式结构文件的文件信息和所述第二页式结构文件的文件信息不同时,用所述第一页式结构文件替换所述第二页式结构文件。
  13. 如权利要求12或13所述的装置,其特征在于,所述文件信息包括 文件大小;
    所述比较单元具体用于对所述第一页式结构文件的文件大小和所述第二页式结构文件的文件大小进行比较。
  14. 如权利要求13所述的装置,其特征在于,
    当所述比较单元得到的所述文件大小的比较结果为不同时,所述重建单元具体用于将所述第一页式结构文件的所有页替换所述第二页式结构文件的所有页。
  15. 如权利要求11或12所述的装置,其特征在于,所述文件信息包括页的个数;
    所述比较单元具体用于对所述第一页式结构文件中页的个数和所述第二页式结构文件中页的个数进行比较。
  16. 如权利要求15所述的装置,其特征在于,
    当所述比较单元得到的所述文件页的个数的比较结果为不同时,所述重建单元具体用于将所述第一页式结构文件的所有页替换所述第二页式结构文件的所有页。
  17. 如权利要求13或15所述的装置,其特征在于,当所述比较单元得到的所述文件信息的比较结果相同时,所述重建单元具体用于:
    对所述第一页式结构文件中每一页的版本信息和所述第二页式结构文件中页的每一页的版本信息逐个进行比较;
    对于页的版本信息不同的页,用所述第一页式结构文件的页替换所述第二页式结构文件的相应的页。
  18. 如权利要求17所述的装置,其特征在于,所述页的版本信息包括日志文件的位置或逻辑系统时间戮。
  19. 如权利要求11至18中任一项所述的装置,其特征在于,所述装置还包括确定单元,所述确定单元用于在所述重建单元根据所述文件信息是否相同的比较结果对所述备机数据库进行重建之前,还要确定所述主机数据库支持复制关系并且所述备机数据库的进程已经正常关闭。
  20. 如权利要求17所述的装置,其特征在于,
    当所述比较单元得到的所述文件信息是否相同的比较结果相同,且页的版本信息的比较结果相同时,所述重建单元用于对所述第二页式结构文件不做修改。
PCT/CN2015/083536 2015-02-13 2015-07-08 重建备机数据库的方法及其装置 WO2016127557A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
RU2017102476A RU2665884C2 (ru) 2015-02-13 2015-07-08 Способ и устройство для восстановления базы данных резервного узла
EP15881718.9A EP3147789B1 (en) 2015-02-13 2015-07-08 Method for re-establishing standby database, and apparatus thereof
JP2017501381A JP6470391B2 (ja) 2015-02-13 2015-07-08 スタンバイノードデータベースを再構築するための方法及び装置
US15/377,683 US10585895B2 (en) 2015-02-13 2016-12-13 Method and apparatus for reconstructing standby node database

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510082880.6 2015-02-13
CN201510082880.6A CN104636480B (zh) 2015-02-13 2015-02-13 重建备机数据库的方法及其装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/377,683 Continuation US10585895B2 (en) 2015-02-13 2016-12-13 Method and apparatus for reconstructing standby node database

Publications (1)

Publication Number Publication Date
WO2016127557A1 true WO2016127557A1 (zh) 2016-08-18

Family

ID=53215226

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/083536 WO2016127557A1 (zh) 2015-02-13 2015-07-08 重建备机数据库的方法及其装置

Country Status (6)

Country Link
US (1) US10585895B2 (zh)
EP (1) EP3147789B1 (zh)
JP (1) JP6470391B2 (zh)
CN (1) CN104636480B (zh)
RU (1) RU2665884C2 (zh)
WO (1) WO2016127557A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021248786A1 (zh) * 2020-06-11 2021-12-16 深圳创维-Rgb电子有限公司 key码数据烧录方法、装置、终端设备和可读存储介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104636480B (zh) 2015-02-13 2018-09-28 华为技术有限公司 重建备机数据库的方法及其装置
CN106484869A (zh) * 2016-10-12 2017-03-08 北京集奥聚合科技有限公司 一种基于mysql binlog的分布式缓存方法及系统
CN107368392A (zh) * 2017-07-25 2017-11-21 郑州云海信息技术有限公司 一种从数据库的重建方法、主数据库及从数据库
CN107547648A (zh) * 2017-08-31 2018-01-05 郑州云海信息技术有限公司 一种内部数据复制方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101477486A (zh) * 2009-01-22 2009-07-08 中国人民解放军国防科学技术大学 一种基于扇区重组的文件备份恢复方法
CN101894137A (zh) * 2010-06-23 2010-11-24 中兴通讯股份有限公司 嵌入式数据库中数据恢复的方法和装置
US8682844B2 (en) * 2005-01-28 2014-03-25 Sap Ag Method and apparatus for collision resolution in an asynchronous database system
CN104111937A (zh) * 2013-04-18 2014-10-22 中兴通讯股份有限公司 主、备数据库及其数据一致性检测、修复方法和装置
CN104636480A (zh) * 2015-02-13 2015-05-20 华为技术有限公司 重建备机数据库的方法及其装置

Family Cites Families (24)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE69413977T2 (de) * 1993-07-01 1999-03-18 Legent Corp Anordnung und verfahren zur verteilten datenverwaltung in vernetzten rechnersystemen
JPH07234812A (ja) * 1994-02-23 1995-09-05 Mitsubishi Electric Corp 分散システムにおけるデータコンペア方式
US5907849A (en) * 1997-05-29 1999-05-25 International Business Machines Corporation Method and system for recovery in a partitioned shared nothing database system using virtual share disks
US6049853A (en) * 1997-08-29 2000-04-11 Sequent Computer Systems, Inc. Data replication across nodes of a multiprocessor computer system
US6289357B1 (en) * 1998-04-24 2001-09-11 Platinum Technology Ip, Inc. Method of automatically synchronizing mirrored database objects
JP4374093B2 (ja) * 1999-06-14 2009-12-02 株式会社ジャストシステム 情報処理装置、情報処理方法、およびその方法をコンピュータに実行させるプログラムを記録したコンピュータ読み取り可能な記録媒体
US6526418B1 (en) * 1999-12-16 2003-02-25 Livevault Corporation Systems and methods for backing up data files
JP2001325107A (ja) * 2000-05-17 2001-11-22 Ntt Comware Corp 情報更新方法
JP2002149465A (ja) * 2000-11-09 2002-05-24 Nec Informatec Systems Ltd 情報共有システム
US7010553B2 (en) * 2002-03-19 2006-03-07 Network Appliance, Inc. System and method for redirecting access to a remote mirrored snapshot
US7051053B2 (en) * 2002-09-30 2006-05-23 Dinesh Sinha Method of lazily replicating files and monitoring log in backup file system
US7698318B2 (en) * 2006-02-10 2010-04-13 Microsoft Corporation Automatically determining file replication mechanisms
JP2007233671A (ja) * 2006-03-01 2007-09-13 Fuji Xerox Co Ltd 画像処理装置、画像処理方法および画像処理プログラム
US7685386B2 (en) 2007-01-24 2010-03-23 International Business Machines Corporation Data storage resynchronization using application features
JP2008257444A (ja) * 2007-04-04 2008-10-23 Nec Corp 類似ファイル管理装置、その方法及びそのプログラム
EP2003579B1 (en) * 2007-06-15 2015-08-19 Hitachi, Ltd. Method and system for data processing with database update for the same
US7865475B1 (en) * 2007-09-12 2011-01-04 Netapp, Inc. Mechanism for converting one type of mirror to another type of mirror on a storage system without transferring data
CN101246535A (zh) * 2008-03-25 2008-08-20 深圳市迅雷网络技术有限公司 一种修复异常文件的方法、系统和装置
US8402071B2 (en) * 2009-06-19 2013-03-19 Aptare, Inc. Catalog that stores file system metadata in an optimized manner
US8219768B2 (en) * 2010-01-05 2012-07-10 Hitachi, Ltd. System and method for establishing a copy pair relationship between source and destination volumes
CN102054035B (zh) * 2010-12-29 2013-01-02 北京播思软件技术有限公司 一种基于数据范围的数据库数据同步方法
CN103077242B (zh) * 2013-01-11 2016-03-09 北京佳讯飞鸿电气股份有限公司 一种实现数据库服务器双机热备的方法
US20140201140A1 (en) * 2013-01-11 2014-07-17 Commvault Systems, Inc. Data synchronization management
US9892153B2 (en) * 2014-12-19 2018-02-13 Oracle International Corporation Detecting lost writes

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8682844B2 (en) * 2005-01-28 2014-03-25 Sap Ag Method and apparatus for collision resolution in an asynchronous database system
CN101477486A (zh) * 2009-01-22 2009-07-08 中国人民解放军国防科学技术大学 一种基于扇区重组的文件备份恢复方法
CN101894137A (zh) * 2010-06-23 2010-11-24 中兴通讯股份有限公司 嵌入式数据库中数据恢复的方法和装置
CN104111937A (zh) * 2013-04-18 2014-10-22 中兴通讯股份有限公司 主、备数据库及其数据一致性检测、修复方法和装置
CN104636480A (zh) * 2015-02-13 2015-05-20 华为技术有限公司 重建备机数据库的方法及其装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3147789A4 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021248786A1 (zh) * 2020-06-11 2021-12-16 深圳创维-Rgb电子有限公司 key码数据烧录方法、装置、终端设备和可读存储介质

Also Published As

Publication number Publication date
EP3147789A4 (en) 2017-07-19
CN104636480A (zh) 2015-05-20
JP6470391B2 (ja) 2019-02-13
EP3147789B1 (en) 2019-04-10
CN104636480B (zh) 2018-09-28
US20170091280A1 (en) 2017-03-30
JP2017521791A (ja) 2017-08-03
EP3147789A1 (en) 2017-03-29
RU2017102476A3 (zh) 2018-07-26
RU2665884C2 (ru) 2018-09-04
US10585895B2 (en) 2020-03-10
RU2017102476A (ru) 2018-07-26

Similar Documents

Publication Publication Date Title
US9727273B1 (en) Scalable clusterwide de-duplication
US8127174B1 (en) Method and apparatus for performing transparent in-memory checkpointing
WO2016127557A1 (zh) 重建备机数据库的方法及其装置
US7814057B2 (en) Page recovery using volume snapshots and logs
US8281093B1 (en) Systems and methods for creating consolidated backups of snapshot hierarchies
JP6026538B2 (ja) 検証されたデータセットの不揮発性媒体ジャーナリング
CN107644030B (zh) 分布式数据库数据同步方法、相关装置及系统
JP4583087B2 (ja) トランザクションの整合性を保つ書き込み時コピーのデータベース
WO2017190604A1 (zh) 数据库系统中事务恢复的方法与数据库管理系统
CN109542682B (zh) 一种数据备份方法、装置、设备和存储介质
US20140379656A1 (en) System and Method for Maintaining a Cluster Setup
US10740184B2 (en) Journal-less recovery for nested crash-consistent storage systems
CN103729442A (zh) 记录事务日志的方法和数据库引擎
US20100017648A1 (en) Complete dual system and system control method
US20170262307A1 (en) Method and apparatus for conversion of virtual machine formats utilizing deduplication metadata
US10613923B2 (en) Recovering log-structured filesystems from physical replicas
US11307922B2 (en) Application crash analysis techniques when memory dump and debug symbols are not co-located
US8639968B2 (en) Computing system reliability
WO2019109256A1 (zh) 一种日志管理方法、服务器和数据库系统
US10740202B2 (en) System and method for efficient comparison of mirrored storage devices
US20230297510A1 (en) Write-behind optimization of covering cache
WO2013091183A1 (zh) 一种键值对的操作方法及装置
CN105760456A (zh) 一种保持数据一致性的方法和装置
US11669501B2 (en) Address mirroring of a file system journal
US11200219B2 (en) System and method for idempotent metadata destage in a storage cluster with delta log based architecture

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: 15881718

Country of ref document: EP

Kind code of ref document: A1

REEP Request for entry into the european phase

Ref document number: 2015881718

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2015881718

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 2017501381

Country of ref document: JP

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2017102476

Country of ref document: RU

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE