WO2021082104A1 - Method and apparatus for data migration, computer device, and storage medium - Google Patents

Method and apparatus for data migration, computer device, and storage medium Download PDF

Info

Publication number
WO2021082104A1
WO2021082104A1 PCT/CN2019/119566 CN2019119566W WO2021082104A1 WO 2021082104 A1 WO2021082104 A1 WO 2021082104A1 CN 2019119566 W CN2019119566 W CN 2019119566W WO 2021082104 A1 WO2021082104 A1 WO 2021082104A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
time
migration
designated
migrated
Prior art date
Application number
PCT/CN2019/119566
Other languages
French (fr)
Chinese (zh)
Inventor
罗国强
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2021082104A1 publication Critical patent/WO2021082104A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/214Database migration support
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • This application relates to the field of data processing technology, and in particular to a data migration method, device, computer equipment, and storage medium.
  • the common method of data migration includes the following steps: 1) Set the target database for receiving the data to be migrated in the target server; 2) Read the information of all the objects to be migrated in the source database, and analyze all the objects to be migrated 3) According to the order of the dependency relationship, perform object creation and data loading in the target database.
  • this method needs to read out the information of all the objects to be migrated in the source database before performing object creation and data loading in the target database.
  • the data migration process when performing a read operation to read the information of all the objects to be migrated, if the objects to be migrated are massive data, there will be a lot of content to be queried, which may easily lead to time-consuming read operations. .
  • the speed of reading information will become slower and slower, resulting in subsequent object creation and data loading unable to start for a long time, which seriously affects the efficiency of data migration and the migration experience of users.
  • the main purpose of this application is to provide a data migration method, device, computer equipment, and storage medium. It aims to solve the problem that the existing data migration method needs to read all the information of the object to be migrated in the source database before the target. The creation of execution objects and the loading of data in the database seriously affect the efficiency of data migration and the technical problems of the user's migration experience.
  • this application proposes a data migration method, which includes the steps:
  • the data to be migrated are sequentially queried out of the data to be migrated in the same quantity as the specified number of designated data to be migrated.
  • the designated data is migrated to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
  • This application also provides a data migration device, including:
  • the first acquisition module is configured to acquire the first time corresponding to the first piece of data in the source database to be migrated, and the second time corresponding to the last piece of data in the data to be migrated, where the first time is The time when the first piece of data was entered into the source database, and the second time is the time when the last piece of data was entered into the source database;
  • a splitting module configured to split the time period between the first time and the second time according to a first preset rule to obtain multiple corresponding time segments
  • the determining module is configured to determine the designated migration quantity corresponding to the designated time segment according to the second preset rule, wherein the designated time segment is any one of the multiple time segments;
  • the query module is used to query the data to be migrated according to the sequence of the time when each piece of data in the data to be migrated is respectively entered into the source database, and query the data to be migrated in turn to find out that the quantity is the same as the specified number of migrations Of multiple specified data;
  • the migration module is configured to migrate the designated data to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
  • the present application provides a computer device including a memory and a processor.
  • the memory stores computer-readable instructions, and the processor implements the steps of the above method when the computer-readable instructions are executed by the processor.
  • the present application also provides a computer-readable storage medium on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the steps of the foregoing method are implemented.
  • each time segment is executed.
  • each time segment can be intelligently allocated a specified number of designated data for migration for migration, and then a preset number of designated migration servers can be called to achieve rapid migration of designated data in the data to be migrated , Which effectively reduces the time spent in the data migration process, reduces the cost of data migration, and improves the efficiency of the migration server.
  • FIG. 1 is a schematic flowchart of a data migration method according to an embodiment of the present application
  • FIG. 2 is a schematic structural diagram of a data migration device according to an embodiment of the present application.
  • Fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present application.
  • a data migration method includes:
  • S1 Obtain the first time corresponding to the first piece of data of the data to be migrated in the source database, and the second time corresponding to the last piece of data of the data to be migrated, where the first time is the first piece of data The time entered into the source database, and the second time is the time when the last piece of data was entered into the source database;
  • S3 Determine the designated migration quantity corresponding to the designated time segment according to the second preset rule, where the designated time segment is any one of the multiple time segments;
  • S5 Migrate the designated data to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
  • the execution subject of the embodiment of the present invention is a data migration device, by which the data to be migrated can be quickly migrated, effectively reducing the time spent in the data migration process.
  • the original data to be migrated from the source database can be synchronized to the temporary database according to the time sequence of the original data to be migrated, so as to store the data to be migrated corresponding to the original data to be migrated through the temporary database.
  • the temporary database has the same structure type as the aforementioned source database. For example, if the source database is a mysql database, the temporary database is also a mysql database.
  • the first time corresponding to the first piece of data in the source database and the second time corresponding to the last piece of data in the data to be migrated are acquired.
  • the corresponding entry time is recorded in the source database.
  • the first time is the time when the first piece of data is entered into the source database
  • the second time is the last The time when a piece of data was entered into the source database.
  • the time period between the first time and the second time is split according to the first preset rule to obtain multiple corresponding time segments.
  • the above-mentioned first preset rule may include: averagely split the time period between the first time and the second time according to the preset number of divisions to obtain multiple time segments with the same number of divisions.
  • the above-mentioned number of divisions can be set according to actual conditions, for example, it can be input by the user according to personal needs, or it can be set by the data migration device itself.
  • the aforementioned time segment only refers to one time interval, and the time segment has no direct relationship with the time when the data to be migrated is entered into the source data. For example, a certain time segment is 30 minutes, such as 09:00-09:30.
  • the designated migration quantity corresponding to the designated time segment is determined according to the second preset rule, where the designated time segment is any one of the multiple time segments.
  • the second preset rule may include: acquiring the total number of data to be migrated and the number of time segments, calculating the first quotient between the total number of data and the number of time segments, and calculating the first quotient The value is determined as the number of migrations specified above.
  • the designated data is migrated to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the temporary database is transferred to the target database, where the target server is set to be used on the target server.
  • the database that receives the data to be migrated can be a database with a different data structure type from the source database.
  • the original data to be migrated in the source database is first synchronized to a temporary database, and then multiple time segments are set for the data to be migrated in the temporary database.
  • each time segment can be intelligently allocated a designated number of designated data for migration to be migrated, and a preset number of designated migration servers can be called to realize data migration for the designated data in the data to be migrated.
  • Fast migration effectively reduces the time spent in the data migration process, reduces the cost of data migration, and improves the efficiency of the migration server.
  • the data to be migrated in the source database can be first transferred. Synchronize to a temporary database, where the temporary database has the same structure type as the source database.
  • the temporary database is also a mysql database.
  • the data to be migrated stored in the temporary database is migrated to the target database, so as to realize the migration process of the data to be migrated.
  • it is beneficial to reduce the pressure on the source database avoid the situation of excessively high concurrency caused by data migration directly through the source database, and effectively reduce the The influence of the online normal business of the source database.
  • step S2 includes:
  • S200 Use the first time as the left endpoint value of the first time segment, and determine whether the first time is within a preset time range, where the first time segment is based on the previous The first time segment divided in the order after arrival;
  • S201 If the first time is within the preset time range, calculate the first sum of the first time and the first preset time value to obtain the first specified time, and compare the first time with the The time period between the first designated times is marked as the first time segment;
  • S202 If the first time is not within the preset time range, calculate the second sum of the first time and the second preset time value to obtain the first specified time, and compare the first time with all The time period between the first designated times is marked as the first time segment;
  • S202 Use the first designated time as the left endpoint value of the second time segment, and determine whether the first designated time is within a preset time range, where the second time segment is the same as the first time segment. The next time segment adjacent to the segment;
  • S204 If the first specified time is within the preset time range, calculate the third sum of the first specified time and the first preset time value to obtain the second specified time, and add the first specified time The time period between and the second designated time is marked as the second time segment;
  • S205 If the first specified time is not within the preset time range, calculate the fourth sum of the first specified time and the second preset time value to obtain the second specified time, and compare the first specified time The time period between the time and the second designated time is marked as the second time segment, and so on, until the time period between the first time and the second time is split.
  • this embodiment can implement the division of time segments through the first preset rule.
  • the above step of splitting the time period between the first time and the second time according to the first preset rule to obtain multiple corresponding time segments may specifically include: first taking the first time as the first time segment The left endpoint value, and determine whether the first time is within the preset time range, where the first time segment is the first time segment that is divided in order from front to back among all the time segments.
  • the time range is not specifically limited, for example, it can be set to a range from 9 o'clock to 21 o'clock.
  • the time period of is marked as the above-mentioned first time segment, where the specific value of the first preset time value is not limited, and can be set according to actual needs, for example, it can be set to 5 minutes.
  • the second sum of the first time and the second preset time value is calculated to obtain the first designated time, and the first time and the first designated time are combined
  • the time period between is marked as the aforementioned first time segment; wherein, the aforementioned second preset time value is not specifically limited, and can be set according to actual needs, for example, it can be set to 30 minutes.
  • the first designated time is then used as the left end value of the second time segment, and it is determined whether the first designated time is within the preset time range, where the second time segment is The next time segment adjacent to the above-mentioned first time segment.
  • first specified time is within the preset time range, calculate the third sum of the first specified time and the first preset time value to obtain the second specified time, and combine the first specified time with the second specified time
  • the time period between is marked as the second time segment described above. If the first specified time is not within the preset time range, calculate the fourth sum of the first specified time and the second preset time value to obtain the second specified time, and compare the first specified time with the second specified time.
  • the time period between the designated times is marked as the above-mentioned second time segment, and so on, until the time period between the above-mentioned first time and the above-mentioned second time is split.
  • step S3 includes:
  • S305 By analogy, in the process of data migration for other time segments, when the designated initial query quantity corresponding to the current time segment is equal to the preset query quantity threshold, after completing the data to be migrated to the source database After the migration of multiple pieces of third data with the same amount of the specified initial query, calculate the specified average response time of each piece of the third data during the migration process, and determine whether the specified average response time is equal to the preset first 2. Response time threshold;
  • the second preset rule can be used to determine the specified number of migrations.
  • the above step of determining the designated migration quantity corresponding to the designated time segment according to the second preset rule specifically includes: when the designated time segment is the first time segment, determining the preset first initial query quantity as the designated migration quantity, Among them, the first initial query quantity is the result of the stress test of the data migration work under the normal state in the test environment, and can be specifically set to 200.
  • the first response time threshold can be set according to actual conditions, for example, it can be set to 200ms. If the first average response time is less than the first response time threshold, the fifth sum of the first initial query quantity and the first preset quantity value is calculated to obtain the second initial query quantity, and the second initial query quantity is determined as the first The designated migration quantity corresponding to the second time segment, wherein the first preset quantity value is not specifically limited, and can be set according to the actual situation, for example, it can be set to 30.
  • the second average response time of each piece of second data during the migration process calculates the second average response time of each piece of second data during the migration process, and determine the second Whether the average response time is less than the preset first response time threshold. If the second average response time is less than the first response time threshold, the sixth sum of the second initial query quantity and the first preset quantity value is calculated to obtain the third initial query quantity, and the third initial query quantity is determined as the first The specified number of migrations corresponding to the three time segments, where the third time segment is the next time segment adjacent to the second time segment.
  • the data to be migrated from the source database is completed with the specified After the migration of multiple pieces of third data with the same initial query amount, calculate the specified average response time of each piece of third data during the migration process, and determine whether the specified average response time is equal to the preset second response time threshold.
  • the above-mentioned second response time threshold is greater than the first response time threshold, and can be specifically set to 300 ms according to actual conditions. If the specified average response time is equal to the second response time threshold, it is further judged whether the target database is at full load.
  • the CPU data and memory data of the target database can be obtained, and then the target database can be analyzed based on the CPU data and memory data The current load situation. If the target database is in a full load state, the query volume threshold is determined as the designated migration number corresponding to all remaining time segments.
  • the designated data of the designated migration quantity can be intelligently allocated for migration according to the second preset rule, which effectively realizes the rapid migration of the data to be migrated.
  • the data migration device will continue to transfer data in the source database.
  • the remaining un-migrated data is re-migrated, so as to realize the complete migration of all the data to be migrated.
  • the number of data corresponding to the un-migrated data currently in the data to be migrated is obtained;
  • the second quotient of the total amount of data and the query volume threshold is calculated Value; according to the second quotient, set multiple specific time segments with the same number as the second quotient; according to the chronological order of each of the above-mentioned unmigrated data, in each of the above specific time segments, call a certain number of migration servers to Multiple pieces of specific data that are the same as the query volume threshold are migrated to the target server until the migration of all the non-migrated data is completed, where the specific data is any piece of non-migrated data of the non-migrated data.
  • the complete migration of all the data to be migrated in the source database is effectively realized, and the integrity of the data migration is
  • the method before the foregoing step S5, the method includes:
  • S500 Obtain the migration server IP input by the user, and configure the migration server IP to implement the invocation of the migration server;
  • S501 Obtain the number of migration server IPs, and determine whether the number of migration server IPs is greater than a preset configuration number threshold;
  • a process of determining a designated migration server for data migration is also included. Specifically, first obtain the migration server IP (Internet Protocol, Internet Protocol address) input by the user, and configure the migration server IP to implement the invocation of the migration server. Then obtain the number of migration server IPs, and determine whether the number of migration server IPs is greater than a preset configuration number threshold, where the configuration number threshold can be set according to actual conditions, for example, it can be set to 4.
  • the configuration number threshold can be set according to actual conditions, for example, it can be set to 4.
  • the first migration server with the same number as the configuration number threshold is selected from the migration server IP, and the first migration server is determined as the designated migration server. For example, if the user configures five migration server IPs, four first migration servers with the same number as the configured number threshold will be randomly selected from the six migration server IPs as the designated migration server. If the number of migration server IPs is not greater than the preset configured number threshold, all second migration servers corresponding to the migration server IPs are determined as the designated migration servers. For example, if the user only configures three migration server IPs, three second migration servers corresponding to the three migration server IPs will be directly used as the designated migration server.
  • step S5 includes:
  • S511 Divide all the designated data into multiple data sets with the same number as the designated migration server;
  • S512 Bind each designated migration server to a data set one by one, and migrate each data set to the target database one by one through each designated migration server.
  • the step of migrating the designated data to the target database through a preset number of designated migration servers may specifically include: first obtaining the number of designated migration servers, and then according to the number of designated migration servers , Divide all the above specified data into multiple data sets with the same number of the above specified migration servers. For example, if the number of designated migration servers is 4, the designated data can be divided into 4 data sets correspondingly.
  • each designated migration server is bound to a data set one by one, and each of the above-mentioned data sets is migrated to the target database through each of the above-mentioned designated migration servers.
  • the binding of the designated migration server and the data set is not specifically limited, and the two can be randomly bound one by one.
  • multiple pieces of designated data are divided into multiple data sets with the same number of designated migration servers, and then each designated migration server bound to each data set is used to complete the migration of the designated data, which improves the migration.
  • the use efficiency of the server effectively reduces the time spent in the data migration process and reduces the cost of data migration.
  • the method includes:
  • S521 Determine, according to the migration record, whether there is migration failure data in the data to be migrated;
  • S523 Determine whether there is any successful migration of the failed data after a preset number of retry repair processing.
  • the data to be migrated in the temporary database will be recorded in the first state mark that has not been migrated; during the migration of the data to be migrated, the data to be migrated in the temporary database will be recorded There is a second state mark in the migration; after the migration of the data to be migrated is completed, the successfully migrated data in the data to be migrated will be recorded with the third state mark of successful migration; and the unsuccessful in the data to be migrated The migrated data will be recorded with a fourth status mark that the migration failed. After the migration record is obtained, it is determined whether there is migration failure data in the data to be migrated according to the migration record.
  • the failed data is retryed and repaired a preset number of times, where the failed data can be repaired by calling a pre-stored automatic repair program.
  • the preset number of times can be based on The actual request is set, for example, it can be set to 3 times. Then it is determined whether there is any successful migration of the above-mentioned failed data after a preset number of retry repair processing. If it does not exist, it means that the failed data has a problem and cannot be repaired through a normal automatic repair procedure, and a reminder message will be sent to transfer the failed data to manual repair processing. After the failed data is successfully repaired manually, the failed data is re-migrated.
  • the data to be migrated after the data to be migrated has failed data that fails to migrate, it will intelligently perform a preset number of retry repair processing on the failed data, so as to effectively repair the failed data that failed to migrate due to network fluctuations or database abnormalities. .
  • the failed data will be manually repaired to ensure that the failed data can be effectively repaired, which effectively guarantees the data to be migrated during the migration process. Data integrity.
  • the method includes:
  • S531 Determine whether the first header information and the first data size value of the first migration data are the same as the prestored second header information and the second data size value of the corresponding first data to be migrated;
  • the current complete data migration process usually includes two parts: migration and reconciliation. After completing the migration process of the data to be migrated, further reconciliation of the data to be migrated is required to Ensure the smooth and complete completion of the migration process for the data to be migrated. Specifically, after completing the migration process of the above-mentioned data to be migrated, first obtain the first header information and the first data size value of the first migration data, where the above-mentioned first migration data is any of all the migration data in the target database. One piece of migration data. In addition, the migration data is in a corresponding relationship with the data to be migrated, that is, the migration data is data obtained after the data to be migrated is migrated.
  • the above-mentioned first header information includes at least the MD5 value and file format of the first migration data.
  • the first header information and the first data size value are obtained, it is then judged whether the first header information and the first data size value are the same as the second header information and the second data size value of the pre-stored first data to be migrated. the same. If they are the same, it indicates that the first migration data and the first data to be migrated are the same data, and the first migration data is marked as the reconciliation completed state. If they are not the same, it indicates that the first migration data and the first data to be migrated are not the same data. For example, there may be data missing during the migration of the first data to be migrated. The data is marked as a reconciliation abnormal state.
  • the first migration data with the abnormally marked first migration data can be subsequently transferred to manual abnormality processing, so that the corresponding maintenance personnel can perform abnormality detection and subsequent abnormality repair processing on the first migration data.
  • an embodiment of the present application also provides a data migration device, including:
  • the first acquisition module 1 is configured to acquire the first time corresponding to the first piece of data in the data to be migrated in the source database, and the second time corresponding to the last piece of data in the data to be migrated, where the first time Is the time when the first piece of data is entered into the source database, and the second time is the time when the last piece of data is entered into the source database;
  • the splitting module 2 is configured to split the time period between the first time and the second time according to a first preset rule to obtain multiple corresponding time segments;
  • the first determining module 3 is configured to determine a designated migration quantity corresponding to a designated time segment according to a second preset rule, wherein the designated time segment is any one of the multiple time segments;
  • the query module 4 is configured to query the data to be migrated in the order of the time when each piece of data in the data to be migrated is separately entered into the source database to query the number of data to be migrated that corresponds to the specified number of migrations. The same multiple specified data;
  • the migration module 5 is configured to migrate the designated data to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
  • an embodiment of the present application also provides a computer device, and the computer device may be a server.
  • the computer equipment includes a processor, a memory, a network interface, and a database connected through a system bus.
  • the processor designed for the computer equipment is used to provide calculation and control capabilities.
  • the memory of the computer device includes a volatile or non-volatile storage medium and internal memory.
  • the volatile or non-volatile storage medium stores an operating system, computer readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the volatile or non-volatile storage medium.
  • the database of the computer equipment is used to store data such as time segments and designated migration quantities.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer-readable instructions are executed by the processor to implement the data migration method shown in any of the above exemplary embodiments.
  • FIG. 3 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 devices and computer equipment to which the solution of the present application is applied.
  • An embodiment of the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be volatile or non-volatile, and computer-readable instructions are stored thereon. When executed by one or more processors, the steps in the foregoing data migration method embodiment are realized when executed by one or more processors.

