WO2020000725A1 - Electronic apparatus, data migration method, and storage medium - Google Patents
Electronic apparatus, data migration method, and storage medium Download PDFInfo
- Publication number
- WO2020000725A1 WO2020000725A1 PCT/CN2018/107702 CN2018107702W WO2020000725A1 WO 2020000725 A1 WO2020000725 A1 WO 2020000725A1 CN 2018107702 W CN2018107702 W CN 2018107702W WO 2020000725 A1 WO2020000725 A1 WO 2020000725A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data
- migration
- migrated
- primary key
- ciphertext
- Prior art date
- Legal status (The legal status 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 status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
Definitions
- the present application relates to the field of communication technologies, and in particular, to an electronic device, a method for data migration, and a storage medium.
- the purpose of this application is to provide an electronic device, a method for data migration, and a storage medium, which are intended to realize the rapid and efficient migration of data of a large number of levels.
- the present application provides an electronic device, the electronic device includes a memory and a processor connected to the memory, and the memory stores a processing system operable on the processor, and the processing When the system is executed by the processor, the following steps are implemented:
- the migration platform After receiving an instruction to migrate the data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the mapping between the original database and the target database Data configuration
- the data to be migrated is read in a multi-threaded manner according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML file data;
- the XML file data is parsed according to a predetermined parsing method, and the parsed XML file data is written to the target database in a manner asynchronous to reading the data to be migrated.
- the present application further provides a method for data migration, and the method for data migration includes:
- mapping data On the operation interface of the migration platform, after receiving an instruction to migrate the data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the original database and the target database are migrated. Configuration of mapping data;
- the present application also provides a computer-readable storage medium, where the computer-readable storage medium stores a processing system, and the processing system implements steps when executed by a processor:
- the migration platform After receiving an instruction to migrate the data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the mapping between the original database and the target database Data configuration
- the data to be migrated is read in a multi-threaded manner according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML file data;
- the XML file data is parsed according to a predetermined parsing method, and the parsed XML file data is written to the target database in a manner asynchronous to reading the data to be migrated.
- This application configures the migration parameters and the mapping data of the original database and the target database on the operation interface of the migration platform.
- migrating data according to the configured migration parameters and mapping data, and using multiple The threaded method reads the data to be migrated, uses XML files as intermediate storage, and controls multiple threads to read XML files, parse the XML files, and migrate the parsed data to the target database.
- This application is a platformized data migration method , Can provide TB-level data volume data migration services for business systems, quickly and efficiently migrate data from different databases and different data table structures.
- FIG. 1 is a schematic diagram of a hardware architecture of an embodiment of an electronic device of the present application
- FIG. 2 is a schematic flowchart of a first embodiment of a data migration method of this application
- FIG. 3 is a schematic flowchart of a second embodiment of a data migration method of this application.
- FIG. 1 is a schematic diagram of a hardware architecture of an electronic device according to an embodiment of the present application.
- the electronic device 1 is a device capable of automatically performing numerical calculation and / or information processing in accordance with an instruction set or stored in advance.
- the electronic device 1 may be a computer, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing.
- Cloud computing is a type of distributed computing.
- a super virtual computer consisting of a loosely coupled set of computers.
- the electronic device 1 may include, but is not limited to, a memory 11, a processor 12, and a network interface 13 that are communicably connected to each other through a system bus.
- the memory 11 stores a processing system that can run on the processor 12. It should be noted that FIG. 1 only shows the electronic device 1 with components 11-13, but it should be understood that it is not required to implement all the illustrated components, and more or fewer components may be implemented instead.
- the memory 11 includes a memory and at least one type of readable storage medium.
- the memory provides a cache for the operation of the electronic device 1;
- the readable storage medium may be, for example, a flash memory, a hard disk, a multimedia card, a card-type memory (for example, SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM) ), Read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disks, optical disks and other non-volatile storage media.
- the readable storage medium may be an internal storage unit of the electronic device 1, such as a hard disk of the electronic device 1.
- the non-volatile storage medium may also be external to the electronic device 1.
- the storage device is, for example, a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card (Flash card), etc. provided on the electronic device 1.
- the readable storage medium of the memory 11 is generally used to store an operating system and various types of application software installed in the electronic device 1, such as program code of a processing system in an embodiment of the present application.
- the memory 11 can also be used to temporarily store various types of data that have been output or are to be output.
- the processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or another data processing chip.
- the processor 12 is generally used to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication with other devices.
- the processor 12 is configured to run program code or process data stored in the memory 11, for example, to run a processing system.
- the network interface 13 may include a wireless network interface or a wired network interface.
- the network interface 13 is generally used to establish a communication connection between the electronic device 1 and other electronic devices.
- the processing system is stored in the memory 11 and includes at least one computer-readable instruction stored in the memory 11, which can be executed by the processor 12 to implement the methods of the embodiments of the present application; and
- the at least one computer-readable instruction may be divided into different logic modules according to different functions implemented by each part thereof.
- the migration platform After receiving an instruction to migrate the data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the mapping between the original database and the target database Data configuration
- the browser is used to log in to the migration platform.
- the data to be migrated may be data of different databases (for example, data migration between MYSQL-> ORACLE and SQLSERVER-> ORACLE), data of different table structures, or data of different data types.
- This embodiment may implement data of different databases. Migration of data, data of different table structures, or data of different data types.
- the migration parameters include: the database name of the original database and the target database, the server corresponding to the original database and the target database, the login account and login password corresponding to the original database and the target database, the data table name, the data table group, and the migration start time , The migration end time point, whether to support rollback, the number of threads (including a minimum of 1 thread, a maximum of 100 threads), and so on.
- the mapping data between the original database and the target database includes: the data table of the original database and the data table of the target database during migration, the fields of the two tables, the correspondence between the data types, and so on.
- configuration of scheduled migration, migration suspension, migration stop and rollback are provided on the operation interface, and scheduled migration can be performed, and during the migration process, migration suspension and migration can be performed. Stop and rollback operations.
- the data to be migrated is read in a multi-threaded manner according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML (Extentsible Markup Language) file data;
- XML Extentsible Markup Language
- This embodiment uses an XML file as an intermediate storage. After the configuration operation is completed, the multi-threaded method is used to read the data to be migrated in the original database according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML file data. .
- the data table of the original database is stored in the target data table in the target database after the XML file.
- One data table of the original database can correspond to multiple XML files.
- the XML file data includes various information of the target data table (for example, data Table name, field name, data type, initial value, etc.).
- a data table in the original database can use multiple threads to read the data to be migrated.
- the data table in the original database has 100 million data volumes. It will take a long time to migrate using one thread. Long, but using 100 threads for migration, the migration speed is increased by 100 times.
- the XML file data is parsed according to a predetermined parsing method, and the parsed XML file data is written to the target database in a manner asynchronous to reading the data to be migrated.
- the predetermined parsing method is a parsing method of the XML simple application program interface.
- the parsing method of the xml simple application program interface is suitable for parsing large XML file data. It parses the XML file data line by line.
- the target data table name, field name, data type, and initial value are parsed. Data that needs to be written to the target data table is stored in memory.
- the loop is parsed to a certain amount, such as 100 times, it will trigger once to submit the data recorded in memory and write the data to the target data table. .
- the operation of reading the data to be migrated in the original database and the operation of writing data to the target data table are asynchronously processed to achieve read / write separation and improve the efficiency of migration.
- this application configures the migration parameters and the mapping data of the original database and the target database on the operation interface of the migration platform.
- the threaded method reads the data to be migrated, uses XML files as intermediate storage, and controls multiple threads to read XML files, parse the XML files, and migrate the parsed data to the target database.
- This application is a platformized data migration method , Can provide business systems with terabytes of data migration services, quickly and efficiently migrate data from different databases and different data table structures.
- the first ciphertext is obtained by encrypting each single line of data in the original database to be migrated according to a predetermined encryption method, and each second line of data stored in the target database is encrypted according to the predetermined encryption method to obtain a second ciphertext.
- the predetermined encryption method is MD5 (Message-Digest Algorithm).
- This embodiment encrypts the data to be migrated in the original database in a row-by-row encryption method, encrypts the data in the target database in a row-by-row encryption method, and compares the first ciphertext with the corresponding second ciphertext. If the two are the same, the verification is passed, and the data corresponding to the second ciphertext is valid in the target database; if the two are not the same, the verification fails, and the data corresponding to the second ciphertext needs to be rolled back from the target data table Clear and remigrate the single line of data. In this way, on the basis of quickly and efficiently migrating large amounts of data, single-line data can be strictly verified to find data that has been wrongly migrated and ensure the accuracy of the migrated data.
- MD5 Message-Digest Algorithm
- a primary key identifier of data stored in the target database is obtained, and a second preset number of primary key identifiers are used as a group, and a second index file of data in the target database is generated based on the primary key identifiers of each group.
- the first preset number and the second preset number may be the same or different.
- the first preset number is the same as the second preset number, for example, the first preset number and the second preset number are 1000.
- a primary key is one or more fields in a data table.
- the primary key identifier is used to uniquely identify a record in the data table.
- the first preset number or the second preset number of primary keys are identified as a group (if the first preset number is not enough, they are filled with characters 0), and the first index file or the second is stored in a fixed-length format. Index files to disk files, each time the primary key data is fetched for processing.
- the first index file is used to record and locate the XML file corresponding to the data to be migrated. Under normal circumstances, because the amount of data to be migrated is very large, and the generated XML files are also very large, it is necessary to first read the first index file during migration, and locate it by the name of the first index file and the primary key data. Can quickly find XML files for migration.
- the second index file is used to identify the primary key of each piece of data in the target database in the target data table after the data to be migrated from the original database is written to the target database.
- the migration operation needs to be rolled back, the corresponding data in the target data table can be extracted through the second index file for cleaning.
- the first index file can quickly find the XML file and perform data migration
- the second index file can quickly extract the data to be rolled back in the target data table and clear it.
- FIG. 2 is a schematic flowchart of an embodiment of a data migration method of the present application.
- the data migration method includes the following steps:
- Step S1 On the operation interface of the migration platform, after receiving an instruction to migrate data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the original database and target Database mapping data for configuration;
- the browser is used to log in to the migration platform.
- the data to be migrated may be data of different databases (for example, data migration between MYSQL-> ORACLE and SQLSERVER-> ORACLE), data of different table structures, or data of different data types.
- This embodiment may implement data of different databases. Migration of data, data of different table structures, or data of different data types.
- the migration parameters include: the database name of the original database and the target database, the server corresponding to the original database and the target database, the login account and login password corresponding to the original database and the target database, the data table name, the data table group, and the migration start time , The migration end time point, whether to support rollback, the number of threads (including a minimum of 1 thread, a maximum of 100 threads), and so on.
- the mapping data between the original database and the target database includes: the data table of the original database and the data table of the target database during migration, the fields of the two tables, the correspondence between the data types, and so on.
- configuration of scheduled migration, migration suspension, migration stop and rollback are provided on the operation interface, and scheduled migration can be performed, and during the migration process, migration suspension and migration can be performed. Stop and rollback operations.
- Step S2 After the configuration operation is completed, read the data to be migrated in a multi-threaded manner according to the configured migration parameters and mapping data, and convert the data to be migrated into XML file data;
- This embodiment uses an XML file as intermediate storage. After the configuration operation is completed, the multi-threaded method is used to read the data to be migrated from the original database according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML file data .
- the data table of the original database is stored in the target data table in the target database after the XML file.
- One data table of the original database can correspond to multiple XML files.
- the XML file data includes various information of the target data table (for example, data Table name, field name, data type, initial value, etc.).
- a data table in the original database can use multiple threads to read the data to be migrated.
- the data table in the original database has 100 million data volumes. It will take a long time to migrate using one thread. Long, but using 100 threads for migration, the migration speed is increased by 100 times.
- step S3 multiple threads are used to obtain the XML file data, the XML file data is parsed according to a predetermined parsing method, and the parsed XML file data is written to the target database in a manner asynchronous to reading the data to be migrated. .
- the predetermined parsing method is a parsing method of the XML simple application program interface.
- the parsing method of the xml simple application program interface is suitable for parsing large XML file data. It parses the XML file data line by line.
- the target data table name, field name, data type, and initial value are parsed. Data that needs to be written to the target data table is stored in memory.
- the loop is parsed to a certain amount, such as 100 times, it will trigger once to submit the data recorded in memory and write the data to the target data table. .
- the operation of reading the data to be migrated in the original database and the operation of writing data to the target data table are asynchronously processed to achieve read / write separation and improve the efficiency of migration.
- this application configures the migration parameters and the mapping data of the original database and the target database on the operation interface of the migration platform.
- the threaded method reads the data to be migrated, uses XML files as intermediate storage, and controls multiple threads to read XML files, parse the XML files, and migrate the parsed data to the target database.
- This application is a platformized data migration method , Can provide TB-level data migration services for business systems, quickly and efficiently migrate data from different databases and different data table structures.
- step S3 the method further includes:
- Step S4 encrypting each single line of data in the original database to be migrated according to a predetermined encryption method to obtain a first ciphertext, and encrypting each single line of data stored in the target database according to the predetermined encryption method.
- Step S45 analyzing whether the first ciphertext is the same as the corresponding second ciphertext
- Step S5 If the first ciphertext and the corresponding second ciphertext are respectively the same, the verification is passed, and the data corresponding to the second ciphertext is valid data in the target database;
- step S6 if the first ciphertext is different from the corresponding second ciphertext, a single line of data corresponding to the second ciphertext is rolled back and cleared to re-migrate the single line of data.
- the predetermined encryption method is MD5 (Message-Digest Algorithm).
- This embodiment encrypts the data to be migrated in the original database in a row-by-row encryption method, encrypts the data in the target database in a row-by-row encryption method, and compares the first ciphertext with the corresponding second ciphertext. If the two are the same, the verification is passed. The data corresponding to the second ciphertext is valid data in the target data. If the two are not the same, the verification fails. The data corresponding to the second ciphertext needs to be returned from the target data table. Roll clear, re-migrate the single line of data. In this way, on the basis of quickly and efficiently migrating large amounts of data, single-line data can be strictly verified to find data that has been wrongly migrated and ensure the accuracy of the migrated data.
- MD5 Message-Digest Algorithm
- the method further includes: obtaining a primary key identifier of the data to be migrated, using a first preset number of primary key identifiers as a group, and based on each group of primary keys. Identifying a first index file that generates the data to be migrated;
- the method further includes: obtaining a primary key identifier of the data stored in the target database, using a second preset number of primary key identifiers as a group, and generating a second index file of data in the target database based on the primary key identifiers of each group.
- the first preset number and the second preset number may be the same or different.
- the first preset number is the same as the second preset number, for example, the first preset number and the second preset number are 1000.
- a primary key is one or more fields in a data table.
- the primary key identifier is used to uniquely identify a record in the data table.
- the first preset number or the second preset number of primary keys are identified as a group (if the first preset number is not enough, they are filled with characters 0), and the first index file or the second is stored in a fixed-length format. Index files to disk files, each time the primary key data is fetched for processing.
- the first index file is used to record and locate the XML file corresponding to the data to be migrated. Under normal circumstances, because the amount of data to be migrated is very large, and the generated XML files are also very large, it is necessary to first read the first index file during migration, and locate it by the name of the first index file and the primary key data. Can quickly find XML files for migration.
- the second index file is used to identify the primary key of each piece of data in the target database in the target data table after the data to be migrated from the original database is written to the target database.
- the migration operation needs to be rolled back, the corresponding data in the target data table can be extracted through the second index file for cleaning.
- the first index file can quickly find the XML file and perform data migration
- the second index file can quickly extract the data to be rolled back in the target data table and clear it.
- the present application also provides a computer-readable storage medium on which a processing system is stored.
- a processing system is executed by a processor, the steps of the foregoing method for data migration are implemented.
- the methods in the above embodiments can be implemented by means of software plus a necessary universal hardware platform, and of course, also by hardware, but in many cases the former is better.
- Implementation Based on such an understanding, the technical solution of this application that is essentially or contributes to the existing technology can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, The optical disc) includes several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in the embodiments of the present application.
- a terminal device which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
优先权申明Declaration of priority
本申请基于巴黎公约申明享有2018年06月29日递交的申请号为CN201810694928.2、名称为“电子装置、数据迁移的方法及存储介质”中国专利申请的优先权,该中国专利申请的整体内容以参考的方式结合在本申请中。This application is based on the Paris Convention and claims the priority of a Chinese patent application filed on June 29, 2018 with an application number of CN201810694928.2, entitled "Electronic Device, Method of Data Migration and Storage Medium", the entire content of the Chinese patent application This application is incorporated by reference.
本申请涉及通信技术领域,尤其涉及一种电子装置、数据迁移的方法及存储介质。The present application relates to the field of communication technologies, and in particular, to an electronic device, a method for data migration, and a storage medium.
目前,在数据量较大(例如,100GB以上)的数据迁移技术中,例如,新旧数据库系统之间的数据迁移,现有的解决方案为由数据库工作人员主导,由开发人员协助,使用数据库层面的方式进行数据迁移。这种方式一般需要较长的时间才能完成数据的迁移,甚至出现无法实现迁移的情况。有鉴于此,在数据量较大时,需要一种快速而高效的数据迁移的解决方案。At present, in the data migration technology with a large amount of data (for example, more than 100GB), for example, data migration between old and new database systems, the existing solution is led by database staff, assisted by developers, and uses the database level Way for data migration. This method generally takes a long time to complete the data migration, and even the situation where migration cannot be achieved occurs. In view of this, when the amount of data is large, a fast and efficient data migration solution is needed.
发明内容Summary of the invention
本申请的目的在于提供一种电子装置、数据迁移的方法及存储介质,旨在实现快速、高效地迁移较大数量级别的数据。The purpose of this application is to provide an electronic device, a method for data migration, and a storage medium, which are intended to realize the rapid and efficient migration of data of a large number of levels.
为实现上述目的,本申请提供一种电子装置,所述电子装置包括存储器及与所述存储器连接的处理器,所述存储器中存储有可在所述处理器上运行的处理系统,所述处理系统被所述处理器执行时实现如下步骤:To achieve the above object, the present application provides an electronic device, the electronic device includes a memory and a processor connected to the memory, and the memory stores a processing system operable on the processor, and the processing When the system is executed by the processor, the following steps are implemented:
在迁移平台的操作界面上,当接收到对一个或多个业务系统的原数据库的待迁移数据进行迁移的指令后,基于该指令对本次迁移的迁移参数以及该 原数据库与目标数据库的映射数据进行配置;On the operation interface of the migration platform, after receiving an instruction to migrate the data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the mapping between the original database and the target database Data configuration
当完成配置操作后,根据所配置的迁移参数及映射数据并利用多线程的方式读取该待迁移数据,并将待迁移数据转换为XML文件数据;After the configuration operation is completed, the data to be migrated is read in a multi-threaded manner according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML file data;
采用多个线程获取该XML文件数据,按照预定的解析方式对该XML文件数据进行解析,并采用与读取该待迁移数据异步的方式将解析后的XML文件数据写入目标数据库中。Multiple threads are used to obtain the XML file data, the XML file data is parsed according to a predetermined parsing method, and the parsed XML file data is written to the target database in a manner asynchronous to reading the data to be migrated.
为实现上述目的,本申请还提供一种数据迁移的方法,所述数据迁移的方法包括:To achieve the above object, the present application further provides a method for data migration, and the method for data migration includes:
S1,在迁移平台的操作界面上,当接收到对一个或多个业务系统的原数据库的待迁移数据进行迁移的指令后,基于该指令对本次迁移的迁移参数以及该原数据库与目标数据库的映射数据进行配置;S1. On the operation interface of the migration platform, after receiving an instruction to migrate the data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the original database and the target database are migrated. Configuration of mapping data;
S2,当完成配置操作后,根据所配置的迁移参数及映射数据并利用多线程的方式读取该待迁移数据,并将待迁移数据转换为XML文件数据;S2. After completing the configuration operation, read the data to be migrated in a multi-threaded manner according to the configured migration parameters and mapping data, and convert the data to be migrated into XML file data;
S3,采用多个线程获取该XML文件数据,按照预定的解析方式对该XML文件数据进行解析,并采用与读取该待迁移数据异步的方式将解析后的XML文件数据写入目标数据库中。S3. Use multiple threads to obtain the XML file data, parse the XML file data according to a predetermined parsing method, and write the parsed XML file data to the target database in a manner asynchronous to reading the data to be migrated.
本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有处理系统,所述处理系统被处理器执行时实现步骤:The present application also provides a computer-readable storage medium, where the computer-readable storage medium stores a processing system, and the processing system implements steps when executed by a processor:
在迁移平台的操作界面上,当接收到对一个或多个业务系统的原数据库的待迁移数据进行迁移的指令后,基于该指令对本次迁移的迁移参数以及该原数据库与目标数据库的映射数据进行配置;On the operation interface of the migration platform, after receiving an instruction to migrate the data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the mapping between the original database and the target database Data configuration
当完成配置操作后,根据所配置的迁移参数及映射数据并利用多线程的方式读取该待迁移数据,并将待迁移数据转换为XML文件数据;After the configuration operation is completed, the data to be migrated is read in a multi-threaded manner according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML file data;
采用多个线程获取该XML文件数据,按照预定的解析方式对该XML文件数据进行解析,并采用与读取该待迁移数据异步的方式将解析后的XML文件 数据写入目标数据库中。Multiple threads are used to obtain the XML file data, the XML file data is parsed according to a predetermined parsing method, and the parsed XML file data is written to the target database in a manner asynchronous to reading the data to be migrated.
本申请的有益效果是:本申请在迁移平台的操作界面上,将迁移参数以及该原数据库与目标数据库的映射数据进行配置,在迁移数据时,根据配置的迁移参数及映射数据,并利用多线程的方式读取待迁移数据,采用XML文件作为中间存储,控制多线程读取XML文件,解析XML文件,将解析后得到的数据迁移至目标数据库中,本申请为平台化的数据迁移的方式,能够为业务系统提供TB级数据量的数据迁移服务,快速、高效地迁移不同数据库及不同数据表结构的数据。The beneficial effect of this application is: This application configures the migration parameters and the mapping data of the original database and the target database on the operation interface of the migration platform. When migrating data, according to the configured migration parameters and mapping data, and using multiple The threaded method reads the data to be migrated, uses XML files as intermediate storage, and controls multiple threads to read XML files, parse the XML files, and migrate the parsed data to the target database. This application is a platformized data migration method , Can provide TB-level data volume data migration services for business systems, quickly and efficiently migrate data from different databases and different data table structures.
图1为本申请电子装置一实施例的硬件架构的示意图;FIG. 1 is a schematic diagram of a hardware architecture of an embodiment of an electronic device of the present application;
图2为本申请数据迁移的方法第一实施例的流程示意图;2 is a schematic flowchart of a first embodiment of a data migration method of this application;
图3为本申请数据迁移的方法第二实施例的流程示意图。FIG. 3 is a schematic flowchart of a second embodiment of a data migration method of this application.
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solution, and advantages of the present application clearer, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the application, and are not used to limit the application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
需要说明的是,在本申请中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛 盾或无法实现时应当认为这种技术方案的结合不存在,也不在本申请要求的保护范围之内。It should be noted that the descriptions related to "first", "second", etc. in this application are for descriptive purposes only, and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated . Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but must be based on those that can be realized by a person of ordinary skill in the art. When the combination of technical solutions conflicts or cannot be achieved, such a combination of technical solutions should be considered non-existent. Is not within the scope of protection claimed in this application.
参阅图1所示,是本申请电子装置一实施例的硬件架构的示意图。电子装置1是一种能够按照事先设定或者存储的指令,自动进行数值计算和/或信息处理的设备。所述电子装置1可以是计算机、也可以是单个网络服务器、多个网络服务器组成的服务器组或者基于云计算的由大量主机或者网络服务器构成的云,其中云计算是分布式计算的一种,由一群松散耦合的计算机集组成的一个超级虚拟计算机。FIG. 1 is a schematic diagram of a hardware architecture of an electronic device according to an embodiment of the present application. The electronic device 1 is a device capable of automatically performing numerical calculation and / or information processing in accordance with an instruction set or stored in advance. The electronic device 1 may be a computer, a single network server, a server group composed of multiple network servers, or a cloud composed of a large number of hosts or network servers based on cloud computing. Cloud computing is a type of distributed computing. A super virtual computer consisting of a loosely coupled set of computers.
在本实施例中,电子装置1可包括,但不仅限于,可通过系统总线相互通信连接的存储器11、处理器12、网络接口13,存储器11存储有可在处理器12上运行的处理系统。需要指出的是,图1仅示出了具有组件11-13的电子装置1,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。In this embodiment, the electronic device 1 may include, but is not limited to, a memory 11, a processor 12, and a network interface 13 that are communicably connected to each other through a system bus. The memory 11 stores a processing system that can run on the processor 12. It should be noted that FIG. 1 only shows the electronic device 1 with components 11-13, but it should be understood that it is not required to implement all the illustrated components, and more or fewer components may be implemented instead.
其中,存储器11包括内存及至少一种类型的可读存储介质。内存为电子装置1的运行提供缓存;可读存储介质可为如闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、随机访问存储器(RAM)、静态随机访问存储器(SRAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、可编程只读存储器(PROM)、磁性存储器、磁盘、光盘等的非易失性存储介质。在一些实施例中,可读存储介质可以是电子装置1的内部存储单元,例如该电子装置1的硬盘;在另一些实施例中,该非易失性存储介质也可以是电子装置1的外部存储设备,例如电子装置1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。本实施例中,存储器11的可读存储介质通常用于存储安装于电子装置1的操作系统和各类应用软件,例如本申请一实施例中的处理系统的程序代码等。此外,存储器11还可以用于暂时地存储已 经输出或者将要输出的各类数据。The memory 11 includes a memory and at least one type of readable storage medium. The memory provides a cache for the operation of the electronic device 1; the readable storage medium may be, for example, a flash memory, a hard disk, a multimedia card, a card-type memory (for example, SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM) ), Read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disks, optical disks and other non-volatile storage media. In some embodiments, the readable storage medium may be an internal storage unit of the electronic device 1, such as a hard disk of the electronic device 1. In other embodiments, the non-volatile storage medium may also be external to the electronic device 1. The storage device is, for example, a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card (Flash card), etc. provided on the electronic device 1. In this embodiment, the readable storage medium of the memory 11 is generally used to store an operating system and various types of application software installed in the electronic device 1, such as program code of a processing system in an embodiment of the present application. In addition, the memory 11 can also be used to temporarily store various types of data that have been output or are to be output.
所述处理器12在一些实施例中可以是中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器、或其他数据处理芯片。该处理器12通常用于控制所述电子装置1的总体操作,例如执行与其他设备进行数据交互或者通信相关的控制和处理等。本实施例中,所述处理器12用于运行所述存储器11中存储的程序代码或者处理数据,例如运行处理系统等。In some embodiments, the processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or another data processing chip. The processor 12 is generally used to control the overall operation of the electronic device 1, such as performing control and processing related to data interaction or communication with other devices. In this embodiment, the processor 12 is configured to run program code or process data stored in the memory 11, for example, to run a processing system.
所述网络接口13可包括无线网络接口或有线网络接口,该网络接口13通常用于在所述电子装置1与其他电子设备之间建立通信连接。The network interface 13 may include a wireless network interface or a wired network interface. The network interface 13 is generally used to establish a communication connection between the electronic device 1 and other electronic devices.
所述处理系统存储在存储器11中,包括至少一个存储在存储器11中的计算机可读指令,该至少一个计算机可读指令可被处理器器12执行,以实现本申请各实施例的方法;以及,该至少一个计算机可读指令依据其各部分所实现的功能不同,可被划为不同的逻辑模块。The processing system is stored in the memory 11 and includes at least one computer-readable instruction stored in the memory 11, which can be executed by the processor 12 to implement the methods of the embodiments of the present application; and The at least one computer-readable instruction may be divided into different logic modules according to different functions implemented by each part thereof.
在一实施例中,上述处理系统被所述处理器12执行时实现如下步骤:In an embodiment, when the processing system is executed by the processor 12, the following steps are implemented:
在迁移平台的操作界面上,当接收到对一个或多个业务系统的原数据库的待迁移数据进行迁移的指令后,基于该指令对本次迁移的迁移参数以及该原数据库与目标数据库的映射数据进行配置;On the operation interface of the migration platform, after receiving an instruction to migrate the data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the mapping between the original database and the target database Data configuration
本实施例中,通过访问浏览器登录迁移平台,在迁移平台的操作界面上,可以选择对一个或多个业务系统的原数据库的数据进行迁移。In this embodiment, the browser is used to log in to the migration platform. On the operation interface of the migration platform, you can choose to migrate the data of the original database of one or more business systems.
其中,待迁移数据可以是不同数据库的数据(例如:MYSQL->ORACLE,SQLSERVER->ORACLE之间的数据迁移)、不同表结构的数据或不同数据类型的数据,本实施例可实现不同数据库的数据、不同表结构的数据或不同数据类型的数据的迁移。The data to be migrated may be data of different databases (for example, data migration between MYSQL-> ORACLE and SQLSERVER-> ORACLE), data of different table structures, or data of different data types. This embodiment may implement data of different databases. Migration of data, data of different table structures, or data of different data types.
其中,迁移参数包括:原数据库与目标数据库的数据库名、原数据库与目标数据库对应的服务器、原数据库与目标数据库对应的登录帐号及登录密码、数据表名、数据表属组、迁移开始时间点、迁移结束时间点、是否支持 回滚、线程数量(其中,最小1个线程,最大100个线程)等。原数据库与目标数据库的映射数据包括:原数据库的数据表及目标数据库的数据表在迁移时两表的字段、数据类型的对应关系等。Among them, the migration parameters include: the database name of the original database and the target database, the server corresponding to the original database and the target database, the login account and login password corresponding to the original database and the target database, the data table name, the data table group, and the migration start time , The migration end time point, whether to support rollback, the number of threads (including a minimum of 1 thread, a maximum of 100 threads), and so on. The mapping data between the original database and the target database includes: the data table of the original database and the data table of the target database during migration, the fields of the two tables, the correspondence between the data types, and so on.
进一步地,为了实现大数据量迁移的灵活性,在该操作界面上提供定时迁移、迁移暂停、迁移停止及回滚的配置,可以执行定时迁移,并在迁移过程中,可以执行迁移暂停、迁移停止及回滚的操作。Further, in order to realize the flexibility of large data migration, configuration of scheduled migration, migration suspension, migration stop and rollback are provided on the operation interface, and scheduled migration can be performed, and during the migration process, migration suspension and migration can be performed. Stop and rollback operations.
当完成配置操作后,根据所配置的迁移参数及映射数据并利用多线程的方式读取该待迁移数据,并将待迁移数据转换为XML(Extentsible Markup Language,可扩展标记语言)文件数据;After the configuration operation is completed, the data to be migrated is read in a multi-threaded manner according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML (Extentsible Markup Language) file data;
本实施例利用XML文件作为中间存储,在完成配置操作后,利用多线程的方式并根据所配置的迁移参数及映射数据读取原数据库中的待迁移数据,将待迁移数据转换为XML文件数据。This embodiment uses an XML file as an intermediate storage. After the configuration operation is completed, the multi-threaded method is used to read the data to be migrated in the original database according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML file data. .
其中,原数据库的数据表经XML文件后存储至目标数据库中的目标数据表中,原数据库的一个数据表可对应多个XML文件,XML文件数据包括目标数据表的各项信息(例如,数据表名、字段名、数据类型、初始值等)。为了快速完成数据的迁移,原数据库的一个数据表可以使用多个线程来读取待迁移数据,例如,原数据库的数据表中有1亿的数据量,如果使用1个线程迁移耗时会很长,但使用100个线程进行迁移,则迁移速度提升100倍。Wherein, the data table of the original database is stored in the target data table in the target database after the XML file. One data table of the original database can correspond to multiple XML files. The XML file data includes various information of the target data table (for example, data Table name, field name, data type, initial value, etc.). In order to complete the data migration quickly, a data table in the original database can use multiple threads to read the data to be migrated. For example, the data table in the original database has 100 million data volumes. It will take a long time to migrate using one thread. Long, but using 100 threads for migration, the migration speed is increased by 100 times.
采用多个线程获取该XML文件数据,按照预定的解析方式对该XML文件数据进行解析,并采用与读取该待迁移数据异步的方式将解析后的XML文件数据写入目标数据库中。Multiple threads are used to obtain the XML file data, the XML file data is parsed according to a predetermined parsing method, and the parsed XML file data is written to the target database in a manner asynchronous to reading the data to be migrated.
其中,采用多个线程获取XML文件数据,以便快速进行数据迁移。预定的解析方式为xml简单应用程序接口的解析方式。具体地,xml简单应用程序接口的解析方式适用于解析大型的XML文件数据,其对XML文件数据进行逐行解析,解析XML文件数据时,将目标数据表名称、字段名、数据类型、 初始值等需要写入目标数据表的数据记录在内存中,每当循环解析到一定数量时,例如100次时,会触发一次将记录在内存中的数据进行提交,将数据写入到目标数据表中。Among them, multiple threads are used to obtain the XML file data for rapid data migration. The predetermined parsing method is a parsing method of the XML simple application program interface. Specifically, the parsing method of the xml simple application program interface is suitable for parsing large XML file data. It parses the XML file data line by line. When parsing the XML file data, the target data table name, field name, data type, and initial value are parsed. Data that needs to be written to the target data table is stored in memory. When the loop is parsed to a certain amount, such as 100 times, it will trigger once to submit the data recorded in memory and write the data to the target data table. .
其中,读取原数据库中的待迁移数据的操作和写入数据至目标数据表的操作为异步处理,实现读/写分离,提高了迁移的效率。Among them, the operation of reading the data to be migrated in the original database and the operation of writing data to the target data table are asynchronously processed to achieve read / write separation and improve the efficiency of migration.
与现有技术相比,本申请在迁移平台的操作界面上,将迁移参数以及该原数据库与目标数据库的映射数据进行配置,在迁移数据时,根据配置的迁移参数及映射数据,并利用多线程的方式读取待迁移数据,采用XML文件作为中间存储,控制多线程读取XML文件,解析XML文件,将解析后得到的数据迁移至目标数据库中,本申请为平台化的数据迁移的方式,能够为业务系统提供TB级数据量的数据迁移服务,快速、高效地迁移不同数据库、不同数据表结构的数据。Compared with the prior art, this application configures the migration parameters and the mapping data of the original database and the target database on the operation interface of the migration platform. When migrating the data, according to the configured migration parameters and mapping data, and using multiple The threaded method reads the data to be migrated, uses XML files as intermediate storage, and controls multiple threads to read XML files, parse the XML files, and migrate the parsed data to the target database. This application is a platformized data migration method , Can provide business systems with terabytes of data migration services, quickly and efficiently migrate data from different databases and different data table structures.
在一优选的实施例中,在上述实施例的基础上,所述处理系统被所述处理器执行时,还实现如下步骤:In a preferred embodiment, based on the above embodiment, when the processing system is executed by the processor, the following steps are further implemented:
按照预定的加密方式将原数据库的待迁移数据中每一单行数据进行加密后得到第一密文,按照该预定的加密方式将存储在该目标数据库中的每一单行数据进行加密后得到第二密文;The first ciphertext is obtained by encrypting each single line of data in the original database to be migrated according to a predetermined encryption method, and each second line of data stored in the target database is encrypted according to the predetermined encryption method to obtain a second ciphertext. Cipher text
若该第一密文与对应的第二密文分别相同,则验证通过;If the first ciphertext and the corresponding second ciphertext are respectively the same, the verification is passed;
若有该第一密文与对应的第二密文不相同,将该第二密文对应的单行数据进行回滚清除,以重新迁移该单行数据。If there is a difference between the first ciphertext and the corresponding second ciphertext, a single line of data corresponding to the second ciphertext is rolled back and cleared to re-migrate the single line of data.
其中,预定的加密方式为MD5(Message-Digest Algorithm 5,信息-摘要算法)。本实施例将原数据库的待迁移数据按照逐行加密的方式进行加密,将目标数据库中的数据按照逐行加密的方式进行加密,将第一密文与对应的第二密文进行对比,如果两者相同,则验证通过,该第二密文对应的数据在目标数据库中是有效的;如果两者不相同,则验证失败,该第二密文对应的 数据需要从目标数据表中回滚清除,重新迁移该单行数据。通过这种方式,在快速、高效地迁移大数据量的数据的基础上,还能够进行单行数据严格的验证,以发现迁移过程出错的数据,确保迁移的数据的准确性。Among them, the predetermined encryption method is MD5 (Message-Digest Algorithm). This embodiment encrypts the data to be migrated in the original database in a row-by-row encryption method, encrypts the data in the target database in a row-by-row encryption method, and compares the first ciphertext with the corresponding second ciphertext. If the two are the same, the verification is passed, and the data corresponding to the second ciphertext is valid in the target database; if the two are not the same, the verification fails, and the data corresponding to the second ciphertext needs to be rolled back from the target data table Clear and remigrate the single line of data. In this way, on the basis of quickly and efficiently migrating large amounts of data, single-line data can be strictly verified to find data that has been wrongly migrated and ensure the accuracy of the migrated data.
在一优选的实施例中,在上述实施例的基础上,所述处理系统被所述处理器执行时,还实现如下步骤:In a preferred embodiment, based on the above embodiment, when the processing system is executed by the processor, the following steps are further implemented:
获取该待迁移数据的主键标识,以第一预设数量的主键标识为一组,基于各组主键标识生成该待迁移数据的第一索引文件;Obtaining a primary key identifier of the data to be migrated, using the first preset number of primary key identifiers as a group, and generating a first index file of the data to be migrated based on each group of primary key identifiers;
获取存储在目标数据库中的数据的主键标识,以第二预设数量的主键标识为一组,基于各组主键标识生成目标数据库中的数据的第二索引文件。A primary key identifier of data stored in the target database is obtained, and a second preset number of primary key identifiers are used as a group, and a second index file of data in the target database is generated based on the primary key identifiers of each group.
其中,第一预设数量与第二预设数量可以相同或者不同,优选地,第一预设数量与第二预设数量相同,例如,第一预设数量与第二预设数量为1000。主键是数据表中的一个或多个字段,主键标识用于唯一标识数据表中的某一条记录。本实施例以第一预设数量或第二预设数量的主键标识为一组(如果不够第一预设数量则以字符0补齐),以定长的格式存放第一索引文件或第二索引文件至磁盘文件中,每次按组取出主键数据进行处理。The first preset number and the second preset number may be the same or different. Preferably, the first preset number is the same as the second preset number, for example, the first preset number and the second preset number are 1000. A primary key is one or more fields in a data table. The primary key identifier is used to uniquely identify a record in the data table. In this embodiment, the first preset number or the second preset number of primary keys are identified as a group (if the first preset number is not enough, they are filled with characters 0), and the first index file or the second is stored in a fixed-length format. Index files to disk files, each time the primary key data is fetched for processing.
其中,第一索引文件用于记录定位待迁移数据对应存放的XML文件。通常情况下,由于待迁移数据的数据量都非常大,其所生成的XML文件也非常多,所以迁移时需要先读取第一索引文件,通过第一索引文件的名称及主键数据进行定位,才能快速找到XML文件进行迁移。The first index file is used to record and locate the XML file corresponding to the data to be migrated. Under normal circumstances, because the amount of data to be migrated is very large, and the generated XML files are also very large, it is necessary to first read the first index file during migration, and locate it by the name of the first index file and the primary key data. Can quickly find XML files for migration.
第二索引文件,用于在将原数据库的待迁移数据写入目标数据库后,目标数据库中的每条数据在目标数据表中的主键标识。当迁移操作需要回滚时,可以通过该第二索引文件提取出目标数据表中对应的数据进行清除。The second index file is used to identify the primary key of each piece of data in the target database in the target data table after the data to be migrated from the original database is written to the target database. When the migration operation needs to be rolled back, the corresponding data in the target data table can be extracted through the second index file for cleaning.
通过上面的描述可以看出,本实施例通过第一索引文件能够快速找到XML文件并进行数据的迁移,通过第二索引文件能够快速提取目标数据表中需要回滚的数据并进行清除。As can be seen from the above description, in this embodiment, the first index file can quickly find the XML file and perform data migration, and the second index file can quickly extract the data to be rolled back in the target data table and clear it.
如图2所示,图2为本申请数据迁移的方法一实施例的流程示意图,该数据迁移的方法包括以下步骤:As shown in FIG. 2, FIG. 2 is a schematic flowchart of an embodiment of a data migration method of the present application. The data migration method includes the following steps:
步骤S1,在迁移平台的操作界面上,当接收到对一个或多个业务系统的原数据库的待迁移数据进行迁移的指令后,基于该指令对本次迁移的迁移参数以及该原数据库与目标数据库的映射数据进行配置;Step S1: On the operation interface of the migration platform, after receiving an instruction to migrate data to be migrated from the original database of one or more business systems, based on the instruction, the migration parameters of the current migration and the original database and target Database mapping data for configuration;
本实施例中,通过访问浏览器登录迁移平台,在迁移平台的操作界面上,可以选择对一个或多个业务系统的原数据库的数据进行迁移。In this embodiment, the browser is used to log in to the migration platform. On the operation interface of the migration platform, you can choose to migrate the data of the original database of one or more business systems.
其中,待迁移数据可以是不同数据库的数据(例如:MYSQL->ORACLE,SQLSERVER->ORACLE之间的数据迁移)、不同表结构的数据或不同数据类型的数据,本实施例可实现不同数据库的数据、不同表结构的数据或不同数据类型的数据的迁移。The data to be migrated may be data of different databases (for example, data migration between MYSQL-> ORACLE and SQLSERVER-> ORACLE), data of different table structures, or data of different data types. This embodiment may implement data of different databases. Migration of data, data of different table structures, or data of different data types.
其中,迁移参数包括:原数据库与目标数据库的数据库名、原数据库与目标数据库对应的服务器、原数据库与目标数据库对应的登录帐号及登录密码、数据表名、数据表属组、迁移开始时间点、迁移结束时间点、是否支持回滚、线程数量(其中,最小1个线程,最大100个线程)等。原数据库与目标数据库的映射数据包括:原数据库的数据表及目标数据库的数据表在迁移时两表的字段、数据类型的对应关系等。Among them, the migration parameters include: the database name of the original database and the target database, the server corresponding to the original database and the target database, the login account and login password corresponding to the original database and the target database, the data table name, the data table group, and the migration start time , The migration end time point, whether to support rollback, the number of threads (including a minimum of 1 thread, a maximum of 100 threads), and so on. The mapping data between the original database and the target database includes: the data table of the original database and the data table of the target database during migration, the fields of the two tables, the correspondence between the data types, and so on.
进一步地,为了实现大数据量迁移的灵活性,在该操作界面上提供定时迁移、迁移暂停、迁移停止及回滚的配置,可以执行定时迁移,并在迁移过程中,可以执行迁移暂停、迁移停止及回滚的操作。Further, in order to realize the flexibility of large data migration, configuration of scheduled migration, migration suspension, migration stop and rollback are provided on the operation interface, and scheduled migration can be performed, and during the migration process, migration suspension and migration can be performed. Stop and rollback operations.
步骤S2,当完成配置操作后,根据所配置的迁移参数及映射数据并利用多线程的方式读取该待迁移数据,并将待迁移数据转换为XML文件数据;Step S2: After the configuration operation is completed, read the data to be migrated in a multi-threaded manner according to the configured migration parameters and mapping data, and convert the data to be migrated into XML file data;
本实施例利用XML文件作为中间存储,在完成配置操作后,利用多线程的方式并根据所配置的迁移参数及映射数据读取原数据库中的待迁移数据, 将待迁移数据转换为XML文件数据。This embodiment uses an XML file as intermediate storage. After the configuration operation is completed, the multi-threaded method is used to read the data to be migrated from the original database according to the configured migration parameters and mapping data, and the data to be migrated is converted into XML file data .
其中,原数据库的数据表经XML文件后存储至目标数据库中的目标数据表中,原数据库的一个数据表可对应多个XML文件,XML文件数据包括目标数据表的各项信息(例如,数据表名、字段名、数据类型、初始值等)。为了快速完成数据的迁移,原数据库的一个数据表可以使用多个线程来读取待迁移数据,例如,原数据库的数据表中有1亿的数据量,如果使用1个线程迁移耗时会很长,但使用100个线程进行迁移,则迁移速度提升100倍。Wherein, the data table of the original database is stored in the target data table in the target database after the XML file. One data table of the original database can correspond to multiple XML files. The XML file data includes various information of the target data table (for example, data Table name, field name, data type, initial value, etc.). In order to complete the data migration quickly, a data table in the original database can use multiple threads to read the data to be migrated. For example, the data table in the original database has 100 million data volumes. It will take a long time to migrate using one thread. Long, but using 100 threads for migration, the migration speed is increased by 100 times.
步骤S3,采用多个线程获取该XML文件数据,按照预定的解析方式对该XML文件数据进行解析,并采用与读取该待迁移数据异步的方式将解析后的XML文件数据写入目标数据库中。In step S3, multiple threads are used to obtain the XML file data, the XML file data is parsed according to a predetermined parsing method, and the parsed XML file data is written to the target database in a manner asynchronous to reading the data to be migrated. .
其中,采用多个线程获取XML文件数据,以便快速进行数据迁移。预定的解析方式为xml简单应用程序接口的解析方式。具体地,xml简单应用程序接口的解析方式适用于解析大型的XML文件数据,其对XML文件数据进行逐行解析,解析XML文件数据时,将目标数据表名称、字段名、数据类型、初始值等需要写入目标数据表的数据记录在内存中,每当循环解析到一定数量时,例如100次时,会触发一次将记录在内存中的数据进行提交,将数据写入到目标数据表中。Among them, multiple threads are used to obtain the XML file data for rapid data migration. The predetermined parsing method is a parsing method of the XML simple application program interface. Specifically, the parsing method of the xml simple application program interface is suitable for parsing large XML file data. It parses the XML file data line by line. When parsing the XML file data, the target data table name, field name, data type, and initial value are parsed. Data that needs to be written to the target data table is stored in memory. When the loop is parsed to a certain amount, such as 100 times, it will trigger once to submit the data recorded in memory and write the data to the target data table. .
其中,读取原数据库中的待迁移数据的操作和写入数据至目标数据表的操作为异步处理,实现读/写分离,提高了迁移的效率。Among them, the operation of reading the data to be migrated in the original database and the operation of writing data to the target data table are asynchronously processed to achieve read / write separation and improve the efficiency of migration.
与现有技术相比,本申请在迁移平台的操作界面上,将迁移参数以及该原数据库与目标数据库的映射数据进行配置,在迁移数据时,根据配置的迁移参数及映射数据,并利用多线程的方式读取待迁移数据,采用XML文件作为中间存储,控制多线程读取XML文件,解析XML文件,将解析后得到的数据迁移至目标数据库中,本申请为平台化的数据迁移的方式,能够为业务系统提供TB级数据量的数据迁移服务,快速、高效地迁移不同数据库、 不同数据表结构的数据。Compared with the prior art, this application configures the migration parameters and the mapping data of the original database and the target database on the operation interface of the migration platform. When migrating the data, according to the configured migration parameters and mapping data, and using multiple The threaded method reads the data to be migrated, uses XML files as intermediate storage, and controls multiple threads to read XML files, parse the XML files, and migrate the parsed data to the target database. This application is a platformized data migration method , Can provide TB-level data migration services for business systems, quickly and efficiently migrate data from different databases and different data table structures.
在一优选的实施例中,在上述实施例的基础上,如图3所示,所述步骤S3之后还包括:In a preferred embodiment, based on the above embodiment, as shown in FIG. 3, after step S3, the method further includes:
步骤S4,按照预定的加密方式将原数据库的待迁移数据中每一单行数据进行加密后得到第一密文,按照该预定的加密方式将存储在该目标数据库中的每一单行数据进行加密后得到第二密文;Step S4, encrypting each single line of data in the original database to be migrated according to a predetermined encryption method to obtain a first ciphertext, and encrypting each single line of data stored in the target database according to the predetermined encryption method. Get the second ciphertext;
步骤S45,分析第一密文与对应的第二密文是否相同;Step S45, analyzing whether the first ciphertext is the same as the corresponding second ciphertext;
步骤S5,若该第一密文与对应的第二密文分别相同,则验证通过,该第二密文对应的数据在目标数据库中为有效的数据;Step S5: If the first ciphertext and the corresponding second ciphertext are respectively the same, the verification is passed, and the data corresponding to the second ciphertext is valid data in the target database;
步骤S6,若有该第一密文与对应的第二密文不相同,将该第二密文对应的单行数据进行回滚清除,以重新迁移该单行数据。In step S6, if the first ciphertext is different from the corresponding second ciphertext, a single line of data corresponding to the second ciphertext is rolled back and cleared to re-migrate the single line of data.
其中,预定的加密方式为MD5(Message-Digest Algorithm 5,信息-摘要算法)。本实施例将原数据库的待迁移数据按照逐行加密的方式进行加密,将目标数据库中的数据按照逐行加密的方式进行加密,将第一密文与对应的第二密文进行对比,如果两者相同,则验证通过,该第二密文对应的数据在目标数据中是有效的数据;如果两者不相同,则验证失败,该第二密文对应的数据需要从目标数据表中回滚清除,重新迁移该单行数据。通过这种方式,在快速、高效地迁移大数据量的数据的基础上,还能够进行单行数据严格的验证,以发现迁移过程出错的数据,确保迁移的数据的准确性。Among them, the predetermined encryption method is MD5 (Message-Digest Algorithm). This embodiment encrypts the data to be migrated in the original database in a row-by-row encryption method, encrypts the data in the target database in a row-by-row encryption method, and compares the first ciphertext with the corresponding second ciphertext. If the two are the same, the verification is passed. The data corresponding to the second ciphertext is valid data in the target data. If the two are not the same, the verification fails. The data corresponding to the second ciphertext needs to be returned from the target data table. Roll clear, re-migrate the single line of data. In this way, on the basis of quickly and efficiently migrating large amounts of data, single-line data can be strictly verified to find data that has been wrongly migrated and ensure the accuracy of the migrated data.
在一优选的实施例中,在上述实施例的基础上,所述步骤S2之后还包括:获取该待迁移数据的主键标识,以第一预设数量的主键标识为一组,基于各组主键标识生成该待迁移数据的第一索引文件;In a preferred embodiment, based on the above embodiment, after step S2, the method further includes: obtaining a primary key identifier of the data to be migrated, using a first preset number of primary key identifiers as a group, and based on each group of primary keys. Identifying a first index file that generates the data to be migrated;
所述步骤S3之后还包括:获取存储在目标数据库中的数据的主键标识,以第二预设数量的主键标识为一组,基于各组主键标识生成目标数据库中的数据的第二索引文件。After step S3, the method further includes: obtaining a primary key identifier of the data stored in the target database, using a second preset number of primary key identifiers as a group, and generating a second index file of data in the target database based on the primary key identifiers of each group.
其中,第一预设数量与第二预设数量可以相同或者不同,优选地,第一预设数量与第二预设数量相同,例如,第一预设数量与第二预设数量为1000。主键是数据表中的一个或多个字段,主键标识用于唯一标识数据表中的某一条记录。本实施例以第一预设数量或第二预设数量的主键标识为一组(如果不够第一预设数量则以字符0补齐),以定长的格式存放第一索引文件或第二索引文件至磁盘文件中,每次按组取出主键数据进行处理。The first preset number and the second preset number may be the same or different. Preferably, the first preset number is the same as the second preset number, for example, the first preset number and the second preset number are 1000. A primary key is one or more fields in a data table. The primary key identifier is used to uniquely identify a record in the data table. In this embodiment, the first preset number or the second preset number of primary keys are identified as a group (if the first preset number is not enough, they are filled with characters 0), and the first index file or the second is stored in a fixed-length format. Index files to disk files, each time the primary key data is fetched for processing.
其中,第一索引文件用于记录定位待迁移数据对应存放的XML文件。通常情况下,由于待迁移数据的数据量都非常大,其所生成的XML文件也非常多,所以迁移时需要先读取第一索引文件,通过第一索引文件的名称及主键数据进行定位,才能快速找到XML文件进行迁移。The first index file is used to record and locate the XML file corresponding to the data to be migrated. Under normal circumstances, because the amount of data to be migrated is very large, and the generated XML files are also very large, it is necessary to first read the first index file during migration, and locate it by the name of the first index file and the primary key data. Can quickly find XML files for migration.
第二索引文件,用于在将原数据库的待迁移数据写入目标数据库后,目标数据库中的每条数据在目标数据表中的主键标识。当迁移操作需要回滚时,可以通过该第二索引文件提取出目标数据表中对应的数据进行清除。The second index file is used to identify the primary key of each piece of data in the target database in the target data table after the data to be migrated from the original database is written to the target database. When the migration operation needs to be rolled back, the corresponding data in the target data table can be extracted through the second index file for cleaning.
通过上面的描述可以看出,本实施例通过第一索引文件能够快速找到XML文件并进行数据的迁移,通过第二索引文件能够快速提取目标数据表中需要回滚的数据并进行清除。As can be seen from the above description, in this embodiment, the first index file can quickly find the XML file and perform data migration, and the second index file can quickly extract the data to be rolled back in the target data table and clear it.
本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有处理系统,所述处理系统被处理器执行时实现上述的数据迁移的方法的步骤。The present application also provides a computer-readable storage medium on which a processing system is stored. When the processing system is executed by a processor, the steps of the foregoing method for data migration are implemented.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present application are merely for description, and do not represent the superiority or inferiority of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、 光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods in the above embodiments can be implemented by means of software plus a necessary universal hardware platform, and of course, also by hardware, but in many cases the former is better. Implementation. Based on such an understanding, the technical solution of this application that is essentially or contributes to the existing technology can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, The optical disc) includes several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in the embodiments of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only preferred embodiments of the present application, and thus do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of the application, or directly or indirectly used in other related technical fields Are included in the scope of patent protection of this application.
Claims (20)
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201810694928.2A CN109189756A (en) | 2018-06-29 | 2018-06-29 | Electronic device, the method for Data Migration and storage medium |
| CN201810694928.2 | 2018-06-29 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020000725A1 true WO2020000725A1 (en) | 2020-01-02 |
Family
ID=64948600
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2018/107702 Ceased WO2020000725A1 (en) | 2018-06-29 | 2018-09-26 | Electronic apparatus, data migration method, and storage medium |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109189756A (en) |
| WO (1) | WO2020000725A1 (en) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112632032A (en) * | 2020-12-18 | 2021-04-09 | 华人运通(上海)云计算科技有限公司 | Data migration method and device, storage medium and terminal equipment |
| CN115438086A (en) * | 2022-10-24 | 2022-12-06 | 中国农业银行股份有限公司 | Bank data migration verification method, device, system and medium |
| CN115470194A (en) * | 2022-09-20 | 2022-12-13 | 中国银行股份有限公司 | Data migration method and related device |
Families Citing this family (15)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112241398B (en) * | 2019-07-19 | 2025-04-15 | 北京京东尚科信息技术有限公司 | A data migration method and system |
| CN110688361A (en) * | 2019-08-16 | 2020-01-14 | 平安普惠企业管理有限公司 | Data migration method, electronic device and computer equipment |
| CN110609826A (en) * | 2019-09-20 | 2019-12-24 | 四川长虹电器股份有限公司 | Data extraction method |
| CN110941511B (en) * | 2019-11-21 | 2023-03-21 | 深信服科技股份有限公司 | Snapshot merging method, device, equipment and storage medium |
| CN111125059B (en) * | 2019-12-17 | 2022-08-12 | 南京甄视智能科技有限公司 | Data migration method and device, storage medium and server |
| CN111198869B (en) * | 2019-12-17 | 2025-02-07 | 未鲲(上海)科技服务有限公司 | Data migration method, device, equipment and computer readable storage medium |
| CN111241060A (en) * | 2020-01-08 | 2020-06-05 | 苏州科达科技股份有限公司 | Data migration method, system, device and storage medium |
| CN113760475A (en) * | 2020-06-04 | 2021-12-07 | 北京沃东天骏信息技术有限公司 | Online system migration method, device, medium and electronic device |
| CN111831625B (en) * | 2020-07-14 | 2024-03-12 | 深圳力维智联技术有限公司 | Data migration method, data migration device and readable storage medium |
| CN111930715B (en) * | 2020-07-16 | 2024-09-13 | 北京金山云网络技术有限公司 | Data migration method, device, computer equipment and storage medium |
| CN111913663A (en) * | 2020-07-29 | 2020-11-10 | 星辰天合(北京)数据科技有限公司 | Method and device for online storage volume migration, and system for online storage volume migration |
| CN111984631A (en) * | 2020-09-02 | 2020-11-24 | 深圳壹账通智能科技有限公司 | Production data migration method, device, computer equipment and storage medium |
| CN113742318B (en) * | 2021-09-14 | 2024-02-20 | 央视国际网络无锡有限公司 | Method for big data migration between relational databases |
| CN114840490B (en) * | 2022-03-23 | 2025-11-04 | 青岛海尔科技有限公司 | Database account migration methods, storage media and electronic devices |
| CN115514986B (en) * | 2022-09-22 | 2024-03-26 | 浙江广播电视集团 | Method and system for realizing material database turning between new and old media resource systems |
Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101739436A (en) * | 2009-09-28 | 2010-06-16 | 孙彬 | XML-based flexible data migration method |
| CN101789021A (en) * | 2010-02-24 | 2010-07-28 | 浪潮通信信息系统有限公司 | Universal configurable database data migration method |
| CN102521318A (en) * | 2011-12-02 | 2012-06-27 | 华侨大学 | General data exchange device based on extensible markup language (XML) |
| CN104462119A (en) * | 2013-09-18 | 2015-03-25 | 腾讯科技(深圳)有限公司 | Data migration method and device |
| CN105760517A (en) * | 2016-02-25 | 2016-07-13 | 浪潮(北京)电子信息产业有限公司 | Method and device for transferring data from Oracle database to DB2 database |
| CN106598977A (en) * | 2015-10-15 | 2017-04-26 | 北京国双科技有限公司 | Data migration method and device |
| CN106682534A (en) * | 2017-01-23 | 2017-05-17 | 郑州云海信息技术有限公司 | Method and device for verifying data integrity in data migration process |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7620665B1 (en) * | 2000-11-21 | 2009-11-17 | International Business Machines Corporation | Method and system for a generic metadata-based mechanism to migrate relational data between databases |
| CN102156699A (en) * | 2010-02-11 | 2011-08-17 | 陈巍 | Data migration method based on JDOM revolving technology |
| CN102999537B (en) * | 2011-09-19 | 2017-01-18 | 阿里巴巴集团控股有限公司 | System and method for data migration |
| WO2012095053A2 (en) * | 2012-03-01 | 2012-07-19 | 华为技术有限公司 | Data migration method and device |
-
2018
- 2018-06-29 CN CN201810694928.2A patent/CN109189756A/en active Pending
- 2018-09-26 WO PCT/CN2018/107702 patent/WO2020000725A1/en not_active Ceased
Patent Citations (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101739436A (en) * | 2009-09-28 | 2010-06-16 | 孙彬 | XML-based flexible data migration method |
| CN101789021A (en) * | 2010-02-24 | 2010-07-28 | 浪潮通信信息系统有限公司 | Universal configurable database data migration method |
| CN102521318A (en) * | 2011-12-02 | 2012-06-27 | 华侨大学 | General data exchange device based on extensible markup language (XML) |
| CN104462119A (en) * | 2013-09-18 | 2015-03-25 | 腾讯科技(深圳)有限公司 | Data migration method and device |
| CN106598977A (en) * | 2015-10-15 | 2017-04-26 | 北京国双科技有限公司 | Data migration method and device |
| CN105760517A (en) * | 2016-02-25 | 2016-07-13 | 浪潮(北京)电子信息产业有限公司 | Method and device for transferring data from Oracle database to DB2 database |
| CN106682534A (en) * | 2017-01-23 | 2017-05-17 | 郑州云海信息技术有限公司 | Method and device for verifying data integrity in data migration process |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112632032A (en) * | 2020-12-18 | 2021-04-09 | 华人运通(上海)云计算科技有限公司 | Data migration method and device, storage medium and terminal equipment |
| CN112632032B (en) * | 2020-12-18 | 2022-12-27 | 华人运通(上海)云计算科技有限公司 | Data migration method and device, storage medium and terminal equipment |
| CN115470194A (en) * | 2022-09-20 | 2022-12-13 | 中国银行股份有限公司 | Data migration method and related device |
| CN115438086A (en) * | 2022-10-24 | 2022-12-06 | 中国农业银行股份有限公司 | Bank data migration verification method, device, system and medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109189756A (en) | 2019-01-11 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020000725A1 (en) | Electronic apparatus, data migration method, and storage medium | |
| US11455217B2 (en) | Transaction consistency query support for replicated data from recovery log to external data stores | |
| US11563560B2 (en) | Blockchain-based data evidence storage method and apparatus | |
| WO2020024408A1 (en) | Test device, test method and storage medium | |
| Macedo et al. | Redis cookbook: Practical techniques for fast data manipulation | |
| CN111181975B (en) | An account management method, device, equipment and storage medium | |
| WO2021051627A1 (en) | Database-based batch importing method, apparatus and device, and storage medium | |
| WO2021174882A1 (en) | Data fragment verification method, apparatus, computer device, and readable storage medium | |
| WO2018120721A1 (en) | Method and system for testing user interface, electronic device, and computer readable storage medium | |
| CN103198122B (en) | Restart the method and apparatus of memory database | |
| US11853284B2 (en) | In-place updates with concurrent reads in a decomposed state | |
| CN114153647B (en) | Rapid data verification method, device and system for cloud storage system | |
| CN114745368A (en) | File downloading method and device, computer equipment and computer readable storage medium | |
| WO2019095667A1 (en) | Database data collection method, application server, and computer readable storage medium | |
| WO2022048358A1 (en) | Data processing method and device, and storage medium | |
| WO2025118755A1 (en) | Task permission verification method and apparatus, non-volatile storage medium and electronic device | |
| CN106021048A (en) | Out-of-order verification method and device of disk pack | |
| CN104781814B (en) | Splitting of reference data from a single table to multiple tables | |
| WO2019169771A1 (en) | Electronic device, access instruction information acquisition method and storage medium | |
| US11314713B2 (en) | Data discovery in relational databases | |
| CN105512329A (en) | GO-language-based dynamic figure cutting system | |
| US10185613B2 (en) | Error determination from logs | |
| WO2019001271A1 (en) | Open platform device, method for obtaining policy number, and computer readable storage medium | |
| CN114722927B (en) | Crash clustering method, device, electronic device and storage medium | |
| CN109542860B (en) | Service data management method based on HDFS and terminal equipment |
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: 18924025 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: 18924025 Country of ref document: EP Kind code of ref document: A1 |