Data migration method, device and system
By determining the field types of data to be migrated in non-relational databases and selecting appropriate migration methods, the problem of low versatility of traditional data migration tools is solved, and support for multiple field types is achieved and data migration is efficient and reliable. sex.
Patent Information
- Application Number
- CN202411081680.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-08-08
AI Technical Summary
Traditional data migration tools are difficult to cover multiple field types, have low versatility, and cannot effectively handle data in non-relational databases during the migration process.
By obtaining the data and configuration information to be migrated, the target storage queue and field type are determined, the appropriate migration method is selected based on the field type, the data is migrated to the target data table, and breakpoints are resumed during the data migration process to improve reliability and efficiency.
It supports more field types, improves the versatility and reliability of data migration, and enhances migration efficiency and breakpoint resumption capabilities.
Smart Images

Figure CN118626474A
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data migration method, device and system. Background Art
[0002] A non-relational database (NoSQL database) is a database design approach that focuses on storing and retrieving data. The non-relational database model is different from the table structure in a relational database, storing data in a data structure such as Cassandra database. Non-relational database design does not require a fixed schema, and its high availability and horizontal scalability make it an ideal choice for large-scale data processing and is suitable for managing large and usually unstructured data sets.
[0003] In modern data management and analysis, database migration is an important task. Database migration is required for system upgrades or scenario changes, data backup, and disaster recovery. However, traditional data migration tools are usually difficult to process data during the migration process. Data migration tools such as SSTableLoader, Cassandra Bulk Loader, and Cassandra Migrator can only perform basic data migration on the more common preset field types in the database, and it is difficult to cover more field types, so their versatility is low.
[0004] Therefore, traditional technologies are in urgent need of a data migration technology that covers more field types and is more versatile. Summary of the invention
[0005] Based on this, it is necessary to provide a data migration method, device and system that covers more field types and has higher versatility to address the above technical problems.
[0006] In a first aspect, the present application provides a data migration method. The method comprises: Get the data and configuration information to be migrated; Determine a target storage queue according to the data to be migrated, and store the data to be migrated into the target storage queue; Reading the data to be migrated in the target storage queue, and determining the field type of the data to be migrated according to the configuration information; A migration method is determined according to the field type, and the data to be migrated is migrated to a target data table according to the migration method.
[0007] In one of the embodiments, before determining the target storage queue according to the data to be migrated, the method further includes: Determining a data reading progress according to the data to be migrated; The data to be migrated continues to be acquired according to the preset batch information and the data reading progress.
[0008] In one embodiment, the configuration information includes a concurrency number, and before determining a target storage queue according to the data to be migrated, further includes: Generate a thread pool according to the concurrent number, wherein the number of core threads in the thread pool matches the concurrent number; The data to be migrated is persistently stored in the thread pool.
[0009] In one embodiment, determining a target storage queue according to the data to be migrated includes: Determine a queue identifier according to the data to be migrated; The target storage queue is determined according to the queue identifier.
[0010] In one embodiment, determining the migration mode according to the field type, and migrating the to-be-migrated data to the target data table according to the migration mode includes: If the field type includes counter, determining that the migration method includes an update statement; The data to be migrated is migrated to the target data table based on the update statement.
[0011] In one embodiment, determining the migration mode according to the field type, and migrating the to-be-migrated data to the target data table according to the migration mode further comprises: If the field type includes a row field including a survival time, determining a first timestamp and a second timestamp of the data to be migrated, wherein the first timestamp includes a time when the data to be migrated is acquired, and the second timestamp includes a time when the data to be migrated in the target storage queue is read; A transmission time is determined based on the first timestamp and the second timestamp, and if the transmission time is less than or equal to the survival time, the data to be migrated is migrated to a target data table.
[0012] In one embodiment, reading the data to be migrated in the target storage queue includes: Determining read position information of the target storage queue; Determining the reading progress of the target storage queue according to the reading position information; If the reading progress is incomplete, the data to be migrated in the target storage queue is read.
[0013] In one of the embodiments, before migrating the data to be migrated to the target data table according to the migration method, the method further includes: Determine whether a migration data table structure is the same as the target data table structure, the migration data being used to store the data to be migrated; If they are not the same, a mapping relationship between the migration data table and the target data table is determined, and the data to be migrated is converted into a target data type according to the mapping relationship, and the target data type matches the target data table structure.
[0014] In the second aspect, the present application also provides a data migration system, which includes a migration data table, a data migration module and a target data table, the data migration module includes at least one data acquisition unit, a data transmission unit and at least one data writing unit, the at least one data acquisition unit and the data transmission unit interact with each other according to a first field mapping relationship or a first preset interface, and the at least one data writing unit and the data transmission unit interact with each other according to a second field mapping relationship or a second preset interface, wherein the data migration module is used to implement the steps of the data migration method described in any one of the first aspects above.
[0015] In a third aspect, the present application also provides a data migration device. The device comprises: Data acquisition module, used to obtain data to be migrated and configuration information; A data storage module, configured to determine a target storage queue according to the data to be migrated, and store the data to be migrated in the target storage queue; A field type determination module, configured to read the data to be migrated in the target storage queue and determine the field type of the data to be migrated according to the configuration information; The data migration module is used to determine a migration method according to the field type, and migrate the data to be migrated to a target data table according to the migration method.
[0016] The above-mentioned data migration method, device and system obtain the data to be migrated and configuration information; determine the target storage queue according to the data to be migrated, and store the data to be migrated in the target storage queue; read the data to be migrated in the target storage queue, and determine the field type of the data to be migrated according to the configuration information; determine the migration method according to the field type, and migrate the data to be migrated to the target data table according to the migration method. On the one hand, the embodiment of the present application determines the field type of the data to be migrated, provides corresponding migration methods for different field types, and completes data migration, which can cover more data types and has a higher versatility of migration method; on the other hand, the embodiment of the present application splits the traditional data migration process, stores the data to be migrated in the target storage queue during the data migration process, improves the breakpoint resume capability of data migration, and thereby improves the reliability and migration efficiency of data migration.
[0017] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 An application environment diagram of a data migration method in an embodiment; Figure 2 A schematic diagram of a data migration method in one embodiment; Figure 3 is a schematic diagram of a data migration system in one embodiment; Figure 4 A schematic diagram of a process of a data reading unit reading data to be migrated in one embodiment; Figure 5 A schematic diagram of a process of storing and transmitting data by a data transmission unit in one embodiment; Figure 6 A schematic diagram of a flow chart of a data writing unit determining a writing progress in one embodiment; Figure 7 It is a schematic diagram of a process of a data writing unit migrating data to a target data table in one embodiment; Figure 8 is a structural block diagram of a data migration device in one embodiment; Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0020] The terms "module", "unit", etc. used below are a combination of software and / or hardware that can implement a predetermined function. Although the devices described in the following embodiments are preferably implemented in hardware, the implementation of software, or a combination of software and hardware is also possible and conceivable.
[0021] The data migration method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the database terminal 102 to be migrated and the target database terminal 106 communicate with the server 104 through the network respectively. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains the data to be migrated and the configuration information at the database terminal 102 to be migrated, and determines the target storage queue in the data storage system according to the data to be migrated, and stores the data to be migrated in the target storage queue. The server 104 reads the data to be migrated in the target storage queue, and determines the field type of the data to be migrated according to the configuration information. The server 104 determines the migration method according to the field type, and migrates the data to be migrated to the target data table of the target database terminal 106 according to the migration method. In the above data migration process, other data processing modules and data storage modules can also replace the server 104 to complete the data migration. Among them, the server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0022] In the present application embodiment, Figure 2 As shown, a data migration method is provided, the method comprising: S201: Acquire data to be migrated and configuration information.
[0023] In the embodiment of the present application, the data to be migrated is stored in a migration data table. The migration data table may include a data table in a database, and the database may include a relational database and a non-relational database. The following uses the widely used Cassandra database as an example to illustrate the non-relational database.
[0024] Cassandra is a distributed, high-performance non-relational database (NoSQL database) that is widely used for large-scale data storage and processing. Its horizontally scalable design enables it to easily handle massive amounts of data while providing high availability and fault tolerance. Cassandra's distributed architecture and lack of central nodes enable it to excel in real-time read and write operations, making it suitable for application scenarios that require high throughput and elastic expansion, such as finance, social media, the Internet of Things, log analysis, and other application scenarios. The need for Cassandra data migration stems from changes in business requirements, database version upgrades, or cloud platform migrations. Data migration helps users migrate data from one Cassandra environment to another without interrupting services, ensuring a smooth transition and data consistency, and addressing the complexity and potential risks of the migration process.
[0025] In an embodiment of the present application, the configuration information may include database configuration information, table and field information, and migration configuration information. Among them, the database configuration information may include connection information of the migration database and the target database, such as the IP address, port name, user name, password, etc. of the migration database and the target database. The table and field information may include the name of the migration data table, the table name, the field list, the field type, the primary key information, the partition key information, etc. The migration configuration information may include preset batch information and the number of concurrency. The preset batch information includes the number of data items read or written each time, and the number of concurrency includes the number of threads for parallel processing.
[0026] S203: Determine a target storage queue according to the data to be migrated, and store the data to be migrated in the target storage queue.
[0027] In an embodiment of the present application, the data to be migrated can be persistently stored during the data migration process to improve the orderliness and reliability of the data migration. After obtaining the data to be migrated, the target storage queue can be determined according to the characteristics of the data to be migrated, and the data to be migrated can be stored in the target storage queue. Among them, the characteristics of the data to be migrated may include field type, data size, primary key value range, etc. The number of target storage queues can be preset. It can be understood that preferentially storing the data to be migrated in the idle queue can improve the storage efficiency and transmission efficiency of the data.
[0028] In some embodiments, determining a target storage queue according to the data to be migrated includes: S301: Determine a queue identifier according to the data to be migrated.
[0029] S303: Determine the target storage queue according to the queue identifier.
[0030] In the embodiment of the present application, the corresponding hash value can be determined according to the data to be migrated, the queue identifier can be determined according to the hash value, and then the target storage queue can be determined according to the queue identifier. Specifically, if 16 storage queues are preset, and the preset queue identifiers are 1-16, the queue identifier can be determined according to the hash value of the data to be migrated modulo 16, and the data to be migrated can be allocated and stored in different storage queues.
[0031] In the embodiment of the present application, after determining the target storage queue, the data to be migrated can be stored at the end of the target storage queue to complete the persistent storage of the data. Storing the data to be migrated in the target storage queue can, on the one hand, disperse the data storage and transmission, improve the transmission efficiency and storage efficiency; on the other hand, it can improve the breakpoint resuming capability of data migration.
[0032] S205: Read the data to be migrated in the target storage queue, and determine the field type of the data to be migrated according to the configuration information.
[0033] In an embodiment of the present application, data to be migrated is stored in a target storage queue. When reading the data to be migrated, the data to be migrated in each target storage queue can be read sequentially, or the data to be migrated in multiple target storage queues can be read simultaneously. When reading the data to be migrated, the field type of the data to be migrated can be determined based on the configuration information. Specifically, the field type can include a counter or a row field containing a time to live (ttl), and different migration methods can be determined accordingly for different field types.
[0034] Furthermore, when data is written into the target data table, data interruption and the like may occur during the writing process. Based on this, an embodiment of the present application also provides a data migration method that can resume data from a breakpoint during the writing process. In some embodiments, reading the data to be migrated in the target storage queue includes: S401: Determine the read position information of the target storage queue.
[0035] S403: Determine the reading progress of the target storage queue according to the reading position information.
[0036] S405: If the reading progress is incomplete, read the data to be migrated in the target storage queue.
[0037] In an embodiment of the present application, when reading the data to be migrated in the target storage queue, the read position information of the target storage queue is determined. The read position information can be used to determine the reading progress of the data to be migrated in the target storage queue. Specifically, the read position information may include position pointer information in the target archive queue, such as offset information, which is used to indicate the position of the data to be read.
[0038] Determine the read progress of the target storage queue according to the read position information. If the read progress is not completed, read the data to be migrated in the target storage queue. Specifically, determine the latest offset information of the target storage queue, and judge whether the current offset data is the latest. If it is not the latest, it means that the read progress is not completed, and read the latest data to be migrated. If the data to be migrated is migrated to the target data table, the read position information is updated accordingly. Specifically, if the data to be migrated is migrated to the target data table, the offset data updates the position information.
[0039] The embodiment of the present application determines the read progress of the target storage queue by reading the position information. During the process of migrating data to the target data table, if there is a data transmission interruption or a write interruption, the data can be continued to be migrated from the migration progress before the interruption according to the read position information. Compared with the traditional technology that requires restarting data migration after data interruption, the present application improves the reliability and efficiency of data migration.
[0040] S207: Determine a migration method according to the field type, and migrate the data to be migrated to a target data table according to the migration method.
[0041] In order to cover more field types and improve the versatility of data migration, in an embodiment of the present application, a corresponding migration method can be determined according to different field types of the data to be migrated, and the data to be migrated can be migrated to the target data table according to the corresponding migration method.
[0042] The following two embodiments illustrate the corresponding migration methods of different field types.
[0043] In some embodiments, determining the migration mode according to the field type, and migrating the to-be-migrated data to the target data table according to the migration mode includes: S501: If the field type includes counter, determine that the migration method includes an update statement.
[0044] S503: Migrate the data to be migrated to the target data table based on the update statement.
[0045] In traditional technology, during the data writing process of data migration, the INSERT statement is usually used to write the data to be migrated, but the INSERT statement cannot write the counter field type. In the embodiment of the present application, when the data is migrated to the target data table, when assembling and writing the CQL (Cassandra Query Language, the language usage identifier of the Cassandra database) statement, it is determined whether the field type of the data to be migrated is a counter. If the field type includes a counter, it is determined that the migration method includes an update statement. Then, based on the update statement, the data to be migrated is migrated to the target data table, and the accumulation of the counter type field after the migration is completed.
[0046] In some embodiments, determining the migration mode according to the field type, and migrating the to-be-migrated data to the target data table according to the migration mode further comprises: S601: If the field type includes a row field including a survival time, determine a first timestamp and a second timestamp of the data to be migrated, wherein the first timestamp includes a time when the data to be migrated is acquired, and the second timestamp includes a time when the data to be migrated in the target storage queue is read.
[0047] S603: Determine a transmission time based on the first timestamp and the second timestamp, and if the transmission time is less than or equal to the survival time, migrate the data to be migrated to a target data table.
[0048] In an embodiment of the present application, when assembling a CQL statement to obtain the data to be migrated, a time to live (ttl) query condition is set. If the field type includes a row field containing a life time, the time for obtaining the data to be migrated is determined as the first timestamp, and the time for reading the data to be migrated in the target storage queue is the second timestamp. Before the data to be migrated is migrated to the target data table, the life time is calibrated based on the first timestamp and the second timestamp. Specifically, the transmission time is determined based on the first timestamp and the second timestamp. If the transmission time is less than or equal to the life time, it means that the data to be migrated is still within the life time, and the life time calibration is completed, and the data to be migrated is migrated to the target data table. If the transmission time is greater than the life time, it means that the data to be migrated has expired or is automatically deleted, and the data to be migrated will not be migrated.
[0049] The above-mentioned data migration method obtains the data to be migrated and the configuration information; determines the target storage queue according to the data to be migrated, and stores the data to be migrated in the target storage queue; reads the data to be migrated in the target storage queue, and determines the field type of the data to be migrated according to the configuration information; determines the migration method according to the field type, and migrates the data to be migrated to the target data table according to the migration method. On the one hand, the embodiment of the present application determines the field type of the data to be migrated, provides corresponding migration methods for different field types, and completes data migration, which can cover more data types and has a higher versatility of migration method; on the other hand, the embodiment of the present application splits the traditional data migration process, stores the data to be migrated in the target storage queue during the data migration process, improves the breakpoint-resume capability of data migration, and thereby improves the reliability and migration efficiency of data migration.
[0050] In order to further improve the reliability of data migration, in some embodiments, the configuration information includes a concurrency number, and before determining a target storage queue according to the data to be migrated, further includes: S701: Generate a thread pool according to the concurrency number, and the number of core threads in the thread pool matches the concurrency number.
[0051] S703: Persistently storing the data to be migrated in the thread pool.
[0052] In the embodiment of the present application, after reading the data to be migrated and before storing it in the target storage queue, a thread pool is generated according to the number of concurrency, and the number of core threads in the thread pool matches the number of concurrency. The data to be migrated is persistently stored in the thread pool. During the process of reading the data to be migrated, by persistently storing the data to be migrated in the thread pool, support can be provided for interruption and continuation of the data reading process, thereby improving the reliability of data migration.
[0053] When obtaining the data to be migrated from the migration data table, the embodiment of the present application also provides a data migration method for implementing breakpoint-resume during the reading process. In some embodiments, before determining the target storage queue according to the data to be migrated, it also includes: S801: Determine data reading progress according to the data to be migrated.
[0054] S803: Continue to obtain the data to be migrated according to the preset batch information and the data reading progress.
[0055] In an embodiment of the present application, when obtaining the data to be migrated from the migration data table, the total progress information corresponding to the data to be migrated can be determined. Specifically, the total progress information can be a token value, and the token value is used to represent the total data range of the data to be migrated. When reading the data to be migrated from the migration data table, it can be executed by one or more migration tasks, each migration task corresponds to a part of the data range of the data to be migrated, and the data ranges corresponding to all migration tasks constitute the total data range. The number of migration tasks can be set according to the actual application scenario.
[0056] When acquiring the data to be migrated, the data reading progress can be determined based on the data to be migrated. Specifically, the data reading progress may include the scanning position of the token ring, that is, the location information of the data task corresponding to the data to be migrated that was read the last time. According to the preset batch information and the data reading progress, the data to be migrated can be continued to be read at the reading interruption point when the previous migration task is interrupted. Among them, the preset batch information includes the maximum batch information. Because the amount of data to be migrated that needs to be read in the task to be migrated may also be large, the amount of data read each time is determined by setting the preset batch information. It can be understood that the data to be migrated in each task to be migrated can be completed by reading multiple batches of data, and the number of reads is determined according to the preset batch information.
[0057] If all batches of data for a data migration task are transferred, the data range of the token value corresponding to the data migration task is marked as migrated and stored persistently. After all token value data ranges are read, all tasks of reading the data to be migrated in the migration data table are completed.
[0058] In an embodiment of the present application, when reading the data to be migrated from the migration data table, if a reading interruption occurs, the data reading progress can be determined according to the data to be migrated, and then the execution point of the previous data migration task can be determined to continue to complete the reading task of the data to be migrated.
[0059] The data migration method provided in the embodiment of the present application can be applied to scenarios where the migration data table and the target data table have the same structure, or can be applied to scenarios where the structures are different. In some embodiments, before migrating the data to be migrated to the target data table according to the migration method, it also includes: S901: Determine whether a migration data table structure is the same as the target data table structure, the migration data being used to store the data to be migrated.
[0060] S903: If they are not the same, determining a mapping relationship between the migration data table and the target data table, and converting the data to be migrated into a target data type according to the mapping relationship, wherein the target data type matches the structure of the target data table.
[0061] In the embodiment of the present application, when obtaining the data to be migrated from the migration data table, it is determined whether the structure of the migration data table is the same as the structure of the target data table.
[0062] If the migration data table and the target data table have the same structure, you only need to configure the full field name and field type of the table and specify the primary key field. When obtaining the data to be migrated from the migration data table, the query CQL statement is automatically assembled based on the field, and the data segmentation query is completed based on the primary key. When migrating to the target data table, the CQL statement is automatically assembled and written to complete the data writing, and finally the data migration is completed.
[0063] If the migration data table and the target data table have different structures, a mapping relationship between the migration data table and the target data table is determined, and the data to be migrated is converted into a target data type according to the mapping relationship, and the target data type matches the target data table structure.
[0064] Specifically, if the migration data table and the target data table have different structures, configure the full field names and field types of the migration data table and the target data table respectively, specify the primary key field, and determine the mapping relationship between the migration data table fields and the target data table fields. When obtaining the data to be migrated from the migration data table, automatically assemble the query CQL statement based on the fields, and complete the data segmentation query based on the primary key. When migrating to the target data table, according to the mapping relationship, the data conversion is automatically completed based on the target data type based on the data to be migrated. After the conversion is completed, a write CQL statement will be generated based on the target data table to complete the data writing and finally complete the data migration.
[0065] The data migration tools in traditional technologies can usually only perform one-to-one data migration, with low migration efficiency and a small migration scope. Based on this, an embodiment of the present application provides a data migration system, the data migration system includes a migration data table, a data migration module and a target data table, the data migration module includes at least one data acquisition unit, a data transmission unit and at least one data writing unit, the at least one data acquisition unit and the data transmission unit perform data interaction according to a first field mapping relationship or a first preset interface, the at least one data writing unit and the data transmission unit perform data interaction according to a second field mapping relationship or a second preset interface, wherein the data migration module is used to implement the steps of the data migration method described in any of the above embodiments.
[0066] In an embodiment of the present application, the data migration system supports one-to-many and many-to-one configurations of data reading units and data writing units. By reserving an extended interface, based on a field mapping relationship or a custom preset interface, the integration of multiple table data into a single table and the splitting of single table data into multiple tables during the data migration process can be realized, which can effectively improve the data migration efficiency and increase the scope of application of data migration.
[0067] The data migration system and data migration method provided by the present application are described below through specific embodiments.
[0068] In some specific embodiments, Figure 3 The data migration system in a specific embodiment is shown, and the data migration system includes a data reading unit, a data transmission unit, and a data writing unit. The data reading unit obtains the migration table data in the migration data table, and transmits it to the data writing unit through the data transmission unit. The data writing unit writes the data to be migrated into the target data table to complete the data migration.
[0069] In some specific embodiments, Figure 4The figure shows a flow chart of the data reading unit reading the data to be migrated. After the data migration task is triggered, the data to be migrated and the configuration information are obtained, and a reading CQL statement is generated. Determine whether the maximum batch information is set. If so, use the set batch information, otherwise use the default batch information. Determine whether concurrency is enabled. If so, create a thread pool according to the number of concurrencies. Otherwise, create a single thread to store the data to be migrated. Query the unmigrated data range, that is, the data range corresponding to the token value of the unmigrated data range, scan the migration data table based on the primary key data range token, and transfer the data to be migrated in segments to the file transfer service, record the data range corresponding to the token value of the migrated data range and store it persistently. Determine whether the data range to be migrated corresponding to the data range token value has been fully migrated. If so, complete the acquisition of the data to be migrated. Otherwise, repeat the above query of the data range corresponding to the token value of the unmigrated data range and subsequent steps.
[0070] In some specific embodiments, Figure 5 The figure shows a flow chart of the data transmission unit storing and transmitting data. The data to be migrated sent by the data reading unit is obtained, and it is determined whether a queue has been created for the data migration task. If not, a new queue is created; if yes, an existing queue is obtained. The hash value is determined according to the data to be migrated, and the data to be migrated is appended to the end of the target storage queue, and the data to be migrated is persistently stored. The data writing unit is notified to obtain the data to be migrated. If the notification is successful, the process ends; if the notification fails, the notification is retried.
[0071] In some specific embodiments, Figure 6 The figure shows a flow chart of the data writing unit determining the writing progress. The data writing unit obtains the data to be migrated and obtains the latest location pointer information, i.e., the offset information. It is determined whether the offset has reached the latest location. If so, it means that the writing is completed and the process ends; if not, the corresponding data to be migrated is obtained and transmitted. It is determined whether the data writing unit has written successfully. If not, it retries to obtain the corresponding data to be migrated and transmits it; if so, it updates the location information and determines again whether the offset has reached the latest location.
[0072] In some specific embodiments, Figure 7The figure shows a flow chart of the data writing unit migrating data to the target data table. The data writing unit receives notification from the data transmission unit and pulls the data to be migrated from the data transmission unit. Determine whether it is custom data processing. If so, call the custom class to process the data and generate a write CQL statement; if not, determine whether to configure the mapping relationship. If so, process the data based on the mapping relationship and generate a write CQL statement; if not, do not further process the data to be migrated and generate a write CQL statement. After generating the write CQL statement, write the data to the target data table and end the process.
[0073] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0074] Based on the same inventive concept, the embodiment of the present application also provides a data migration device 1100 for implementing the data migration method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations of one or more data migration device 1100 embodiments provided below can refer to the limitations of the data migration method above, and will not be repeated here.
[0075] In one embodiment, Figure 8 As shown, a data migration device 1100 is provided, comprising: The data acquisition module 1101 is used to acquire the data to be migrated and the configuration information; The data storage module 1102 is used to determine a target storage queue according to the data to be migrated, and store the data to be migrated in the target storage queue; A field type determination module 1103 is used to read the data to be migrated in the target storage queue and determine the field type of the data to be migrated according to the configuration information; The data migration module 1104 is used to determine a migration method according to the field type, and migrate the data to be migrated to a target data table according to the migration method.
[0076] In some embodiments, the data acquisition module 1101 is further used to determine a data reading progress according to the data to be migrated; and continue to acquire the data to be migrated according to preset batch information and the data reading progress.
[0077] In some embodiments, the configuration information includes a concurrency number, and the data storage module 1102 is further used to generate a thread pool according to the concurrency number, and the number of core threads of the thread pool matches the concurrency number; and the data to be migrated is persistently stored in the thread pool.
[0078] In some embodiments, the data storage module 1102 is further configured to determine a queue identifier according to the data to be migrated; and determine the target storage queue according to the queue identifier.
[0079] In some embodiments, the data migration module 1104 is further configured to determine, if the field type includes counter, that the migration method includes an update statement; and migrate the data to be migrated to the target data table based on the update statement.
[0080] In some embodiments, the data migration module 1104 is also used to determine a first timestamp and a second timestamp of the data to be migrated if the field type includes a row field containing a survival time, the first timestamp including the time for acquiring the data to be migrated, and the second timestamp including the time for reading the data to be migrated in the target storage queue; determine the transmission time based on the first timestamp and the second timestamp, and if the transmission time is less than or equal to the survival time, migrate the data to be migrated to the target data table.
[0081] In some embodiments, the field type determination module 1103 is also used to determine the read position information of the target storage queue; determine the read progress of the target storage queue according to the read position information; if the read progress is incomplete, read the data to be migrated in the target storage queue.
[0082] In some embodiments, the data migration device 1100 also includes a data type conversion module 1105, and the data type conversion module 1105 is also used to determine whether the migration data table structure is the same as the target data table structure, and the migration data is used to store the data to be migrated; if they are not the same, the mapping relationship between the migration data table and the target data table is determined, and the data to be migrated is converted into a target data type according to the mapping relationship, and the target data type matches the target data table structure.
[0083] Each module in the above-mentioned data migration device 1100 can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.
[0084] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a data migration method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse, etc.
[0085] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0086] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the data migration method described in any of the above embodiments are implemented.
[0087] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the data migration method described in any of the above embodiments are implemented.
[0088] In one embodiment, a computer program product is provided, including a computer program, which implements the steps of the data migration method described in any of the above embodiments when executed by a processor.
[0089] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with general skills in the technical field to which this application belongs. The words "one", "a", "the", "these" and the like in this application do not indicate a quantitative limitation, and they may be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone. Generally, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0090] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0091] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0092] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0093] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data migration method, characterized in that: The method comprises: Get the data and configuration information to be migrated; Determine a target storage queue according to the data to be migrated, and store the data to be migrated into the target storage queue; Reading the data to be migrated in the target storage queue, and determining the field type of the data to be migrated according to the configuration information; A migration method is determined according to the field type, and the data to be migrated is migrated to a target data table according to the migration method.
2. The method according to claim 1, characterized in that Before determining the target storage queue according to the data to be migrated, the method further includes: Determining a data reading progress according to the data to be migrated; The data to be migrated continues to be acquired according to the preset batch information and the data reading progress.
3. The method according to claim 1, characterized in that The configuration information includes a concurrency number, and before determining a target storage queue according to the data to be migrated, further includes: Generate a thread pool according to the concurrent number, wherein the number of core threads in the thread pool matches the concurrent number; The data to be migrated is persistently stored in the thread pool.
4. The method according to claim 1, characterized in that: Determining a target storage queue according to the data to be migrated includes: Determine a queue identifier according to the data to be migrated; The target storage queue is determined according to the queue identifier.
5. The method according to claim 1, characterized in that Determining a migration mode according to the field type, and migrating the to-be-migrated data to a target data table according to the migration mode includes: If the field type includes counter, determining that the migration method includes an update statement; The data to be migrated is migrated to the target data table based on the update statement.
6. The method according to claim 1, characterized in that The determining the migration mode according to the field type and migrating the to-be-migrated data to the target data table according to the migration mode further comprises: If the field type includes a row field including a survival time, determining a first timestamp and a second timestamp of the data to be migrated, wherein the first timestamp includes a time when the data to be migrated is acquired, and the second timestamp includes a time when the data to be migrated in the target storage queue is read; A transmission time is determined based on the first timestamp and the second timestamp, and if the transmission time is less than or equal to the survival time, the data to be migrated is migrated to a target data table.
7. The method according to claim 1, characterized in that The reading the data to be migrated in the target storage queue comprises: Determining read position information of the target storage queue; Determining the reading progress of the target storage queue according to the reading position information; If the reading progress is incomplete, the data to be migrated in the target storage queue is read.
8. The method according to claim 1, characterized in that Before migrating the data to be migrated to the target data table according to the migration method, the method further includes: Determine whether a migration data table structure is the same as the target data table structure, the migration data being used to store the data to be migrated; If they are not the same, a mapping relationship between the migration data table and the target data table is determined, and the data to be migrated is converted into a target data type according to the mapping relationship, and the target data type matches the target data table structure.
9. A data migration system, characterized in that: The data migration system includes a migration data table, a data migration module and a target data table. The data migration module includes at least one data acquisition unit, a data transmission unit and at least one data writing unit. The at least one data acquisition unit interacts with the data transmission unit according to a first field mapping relationship or a first preset interface. The at least one data writing unit interacts with the data transmission unit according to a second field mapping relationship or a second preset interface. The data migration module is used to implement the steps of the data migration method according to any one of claims 1 to 8.
10. A data migration device, characterized in that: The device comprises: Data acquisition module, used to obtain data to be migrated and configuration information; A data storage module, used for determining a target storage queue according to the data to be migrated, and storing the data to be migrated in the target storage queue; A field type determination module, configured to read the data to be migrated in the target storage queue and determine the field type of the data to be migrated according to the configuration information; The data migration module is used to determine a migration method according to the field type, and migrate the data to be migrated to a target data table according to the migration method.
Citation Information
Patent Citations
System and method of data migration
CN102982085A
A method and apparatus for migrating data
CN109284281A
Cross-database data migration method and device
CN111258987A
Data migration method and device, electronic equipment and storage medium
CN115599769A
Method and apparatus for migration of a virtualized file system, data storage system for migration of a virtualized file system, and file server for use in a data storage system
EP2821914A1