Abstract

A method and apparatus for data migration, a computer device, and a storage medium, the method comprising: acquiring a first time corresponding to first item of data in data to be migrated in a source database and a second time corresponding to a last item of data in the data to be migrated; according to a first preset rule, splitting the time period between the first time and the second time to obtain a plurality of time slices; according to a second preset rule, determining a specified migration quantity corresponding to a specified time slice; according to the successive sequence of the times at which each item of data in the data to be migrated are entered into the source database, sequentially querying from the data to be migrated the same quantity of a plurality of items of specified data as the specified migration quantity; and migrating the specified data to a target database by means of a preset quantity of specified migration servers, and continuing until all of the data to be migrated in the source database is migrated to the target database. Thus, the rapid migration of data to be migrated may be achieved and data migration costs are reduced.

Description

数据迁移方法、装置、计算机设备和存储介质Data migration method, device, computer equipment and storage medium
本申请要求于2019年10月29日提交中国专利局、申请号为2019110380724,发明名称为“数据迁移方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on October 29, 2019, the application number is 2019110380724, and the invention title is "data migration method, device, computer equipment and storage medium", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请涉及数据处理技术领域,具体涉及一种数据迁移方法、装置、计算机设备和存储介质。This application relates to the field of data processing technology, and in particular to a data migration method, device, computer equipment, and storage medium.
背景技术Background technique
随着现代科技的快速发展,人们的生活越来越离不开数据,而我们日常所用的各种存储系统也是依托数据来执行各种功能,数据库管理得到越来越广泛的应用,而在使用数据库的过程中,由于系统的切换和对不同系统中数据的统计和筛选等需求,经常需要对数据库中的数据进行数据迁移。With the rapid development of modern technology, people’s lives are becoming more and more inseparable from data, and the various storage systems we use daily also rely on data to perform various functions. Database management is more and more widely used, and In the process of database, due to system switching and statistics and filtering of data in different systems, data in the database often needs to be migrated.
目前,数据迁移常见的方法包括以下步骤:1)在目标服务器中设置用于接收待迁移数据的目标数据库;2)读取出源数据库中的所有待迁移对象的信息,并分析所有待迁移对象之间的依赖关系;3)根据依赖关系的顺序,在目标数据库内执行对象创建和数据装载。At present, the common method of data migration includes the following steps: 1) Set the target database for receiving the data to be migrated in the target server; 2) Read the information of all the objects to be migrated in the source database, and analyze all the objects to be migrated 3) According to the order of the dependency relationship, perform object creation and data loading in the target database.
对于上述数据迁移方法,这种方法需要在读取出源数据库中的所有待迁移对象的信息之后,才能在目标数据库中执行对象的创建和数据的装载。而在数据迁移过程中,在执行读取所有待迁移对象的信息的读取操作时,如果待迁移对象为海量数据,则所需要查询的内容会非常多,容易导致该读取操作比较耗时。并且,随着待迁移对象的数量增加,读取信息的速度会越来越慢,从而导致后续的对象的创建和数据的装载长时间无法开始,严重影响数据迁移的效率和用户的迁移体验。For the above data migration method, this method needs to read out the information of all the objects to be migrated in the source database before performing object creation and data loading in the target database. In the data migration process, when performing a read operation to read the information of all the objects to be migrated, if the objects to be migrated are massive data, there will be a lot of content to be queried, which may easily lead to time-consuming read operations. . Moreover, as the number of objects to be migrated increases, the speed of reading information will become slower and slower, resulting in subsequent object creation and data loading unable to start for a long time, which seriously affects the efficiency of data migration and the migration experience of users.
技术问题technical problem
本申请的主要目的为提供一种数据迁移方法、装置、计算机设备和存储介质,旨在解决现有的数据迁移方法需要在读取出源数据库中的所有待迁移对象的信息之后,才能在目标数据库中执行对象的创建和数据的装载,严重影响数据迁移的效率和用户的迁移体验的技术问题。The main purpose of this application is to provide a data migration method, device, computer equipment, and storage medium. It aims to solve the problem that the existing data migration method needs to read all the information of the object to be migrated in the source database before the target The creation of execution objects and the loading of data in the database seriously affect the efficiency of data migration and the technical problems of the user's migration experience.
技术解决方案Technical solutions
为了实现上述申请目的,本申请提出一种数据迁移方法,方法包括步骤:In order to achieve the purpose of the above application, this application proposes a data migration method, which includes the steps:
获取源数据库中待迁移数据的第一条数据对应的第一时间,以及所述待迁移数据的最后一条数据对应的第二时间,其中,所述第一时间为所述第一条数据录入至所述源数据库中的时间,所述第二时间为所述最后一条数据录入至所述源数据库中的时间;Obtain the first time corresponding to the first piece of data of the data to be migrated in the source database, and the second time corresponding to the last piece of data of the data to be migrated, where the first time is the time when the first piece of data is entered The time in the source database, and the second time is the time when the last piece of data is entered into the source database;
按照第一预设规则对所述第一时间至所述第二时间之间的时间段进行拆分,得到对应的多个时间片段;Split the time period between the first time and the second time according to a first preset rule to obtain multiple corresponding time segments;
按照第二预设规则确定出与指定时间片段对应的指定迁移数量,其中,所述指定时间片段为所述多个时间片段中的任意一个时间片段;Determine the designated migration quantity corresponding to the designated time segment according to the second preset rule, where the designated time segment is any one of the multiple time segments;
按照所述待迁移数据中的每一条数据分别录入至所述源数据库中的时间的先后排列顺序,依次从所述待迁移数据中查询出与所述指定迁移数量的数量相同的多条指定数据;According to the sequence of the time when each piece of data in the data to be migrated is entered into the source database, the data to be migrated are sequentially queried out of the data to be migrated in the same quantity as the specified number of designated data to be migrated. ;
通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库。The designated data is migrated to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
本申请还提供一种数据迁移装置,包括:This application also provides a data migration device, including:
第一获取模块,用于获取源数据库中待迁移数据的第一条数据对应的第一时间,以及所述待迁移数据中的最后一条数据对应的第二时间,其中,所述第一时间为所述第一条数据录入至所述源数据库中的时间,所述第二时间为所述最后一条数据录入至所述源数据库中的时间;The first acquisition module is configured to acquire the first time corresponding to the first piece of data in the source database to be migrated, and the second time corresponding to the last piece of data in the data to be migrated, where the first time is The time when the first piece of data was entered into the source database, and the second time is the time when the last piece of data was entered into the source database;
拆分模块,用于按照第一预设规则对所述第一时间至所述第二时间之间的时间段进行拆分,得到对应的多个时间片段;A splitting module, configured to split the time period between the first time and the second time according to a first preset rule to obtain multiple corresponding time segments;
确定模块,用于按照第二预设规则确定出与指定时间片段对应的指定迁移数量,其中,所述指定时间片段为所述多个时间片段中的任意一个时间片段;The determining module is configured to determine the designated migration quantity corresponding to the designated time segment according to the second preset rule, wherein the designated time segment is any one of the multiple time segments;
查询模块,用于按照所述待迁移数据中的每一条数据分别录入至所述源数据库中的时间的先后排列顺序,依次从所述待迁移数据中查询出与所述指定迁移数量的数量相同的多条指定数据;The query module is used to query the data to be migrated according to the sequence of the time when each piece of data in the data to be migrated is respectively entered into the source database, and query the data to be migrated in turn to find out that the quantity is the same as the specified number of migrations Of multiple specified data;
迁移模块,用于通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库。The migration module is configured to migrate the designated data to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
本申请提供一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述处理器执行所述计算机可读指令时实现上述方法的步骤。The present application provides a computer device including a memory and a processor. The memory stores computer-readable instructions, and the processor implements the steps of the above method when the computer-readable instructions are executed by the processor.
本申请还提供一种计算机可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现上述方法的步骤。The present application also provides a computer-readable storage medium on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the steps of the foregoing method are implemented.
有益效果Beneficial effect
本申请中提供的数据迁移方法、装置、计算机设备和存储介质,在需要对源数据库的待迁移数据进行迁移时,首先为临时数据库中的待迁移数据设置出多个时间片段,并在执行每个时间片段的数据迁移时,可以对每个时间片段智能的分配用于进行迁移的指定迁移数量的指定数据,再调用预设数量的指定迁移服务器来实现对于待迁移数据中指定数据的快速迁移,有效的减少了在数据迁移过程中所耗费的时间,降低了数据迁移的成本,提高了迁移服务器的使用效率。In the data migration method, device, computer equipment, and storage medium provided in this application, when the data to be migrated in the source database needs to be migrated, multiple time segments are set for the data to be migrated in the temporary database, and each time segment is executed. When migrating data in two time segments, each time segment can be intelligently allocated a specified number of designated data for migration for migration, and then a preset number of designated migration servers can be called to achieve rapid migration of designated data in the data to be migrated , Which effectively reduces the time spent in the data migration process, reduces the cost of data migration, and improves the efficiency of the migration server.
附图说明Description of the drawings
图1是本申请一实施例的数据迁移方法的流程示意图;FIG. 1 is a schematic flowchart of a data migration method according to an embodiment of the present application;
图2是本申请一实施例的数据迁移装置的结构示意图;FIG. 2 is a schematic structural diagram of a data migration device according to an embodiment of the present application;
图3是本申请一实施例的计算机设备的结构示意图。Fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present application.
本发明的最佳实施方式The best mode of the present invention
应当理解,此处所描述的具体实施例仅仅用于解释本申请,并不用于限定本申请。It should be understood that the specific embodiments described here are only used to explain the present application, and are not used to limit the present application.
参照图1,本申请一实施例的数据迁移方法,包括:Referring to FIG. 1, a data migration method according to an embodiment of the present application includes:
S1:获取源数据库中待迁移数据的第一条数据对应的第一时间,以及所述待迁移数据的最后一条数据对应的第二时间,其中,所述第一时间为所述第一条数据录入至所述源数据库中的时间,所述第二时间为所述最后一条数据录入至所述源数据库中的时间;S1: Obtain the first time corresponding to the first piece of data of the data to be migrated in the source database, and the second time corresponding to the last piece of data of the data to be migrated, where the first time is the first piece of data The time entered into the source database, and the second time is the time when the last piece of data was entered into the source database;
S2:按照第一预设规则对所述第一时间至所述第二时间之间的时间段进行拆分,得到对应的多个时间片段;S2: Split the time period between the first time and the second time according to the first preset rule to obtain multiple corresponding time segments;
S3:按照第二预设规则确定出与指定时间片段对应的指定迁移数量,其中,所述指定时间片段为所述多个时间片段中的任意一个时间片段;S3: Determine the designated migration quantity corresponding to the designated time segment according to the second preset rule, where the designated time segment is any one of the multiple time segments;
S4:按照所述待迁移数据中的每一条数据分别录入至所述源数据库中的时间的先后排列顺序,依次从所述待迁移数据中查询出与所述指定迁移数量的数量相同的多条指定数据;S4: According to the sequence of the time when each piece of data in the data to be migrated is separately entered into the source database, sequentially query from the data to be migrated the same number as the specified number of migrations Specify data;
S5:通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库。S5: Migrate the designated data to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
如上述步骤S1至S5所述,本发明实施例的执行主体为一种数据迁移装置,通过该数据迁移装置可以实现对于待迁移数据的快速迁移,有效减少在数据迁移过程中所耗费的时间。具体地,首先可按照原始待迁移数据的时间先后顺序,将源数据库的原始待迁移数据同步至临时数据库,以通过上述临时数据库来存储与上述原始待迁移数据对应的待迁移数据,其中,上述临时数据库具有与上述源数据库相同的结构类型,举例地,如果源数据库为mysql数据库,则临时数据库也为mysql数据库。通过将待迁移数据从源数据库同步到临时数据库进行存储,有利于降低源数据库的压力,避免出现由于直接通过源数据库进行数据迁移而导致并发量过高的情况,有效的降低了对源数据库的在线正常业务的影响。在完成了对原始待迁移数据的同步后,获取上述源数据库中的第一条数据对应的第一时间,以及待迁移数据中的最后一条数据对应的第二时间。其中,在将待迁移数据录入至源数据库时,在源数据库中都会记录其对应的录入时间,上述第一时间为该第一条数据录入到源数据库中的时间,上述第二时间为该最后一条数据录入到源数据库中的时间。然后按照第一预设规则将上述第一时间至上述第二时间之间的时间段进行拆分,得到对应的多个时间片段。其中,上述第一预设规则可包括:根据预设的划分数量对第一时间至第二时间之间的时间段进行平均拆分,来得到与上述划分数量的数量相同的多个时间片段,上述划分数量可根据实际情况进行设置,例如可由用户根据个人需求输入的,也可为数据迁移装置自行设定的。另外,上述时间片段只指代一个时间区间,且该时间片段与待迁移数据录入到源数据中的时间无直接关系,例如某一个时间片段为30分钟,如为09:00-09:30。在获得了经过拆分后的时间片段后,再按照第二预设规则确定出与指定时间片段对应的指定迁移数量,其中,上述指定时间片段为上述多个时间片段中的任意一个时间片段,上述第二预设规则可包括:获取上述待迁移数据的数据总数量以及上述时间片段的数量,计算上述数据总数量与上述时间片段的数量之间的第一商值,并将上述第一商值确定为上述指定迁移数量。最后按照待迁移数据中的每一条数据分别录入至源数据库中的时间的先后排列顺序,依次从临时数据库中查询出与上述指定迁移数量的数量相同的多条指定数据,并在得到上述指定数据后,通过预设数量的指定迁移服务器将该指定数据迁移至目标数据库,依此类推,直至将临时数据库中的所有待迁移数据转移至目标数据库,其中,上述目标服务器为设置在目标服务器上用于接收待迁移数据的数据库,且可为与上述源数据库为数据结构类型不相同的数据库。本实施例在需要对源数据库的待迁移数据进行迁移时,首先将源数据库的原始待迁移数据同步到一个临时数据库中,然后为临时数据库中的待迁移数据设置出多个时间片段,并在执行每个时间片段的数据迁移时,可以对每个时间片段智能的分配用于进行迁移的指定迁移数量的指定数据,并调用预设数量的指定迁移服务器来实现对于待迁移数据中指定数据的快速迁移,有效的减少了在数据迁移过程中所耗费的时间,降低了数据迁移的成本,提高了迁移服务器的使用效率。在另一个实施例中,为了避免出现直接通过源数据库进行数据迁移,而导致并发量过高,对源数据库的在线正常业务造成较大影响的情况,还可先将源数据库中的待迁移数据同步至临时数据库,其中上述临时数据库具有与上述源数据库相同的结构类型,举例地,如果源数据库为mysql数据库,则临时数据库也为mysql数据库。并在临时数据库中完成对于待迁移数据的同步后,再将临时数据库内存储的待迁移数据迁移到目标数据库内,以实现对于待迁移数据的迁移流程。本实施例通过将待迁移数据从源数据库同步到临时数据库进行存储,有利于降低源数据库的压力,避免出现由于直接通过源数据库进行数据迁移而导致并发量过高的情况,有效的降低了对源数据库的在线正常业务的影响。As described in the above steps S1 to S5, the execution subject of the embodiment of the present invention is a data migration device, by which the data to be migrated can be quickly migrated, effectively reducing the time spent in the data migration process. Specifically, first, the original data to be migrated from the source database can be synchronized to the temporary database according to the time sequence of the original data to be migrated, so as to store the data to be migrated corresponding to the original data to be migrated through the temporary database. The temporary database has the same structure type as the aforementioned source database. For example, if the source database is a mysql database, the temporary database is also a mysql database. By synchronizing the data to be migrated from the source database to the temporary database for storage, it is helpful to reduce the pressure on the source database, avoid the high concurrency caused by data migration directly through the source database, and effectively reduce the cost of the source database. The impact of normal online business. After completing the synchronization of the original data to be migrated, the first time corresponding to the first piece of data in the source database and the second time corresponding to the last piece of data in the data to be migrated are acquired. Wherein, when the data to be migrated is entered into the source database, the corresponding entry time is recorded in the source database. The first time is the time when the first piece of data is entered into the source database, and the second time is the last The time when a piece of data was entered into the source database. Then, the time period between the first time and the second time is split according to the first preset rule to obtain multiple corresponding time segments. Wherein, the above-mentioned first preset rule may include: averagely split the time period between the first time and the second time according to the preset number of divisions to obtain multiple time segments with the same number of divisions. The above-mentioned number of divisions can be set according to actual conditions, for example, it can be input by the user according to personal needs, or it can be set by the data migration device itself. In addition, the aforementioned time segment only refers to one time interval, and the time segment has no direct relationship with the time when the data to be migrated is entered into the source data. For example, a certain time segment is 30 minutes, such as 09:00-09:30. After the split time segment is obtained, the designated migration quantity corresponding to the designated time segment is determined according to the second preset rule, where the designated time segment is any one of the multiple time segments, The second preset rule may include: acquiring the total number of data to be migrated and the number of time segments, calculating the first quotient between the total number of data and the number of time segments, and calculating the first quotient The value is determined as the number of migrations specified above. Finally, according to the order of the time when each piece of data in the data to be migrated was entered into the source database, the temporary database was queried in turn from the temporary database with the same number of specified data as the specified number of migrations, and the specified data was obtained. After that, the designated data is migrated to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the temporary database is transferred to the target database, where the target server is set to be used on the target server. The database that receives the data to be migrated can be a database with a different data structure type from the source database. In this embodiment, when the data to be migrated in the source database needs to be migrated, the original data to be migrated in the source database is first synchronized to a temporary database, and then multiple time segments are set for the data to be migrated in the temporary database. When performing data migration for each time segment, each time segment can be intelligently allocated a designated number of designated data for migration to be migrated, and a preset number of designated migration servers can be called to realize data migration for the designated data in the data to be migrated. Fast migration effectively reduces the time spent in the data migration process, reduces the cost of data migration, and improves the efficiency of the migration server. In another embodiment, in order to avoid data migration directly through the source database, resulting in excessively high concurrency, which will have a greater impact on the normal online business of the source database, the data to be migrated in the source database can be first transferred. Synchronize to a temporary database, where the temporary database has the same structure type as the source database. For example, if the source database is a mysql database, the temporary database is also a mysql database. After the synchronization of the data to be migrated is completed in the temporary database, the data to be migrated stored in the temporary database is migrated to the target database, so as to realize the migration process of the data to be migrated. In this embodiment, by synchronizing the data to be migrated from the source database to the temporary database for storage, it is beneficial to reduce the pressure on the source database, avoid the situation of excessively high concurrency caused by data migration directly through the source database, and effectively reduce the The influence of the online normal business of the source database.
进一步地,本申请一实施例中,上述步骤S2,包括:Further, in an embodiment of the present application, the above step S2 includes:
S200:将所述第一时间作为第一时间片段的左端点值,并判断所述第一时间是否处于预设时间范围内,其中,所述第一时间片段为所有所述时间片段中按照从前到后的顺序划分的第一个时间片段;S200: Use the first time as the left endpoint value of the first time segment, and determine whether the first time is within a preset time range, where the first time segment is based on the previous The first time segment divided in the order after arrival;
S201:若所述第一时间处于预设时间范围内,计算所述第一时间与第一预设时间值的第一和值,得到第一指定时间,并将所述第一时间与所述第一指定时间之间的时间段标记为所述第一时间片段;S201: If the first time is within the preset time range, calculate the first sum of the first time and the first preset time value to obtain the first specified time, and compare the first time with the The time period between the first designated times is marked as the first time segment;
S202:若所述第一时间不处于预设时间范围内,计算所述第一时间与第二预设时间值的第二和值,得到第一指定时间,并将所述第一时间与所述第一指定时间之间的时间段标记为所述第一时间片段;S202: If the first time is not within the preset time range, calculate the second sum of the first time and the second preset time value to obtain the first specified time, and compare the first time with all The time period between the first designated times is marked as the first time segment;
S202:将所述第一指定时间作为第二时间片段的左端点值,并判断所述第一指定时间是否处于预设时间范围内,其中,所述第二时间片段为与所述第一时间片段相邻的下一个时间片段;S202: Use the first designated time as the left endpoint value of the second time segment, and determine whether the first designated time is within a preset time range, where the second time segment is the same as the first time segment. The next time segment adjacent to the segment;
S204:若所述第一指定时间处于预设时间范围内,计算所述第一指定时间与第一预设时间值的第三和值,得到第二指定时间,并将所述第一指定时间与所述第二指定时间之间的时间段标记为所述第二时间片段;S204: If the first specified time is within the preset time range, calculate the third sum of the first specified time and the first preset time value to obtain the second specified time, and add the first specified time The time period between and the second designated time is marked as the second time segment;
S205:若所述第一指定时间不处于预设时间范围内,计算所述第一指定时间与第二预设时间值的第四和值,得到第二指定时间,并将所述第一指定时间与所述第二指定时间之间的时间段标记为所述第二时间片段,依此类推,直至完成对所述第一时间至所述第二时间之间的时间段的拆分。S205: If the first specified time is not within the preset time range, calculate the fourth sum of the first specified time and the second preset time value to obtain the second specified time, and compare the first specified time The time period between the time and the second designated time is marked as the second time segment, and so on, until the time period between the first time and the second time is split.
如上述步骤S200至S205所述,本实施例可通过第一预设规则来实现对于时间片段的划分。上述按照第一预设规则对第一时间至第二时间之间的时间段进行拆分,得到对应的多个时间片段的步骤,具体可包括:首先将上述第一时间作为第一时间片段的左端点值,并判断上述第一时间是否处于预设时间范围内,其中,上述第一时间片段为所有上述时间片段中按照从前到后的顺序划分的第一个时间片段,另外,对上述预设时间范围不作具体限定,例如可设置为9点至21点的范围。如果第一时间处于预设时间范围内,则计算上述第一时间与第一预设时间值的第一和值,得到第一指定时间,并将上述第一时间与上述第一指定时间之间的时间段标记为上述第一时间片段,其中,对第一预设时间值的具体取值不作限定,可根据实际需要进行设置,例如可设置为5min。而如果第一时间不处于预设时间范围内,则计算上述第一时间与第二预设时间值的第二和值,得到第一指定时间,并将上述第一时间与上述第一指定时间之间的时间段标记为上述第一时间片段;其中,对上述第二预设时间值不作具体限定,可根据实际需要进行设置,例如可设置为30min。在得到了上述第一指定时间后,再将上述第一指定时间作为第二时间片段的左端点值,并判断上述第一指定时间是否处于预设时间范围内,其中,上述第二时间片段为与上述第一时间片段相邻的下一个时间片段。如果第一指定时间处于预设时间范围内,计算上述第一指定时间与第一预设时间值的第三和值,得到第二指定时间,并将上述第一指定时间与上述第二指定时间之间的时间段标记为上述第二时间片段。而如果第一指定时间不处于预设时间范围内,计算上述第一指定时间与第二预设时间值的第四和值,得到第二指定时间,并将上述第一指定时间与上述第二指定时间之间的时间段标记为上述第二时间片段,依此类推,直至完成对上述第一时间至上述第二时间之间的时间段的拆分。As described in the foregoing steps S200 to S205, this embodiment can implement the division of time segments through the first preset rule. The above step of splitting the time period between the first time and the second time according to the first preset rule to obtain multiple corresponding time segments may specifically include: first taking the first time as the first time segment The left endpoint value, and determine whether the first time is within the preset time range, where the first time segment is the first time segment that is divided in order from front to back among all the time segments. The time range is not specifically limited, for example, it can be set to a range from 9 o'clock to 21 o'clock. If the first time is within the preset time range, calculate the first sum value of the first time and the first preset time value to obtain the first designated time, and calculate the difference between the first time and the first designated time The time period of is marked as the above-mentioned first time segment, where the specific value of the first preset time value is not limited, and can be set according to actual needs, for example, it can be set to 5 minutes. If the first time is not within the preset time range, the second sum of the first time and the second preset time value is calculated to obtain the first designated time, and the first time and the first designated time are combined The time period between is marked as the aforementioned first time segment; wherein, the aforementioned second preset time value is not specifically limited, and can be set according to actual needs, for example, it can be set to 30 minutes. After the first designated time is obtained, the first designated time is then used as the left end value of the second time segment, and it is determined whether the first designated time is within the preset time range, where the second time segment is The next time segment adjacent to the above-mentioned first time segment. If the first specified time is within the preset time range, calculate the third sum of the first specified time and the first preset time value to obtain the second specified time, and combine the first specified time with the second specified time The time period between is marked as the second time segment described above. If the first specified time is not within the preset time range, calculate the fourth sum of the first specified time and the second preset time value to obtain the second specified time, and compare the first specified time with the second specified time. The time period between the designated times is marked as the above-mentioned second time segment, and so on, until the time period between the above-mentioned first time and the above-mentioned second time is split.
进一步地,本申请一实施例中,上述步骤S3,包括:Further, in an embodiment of the present application, the above step S3 includes:
S300:当所述指定时间片段为所述第一时间片段时,将预设的第一初始查询数量确定为所述指定迁移数量;S300: When the designated time segment is the first time segment, determine the preset first initial query quantity as the designated migration quantity;
S301:在完成了对所述源数据库的待迁移数据中与所述第一初始查询数量相同的多条第一数据的迁移后,计算每一条所述第一数据在迁移过程中的第一平均响应时间,并判断所述第一平均响应时间是否小于预设的第一响应时间阈值;S301: After completing the migration of multiple pieces of first data with the same quantity as the first initial query in the data to be migrated in the source database, calculate the first average of each piece of the first data in the migration process Response time, and determine whether the first average response time is less than a preset first response time threshold;
S302:若是,计算所述第一初始查询数量与第一预设数量值的第五和值,得到第二初始查询数量,并将所述第二初始查询数量确定为与所述第二时间片段对应的指定迁移数量;S302: If yes, calculate the fifth sum of the first initial query quantity and the first preset quantity value to obtain a second initial query quantity, and determine the second initial query quantity to be the same as the second time segment The corresponding designated migration quantity;
S303:在完成了对所述源数据库的待迁移数据中与所述第二初始查询数量相同的多条第二数据的迁移后,计算每一条所述第二数据在迁移过程中的第二平均响应时间,并判断所述第二平均响应时间是否小于所述第一响应时间阈值;S303: After completing the migration of multiple pieces of second data with the same quantity as the second initial query in the data to be migrated in the source database, calculate the second average of each piece of the second data in the migration process Response time, and determine whether the second average response time is less than the first response time threshold;
S303:若是,计算所述第二初始查询数量与所述第一预设数量值的第六和值,得到第三初始查询数量,并将所述第三初始查询数量确定为与第三时间片段对应的指定迁移数量,其中,所述第三时间片段为与所述第二时间片段相邻的下一个时间片段;S303: If yes, calculate the sixth sum of the second initial query quantity and the first preset quantity value to obtain a third initial query quantity, and determine the third initial query quantity to be the same as the third time segment Corresponding designated migration quantity, wherein the third time segment is the next time segment adjacent to the second time segment;
S305:依此类推,在进行对于其他时间片段的数据迁移过程中,当当前时间片段对应的指定初始查询数量等于预设的查询量阈值时,在完成了对所述源数据库的待迁移数据中与所述指定初始查询量相同的多条第三数据的迁移后,计算每一条所述第三数据在迁移过程中的指定平均响应时间,并判断所述指定平均响应时间是否等于预设的第二响应时间阈值;S305: By analogy, in the process of data migration for other time segments, when the designated initial query quantity corresponding to the current time segment is equal to the preset query quantity threshold, after completing the data to be migrated to the source database After the migration of multiple pieces of third data with the same amount of the specified initial query, calculate the specified average response time of each piece of the third data during the migration process, and determine whether the specified average response time is equal to the preset first 2. Response time threshold;
S306:若等于预设的第二响应时间阈值,判断所述目标数据库是否处于满负荷状态;S306: If it is equal to the preset second response time threshold, determine whether the target database is in a full load state;
S307:若处于满负荷状态,将所述查询量阈值确定为剩余的所有时间片段分别对应的指定迁移数量。S307: If it is in a full load state, determine the query amount threshold as the designated migration amount corresponding to all remaining time segments, respectively.
如上述步骤S300至 S307所述,本实施例可通过第二预设规则来实现对于指定迁移数量的确定。上述按照第二预设规则确定出与指定时间片段对应的指定迁移数量的步骤,具体包括:当指定时间片段为第一时间片段时,将预设的第一初始查询数量确定为指定迁移数量,其中,第一初始查询数量是经过测试环境对正常状态下的数据迁移工作进行了压力测试后得到的结果,具体可设置为200。在完成了对源数据库的待迁移数据中与第一初始查询数量相同的多条第一数据的迁移后,计算每一条第一数据在迁移过程中的第一平均响应时间,并判断第一平均响应时间是否小于预设的第一响应时间阈值,其中,第一响应时间阈值可根据实际情况进行设定,例如可设置为200ms。如果第一平均响应时间小于第一响应时间阈值,则计算第一初始查询数量与第一预设数量值的第五和值,得到第二初始查询数量,并将第二初始查询数量确定为第二时间片段对应的指定迁移数量,其中,对第一预设数量值不作具体限定,可根据实际情况进行设定,例如可设为30。在完成了对源数据库的待迁移数据中与第二初始查询数量相同的多条第二数据的迁移后,再计算每一条第二数据在迁移过程中的第二平均响应时间,并判断第二平均响应时间是否小于预设的第一响应时间阈值。如果第二平均响应时间小于第一响应时间阈值,则计算第二初始查询数量与第一预设数量值的第六和值,得到第三初始查询数量,并将第三初始查询数量确定为第三时间片段对应的指定迁移数量,其中,上述第三时间片段为与上述第二时间片段相邻的下一个时间片段。依此类推,在进行对于其他时间片段的数据迁移过程中,当当前时间片段对应的指定初始查询数量等于预设的查询量阈值时,在完成了对上述源数据库的待迁移数据中与上述指定初始查询量相同的多条第三数据的迁移后,计算每一条上述第三数据在迁移过程中的指定平均响应时间,并判断上述指定平均响应时间是否等于预设的第二响应时间阈值。其中,上述第二响应时间阈值大于第一响应时间阈值,根据实际情况具体可设为300ms。如果指定平均响应时间等于第二响应时间阈值,则进一步判断目标数据库是否处于满负荷状态,其中,可以通过获取目标数据库的CPU数据与内存数据,再根据该CPU数据与内存数据来分析出目标数据库当前的负荷情况。如果目标数据库处于满负荷状态,则将查询量阈值确定为剩余的所有时间片段分别对应的指定迁移数量。本实施例在执行每个时间片段的数据迁移时,可以根据第二预设规则智能的分配指定迁移数量的指定数据进行迁移,有效的实现了对于待迁移数据的快速迁移。在另一个实施例中,如果出现了在完成剩余的所有时间片段对应的数据迁移过程后,还没有完成对于所有的待迁移数据的迁移的情况时,则数据迁移装置还会继续对源数据库中剩余的未迁移的数据进行再迁移处理,以实现对于全部的待迁移数据的完整迁移。具体地,在完成了上述剩余的所有时间片段对应的数据迁移过程后,获取当前在上述待迁移数据中的未迁移数据对应的数据数量;计算上述数据总量与上述查询量阈值的第二商值;根据上述第二商值,设置与第二商值数量相同的多个特定时间片段;按照各上述未迁移数据的时间先后顺序,在每一个上述特定时间片段,调用一定数量的迁移服务器将与上述查询量阈值的数量相同的多条特定数据迁移到上述目标服务器,直至完成对所有上述未迁移数据的迁移,其中,上述特定数据为上述未迁移数据的任意一条未迁移数据。本实施例通过对源数据库中剩余的未迁移的数据进行再迁移处理,有效的实现了对于源数据库中全部的待迁移数据的完整迁移,保证了数据迁移的完整性。As described in the foregoing steps S300 to S307, in this embodiment, the second preset rule can be used to determine the specified number of migrations. The above step of determining the designated migration quantity corresponding to the designated time segment according to the second preset rule specifically includes: when the designated time segment is the first time segment, determining the preset first initial query quantity as the designated migration quantity, Among them, the first initial query quantity is the result of the stress test of the data migration work under the normal state in the test environment, and can be specifically set to 200. After completing the migration of multiple pieces of first data with the same number of first initial queries in the data to be migrated in the source database, calculate the first average response time of each piece of first data during the migration process, and determine the first average Whether the response time is less than the preset first response time threshold, where the first response time threshold can be set according to actual conditions, for example, it can be set to 200ms. If the first average response time is less than the first response time threshold, the fifth sum of the first initial query quantity and the first preset quantity value is calculated to obtain the second initial query quantity, and the second initial query quantity is determined as the first The designated migration quantity corresponding to the second time segment, wherein the first preset quantity value is not specifically limited, and can be set according to the actual situation, for example, it can be set to 30. After completing the migration of multiple pieces of second data with the same number of second initial queries in the data to be migrated in the source database, calculate the second average response time of each piece of second data during the migration process, and determine the second Whether the average response time is less than the preset first response time threshold. If the second average response time is less than the first response time threshold, the sixth sum of the second initial query quantity and the first preset quantity value is calculated to obtain the third initial query quantity, and the third initial query quantity is determined as the first The specified number of migrations corresponding to the three time segments, where the third time segment is the next time segment adjacent to the second time segment. By analogy, in the process of data migration for other time segments, when the specified initial query number corresponding to the current time segment is equal to the preset query volume threshold, the data to be migrated from the source database is completed with the specified After the migration of multiple pieces of third data with the same initial query amount, calculate the specified average response time of each piece of third data during the migration process, and determine whether the specified average response time is equal to the preset second response time threshold. Wherein, the above-mentioned second response time threshold is greater than the first response time threshold, and can be specifically set to 300 ms according to actual conditions. If the specified average response time is equal to the second response time threshold, it is further judged whether the target database is at full load. Among them, the CPU data and memory data of the target database can be obtained, and then the target database can be analyzed based on the CPU data and memory data The current load situation. If the target database is in a full load state, the query volume threshold is determined as the designated migration number corresponding to all remaining time segments. In this embodiment, when the data migration of each time segment is performed, the designated data of the designated migration quantity can be intelligently allocated for migration according to the second preset rule, which effectively realizes the rapid migration of the data to be migrated. In another embodiment, if after completing the data migration process corresponding to all the remaining time segments, the migration of all the data to be migrated has not been completed, the data migration device will continue to transfer data in the source database. The remaining un-migrated data is re-migrated, so as to realize the complete migration of all the data to be migrated. Specifically, after the data migration process corresponding to all the remaining time segments is completed, the number of data corresponding to the un-migrated data currently in the data to be migrated is obtained; the second quotient of the total amount of data and the query volume threshold is calculated Value; according to the second quotient, set multiple specific time segments with the same number as the second quotient; according to the chronological order of each of the above-mentioned unmigrated data, in each of the above specific time segments, call a certain number of migration servers to Multiple pieces of specific data that are the same as the query volume threshold are migrated to the target server until the migration of all the non-migrated data is completed, where the specific data is any piece of non-migrated data of the non-migrated data. In this embodiment, by performing re-migration processing on the remaining un-migrated data in the source database, the complete migration of all the data to be migrated in the source database is effectively realized, and the integrity of the data migration is ensured.
进一步地,本申请一实施例中,上述步骤S5之前,包括:Further, in an embodiment of the present application, before the foregoing step S5, the method includes:
S500:获取用户输入的迁移服务器IP,并对所述迁移服务器IP进行配置,以实现对于所述迁移服务器的调用;S500: Obtain the migration server IP input by the user, and configure the migration server IP to implement the invocation of the migration server;
S501:获取所述迁移服务器IP的数量,并判断所述迁移服务器IP的数量是否大于预设的配置数量阈值;S501: Obtain the number of migration server IPs, and determine whether the number of migration server IPs is greater than a preset configuration number threshold;
S502:若大于预设的配置数量阈值,从所述迁移服务器IP中筛选出与所述配置数量阈值的数量相同的第一迁移服务器,并将所述第一迁移服务器确定为所述指定迁移服务器;S502: If it is greater than the preset configuration number threshold, filter out the first migration server with the same number as the configuration number threshold from the migration server IP, and determine the first migration server as the designated migration server ;
S503:若不大于预设的配置数量阈值,将所述迁移服务器IP的对应的所有第二迁移服务器确定为所述指定迁移服务器。S503: If it is not greater than a preset configuration number threshold, determine all second migration servers corresponding to the migration server IP as the designated migration server.
如上述步骤S500至S503所述,在通过预设数量的指定迁移服务器将指定数据迁移至目标数据库的步骤之前,还包括确定出用于进行数据迁移的指定迁移服务器的过程。具体地,首先获取用户输入的迁移服务器IP(InternetProtocol,互联网协议地址),并对上述迁移服务器IP进行配置,以实现对于上述迁移服务器的调用。然后获取上述迁移服务器IP的数量,并判断迁移服务器IP的数量是否大于预设的配置数量阈值,其中,上述配置数量阈值可根据实际情况进行设定,例如可设为4。如果迁移服务器IP的数量大于预设的配置数量阈值,则从迁移服务器IP中筛选出与上述配置数量阈值的数量相同的第一迁移服务器,并将该第一迁移服务器确定为上述指定迁移服务器。举例地,如果用户配置了5个迁移服务器IP,则会从该6个迁移服务器IP中随机选取出与配置数量阈值的数量相同的4个第一迁移服务器来作为指定迁移服务器。而如果迁移服务器IP的数量不大于预设的配置数量阈值,则将上述迁移服务器IP的对应的所有第二迁移服务器确定为上述指定迁移服务器。举例地,如果用户只配置了3个迁移服务器IP,则会直接将与该3个迁移服务器IP对应的3个第二迁移服务器作为该指定迁移服务器。本实施例在执行每个时间片段的数据迁移时,会智能的为每一个时间片段分配指定迁移数量的指定数据进行迁移,并通过对应数量的指定迁移服务器来对迁移该指定数据,从而有效的实现了对于待迁移数据的快速迁移,并提高了迁移服务器的使用效率。As described in the above steps S500 to S503, before the step of migrating the designated data to the target database through a preset number of designated migration servers, a process of determining a designated migration server for data migration is also included. Specifically, first obtain the migration server IP (Internet Protocol, Internet Protocol address) input by the user, and configure the migration server IP to implement the invocation of the migration server. Then obtain the number of migration server IPs, and determine whether the number of migration server IPs is greater than a preset configuration number threshold, where the configuration number threshold can be set according to actual conditions, for example, it can be set to 4. If the number of migration server IPs is greater than the preset configuration number threshold, the first migration server with the same number as the configuration number threshold is selected from the migration server IP, and the first migration server is determined as the designated migration server. For example, if the user configures five migration server IPs, four first migration servers with the same number as the configured number threshold will be randomly selected from the six migration server IPs as the designated migration server. If the number of migration server IPs is not greater than the preset configured number threshold, all second migration servers corresponding to the migration server IPs are determined as the designated migration servers. For example, if the user only configures three migration server IPs, three second migration servers corresponding to the three migration server IPs will be directly used as the designated migration server. In this embodiment, when performing data migration for each time segment, it will intelligently allocate a designated number of designated data to be migrated for each time segment for migration, and migrate the designated data through a corresponding number of designated migration servers, thereby effectively migrating the designated data. The rapid migration of the data to be migrated is realized, and the use efficiency of the migration server is improved.
进一步地,本申请一实施例中,上述步骤S5,包括:Further, in an embodiment of the present application, the above step S5 includes:
S510:获取所述指定迁移服务器的数量;S510: Acquire the number of designated migration servers;
S511:将所有所述指定数据划分为与所述指定迁移服务器的数量相同的多个数据集;S511: Divide all the designated data into multiple data sets with the same number as the designated migration server;
S512:将每个指定迁移服务器与一个数据集进行一一绑定,通过各所述指定迁移服务器将各所述数据集一一迁移至所述目标数据库中。S512: Bind each designated migration server to a data set one by one, and migrate each data set to the target database one by one through each designated migration server.
如上述步骤S510至S512所述,上述通过预设数量的指定迁移服务器将上述指定数据迁移至目标数据库的步骤,具体可包括:首先获取上述指定迁移服务器的数量,然后根据该指定迁移服务器的数量,将上述所有指定数据划分为与上述指定迁移服务器的数量相同的多个数据集。举例地,如果上述指定迁移服务器的数量为4个,则可以将上述指定数据对应划分为4个数据集,其中,对于各数据集的可容纳数据量不作具体限定,优选将各数据集的可容纳数据量设置为相等的数值,如果上述指定数据的数量为200,则各数据集的可容纳数据量为50。在完成了对数据集的划分后,再将每个指定迁移服务器与一个数据集进行一一绑定,并通过各上述指定迁移服务器将各上述数据集迁移至目标数据库中。其中,对于指定迁移服务器与数据集的绑定不作具体限定,两者之间可以随机一一绑定。本实施例通过将多条指定数据划分为与指定迁移服务器的数量相同的多个数据集,再通过与各数据集一一绑定的各个指定迁移服务器来完成对于指定数据的迁移,提高了迁移服务器的使用效率,有效的减少了数据迁移过程中所耗费的时间,降低了数据迁移的成本。As described in the above steps S510 to S512, the step of migrating the designated data to the target database through a preset number of designated migration servers may specifically include: first obtaining the number of designated migration servers, and then according to the number of designated migration servers , Divide all the above specified data into multiple data sets with the same number of the above specified migration servers. For example, if the number of designated migration servers is 4, the designated data can be divided into 4 data sets correspondingly. There is no specific limitation on the amount of data that can be accommodated in each data set. The amount of data that can be accommodated is set to an equal value. If the amount of specified data mentioned above is 200, the amount of data that can be accommodated in each data set is 50. After the data set is divided, each designated migration server is bound to a data set one by one, and each of the above-mentioned data sets is migrated to the target database through each of the above-mentioned designated migration servers. Among them, the binding of the designated migration server and the data set is not specifically limited, and the two can be randomly bound one by one. In this embodiment, multiple pieces of designated data are divided into multiple data sets with the same number of designated migration servers, and then each designated migration server bound to each data set is used to complete the migration of the designated data, which improves the migration. The use efficiency of the server effectively reduces the time spent in the data migration process and reduces the cost of data migration.
本申请一实施例中,上述步骤S5之后,包括:In an embodiment of the present application, after the above step S5, the method includes:
S520:在完成对所述待迁移数据的迁移后,获取所述待迁移数据的迁移记录;S520: After completing the migration of the data to be migrated, obtain a migration record of the data to be migrated;
S521:根据所述迁移记录,判断在所述待迁移数据中是否存在迁移失败的失败数据;S521: Determine, according to the migration record, whether there is migration failure data in the data to be migrated;
S522:若是,对所述失败数据进行预设次数的重试修复处理;S522: If yes, perform a preset number of retry repair processing on the failed data;
S523:判断在经过预设次数的重试修复处理后,是否存在任意一次对于所述失败数据的成功迁移;S523: Determine whether there is any successful migration of the failed data after a preset number of retry repair processing.
S524:若否,将所述失败数据转至人工修复处理。S524: If not, transfer the failed data to manual repair processing.
如上述步骤S520至S524所述,在对待迁移数据进行数据迁移的过程中,还可能出现在待迁移数据中存在一些迁移失败的失败数据的情况,则还需要对该失败数据进行修复处理。具体地,在完成对待迁移数据的迁移后,获取上述待迁移数据的迁移记录。其中,当没有开始对待迁移数据进行迁移时,临时数据库中的待迁移数据中会记录有未迁移的第一状态标记;在待迁移数据的迁移过程中,临时数据库中的待迁移数据中会记录有迁移中的第二状态标记;在完成对待迁移数据的的迁移后,在待迁移数据中的已经成功迁移的数据会记录有迁移成功的第三状态标记;而在待迁移数据中的未成功迁移的数据会记录有迁移失败的第四状态标记。在得到了上述迁移记录后,根据上述迁移记录,判断在上述待迁移数据中是否存在迁移失败的失败数据。如果存在迁移失败的失败数据,则对上述失败数据进行预设次数的重试修复处理,其中,可通过调用预存储的自动修复程序来对该失败数据进行修复,另外,上述预设次数可根据实际请求进行设置,例如可设为3次。然后判断在经过预设次数的重试修复处理后,是否存在任意一次对上述失败数据的成功迁移。如果不存在,表示该失败数据存有问题且无法通过正常的自动修复程序进行修复,则会发出提醒信息,将所述失败数据转至人工修复处理。之后在人工对该失败数据进行成功修复后,再对该失败数据进行再迁移处理。本实施例在待迁移数据中存在迁移失败的失败数据后,会智能的对该失败数据进行预设次数的重试修复处理,以有效的修复由于网络波动或者数据库异常而导致迁移失败的失败数据。另外,如果上述进行的多次重试修复处理均未见效,则会对该失败数据进行人工修复处理,以确保能够实现对于失败数据的有效修复,有效的保证了待迁移数据在迁移过程中的数据完整性。As described in the above steps S520 to S524, during the process of data migration for the data to be migrated, there may be some failed data in the data to be migrated, and the failed data needs to be repaired. Specifically, after the migration of the data to be migrated is completed, the migration record of the data to be migrated is obtained. Among them, when the data to be migrated has not started to be migrated, the data to be migrated in the temporary database will be recorded in the first state mark that has not been migrated; during the migration of the data to be migrated, the data to be migrated in the temporary database will be recorded There is a second state mark in the migration; after the migration of the data to be migrated is completed, the successfully migrated data in the data to be migrated will be recorded with the third state mark of successful migration; and the unsuccessful in the data to be migrated The migrated data will be recorded with a fourth status mark that the migration failed. After the migration record is obtained, it is determined whether there is migration failure data in the data to be migrated according to the migration record. If there is failed data that fails to migrate, the failed data is retryed and repaired a preset number of times, where the failed data can be repaired by calling a pre-stored automatic repair program. In addition, the preset number of times can be based on The actual request is set, for example, it can be set to 3 times. Then it is determined whether there is any successful migration of the above-mentioned failed data after a preset number of retry repair processing. If it does not exist, it means that the failed data has a problem and cannot be repaired through a normal automatic repair procedure, and a reminder message will be sent to transfer the failed data to manual repair processing. After the failed data is successfully repaired manually, the failed data is re-migrated. In this embodiment, after the data to be migrated has failed data that fails to migrate, it will intelligently perform a preset number of retry repair processing on the failed data, so as to effectively repair the failed data that failed to migrate due to network fluctuations or database abnormalities. . In addition, if the above-mentioned multiple retries of the repair processing are not effective, the failed data will be manually repaired to ensure that the failed data can be effectively repaired, which effectively guarantees the data to be migrated during the migration process. Data integrity.
进一步地,本申请一实施例中,上述步骤S5之后,包括:Further, in an embodiment of the present application, after the above step S5, the method includes:
S530:在完成对所述待迁移数据的迁移后,获取第一迁移数据的第一头信息与第一数据大小值,其中,所述第一迁移数据为所述目标数据库内的所有迁移数据中的任意一条迁移数据,且所述迁移数据与所述待迁移数据为对应关系;S530: After completing the migration of the data to be migrated, obtain the first header information and the first data size value of the first migration data, where the first migration data is among all the migration data in the target database Any piece of migration data in, and the migration data and the data to be migrated are in a corresponding relationship;
S531:判断所述第一迁移数据的第一头信息、第一数据大小值,与预存储的对应的第一待迁移数据的第二头信息、第二数据大小值是否相同;S531: Determine whether the first header information and the first data size value of the first migration data are the same as the prestored second header information and the second data size value of the corresponding first data to be migrated;
S532:若相同,将所述第一迁移数据标记为对账完成状态,否则将所述第一迁移数据标记为对账异常状态,依次类推,直至完成对于所有所述迁移数据的对账处理。S532: If the same, mark the first migration data as the reconciliation completed state, otherwise mark the first migration data as the reconciliation abnormal state, and so on, until the reconciliation process for all the migration data is completed.
如上述步骤S530至S532所述,目前完整的数据迁移过程通常包括迁移和对账两部分,在完成了对上述待迁移数据的迁移过程后,还需要进一步进行对待迁移数据的对账处理,以确保顺利完整的完成了对于待迁移数据的迁移过程。具体地,在完成对上述待迁移数据的迁移过程后,首先获取第一迁移数据的第一头信息、第一数据大小值,其中,上述第一迁移数据为目标数据库内所有迁移数据中的任意一条迁移数据。并且,上述迁移数据与上述待迁移数据为对应关系,即上述迁移数据由对待迁移数据进行迁移后得到的数据。另外,上述第一头信息至少包含第一迁移数据的MD5值与文件格式。在得到了上述第一头信息与第一数据大小值后,再判断第一头信息与第一数据大小值,与预存储的第一待迁移数据的第二头信息、第二数据大小值是否相同。如果相同,表明第一迁移数据与第一待迁移数据为相同的数据,则将述第一迁移数据标记为对账完成状态。如果不相同,表明第一迁移数据与第一待迁移数据不为相同的数据,例如可能出现了第一待迁移数据在迁移过程中出现了数据缺失的情况,则此时会将上述第一迁移数据标记为对账异常状态。依此类推,直至完成对于所有上述迁移数据的对账处理。进一步地,当出现了第一迁移数据的第一头信息、第一大小值,与预存储的对应的第一待迁移数据的第二头信息、第二大小值不相同的情况时,在对上述第一迁移数据进行异常标记后,后续还可将该带有异常标记的第一迁移数据转至人工进行异常处理,以通过相应维护人员对第一迁移数据进行异常检测以及后续的异常修复处理。As described in the above steps S530 to S532, the current complete data migration process usually includes two parts: migration and reconciliation. After completing the migration process of the data to be migrated, further reconciliation of the data to be migrated is required to Ensure the smooth and complete completion of the migration process for the data to be migrated. Specifically, after completing the migration process of the above-mentioned data to be migrated, first obtain the first header information and the first data size value of the first migration data, where the above-mentioned first migration data is any of all the migration data in the target database. One piece of migration data. In addition, the migration data is in a corresponding relationship with the data to be migrated, that is, the migration data is data obtained after the data to be migrated is migrated. In addition, the above-mentioned first header information includes at least the MD5 value and file format of the first migration data. After the first header information and the first data size value are obtained, it is then judged whether the first header information and the first data size value are the same as the second header information and the second data size value of the pre-stored first data to be migrated. the same. If they are the same, it indicates that the first migration data and the first data to be migrated are the same data, and the first migration data is marked as the reconciliation completed state. If they are not the same, it indicates that the first migration data and the first data to be migrated are not the same data. For example, there may be data missing during the migration of the first data to be migrated. The data is marked as a reconciliation abnormal state. And so on, until the reconciliation of all the above migration data is completed. Further, when the first header information and the first size value of the first migration data are different from the second header information and the second size value of the corresponding first data to be migrated in advance, the After the above-mentioned first migration data is abnormally marked, the first migration data with the abnormally marked first migration data can be subsequently transferred to manual abnormality processing, so that the corresponding maintenance personnel can perform abnormality detection and subsequent abnormality repair processing on the first migration data. .
参照图2,本申请一实施例中还提供了一种数据迁移装置,包括:2, an embodiment of the present application also provides a data migration device, including:
第一获取模块1,用于获取源数据库中待迁移数据的第一条数据对应的第一时间,以及所述待迁移数据中的最后一条数据对应的第二时间,其中,所述第一时间为所述第一条数据录入至所述源数据库中的时间,所述第二时间为所述最后一条数据录入至所述源数据库中的时间;The first acquisition module 1 is configured to acquire the first time corresponding to the first piece of data in the data to be migrated in the source database, and the second time corresponding to the last piece of data in the data to be migrated, where the first time Is the time when the first piece of data is entered into the source database, and the second time is the time when the last piece of data is entered into the source database;
拆分模块2,用于按照第一预设规则对所述第一时间至所述第二时间之间的时间段进行拆分,得到对应的多个时间片段;The splitting module 2 is configured to split the time period between the first time and the second time according to a first preset rule to obtain multiple corresponding time segments;
第一确定模块3,用于按照第二预设规则确定出与指定时间片段对应的指定迁移数量,其中,所述指定时间片段为所述多个时间片段中的任意一个时间片段;The first determining module 3 is configured to determine a designated migration quantity corresponding to a designated time segment according to a second preset rule, wherein the designated time segment is any one of the multiple time segments;
查询模块4,用于按照所述待迁移数据中的每一条数据分别录入至所述源数据库中的时间的先后排列顺序,依次从所述待迁移数据中查询出与所述指定迁移数量的数量相同的多条指定数据;The query module 4 is configured to query the data to be migrated in the order of the time when each piece of data in the data to be migrated is separately entered into the source database to query the number of data to be migrated that corresponds to the specified number of migrations. The same multiple specified data;
迁移模块5,用于通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库。The migration module 5 is configured to migrate the designated data to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
参照图3,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括易失性或非易失性存储介质、内存储器。该易失性或非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为易失性或非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储时间片段以及指定迁移数量等数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现上述任一个示例性实施例所示出的数据迁移方法。本领域技术人员可以理解,图3中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的装置、计算机设备的限定。Referring to FIG. 3, an embodiment of the present application also provides a computer device, and the computer device may be a server. The computer equipment includes a processor, a memory, a network interface, and a database connected through a system bus. Among them, the processor designed for the computer equipment is used to provide calculation and control capabilities. The memory of the computer device includes a volatile or non-volatile storage medium and internal memory. The volatile or non-volatile storage medium stores an operating system, computer readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the volatile or non-volatile storage medium. The database of the computer equipment is used to store data such as time segments and designated migration quantities. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer-readable instructions are executed by the processor to implement the data migration method shown in any of the above exemplary embodiments. Those skilled in the art can understand that the structure shown in FIG. 3 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 devices and computer equipment to which the solution of the present application is applied.
本申请一实施例还提供一种计算机可读存储介质,该计算机可读存储介质可以是易失性的,也可以是非易失性的,其上存储有计算机可读指令,该计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行时实现上述数据迁移方法实施例中的步骤。An embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium may be volatile or non-volatile, and computer-readable instructions are stored thereon. When executed by one or more processors, the steps in the foregoing data migration method embodiment are realized when executed by one or more processors.
以上所述仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only the preferred embodiments of this application, and do not limit the scope of this application. Any equivalent structure or equivalent process transformation made using the content of the specification and drawings of this application, or directly or indirectly applied to other related The technical field is equally included in the scope of patent protection of this application.

