Data migration control method, system, computer device and storage medium
By automatically adjusting the classification and migration scope of the data tables to be migrated in the HBase database, the problem of high manpower and material resources consumption in large-scale data migration is solved, and the automation and efficiency of data migration are realized.
Patent Information
- Application Number
- CN202210156515.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-21
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-02-21
AI Technical Summary
During the data migration process, especially large-scale data migration tasks, human monitoring and viewing are required, which results in a large consumption of manpower and material resources and takes a long time. When the task fails, human operations are required, which increases costs and inefficiency. question.
By classifying the data tables to be migrated, calculating the migration scope based on storage capacity and primary key values, and automatically adjusting the migration scope, the data migration is automated and the consumption of manpower and material resources is reduced.
It increases the speed of data migration, reduces the consumption of manpower and material resources, realizes the automation of the data migration process, and reduces costs and time overhead.
Smart Images

Figure CN114564443B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data migration control method, system, computer device and storage medium. Background Art
[0002] HBase (Hadoop Database) is a highly reliable, high-performance, column-oriented, scalable distributed storage system. In the HBase database, data migration scenarios often occur. Depending on the scenario, the migrated data can reach tens of TB, hundreds of TB, or even PB-level data. The migrated table data often reaches hundreds of tables.
[0003] During the data migration process, data with a large amount of data requires manual monitoring and review. When the data volume is large, a migration task may take several hours or even more than ten hours of monitoring and review, resulting in a waste of manpower and material resources. Summary of the invention
[0004] Based on this, a data migration control method, system, computer device and storage medium are provided to reduce the consumption of manpower and material resources in the process of data migration.
[0005] In one aspect, a method for controlling data migration is provided, the method comprising:
[0006] Acquire the storage capacity of the data table to be migrated, and obtain a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes the first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold, and the second classification file includes the second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold;
[0007] Acquire a mirror data table according to the first data table to be migrated, and write the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file;
[0008] Obtain the storage capacity and primary key value of the second data table to be migrated, calculate the migration range of the second data table to be migrated according to the storage capacity and the primary key value, read the second data table to be migrated according to the migration range, obtain the reading result, adjust the migration range according to the reading result, and read the second data table to be migrated according to the adjusted migration range, traverse the reading result to obtain at least one sub-data table, store it, write the at least one sub-data table into a second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated to the second export file.
[0009] In one embodiment, it also includes:
[0010] When it is determined that the acquisition of the mirror data table according to the first data table to be migrated fails, the number of failed acquisitions of the first data table to be migrated is increased by 1, and it is determined whether the number of failed acquisitions of the first data table to be migrated reaches a preset maximum number of retries;
[0011] If yes, writing the first to-be-migrated data table into a first failure file;
[0012] If not, a mirror data table is obtained according to the first data table to be migrated.
[0013] In one embodiment, it also includes:
[0014] Determining whether all of the first to-be-migrated data tables in the first classification file have been migrated;
[0015] If yes, get the first export file and the first failed file, and end the migration;
[0016] If not, continue to migrate the remaining first data tables to be migrated in the first classification file.
[0017] In one embodiment, the step of calculating the migration range of the second to-be-migrated data table according to the storage capacity and the primary key value includes:
[0018] Obtaining the number of migrations of the second data table to be migrated according to the quotient of the storage capacity of the second data table to be migrated and a preset initial migration storage capacity;
[0019] The migration step length of the second data table to be migrated is obtained according to the quotient of the primary key value of the second data table to be migrated and the migration number, and the migration range is determined according to the migration step length.
[0020] In one embodiment, the step of reading the second to-be-migrated data table according to the migration range, obtaining a reading result, and adjusting the migration range according to the reading result includes:
[0021] Determining whether reading the second to-be-migrated data table according to the migration range is successful;
[0022] If so, increase the migration step size;
[0023] If not, reduce the migration step size.
[0024] In one embodiment, the step of determining that the second to-be-migrated data table is read successfully further includes:
[0025] Determine whether the second to-be-migrated data table has been read;
[0026] If yes, write the at least one sub-data table into the second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated into the second export file;
[0027] If not, the migration range is updated according to the increased migration step size, and the second to-be-migrated data table is continued to be read according to the updated migration range.
[0028] In one embodiment, the step of determining that the export of the second to-be-migrated data table fails further includes:
[0029] Determining whether the reduced migration step length reaches a preset minimum migration step length;
[0030] If yes, write the second to-be-migrated data table into a second failed file, and set the migration step length to a minimum migration step length;
[0031] If not, the migration range is updated according to the reduced migration step size, and the second to-be-migrated data table is continued to be read according to the updated migration range.
[0032] In another aspect, a control system for data migration is provided, the system comprising:
[0033] a data classification module, configured to obtain a storage capacity of a data table to be migrated, and obtain a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes a first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold, and the second classification file includes a second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold;
[0034] a first data migration module, configured to obtain a mirror data table according to the first data table to be migrated, and write the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file;
[0035] The second data migration module is used to obtain the storage capacity and primary key value of the second data table to be migrated, calculate the migration range of the second data table to be migrated according to the storage capacity and the primary key value, read the second data table to be migrated according to the migration range, obtain the reading result, adjust the migration range according to the reading result, read the second data table to be migrated according to the adjusted migration range, traverse the reading result to obtain at least one sub-data table, store it, write the at least one sub-data table into a second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated to the second export file.
[0036] In another aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:
[0037] Acquire the storage capacity of the data table to be migrated, and obtain a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes the first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold, and the second classification file includes the second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold;
[0038] Acquire a mirror data table according to the first data table to be migrated, and write the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file;
[0039] Obtain the storage capacity and primary key value of the second data table to be migrated, calculate the migration range of the second data table to be migrated according to the storage capacity and the primary key value, read the second data table to be migrated according to the migration range, obtain the reading result, adjust the migration range according to the reading result, and read the second data table to be migrated according to the adjusted migration range, traverse the reading result to obtain at least one sub-data table, store it, write the at least one sub-data table into a second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated to the second export file.
[0040] In another aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0041] Acquire the storage capacity of the data table to be migrated, and obtain a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes the first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold, and the second classification file includes the second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold;
[0042] Acquire a mirror data table according to the first data table to be migrated, and write the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file;
[0043] Obtain the storage capacity and primary key value of the second data table to be migrated, calculate the migration range of the second data table to be migrated according to the storage capacity and the primary key value, read the second data table to be migrated according to the migration range, obtain the reading result, adjust the migration range according to the reading result, and read the second data table to be migrated according to the adjusted migration range, traverse the reading result to obtain at least one sub-data table, store it, write the at least one sub-data table into a second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated to the second export file.
[0044] The control method, system, computer device and storage medium of data migration described above obtain the storage capacity of the data table to be migrated, write the first data table to be migrated into the first classification file, wherein the first data table to be migrated is a data table to be migrated whose storage capacity is less than or equal to a preset threshold, and write the second data table to be migrated into the second classification file, wherein the second data table to be migrated is a data table to be migrated whose storage capacity is greater than the preset threshold; obtain a mirror data table according to the first data table to be migrated, write the mirror data table into the first export file, so that the first data table to be migrated is migrated to the first export file; obtain a migration range according to the storage capacity and primary key value of the second data table to be migrated, read the second data table to be migrated according to the migration range, and The migration range is adjusted according to the read result, the read result is traversed to obtain at least one sub-data table, and the sub-data table is stored, and the at least one sub-data table is written into the second export file to obtain the corresponding second data table to be migrated, so that the second data table to be migrated is migrated to the second export file; by classifying the data tables to be migrated, a first data table to be migrated and a second data table to be migrated are obtained, and different migration methods are adopted for the first data table to be migrated and the second data table to be migrated respectively, and in the migration process of the second data table to be migrated, the migration range is automatically adjusted according to the read result, so as to improve the migration rate of the second data table to be migrated, and the whole migration process is automatically carried out without manual monitoring, thereby reducing the consumption of manpower and material resources in the data migration process. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 An application environment diagram of a data migration control method in one embodiment;
[0046] Figure 2 A schematic diagram of a flow chart of a method for controlling data migration in one embodiment;
[0047] Figure 3 A schematic diagram of a flow chart of a method for controlling data migration in one embodiment;
[0048] Figure 4 A schematic diagram of a flow chart of a method for controlling data migration in one embodiment;
[0049] Figure 5 A schematic diagram of a flow chart of a method for controlling data migration in one embodiment;
[0050] Figure 6 A schematic diagram of a flow chart of a method for controlling data migration in one embodiment;
[0051] Figure 7 A schematic diagram of a flow chart of a method for controlling data migration in one embodiment;
[0052] Figure 8 A schematic diagram of a flow chart of a method for controlling data migration in one embodiment;
[0053] Fig. 9 A schematic diagram of a flow chart of a method for controlling data migration in one embodiment;
[0054] Fig.10 A schematic diagram of a process for classifying data tables to be migrated in one embodiment;
[0055] Fig.11 A schematic diagram of a process of migrating a first data table to be migrated in an embodiment;
[0056] Fig.12 A schematic diagram of a process of migrating a second data table to be migrated in one embodiment;
[0057] Fig.13 A structural block diagram of a control system for data migration in one embodiment;
[0058] Fig.14 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0060] The data migration control method provided in this application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the server 104. The data table to be migrated is classified to obtain a first data table to be migrated and a second data table to be migrated, and different migration methods are adopted for the first data table to be migrated and the second data table to be migrated, respectively. In the migration process of the second data table to be migrated, the migration range is adjusted, thereby improving the migration rate of the second data table to be migrated, and reducing the consumption of manpower and material resources in the process of data migration. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers and portable wearable devices, and the server 104 can be implemented by an independent server or a server cluster composed of multiple servers.
[0061] In the existing data migration process, manual monitoring is required. When the amount of data is large, the migration task takes a relatively long time, and when the task fails, manual operation is required, resulting in the consumption of manpower and material resources. To this end, a data migration control method, system, computer equipment and storage medium are proposed. According to the storage capacity of the data table to be migrated, the data table to be migrated is divided into a first data table to be migrated and a second data table to be migrated. Different migration methods are adopted for the first data table to be migrated and the second data table to be migrated respectively, and in the migration process of the second data table to be migrated, the migration range is automatically adjusted, thereby improving the migration rate of the second migration data table and reducing the consumption of manpower and material resources in the data migration process.
[0062] In one embodiment, Figure 2 As shown, a data migration control method is provided, and the method is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps:
[0063] S1: Obtain the storage capacity of the data table to be migrated, and obtain a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes a first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold, and the second classification file includes a second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold.
[0064] In the data interaction process of HBase, there are often scenarios of data migration. Depending on the scenarios of data migration, the storage capacity of the data to be migrated may be at the KB, MB or GB level, or may be at the TB or PB level. This embodiment classifies the data tables to be migrated according to their storage capacity, classifies the data tables to be migrated whose storage capacity is less than or equal to the preset threshold as the first data tables to be migrated, and writes the first data tables to be migrated into the first classification file to perform subsequent data migration tasks; classifies the data tables to be migrated whose storage capacity is greater than the preset threshold as the second data tables to be migrated, and writes the second data tables to be migrated into the second classification file to perform subsequent data migration tasks.
[0065] S2: Acquire a mirror data table according to the first data table to be migrated, and write the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file.
[0066] For the first data table to be migrated with a smaller storage capacity, a mirror data table of the first data table to be migrated is obtained and the mirror data table is written into the first export file, so that the first data table to be migrated is migrated into the first export file.
[0067] S3: Obtain the storage capacity and primary key value of the second data table to be migrated, calculate the migration range of the second data table to be migrated according to the storage capacity and the primary key value, read the second data table to be migrated according to the migration range, obtain the reading result, adjust the migration range according to the reading result, read the second data table to be migrated according to the adjusted migration range, traverse the reading result to obtain at least one sub-data table, store it, write the at least one sub-data table into the second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated to the second export file.
[0068] For the second data table to be migrated with a larger storage capacity, a migration range is calculated according to the storage capacity and primary key value of the second data table to be migrated, and the current second data table to be migrated is read according to the migration range, wherein the primary key value can uniquely identify each row in the second data table to be migrated; and the migration range is adjusted according to the reading result, if the reading is successful, the migration range is expanded, if the reading fails, the migration range is reduced, and the current second data table to be migrated is continued to be read according to the adjusted migration range until the current second data table to be migrated is read; the reading result is traversed to obtain at least one sub-data table, and the sub-data table is stored, and the at least one sub-data table is written into the second export file, when the sub-data table is one, it is the corresponding original second data table to be migrated, when the sub-data table is two or more, the two or more sub-data tables are merged to obtain the corresponding original second data table to be migrated, so that the current second data table to be migrated is migrated to the second export file; according to the above steps, the remaining second data tables to be migrated in the second classification file are continued to be migrated until the second data tables to be migrated in the second classification file are migrated.
[0069] The data table to be migrated is classified to obtain the first data table to be migrated written into the first classification file and the second data table to be migrated written into the second classification file; the mirror data table of the first data table to be migrated is written into the first export file to achieve migration of the first data table to be migrated into the first export file; the migration range is calculated according to the storage capacity and primary key value of the second data table to be migrated, and the second data table to be migrated is migrated according to the migration range, thereby performing multiple task migrations on the second data table to be migrated with a larger storage capacity, so that the second data table to be migrated is migrated to the second export file, and the migration range is adjusted in a targeted manner after each task is exported, thereby improving the migration rate of the second data table to be migrated, and reducing the consumption of manpower and material resources in the process of data migration.
[0070] In one embodiment, Figure 3 As shown, the data migration control method also includes:
[0071] S211: when it is determined that the acquisition of the mirror data table according to the first data table to be migrated fails, the number of failed acquisitions of the first data table to be migrated is increased by 1, and it is determined whether the number of failed acquisitions of the first data table to be migrated reaches a preset maximum number of retries;
[0072] S212: If yes, write the first to-be-migrated data table into a first failure file;
[0073] S213: If not, obtain a mirror data table according to the first data table to be migrated.
[0074] The mirror data table is obtained according to the current first data table to be migrated, and it is determined whether it is successful. If so, the current first data table to be migrated is written into the first export file, thereby completing the migration of the current first data table to be migrated into the first export file; if not, the number of export failures of the current first data table to be migrated is increased by 1, and it is determined whether the number of export failures reaches a preset maximum number of retries; if so, it is determined that the migration of the current first data table to be migrated has failed, and the current first data table to be migrated is written into the first failure file; if not, the step of obtaining the mirror data table according to the current first data table to be migrated is continued until the number of export failures of the current first data table to be migrated reaches the maximum number of retries, or the export is successful and written into the first export file, and then the remaining first data tables to be migrated in the first classification file are continued to be migrated.
[0075] In one embodiment, Figure 4 As shown, the data migration control method also includes:
[0076] S221: Determine whether all of the first to-be-migrated data tables in the first classification file have been migrated;
[0077] S222: If yes, obtain the first export file and the first failed file, and end the migration;
[0078] S223: If not, continue to migrate the remaining first data tables to be migrated in the first classification file.
[0079] After migrating each of the first data tables to be migrated, it is determined whether all of the first data tables to be migrated in the first classification file have been migrated. If so, the final first export file and the first failure file are obtained, and the migration task is terminated; if not, the remaining first data tables to be migrated in the first classification file are continued to be migrated until the migration of the first data tables to be migrated in the first classification file is completed.
[0080] In one embodiment, Figure 5 As shown, the step of calculating the migration range of the second data table to be migrated according to the storage capacity and the primary key value includes:
[0081] S311: Obtaining the number of migrations of the second data table to be migrated according to the quotient of the storage capacity of the second data table to be migrated and the preset initial migration storage capacity;
[0082] S312: Obtain a migration step length of the second data table to be migrated according to a quotient of the primary key value of the second data table to be migrated and the number of migrations, and determine the migration range according to the migration step length.
[0083] Calculate the quotient of the current storage capacity of the second data table to be migrated and the preset initial migration storage capacity to obtain the current number of migrations of the second data table to be migrated; calculate the quotient of the current primary key value of the second data table to be migrated and the number of migrations to obtain the current migration step of the second data table to be migrated, and obtain the migration range according to the migration step. For example, assuming that the current storage capacity of the second data table to be migrated is 5T, the primary key value is 1000, and the initial migration storage capacity is 0.5T, then the current number of migrations of the first data table to be migrated is 5T / 0.5T=10 times, and the migration step is 1000 / 10=100, so the initial migration range is (0-100).
[0084] In one embodiment, Figure 6 As shown, the steps of reading the second data table to be migrated according to the migration range, obtaining a reading result, and adjusting the migration range according to the reading result include:
[0085] S321: Determine whether reading the second to-be-migrated data table according to the migration range is successful;
[0086] S322: If yes, increase the migration step length;
[0087] S323: If not, reduce the migration step size.
[0088] The second data table to be migrated is read according to the migration range to obtain the reading result, and it is determined whether the reading of the second data table to be migrated is successful according to the obtained result. If so, the migration step length is increased; if not, the migration step length is reduced. The reading result is collected in real time, and the migration step length is adjusted in real time according to the reading result, so that the migration range can be adjusted later, thereby improving the rate of data migration.
[0089] In one embodiment, Figure 7 As shown, the step of determining that the second table of data to be migrated is read successfully also includes:
[0090] S331: Determine whether the second to-be-migrated data table has been read;
[0091] S332: If yes, write the at least one sub-data table into the second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table in the second export file, so that the second data table to be migrated is migrated into the second export file;
[0092] S333: If not, update the migration range according to the increased migration step size, and continue to read the second to-be-migrated data table according to the updated migration range.
[0093] Determine whether the current second data table to be migrated is exported successfully. If so, write the at least one sub-data table into the second export file. When there is one sub-data table, it is the corresponding original second data table to be migrated. When there are two or more sub-data tables, merge the two or more sub-data tables to obtain the corresponding original second data table to be migrated, so that the current second data table to be migrated is migrated to the second export file. If not, expand the migration range according to the increased migration step, and continue to read the current second data table to be migrated according to the expanded migration range, continue to determine whether the current second data table to be migrated has been read, and execute corresponding steps until the current second data table to be migrated is read.
[0094] In one embodiment, Figure 8 As shown, the step of determining that the second to-be-migrated data table fails to be read further includes:
[0095] S341: Determine whether the reduced migration step length reaches a preset minimum migration step length;
[0096] S342: If yes, write the second to-be-migrated data table into a second failed file, and set the migration step length to a minimum migration step length;
[0097] S343: If not, update the migration range according to the reduced migration step size, and continue to read the second to-be-migrated data table according to the updated migration range.
[0098] Determine whether the reduced migration step reaches the minimum migration step; if so, determine that the migration of the current second data table to be migrated has failed, write the current second data table to be migrated into the second failure file, and set the migration step to the minimum to perform the next migration of the second data table to be migrated; if not, calculate the reduced migration range based on the reduced migration step, and continue to read the current second data table to be migrated based on the reduced migration range.
[0099] In one embodiment, Fig. 9 As shown, the data migration control method also includes:
[0100] S351: Determine whether all of the second to-be-migrated data tables in the second classification file have been migrated;
[0101] S352: If yes, obtain the second export file and the second failure file, and end the migration;
[0102] S353: If not, continue to migrate the remaining second data tables to be migrated in the second classification file.
[0103] Determine whether the second data tables to be migrated in the second classification file have been completely migrated. If so, obtain the final second export file and the second failure file and end the migration task; if not, continue to migrate the remaining second data tables to be migrated in the second classification file until the migration of the second data tables to be migrated in the second classification file is completed.
[0104] In one embodiment, Fig.10As shown, it is a flowchart for classifying the data tables to be migrated according to their storage capacity. The specific process is as follows: start classification, obtain the storage capacity of the data tables to be migrated, write the data tables to be migrated whose storage capacity is less than or equal to the preset threshold into the first classification file, for the convenience of description, the data tables to be migrated in the first classification file are named as first data tables to be migrated; write the data tables to be migrated whose storage capacity is greater than the preset threshold into the second classification file, for the convenience of description, the data tables to be migrated in the second classification file are named as second data tables to be migrated, and end classification.
[0105] In one embodiment, Fig.11 As shown, it is a flowchart for migrating the first data table to be migrated. Taking the data migration of the current first data table to be migrated as an example, the specific process is as follows: starting the migration task, obtaining the current first data table to be migrated, obtaining the mirror data table according to the current first data table to be migrated, and judging whether the acquisition of the mirror data table is successful;
[0106] If the image data table is successfully obtained, the image data table is written into the first export file to complete the migration of the current first data table to be migrated into the first export file, and it is determined whether the first data table to be migrated is completely migrated. If the first data table to be migrated is completely migrated, the final first export file and the first failure file are obtained, and the export is terminated. If the first data table to be migrated is not completely migrated, the next migration task of the first data table to be migrated is performed;
[0107] If the acquisition of the mirror data table fails, the number of failed acquisitions of the current first data table to be migrated is increased by 1, and it is determined whether the number of failed acquisitions reaches a preset maximum number of retries; if the maximum number of retries is reached, the current first data table to be migrated is written into the first failure file, and the step of determining whether the first data table to be migrated is completely migrated is executed; if the maximum number of retries is not reached, the migration step of the current first data table to be migrated is continued.
[0108] In one embodiment, Fig.12 As shown, it is a flowchart of migrating the second data table to be migrated. Taking the data migration of the current second data table to be migrated as an example, the specific process is as follows: starting the migration task, obtaining the current second data table to be migrated, and the storage capacity and primary key value of the current second data table to be migrated, calculating the migration range of the current second data table to be migrated according to the storage capacity and the primary key value, reading the current second data table to be migrated according to the migration range, and judging whether the reading is successful;
[0109] If the reading is successful, increase the migration step length, and determine whether the reading of the current second data table to be migrated is complete. If the reading of the current second data table to be migrated is complete, write the obtained at least one sub-data table into the second export file, and restore it to the original second data table to be migrated, so as to complete the migration of the current second data table to be migrated into the second export file. The restoration process has been described above and will not be repeated here. Determine whether the second data table to be migrated has been completely migrated. If the second data table to be migrated has been completely migrated, obtain the final second export file and the second failure file, and end the migration. If the second data table to be migrated has not been completely migrated, perform the migration task of the remaining second data table to be migrated. If the current second data table to be migrated has not been completely read, calculate the migration range according to the increased migration step length, and continue to execute the step of migrating the current second data table to be migrated according to the increased migration range.
[0110] If the reading fails, reduce the migration step length, and determine whether the reduced migration step length reaches the preset minimum migration step length; if the reduced migration step length reaches the preset minimum migration step length, write the current second data table to be migrated into the second failure file, set the migration step length to the minimum, and execute the step of determining whether the second data table to be migrated has been completely migrated; if the reduced migration step length does not reach the preset minimum migration step length, calculate the migration range according to the reduced migration step length, and continue to execute the step of migrating the current second data table to be migrated according to the reduced migration step length.
[0111] In the above-mentioned data migration control method, the data table to be migrated is classified to obtain the first data table to be migrated written in the first classification file and the second data table to be migrated written in the second classification file; the mirror data table of the first data table to be migrated is written in the first export file to achieve the migration of the first data table to be migrated to the first export file; the migration range is calculated according to the storage capacity and primary key value of the second data table to be migrated, and the second data table to be migrated is read according to the migration range, so that the second data table to be migrated with a larger storage capacity is read at least once to obtain at least one sub-data table, and after reading the current second data table to be migrated, the at least one sub-data table is written into the second export file and restored, so that the second data table to be migrated is migrated to the second export file, and the migration range is adjusted in a targeted manner after each reading, so as to improve the migration rate of the second data table to be migrated, and reduce the consumption of manpower and material resources in the process of data migration.
[0112] It should be understood that although Figure 2-12 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-12 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0113] In one embodiment, Fig.13 As shown, a control system for data migration is provided, comprising: a data classification module, a first data migration module and a second data migration module, wherein:
[0114] A data classification module is used to obtain the storage capacity of a data table to be migrated, and obtain a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes a first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold value, and the second classification file includes a second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold value.
[0115] In the data interaction process of HBase, there are often scenarios of data migration. Depending on the scenarios of data migration, the storage capacity of the data to be migrated may be at the KB, MB or GB level, or may be at the TB or PB level. The data classification module classifies the data tables to be migrated according to their storage capacity, classifies the data tables to be migrated whose storage capacity is less than or equal to the preset threshold as the first data tables to be migrated, and writes the first data tables to be migrated into the first classification file for subsequent data migration tasks; classifies the data tables to be migrated whose storage capacity is greater than the preset threshold as the second data tables to be migrated, and writes the second data tables to be migrated into the second classification file for subsequent data migration tasks.
[0116] The first data migration module is used to obtain a mirror data table according to the first data table to be migrated, and write the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file.
[0117] For the first data table to be migrated with a smaller storage capacity, the first data migration module obtains a mirror data table of the first data table to be migrated and writes the mirror data table into a first export file, so as to migrate the first data table to be migrated into the first export file.
[0118] The second data migration module is used to obtain the storage capacity and primary key value of the second data table to be migrated, calculate the migration range of the second data table to be migrated according to the storage capacity and the primary key value, read the second data table to be migrated according to the migration range, obtain the reading result, adjust the migration range according to the reading result, read the second data table to be migrated according to the adjusted migration range, traverse the reading result to obtain at least one sub-data table, store it, write the at least one sub-data table into a second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated to the second export file.
[0119] For the second data table to be migrated with a larger storage capacity, the second data migration module calculates a migration range according to the storage capacity and the primary key value of the second data table to be migrated, and reads the current second data table to be migrated according to the migration range, wherein the primary key value can uniquely identify each row in the data table; and adjusts the migration range according to the reading result, if the reading is successful, the migration range is expanded, if the reading fails, the migration range is reduced, and the current second data table to be migrated is continued to be read according to the adjusted migration range until the current second data table to be migrated is read; traverse the reading result to obtain at least one sub-data table, store it, and write the at least one sub-data table into the second export file, when the sub-data table is one, it is the corresponding original second data table to be migrated, when the sub-data table is two or more, merge the two or more sub-data tables to obtain the corresponding original second data table to be migrated, so that the current second data table to be migrated is migrated to the second export file; according to the above steps, continue to migrate the remaining second data tables to be migrated in the second classification file until the second data tables to be migrated in the second classification file are migrated.
[0120] The data classification module classifies the data table to be migrated to obtain the first data table to be migrated written into the first classification file and the second data table to be migrated written into the second classification file; the first data migration module writes the mirror data table of the first data table to be migrated into the first export file to achieve migration of the first data table to be migrated into the first export file; the second data migration module calculates the migration range according to the storage capacity and primary key value of the second data table to be migrated, migrates the second data table to be migrated according to the migration range, thereby performing multiple task migrations on the second data table to be migrated with a larger storage capacity, so that the second data table to be migrated is migrated to the second export file, and the migration range is adjusted in a targeted manner after each task is exported, thereby improving the migration rate of the second data table to be migrated, thereby reducing the consumption of manpower and material resources in the process of data migration.
[0121] In one embodiment, Fig.13 As shown, the first data migration module is also used for: when it is determined that the acquisition of the mirror data table according to the first data table to be migrated fails, adding 1 to the number of failures in acquiring the first data table to be migrated, and judging whether the number of failures in acquiring the first data table to be migrated reaches a preset maximum number of retries; if so, writing the first data table to be migrated into a first failure file; if not, acquiring the mirror data table according to the first data table to be migrated.
[0122] The first data migration module obtains the mirror data table according to the current first data table to be migrated, and determines whether it is successful. If so, the current first data table to be migrated is written into the first export file, thereby completing the migration of the current first data table to be migrated into the first export file; if not, the number of export failures of the current first data table to be migrated is increased by 1, and it is determined whether the number of export failures reaches a preset maximum number of retries; if so, it is determined that the migration of the current first data table to be migrated has failed, and the current first data table to be migrated is written into the first failure file; if not, the step of obtaining the mirror data table according to the current first data table to be migrated is continued until the number of export failures of the current first data table to be migrated reaches the maximum number of retries, or the export is successful and written into the first export file, and then the remaining first data tables to be migrated in the first classification file are continued to be migrated.
[0123] In one embodiment, Fig.13As shown, the first data migration module is also used to: determine whether the first data table to be migrated in the first classification file has been completely migrated; if so, obtain the first export file and the first failure file and end the migration; if not, continue to migrate the remaining first data tables to be migrated in the first classification file.
[0124] After migrating each of the first data tables to be migrated, the first data migration module determines whether all of the first data tables to be migrated in the first classification file have been migrated. If so, the final first export file and the first failure file are obtained, and the migration task is terminated; if not, the remaining first data tables to be migrated in the first classification file continue to be migrated until the migration of the first data tables to be migrated in the first classification file is completed.
[0125] In one embodiment, Fig.13 As shown, the step in which the second data migration module calculates the migration range of the second data table to be migrated according to the storage capacity and the primary key value includes: obtaining the number of migrations of the second data table to be migrated according to the quotient of the storage capacity of the second data table to be migrated and the preset initial migration storage capacity; obtaining the migration step of the second data table to be migrated according to the quotient of the primary key value of the second data table to be migrated and the number of migrations, and determining the migration range according to the migration step.
[0126] The second data migration module calculates the quotient of the current storage capacity of the second data table to be migrated and the preset initial migration storage capacity to obtain the current number of migrations of the second data table to be migrated; calculates the quotient of the current primary key value of the second data table to be migrated and the number of migrations to obtain the current migration step of the second data table to be migrated, and obtains the migration range according to the migration step. For example, assuming that the current storage capacity of the second data table to be migrated is 5T, the primary key value is 1000, and the initial migration storage capacity is 0.5T, then the current number of migrations of the first data table to be migrated is 5T / 0.5T=10 times, and the migration step is 1000 / 10=100, so the initial migration range is (0-100).
[0127] In one embodiment, Fig.13 As shown, the second data migration module reads the second data table to be migrated according to the migration range to obtain a reading result, and the step of adjusting the migration range according to the reading result includes: determining whether reading the second data table to be migrated according to the migration range is successful; if so, increasing the migration step; if not, reducing the migration step.
[0128] The second data migration module reads the current second data table to be migrated according to the migration range, obtains the reading result, and determines whether the reading of the current second data table to be migrated is successful according to the obtained result. If so, the migration step length is increased; if not, the migration step length is reduced. The reading result is collected in real time, and the migration step length is adjusted in real time according to the reading result, so that the migration range can be adjusted subsequently, thereby improving the data migration rate.
[0129] In one embodiment, Fig.13 As shown, the step in which the second data migration module determines that the second data table to be migrated is read successfully also includes: determining whether the reading of the second data table to be migrated is completed; if so, writing the at least one sub-data table into the second export file, and obtaining the corresponding second data to be migrated based on the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated to the second export file; if not, updating the migration range according to the increased migration step, and continuing to read the second data table to be migrated according to the updated migration range.
[0130] The second data migration module determines whether the current second data table to be migrated is exported successfully. If so, the at least one sub-data table is written into the second export file. When there is one sub-data table, it is the corresponding original second data table to be migrated. When there are two or more sub-data tables, two or more sub-data tables are merged to obtain the corresponding original second data table to be migrated, so that the current second data table to be migrated is migrated to the second export file; if not, the migration range is expanded according to the increased migration step, and the current second data table to be migrated is continued to be read according to the expanded migration range, and it is continuously determined whether the current second data table to be migrated is read completely, and corresponding steps are executed until the current second data table to be migrated is read completely.
[0131] In one embodiment, Fig.13 As shown, the step in which the second data migration module determines that the reading of the second data table to be migrated fails also includes: determining whether the reduced migration step size reaches a preset minimum migration step size; if so, writing the second data table to be migrated into a second failure file, and setting the migration step size to the minimum migration step size; if not, updating the migration range according to the reduced migration step size, and continuing to read the second data table to be migrated according to the updated migration range.
[0132] The second data migration module determines whether the reduced migration step reaches the minimum migration step. If so, it is determined that the migration of the current second data table to be migrated has failed, and the current second data table to be migrated is written into the second failure file, and the migration step is set to the minimum to perform the next migration of the second data table to be migrated; if not, the reduced migration range is calculated based on the reduced migration step, and the current second data table to be migrated is continued to be read based on the reduced migration range.
[0133] In one embodiment, Fig.13 As shown, the second data migration module is also used to: determine whether the second data tables to be migrated in the second classification file have been completely migrated; if so, obtain a second export file and a second failure file and end the migration; if not, continue to migrate the remaining second data tables to be migrated in the second classification file.
[0134] The second data migration module determines whether the second data tables to be migrated in the second classification file have been completely migrated. If so, the final second export file and the second failure file are obtained, and the migration task is terminated; if not, the remaining second data tables to be migrated in the second classification file continue to be migrated until the migration of the second data tables to be migrated in the second classification file is completed.
[0135] For the specific definition of the control system of data migration, please refer to the definition of the control method of data migration mentioned above, which will not be repeated here. Each module in the above-mentioned control system of data migration can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0136] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.14As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the data table to be migrated, wherein the data table to be migrated includes the first data table to be migrated and the second data table to be migrated. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a control method for data migration is implemented.
[0137] Those skilled in the art will understand that Fig.14 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0138] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0139] S1: acquiring a storage capacity of a data table to be migrated, and obtaining a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes a first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold, and the second classification file includes a second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold;
[0140] S2: acquiring a mirror data table according to the first data table to be migrated, and writing the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file;
[0141] S3: Obtain the storage capacity and primary key value of the second data table to be migrated, calculate the migration range of the second data table to be migrated according to the storage capacity and the primary key value, read the second data table to be migrated according to the migration range, obtain the reading result, adjust the migration range according to the reading result, read the second data table to be migrated according to the adjusted migration range, traverse the reading result to obtain at least one sub-data table, store it, write the at least one sub-data table into the second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated to the second export file.
[0142] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0143] S1: acquiring a storage capacity of a data table to be migrated, and obtaining a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes a first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold, and the second classification file includes a second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold;
[0144] S2: acquiring a mirror data table according to the first data table to be migrated, and writing the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file;
[0145] S3: Obtain the storage capacity and primary key value of the second data table to be migrated, calculate the migration range of the second data table to be migrated according to the storage capacity and the primary key value, read the second data table to be migrated according to the migration range, obtain the reading result, adjust the migration range according to the reading result, read the second data table to be migrated according to the adjusted migration range, traverse the reading result to obtain at least one sub-data table, store it, write the at least one sub-data table into the second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated to the second export file.
[0146] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0147] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0148] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A data migration control method, characterized in that: The method comprises: Acquire the storage capacity of the data table to be migrated, and obtain a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes the first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold, and the second classification file includes the second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold; Acquire a mirror data table according to the first data table to be migrated, and write the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file; Obtaining a storage capacity and a primary key value of the second data table to be migrated, calculating a migration range of the second data table to be migrated according to the storage capacity and the primary key value, reading the second data table to be migrated according to the migration range, obtaining a reading result, adjusting the migration range according to the reading result, and reading the second data table to be migrated according to the adjusted migration range, traversing the reading result to obtain at least one sub-data table, storing the sub-data table, writing the at least one sub-data table into a second export file, and obtaining corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated into the second export file; The step of calculating the migration range of the second to-be-migrated data table according to the storage capacity and the primary key value includes: Obtaining the number of migrations of the second data table to be migrated according to the quotient of the storage capacity of the second data table to be migrated and a preset initial migration storage capacity; The migration step length of the second data table to be migrated is obtained according to the quotient of the primary key value of the second data table to be migrated and the migration number, and the migration range is determined according to the migration step length.
2. The data migration control method according to claim 1, characterized in that: Also includes: When it is determined that the acquisition of the mirror data table according to the first data table to be migrated fails, the number of failed acquisitions of the first data table to be migrated is increased by 1, and it is determined whether the number of failed acquisitions of the first data table to be migrated reaches a preset maximum number of retries; If yes, writing the first to-be-migrated data table into a first failure file; If not, a mirror data table is obtained according to the first data table to be migrated.
3. The data migration control method according to claim 2, characterized in that: Also includes: Determining whether all of the first to-be-migrated data tables in the first classification file have been migrated; If yes, get the first export file and the first failed file, and end the migration; If not, continue to migrate the remaining first data tables to be migrated in the first classification file.
4. The data migration control method according to claim 1, characterized in that: The steps of reading the second to-be-migrated data table according to the migration range, obtaining a reading result, and adjusting the migration range according to the reading result include: Determining whether reading the second to-be-migrated data table according to the migration range is successful; If so, increase the migration step size; If not, reduce the migration step size.
5. The data migration control method according to claim 4, characterized in that: The step of determining that the second to-be-migrated data table is read successfully also includes: Determine whether the second to-be-migrated data table has been read; If yes, write the at least one sub-data table into the second export file, and obtain the corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated into the second export file; If not, the migration range is updated according to the increased migration step size, and the second to-be-migrated data table is continued to be read according to the updated migration range.
6. The data migration control method according to claim 4, characterized in that: The step of determining that the second to-be-migrated data table fails to be read further includes: Determining whether the reduced migration step length reaches a preset minimum migration step length; If yes, write the second to-be-migrated data table into a second failed file, and set the migration step length to a minimum migration step length; If not, the migration range is updated according to the reduced migration step size, and the second to-be-migrated data table is continued to be read according to the updated migration range.
7. A data migration control system, characterized in that: The system comprises: a data classification module, configured to obtain a storage capacity of a data table to be migrated, and obtain a first classification file and a second classification file according to the storage capacity, wherein the first classification file includes a first data table to be migrated, and the storage capacity of the first data table to be migrated is less than or equal to a preset threshold, and the second classification file includes a second data table to be migrated, and the storage capacity of the second data table to be migrated is greater than the preset threshold; a first data migration module, configured to obtain a mirror data table according to the first data table to be migrated, and write the mirror data table into a first export file, so that the first data table to be migrated is migrated into the first export file; a second data migration module, configured to obtain a storage capacity and a primary key value of the second data table to be migrated, calculate a migration range of the second data table to be migrated according to the storage capacity and the primary key value, read the second data table to be migrated according to the migration range, obtain a read result, adjust the migration range according to the read result, read the second data table to be migrated according to the adjusted migration range, traverse the read result to obtain at least one sub-data table, store the sub-data table, write the at least one sub-data table into a second export file, and obtain corresponding second data to be migrated according to the at least one sub-data table from the second export file, so that the second data table to be migrated is migrated into the second export file; The step of calculating the migration range of the second data table to be migrated according to the storage capacity and the primary key value includes: obtaining the number of migrations of the second data table to be migrated according to the quotient of the storage capacity of the second data table to be migrated and the preset initial migration storage capacity; obtaining the migration step of the second data table to be migrated according to the quotient of the primary key value of the second data table to be migrated and the number of migrations, and determining the migration range according to the migration step.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the data migration control method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data migration control method according to any one of claims 1 to 6 are implemented.