Claims (20)

  1. 一种数据迁移方法,其特征在于,包括:A data migration method is characterized in that it includes:
    获取源数据库中待迁移数据的第一条数据对应的第一时间,以及所述待迁移数据的最后一条数据对应的第二时间,其中,所述第一时间为所述第一条数据录入至所述源数据库中的时间,所述第二时间为所述最后一条数据录入至所述源数据库中的时间;Obtain the first time corresponding to the first piece of data of the data to be migrated in the source database, and the second time corresponding to the last piece of data of the data to be migrated, where the first time is the time when the first piece of data is entered The time in the source database, and the second time is the time when the last piece of data is entered into the source database;
    按照第一预设规则对所述第一时间至所述第二时间之间的时间段进行拆分,得到对应的多个时间片段;Split the time period between the first time and the second time according to a first preset rule to obtain multiple corresponding time segments;
    按照第二预设规则确定出与指定时间片段对应的指定迁移数量,其中,所述指定时间片段为所述多个时间片段中的任意一个时间片段;Determine the designated migration quantity corresponding to the designated time segment according to the second preset rule, where the designated time segment is any one of the multiple time segments;
    按照所述待迁移数据中的每一条数据分别录入至所述源数据库中的时间的先后排列顺序,依次从所述待迁移数据中查询出与所述指定迁移数量的数量相同的多条指定数据;According to the sequence of the time when each piece of data in the data to be migrated is entered into the source database, the data to be migrated are sequentially queried out of the data to be migrated in the same quantity as the specified number of designated data to be migrated. ;
    通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库。The designated data is migrated to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
  2. 根据权利要求1所述的数据迁移方法,其特征在于,所述按照第一预设规则对所述第一时间至所述第二时间之间的时间段进行拆分,得到对应的多个时间片段的步骤,包括:The data migration method according to claim 1, wherein the time period between the first time and the second time is split according to a first preset rule to obtain corresponding multiple times The steps of the fragment include:
    将所述第一时间作为第一时间片段的左端点值,并判断所述第一时间是否处于预设时间范围内,其中,所述第一时间片段为所有所述时间片段中按照从前到后的顺序划分的第一个时间片段;The first time is taken as the left endpoint value of the first time segment, and it is judged whether the first time is within a preset time range, wherein the first time segment is the order from front to back among all the time segments. The first time segment divided in the order of
    若所述第一时间处于预设时间范围内,计算所述第一时间与第一预设时间值的第一和值,得到第一指定时间,并将所述第一时间与所述第一指定时间之间的时间段标记为所述第一时间片段;If the first time is within the preset time range, calculate the first sum of the first time and the first preset time value to obtain the first designated time, and compare the first time with the first The time period between designated times is marked as the first time segment;
    若所述第一时间不处于预设时间范围内,计算所述第一时间与第二预设时间值的第二和值,得到第一指定时间,并将所述第一时间与所述第一指定时间之间的时间段标记为所述第一时间片段;If the first time is not within the preset time range, calculate the second sum of the first time and the second preset time value to obtain the first designated time, and compare the first time with the first time A time period between designated times is marked as the first time segment;
    将所述第一指定时间作为第二时间片段的左端点值,并判断所述第一指定时间是否处于预设时间范围内,其中,所述第二时间片段为与所述第一时间片段相邻的下一个时间片段;Use the first designated time as the left endpoint value of the second time segment, and determine whether the first designated time is within a preset time range, wherein the second time segment is the same as the first time segment Next time segment of neighbor;
    若所述第一指定时间处于预设时间范围内,计算所述第一指定时间与第一预设时间值的第三和值,得到第二指定时间,并将所述第一指定时间与所述第二指定时间之间的时间段标记为所述第二时间片段;If the first specified time is within the preset time range, calculate the third sum of the first specified time and the first preset time value to obtain the second specified time, and combine the first specified time with all The time period between the second designated times is marked as the second time segment;
    若所述第一指定时间不处于预设时间范围内,计算所述第一指定时间与第二预设时间值的第四和值,得到第二指定时间,并将所述第一指定时间与所述第二指定时间之间的时间段标记为所述第二时间片段,依此类推,直至完成对所述第一时间至所述第二时间之间的时间段的拆分。If the first specified time is not within the preset time range, calculate the fourth sum of the first specified time and the second preset time value to obtain the second specified time, and combine the first specified time with The time period between the second designated time is marked as the second time segment, and so on, until the time period between the first time and the second time is split.
  3. 根据权利要求2所述的数据迁移方法,其特征在于,所述按照第二预设规则确定出与指定时间片段对应的指定迁移数量的步骤,包括:The data migration method according to claim 2, wherein the step of determining a designated migration quantity corresponding to a designated time segment according to a second preset rule comprises:
    当所述指定时间片段为所述第一时间片段时,将预设的第一初始查询数量确定为所述指定迁移数量;When the designated time segment is the first time segment, determining the preset first initial query quantity as the designated migration quantity;
    在完成了对所述源数据库的待迁移数据中与所述第一初始查询数量相同的多条第一数据的迁移后,计算每一条所述第一数据在迁移过程中的第一平均响应时间,并判断所述第一平均响应时间是否小于预设的第一响应时间阈值;After completing the migration of multiple pieces of first data with the same quantity as the first initial query in the data to be migrated in the source database, calculate the first average response time of each piece of the first data in the migration process , And determine whether the first average response time is less than a preset first response time threshold;
    若是,计算所述第一初始查询数量与第一预设数量值的第五和值,得到第二初始查询数量,并将所述第二初始查询数量确定为与所述第二时间片段对应的指定迁移数量;If yes, calculate the fifth sum of the first initial query quantity and the first preset quantity value to obtain the second initial query quantity, and determine the second initial query quantity as corresponding to the second time segment Specify the number of migrations;
    在完成了对所述源数据库的待迁移数据中与所述第二初始查询数量相同的多条第二数据的迁移后,计算每一条所述第二数据在迁移过程中的第二平均响应时间,并判断所述第二平均响应时间是否小于所述第一响应时间阈值;After completing the migration of multiple pieces of second data with the same quantity as the second initial query in the data to be migrated in the source database, calculate the second average response time of each piece of the second data in the migration process , And determine whether the second average response time is less than the first response time threshold;
    若是,计算所述第二初始查询数量与所述第一预设数量值的第六和值,得到第三初始查询数量,并将所述第三初始查询数量确定为与第三时间片段对应的指定迁移数量,其中,所述第三时间片段为与所述第二时间片段相邻的下一个时间片段;If yes, calculate the sixth sum of the second initial query quantity and the first preset quantity value to obtain the third initial query quantity, and determine the third initial query quantity as corresponding to the third time segment Specify the number of migrations, where the third time segment is the next time segment adjacent to the second time segment;
    依此类推,在进行对于其他时间片段的数据迁移过程中,当当前时间片段对应的指定初始查询数量等于预设的查询量阈值时,在完成了对所述源数据库的待迁移数据中与所述指定初始查询量相同的多条第三数据的迁移后,计算每一条所述第三数据在迁移过程中的指定平均响应时间,并判断所述指定平均响应时间是否等于预设的第二响应时间阈值;By analogy, in the process of data migration for other time segments, when the designated initial query quantity corresponding to the current time segment is equal to the preset query quantity threshold, the data to be migrated from the source database is completed with all the data to be migrated. After the migration of the multiple pieces of third data with the same specified initial query amount, calculate the specified average response time of each piece of the third data during the migration process, and determine whether the specified average response time is equal to the preset second response Time threshold
    若等于预设的第二响应时间阈值,判断所述目标数据库是否处于满负荷状态;If it is equal to the preset second response time threshold, determine whether the target database is in a full load state;
    若处于满负荷状态,将所述查询量阈值确定为剩余的所有时间片段分别对应的指定迁移数量。If it is in a full load state, the query amount threshold is determined as the designated migration amount corresponding to all the remaining time segments, respectively.
  4. 根据权利要求1所述的数据迁移方法,其特征在于,所述通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库的步骤之前,包括:The data migration method according to claim 1, wherein before the step of migrating the designated data to the target database through a preset number of designated migration servers, the method comprises:
    获取用户输入的迁移服务器IP,并对所述迁移服务器IP进行配置,以实现对于所述迁移服务器的调用;Acquire the migration server IP input by the user, and configure the migration server IP to implement the invocation of the migration server;
    获取所述迁移服务器IP的数量,并判断所述迁移服务器IP的数量是否大于预设的配置数量阈值;Acquiring the number of migration server IPs, and determining whether the number of migration server IPs is greater than a preset configuration number threshold;
    若大于预设的配置数量阈值,从所述迁移服务器IP中筛选出与所述配置数量阈值的数量相同的第一迁移服务器,并将所述第一迁移服务器确定为所述指定迁移服务器;If it is greater than the preset configuration number threshold, filter out the first migration server with the same number as the configuration number threshold from the migration server IP, and determine the first migration server as the designated migration server;
    若不大于预设的配置数量阈值,将所述迁移服务器IP的对应的所有第二迁移服务器确定为所述指定迁移服务器。If it is not greater than the preset configuration number threshold, all second migration servers corresponding to the migration server IP are determined as the designated migration server.
  5. 根据权利要求1所述的数据迁移方法,其特征在于,所述通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库的步骤,包括:The data migration method according to claim 1, wherein the step of migrating the designated data to the target database through a preset number of designated migration servers comprises:
    获取所述指定迁移服务器的数量;Obtaining the number of the designated migration server;
    将所有所述指定数据划分为与所述指定迁移服务器的数量相同的多个数据集;Dividing all the designated data into multiple data sets with the same number as the designated migration server;
    将每个指定迁移服务器与一个数据集进行一一绑定,通过各所述指定迁移服务器将各所述数据集一一迁移至所述目标数据库中。Each designated migration server is bound to a data set one by one, and each data set is migrated to the target database one by one through each designated migration server.
  6. 根据权利要求1所述的数据迁移方法,其特征在于,所述通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库的步骤之后,包括:The data migration method according to claim 1, wherein the designated data is migrated to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database are migrated. After the step of data migration to the target database, it includes:
    在完成对所述待迁移数据的迁移后,获取所述待迁移数据的迁移记录;After completing the migration of the data to be migrated, obtain the migration record of the data to be migrated;
    根据所述迁移记录,判断在所述待迁移数据中是否存在迁移失败的失败数据;According to the migration record, determine whether there is migration failure data in the data to be migrated;
    若是,对所述失败数据进行预设次数的重试修复处理;If yes, perform a preset number of retry repair processing on the failed data;
    判断在经过预设次数的重试修复处理后,是否存在任意一次对于所述失败数据的成功迁移;Judging whether there is any successful migration of the failed data after a preset number of retry repair processing;
    若否,将所述失败数据转至人工修复处理。If not, transfer the failed data to manual repair processing.
  7. 根据权利要求1所述的数据迁移方法,其特征在于,所述通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库的步骤之后,包括:The data migration method according to claim 1, wherein the designated data is migrated to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database are migrated. After the step of data migration to the target database, it includes:
    在完成对所述待迁移数据的迁移后,获取第一迁移数据的第一头信息与第一数据大小值,其中,所述第一迁移数据为所述目标数据库内的所有迁移数据中的任意一条迁移数据,且所述迁移数据与所述待迁移数据为对应关系;After completing the migration of the data to be migrated, obtain the first header information and the first data size value of the first migration data, where the first migration data is any of all the migration data in the target database One piece of migration data, and the migration data and the data to be migrated are in a corresponding relationship;
    判断所述第一迁移数据的第一头信息、第一数据大小值,与预存储的对应的第一待迁移数据的第二头信息、第二数据大小值是否相同;Judging whether the first header information and the first data size value of the first migration data are the same as the second header information and the second data size value of the pre-stored corresponding first data to be migrated;
    若相同,将所述第一迁移数据标记为对账完成状态,否则将所述第一迁移数据标记为对账异常状态,依次类推,直至完成对于所有所述待迁移数据的对账处理。If they are the same, mark the first migration data as the reconciliation completed state, otherwise mark the first migration data as the reconciliation abnormal state, and so on, until the reconciliation process for all the data to be migrated is completed.
  8. 一种数据迁移装置,其特征在于,包括:A data migration device is characterized in that it comprises:
    第一获取模块,用于获取源数据库中待迁移数据的第一条数据对应的第一时间,以及所述待迁移数据中的最后一条数据对应的第二时间,其中,所述第一时间为所述第一条数据录入至所述源数据库中的时间,所述第二时间为所述最后一条数据录入至所述源数据库中的时间;The first acquisition module is configured to acquire the first time corresponding to the first piece of data in the source database to be migrated, and the second time corresponding to the last piece of data in the data to be migrated, where the first time is The time when the first piece of data was entered into the source database, and the second time is the time when the last piece of data was entered into the source database;
    拆分模块,用于按照第一预设规则对所述第一时间至所述第二时间之间的时间段进行拆分,得到对应的多个时间片段;A splitting module, configured to split the time period between the first time and the second time according to a first preset rule to obtain multiple corresponding time segments;
    确定模块,用于按照第二预设规则确定出与指定时间片段对应的指定迁移数量,其中,所述指定时间片段为所述多个时间片段中的任意一个时间片段;The determining module is configured to determine the designated migration quantity corresponding to the designated time segment according to the second preset rule, wherein the designated time segment is any one of the multiple time segments;
    查询模块,用于按照所述待迁移数据中的每一条数据分别录入至所述源数据库中的时间的先后排列顺序,依次从所述待迁移数据中查询出与所述指定迁移数量的数量相同的多条指定数据;The query module is used to query the data to be migrated according to the sequence of the time when each piece of data in the data to be migrated is respectively entered into the source database, and query the data to be migrated in turn to find out that the quantity is the same as the specified number of migrations Of multiple specified data;
    迁移模块,用于通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库。The migration module is configured to migrate the designated data to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
  9. 根据权利要求8所述的数据迁移装置,其特征在于,所述拆分模块,包括:The data migration device according to claim 8, wherein the splitting module comprises:
    第一判断单元,用于将所述第一时间作为第一时间片段的左端点值,并判断所述第一时间是否处于预设时间范围内,其中,所述第一时间片段为所有所述时间片段中按照从前到后的顺序划分的第一个时间片段;The first determining unit is configured to use the first time as the left endpoint value of the first time segment, and determine whether the first time is within a preset time range, wherein the first time segment is all the The first time segment in the time segment divided from front to back;
    第一计算单元,用于若所述第一时间处于预设时间范围内,计算所述第一时间与第一预设时间值的第一和值,得到第一指定时间,并将所述第一时间与所述第一指定时间之间的时间段标记为所述第一时间片段;The first calculation unit is configured to calculate the first sum of the first time and the first preset time value if the first time is within the preset time range, to obtain the first specified time, and to compare the first time The time period between a time and the first designated time is marked as the first time segment;
    第二计算单元,用于若所述第一时间不处于预设时间范围内,计算所述第一时间与第二预设时间值的第二和值,得到第一指定时间,并将所述第一时间与所述第一指定时间之间的时间段标记为所述第一时间片段;The second calculation unit is configured to calculate the second sum of the first time and the second preset time value if the first time is not within the preset time range to obtain the first specified time, and compare the The time period between the first time and the first designated time is marked as the first time segment;
    第二判断单元,用于将所述第一指定时间作为第二时间片段的左端点值,并判断所述第一指定时间是否处于预设时间范围内,其中,所述第二时间片段为与所述第一时间片段相邻的下一个时间片段;The second determining unit is configured to use the first designated time as the left endpoint value of the second time segment, and determine whether the first designated time is within a preset time range, wherein the second time segment is and The next time segment adjacent to the first time segment;
    第三计算单元,用于若所述第一指定时间处于预设时间范围内,计算所述第一指定时间与第一预设时间值的第三和值,得到第二指定时间,并将所述第一指定时间与所述第二指定时间之间的时间段标记为所述第二时间片段;The third calculation unit is configured to calculate the third sum of the first specified time and the first preset time value if the first specified time is within the preset time range, to obtain the second specified time, and compare the The time period between the first designated time and the second designated time is marked as the second time segment;
    第四计算单元,用于若所述第一指定时间不处于预设时间范围内,计算所述第一指定时间与第二预设时间值的第四和值,得到第二指定时间,并将所述第一指定时间与所述第二指定时间之间的时间段标记为所述第二时间片段,依此类推,直至完成对所述第一时间至所述第二时间之间的时间段的拆分。The fourth calculation unit is configured to calculate the fourth sum of the first specified time and the second preset time value if the first specified time is not within the preset time range to obtain the second specified time, and The time period between the first designated time and the second designated time is marked as the second time segment, and so on, until the time period between the first time and the second time is completed Split.
  10. 根据权利要求9所述的数据迁移装置,其特征在于,所述第一确定模块,包括:The data migration device according to claim 9, wherein the first determining module comprises:
    第一确定单元,用于当所述指定时间片段为所述第一时间片段时,将预设的第一初始查询数量确定为所述指定迁移数量;A first determining unit, configured to determine a preset first initial query quantity as the designated migration quantity when the designated time segment is the first time segment;
    第三判断单元,用于在完成了对所述源数据库的待迁移数据中与所述第一初始查询数量相同的多条第一数据的迁移后,计算每一条所述第一数据在迁移过程中的第一平均响应时间,并判断所述第一平均响应时间是否小于预设的第一响应时间阈值;The third judgment unit is used to calculate the migration process of each piece of the first data after completing the migration of the multiple pieces of first data with the same quantity as the first initial query in the data to be migrated in the source database And determine whether the first average response time is less than a preset first response time threshold;
    第二确定单元,用于若是,计算所述第一初始查询数量与第一预设数量值的第五和值,得到第二初始查询数量,并将所述第二初始查询数量确定为与所述第二时间片段对应的指定迁移数量;The second determining unit is configured to, if yes, calculate the fifth sum of the first initial query quantity and the first preset quantity value to obtain a second initial query quantity, and determine the second initial query quantity to be The designated migration quantity corresponding to the second time segment;
    第四判断单元,用于在完成了对所述源数据库的待迁移数据中与所述第二初始查询数量相同的多条第二数据的迁移后,计算每一条所述第二数据在迁移过程中的第二平均响应时间,并判断所述第二平均响应时间是否小于所述第一响应时间阈值;The fourth judgment unit is used to calculate the migration process of each piece of the second data after completing the migration of the multiple pieces of second data with the same quantity as the second initial query in the data to be migrated in the source database And determine whether the second average response time is less than the first response time threshold;
    第三确定单元,用于若是,计算所述第二初始查询数量与所述第一预设数量值的第六和值,得到第三初始查询数量,并将所述第三初始查询数量确定为与第三时间片段对应的指定迁移数量,其中,所述第三时间片段为与所述第二时间片段相邻的下一个时间片段;The third determining unit is configured to, if yes, calculate the sixth sum of the second initial query quantity and the first preset quantity value to obtain a third initial query quantity, and determine the third initial query quantity as A specified number of migrations corresponding to a third time segment, wherein the third time segment is the next time segment adjacent to the second time segment;
    第五判断单元,用于依此类推,在进行对于其他时间片段的数据迁移过程中,当当前时间片段对应的指定初始查询数量等于预设的查询量阈值时,在完成了对所述源数据库的待迁移数据中与所述指定初始查询量相同的多条第三数据的迁移后,计算每一条所述第三数据在迁移过程中的指定平均响应时间,并判断所述指定平均响应时间是否等于预设的第二响应时间阈值;The fifth judging unit is used for analogy. In the process of data migration for other time segments, when the specified initial query quantity corresponding to the current time segment is equal to the preset query volume threshold, the source database is completed After the migration of multiple pieces of third data with the same amount of the specified initial query in the data to be migrated, calculate the specified average response time of each piece of the third data during the migration process, and determine whether the specified average response time Equal to the preset second response time threshold;
    第六判断单元,用于若等于预设的第二响应时间阈值,判断所述目标数据库是否处于满负荷状态;The sixth determining unit is configured to determine whether the target database is in a full load state if it is equal to a preset second response time threshold;
    第四确定单元,用于若处于满负荷状态,将所述查询量阈值确定为剩余的所有时间片段分别对应的指定迁移数量。The fourth determining unit is configured to determine the query volume threshold as the designated migration number corresponding to all remaining time segments if it is in a full load state.
  11. 根据权利要求8所述的数据迁移装置,其特征在于,所述装置包括:The data migration device according to claim 8, wherein the device comprises:
    第二获取模块,用于获取用户输入的迁移服务器IP,并对所述迁移服务器IP进行配置,以实现对于所述迁移服务器的调用;The second obtaining module is configured to obtain the migration server IP input by the user, and configure the migration server IP to implement the call to the migration server;
    第一判断模块,用于获取所述迁移服务器IP的数量,并判断所述迁移服务器IP的数量是否大于预设的配置数量阈值;The first judgment module is configured to obtain the number of migration server IPs, and determine whether the number of migration server IPs is greater than a preset configuration number threshold;
    筛选模块,用于若大于预设的配置数量阈值,从所述迁移服务器IP中筛选出与所述配置数量阈值的数量相同的第一迁移服务器,并将所述第一迁移服务器确定为所述指定迁移服务器;The screening module is configured to, if it is greater than the preset configuration number threshold, filter out the first migration server with the same number as the configuration number threshold from the migration server IP, and determine the first migration server as the Specify the migration server;
    第二确定模块,用于若不大于预设的配置数量阈值,将所述迁移服务器IP的对应的所有第二迁移服务器确定为所述指定迁移服务器。The second determining module is configured to determine all second migration servers corresponding to the migration server IP as the designated migration server if it is not greater than a preset configuration number threshold.
  12. 根据权利要求8所述的数据迁移装置,其特征在于,所述迁移模块,包括:The data migration device according to claim 8, wherein the migration module comprises:
    获取单元,用于获取所述指定迁移服务器的数量;An obtaining unit for obtaining the number of the designated migration server;
    划分单元,用于将所有所述指定数据划分为与所述指定迁移服务器的数量相同的多个数据集;A dividing unit, configured to divide all the designated data into multiple data sets with the same quantity as the designated migration server;
    绑定单元,用于将每个指定迁移服务器与一个数据集进行一一绑定,通过各所述指定迁移服务器将各所述数据集一一迁移至所述目标数据库中。The binding unit is used to bind each designated migration server to a data set one by one, and migrate each of the data sets to the target database one by one through each designated migration server.
  13. 根据权利要求8所述的数据迁移装置,其特征在于,所述装置包括:The data migration device according to claim 8, wherein the device comprises:
    第三获取模块,用于在完成对所述待迁移数据的迁移后,获取所述待迁移数据的迁移记录;The third acquiring module is configured to acquire the migration record of the data to be migrated after completing the migration of the data to be migrated;
    第二判断模块,用于根据所述迁移记录,判断在所述待迁移数据中是否存在迁移失败的失败数据;The second judgment module is configured to judge whether there is migration failure data in the data to be migrated according to the migration record;
    第一处理模块,用于若是,对所述失败数据进行预设次数的重试修复处理;The first processing module is configured to, if yes, perform a preset number of retry repair processing on the failed data;
    第三判断模块,用于判断在经过预设次数的重试修复处理后,是否存在任意一次对于所述失败数据的成功迁移;The third judgment module is used for judging whether there is any successful migration of the failed data after a preset number of retry repair processing;
    第二处理模块,用于若否,将所述失败数据转至人工修复处理。The second processing module is configured to, if not, transfer the failed data to manual repair processing.
  14. 根据权利要求8所述的数据迁移装置,其特征在于,所述装置包括:The data migration device according to claim 8, wherein the device comprises:
    第四获取模块,用于在完成对所述待迁移数据的迁移后,获取第一迁移数据的第一头信息与第一数据大小值,其中,所述第一迁移数据为所述目标数据库内的所有迁移数据中的任意一条迁移数据,且所述迁移数据与所述待迁移数据为对应关系;The fourth acquiring module is configured to acquire the first header information and the first data size value of the first migration data after the migration of the data to be migrated is completed, wherein the first migration data is in the target database Any piece of migration data among all migration data in, and the migration data and the data to be migrated are in a corresponding relationship;
    第四判断模块,用于判断所述第一迁移数据的第一头信息、第一数据大小值,与预存储的对应的第一待迁移数据的第二头信息、第二数据大小值是否相同;The fourth judging module is used to judge whether the first header information and the first data size value of the first migration data are the same as the second header information and the second data size value of the pre-stored corresponding first data to be migrated ;
    第三处理模块,用于若相同,将所述第一迁移数据标记为对账完成状态,否则将所述第一迁移数据标记为对账异常状态,依次类推,直至完成对于所有所述迁移数据的对账处理。The third processing module is configured to mark the first migration data as the reconciliation completed state if they are the same, otherwise mark the first migration data as the reconciliation abnormal state, and so on, until the completion of all the migration data The reconciliation process.
  15. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现数据迁移方法,该数据迁移方法,包括:A computer device includes a memory and a processor, the memory stores computer-readable instructions, and is characterized in that when the processor executes the computer-readable instructions, a data migration method is implemented, and the data migration method includes:
    获取源数据库中待迁移数据的第一条数据对应的第一时间,以及所述待迁移数据的最后一条数据对应的第二时间,其中,所述第一时间为所述第一条数据录入至所述源数据库中的时间,所述第二时间为所述最后一条数据录入至所述源数据库中的时间;Obtain the first time corresponding to the first piece of data of the data to be migrated in the source database, and the second time corresponding to the last piece of data of the data to be migrated, where the first time is the time when the first piece of data is entered The time in the source database, and the second time is the time when the last piece of data is entered into the source database;
    按照第一预设规则对所述第一时间至所述第二时间之间的时间段进行拆分,得到对应的多个时间片段;Split the time period between the first time and the second time according to a first preset rule to obtain multiple corresponding time segments;
    按照第二预设规则确定出与指定时间片段对应的指定迁移数量,其中,所述指定时间片段为所述多个时间片段中的任意一个时间片段;Determine the designated migration quantity corresponding to the designated time segment according to the second preset rule, where the designated time segment is any one of the multiple time segments;
    按照所述待迁移数据中的每一条数据分别录入至所述源数据库中的时间的先后排列顺序,依次从所述待迁移数据中查询出与所述指定迁移数量的数量相同的多条指定数据;According to the sequence of the time when each piece of data in the data to be migrated is entered into the source database, the data to be migrated are sequentially queried out of the data to be migrated in the same quantity as the specified number of designated data to be migrated. ;
    通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库。The designated data is migrated to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
  16. 根据权利要求15所述的计算机设备,其特征在于,所述通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库的步骤之前,包括:The computer device according to claim 15, wherein before the step of migrating the designated data to the target database through a preset number of designated migration servers, the method comprises:
    获取用户输入的迁移服务器IP,并对所述迁移服务器IP进行配置,以实现对于所述迁移服务器的调用;Acquire the migration server IP input by the user, and configure the migration server IP to implement the invocation of the migration server;
    获取所述迁移服务器IP的数量,并判断所述迁移服务器IP的数量是否大于预设的配置数量阈值;Acquiring the number of migration server IPs, and determining whether the number of migration server IPs is greater than a preset configuration number threshold;
    若大于预设的配置数量阈值,从所述迁移服务器IP中筛选出与所述配置数量阈值的数量相同的第一迁移服务器,并将所述第一迁移服务器确定为所述指定迁移服务器;If it is greater than the preset configuration number threshold, filter out the first migration server with the same number as the configuration number threshold from the migration server IP, and determine the first migration server as the designated migration server;
    若不大于预设的配置数量阈值,将所述迁移服务器IP的对应的所有第二迁移服务器确定为所述指定迁移服务器。If it is not greater than the preset configuration number threshold, all second migration servers corresponding to the migration server IP are determined as the designated migration server.
  17. 根据权利要求15所述的计算机设备,其特征在于,所述通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库的步骤,包括:15. The computer device according to claim 15, wherein the step of migrating the designated data to the target database through a preset number of designated migration servers comprises:
    获取所述指定迁移服务器的数量;Obtaining the number of the designated migration server;
    将所有所述指定数据划分为与所述指定迁移服务器的数量相同的多个数据集;Dividing all the designated data into multiple data sets with the same number as the designated migration server;
    将每个指定迁移服务器与一个数据集进行一一绑定,通过各所述指定迁移服务器将各所述数据集一一迁移至所述目标数据库中。Each designated migration server is bound to a data set one by one, and each data set is migrated to the target database one by one through each designated migration server.
  18. 一种计算机可读存储介质,其上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现数据迁移方法,该数据迁移方法,包括:A computer-readable storage medium having computer-readable instructions stored thereon, wherein the computer-readable instructions are executed by a processor to implement a data migration method, and the data migration method includes:
    获取源数据库中待迁移数据的第一条数据对应的第一时间,以及所述待迁移数据的最后一条数据对应的第二时间,其中,所述第一时间为所述第一条数据录入至所述源数据库中的时间,所述第二时间为所述最后一条数据录入至所述源数据库中的时间;Obtain the first time corresponding to the first piece of data of the data to be migrated in the source database, and the second time corresponding to the last piece of data of the data to be migrated, where the first time is the time when the first piece of data is entered The time in the source database, and the second time is the time when the last piece of data is entered into the source database;
    按照第一预设规则对所述第一时间至所述第二时间之间的时间段进行拆分,得到对应的多个时间片段;Split the time period between the first time and the second time according to a first preset rule to obtain multiple corresponding time segments;
    按照第二预设规则确定出与指定时间片段对应的指定迁移数量,其中,所述指定时间片段为所述多个时间片段中的任意一个时间片段;Determine the designated migration quantity corresponding to the designated time segment according to the second preset rule, where the designated time segment is any one of the multiple time segments;
    按照所述待迁移数据中的每一条数据分别录入至所述源数据库中的时间的先后排列顺序,依次从所述待迁移数据中查询出与所述指定迁移数量的数量相同的多条指定数据;According to the sequence of the time when each piece of data in the data to be migrated is entered into the source database, the data to be migrated are sequentially queried out of the data to be migrated in the same quantity as the specified number of designated data to be migrated. ;
    通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库,依此类推,直至将所述源数据库中的所有待迁移数据迁移至所述目标数据库。The designated data is migrated to the target database through a preset number of designated migration servers, and so on, until all the data to be migrated in the source database is migrated to the target database.
  19. 根据权利要求18所述的计算机可读存储介质,其特征在于,所述通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库的步骤之前,包括:18. The computer-readable storage medium according to claim 18, wherein before the step of migrating the designated data to the target database through a preset number of designated migration servers, the method comprises:
    获取用户输入的迁移服务器IP,并对所述迁移服务器IP进行配置,以实现对于所述迁移服务器的调用;Acquire the migration server IP input by the user, and configure the migration server IP to implement the invocation of the migration server;
    获取所述迁移服务器IP的数量,并判断所述迁移服务器IP的数量是否大于预设的配置数量阈值;Acquiring the number of migration server IPs, and determining whether the number of migration server IPs is greater than a preset configuration number threshold;
    若大于预设的配置数量阈值,从所述迁移服务器IP中筛选出与所述配置数量阈值的数量相同的第一迁移服务器,并将所述第一迁移服务器确定为所述指定迁移服务器;If it is greater than the preset configuration number threshold, filter out the first migration server with the same number as the configuration number threshold from the migration server IP, and determine the first migration server as the designated migration server;
    若不大于预设的配置数量阈值,将所述迁移服务器IP的对应的所有第二迁移服务器确定为所述指定迁移服务器。If it is not greater than the preset configuration number threshold, all second migration servers corresponding to the migration server IP are determined as the designated migration server.
  20. 根据权利要求18所述的计算机可读存储介质,其特征在于,所述通过预设数量的指定迁移服务器将所述指定数据迁移至目标数据库的步骤,包括:18. The computer-readable storage medium according to claim 18, wherein the step of migrating the designated data to the target database through a preset number of designated migration servers comprises:
    获取所述指定迁移服务器的数量;Obtaining the number of the designated migration server;
    将所有所述指定数据划分为与所述指定迁移服务器的数量相同的多个数据集;Dividing all the designated data into multiple data sets with the same number as the designated migration server;
    将每个指定迁移服务器与一个数据集进行一一绑定,通过各所述指定迁移服务器将各所述数据集一一迁移至所述目标数据库中。Each designated migration server is bound to a data set one by one, and each data set is migrated to the target database one by one through each designated migration server.
PCT/CN2019/119566 2019-10-29 2019-11-20 Method and apparatus for data migration, computer device, and storage medium WO2021082104A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911038072.4 2019-10-29
CN201911038072.4A CN111008188B (en) 2019-10-29 2019-10-29 Data migration method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2021082104A1 true WO2021082104A1 (en) 2021-05-06

Family

ID=70111499

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/119566 WO2021082104A1 (en) 2019-10-29 2019-11-20 Method and apparatus for data migration, computer device, and storage medium

Country Status (2)

Country Link
CN (1) CN111008188B (en)
WO (1) WO2021082104A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117591497A (en) * 2024-01-18 2024-02-23 中核武汉核电运行技术股份有限公司 Nuclear power historical data cross-system migration method
CN117591497B (en) * 2024-01-18 2024-05-03 中核武汉核电运行技术股份有限公司 Nuclear power historical data cross-system migration method

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112131179B (en) * 2020-09-23 2023-11-21 平安科技(深圳)有限公司 Task state detection method, device, computer equipment and storage medium
CN113220660A (en) * 2021-04-15 2021-08-06 远景智能国际私人投资有限公司 Data migration method, device and equipment and readable storage medium
CN113342780A (en) * 2021-06-28 2021-09-03 深圳壹账通智能科技有限公司 DSU data migration method and device and computer equipment
CN113360479B (en) * 2021-06-29 2023-10-20 深圳市天汇世纪科技有限公司 Data migration method, device, computer equipment and storage medium
CN113326074B (en) * 2021-06-30 2022-04-15 中国平安人寿保险股份有限公司 Delay event processing method and device, computer equipment and storage medium
CN113515503A (en) * 2021-07-23 2021-10-19 浩鲸云计算科技股份有限公司 Table-based InfluxDB data migration method
CN114020281B (en) * 2021-11-08 2022-10-14 中电金信软件有限公司 Database deployment method, application service deployment method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102004746A (en) * 2009-09-02 2011-04-06 中国银联股份有限公司 Data transfer control method and device
CN107977462A (en) * 2017-12-21 2018-05-01 泰康保险集团股份有限公司 Data migration method and device
CN108509556A (en) * 2018-03-22 2018-09-07 上海达梦数据库有限公司 Data migration method and device, server, storage medium
CN109460188A (en) * 2018-11-13 2019-03-12 郑州云海信息技术有限公司 A kind of data migration method, system, equipment and computer readable storage medium

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9619474B2 (en) * 2011-03-31 2017-04-11 EMC IP Holding Company LLC Time-based data partitioning
US20150200833A1 (en) * 2014-01-10 2015-07-16 Seagate Technology Llc Adaptive Data Migration Using Available System Bandwidth
CN105338051B (en) * 2014-08-15 2018-09-18 阿里巴巴集团控股有限公司 A kind of method of data synchronization and equipment
CN105183582B (en) * 2015-07-30 2019-03-08 北京奇虎科技有限公司 Data back up method and device
CN106502576B (en) * 2015-09-06 2020-06-23 中兴通讯股份有限公司 Migration strategy adjusting method and device
CN106970921B (en) * 2016-01-14 2020-10-16 阿里巴巴集团控股有限公司 Data migration method and device
CN105808376B (en) * 2016-02-24 2019-06-14 北京金山安全软件有限公司 Data backup method and device and electronic equipment
JP6495872B2 (en) * 2016-08-17 2019-04-03 日本電信電話株式会社 Migration system, migration method, and migration program
CN109376196B (en) * 2018-09-25 2021-04-13 浪潮软件科技有限公司 Method and device for batch synchronization of redo logs
CN110287258A (en) * 2019-06-26 2019-09-27 深圳前海微众银行股份有限公司 A kind of data synchronizing processing method and device based on dual data source

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102004746A (en) * 2009-09-02 2011-04-06 中国银联股份有限公司 Data transfer control method and device
CN107977462A (en) * 2017-12-21 2018-05-01 泰康保险集团股份有限公司 Data migration method and device
CN108509556A (en) * 2018-03-22 2018-09-07 上海达梦数据库有限公司 Data migration method and device, server, storage medium
CN109460188A (en) * 2018-11-13 2019-03-12 郑州云海信息技术有限公司 A kind of data migration method, system, equipment and computer readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117591497A (en) * 2024-01-18 2024-02-23 中核武汉核电运行技术股份有限公司 Nuclear power historical data cross-system migration method
CN117591497B (en) * 2024-01-18 2024-05-03 中核武汉核电运行技术股份有限公司 Nuclear power historical data cross-system migration method

Also Published As

Publication number Publication date
CN111008188B (en) 2023-08-15
CN111008188A (en) 2020-04-14

Similar Documents

Publication Publication Date Title
WO2021082104A1 (en) Method and apparatus for data migration, computer device, and storage medium
US10489378B2 (en) Detection and resolution of conflicts in data synchronization
US8683263B2 (en) Cooperative client and server logging
CN109933632B (en) Data migration method, device and equipment for database
WO2023005075A1 (en) Disaster recovery method and system for data, terminal device and computer storage medium
CN112434043B (en) Data synchronization method, device, electronic equipment and medium
US9183038B2 (en) Job management system that determines if master data has been updated, then re-executes a sub-job based on available executing computers and data sharing status
WO2019047565A1 (en) Task processing method, device, computer device, and storage medium
WO2009089746A1 (en) Method, device and system for realizing task in cluster environment
CN110647531A (en) Data synchronization method, device, equipment and computer readable storage medium
WO2021139322A1 (en) Method and apparatus for processing network device data, computer equipment and storage medium
US20180032567A1 (en) Method and device for processing data blocks in a distributed database
CN106354566A (en) Command processing method and server
WO2017181430A1 (en) Method and device for duplicating database in distributed system
CN111177173A (en) System and method for realizing data synchronization optimization processing under big data environment
WO2012101531A1 (en) Data integrity protection in storage volumes
CN108255703B (en) SQL script fault repairing method and terminal thereof
WO2024051454A1 (en) Method and apparatus for processing transaction log
CN111078418B (en) Operation synchronization method, device, electronic equipment and computer readable storage medium
CN115640280A (en) Data migration method and device
WO2023024248A1 (en) Bus anomaly handling method and apparatus, electronic device and readable storage medium
JP2009181495A (en) Job processing system and job management method
CN114756410A (en) Data recovery method, device and medium for dual-computer hot standby system
CN103259863A (en) System and method for controlling zookeeper services based on clusters
JP2009181494A (en) Job processing system and job information acquisition method

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19950897

Country of ref document: EP

Kind code of ref document: A1