CN116226080A - Data migration method, device, electronic equipment and storage medium - Google Patents
Data migration method, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN116226080A CN116226080A CN202211666296.1A CN202211666296A CN116226080A CN 116226080 A CN116226080 A CN 116226080A CN 202211666296 A CN202211666296 A CN 202211666296A CN 116226080 A CN116226080 A CN 116226080A
- Authority
- CN
- China
- Prior art keywords
- user request
- application
- topic
- identification information
- sending
- 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.)
- Pending
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
- G06F16/214—Database migration support
-
- 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/25—Integrating or interfacing systems involving database management systems
- G06F16/252—Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
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
本申请公开了一种数据迁移方法、装置、电子设备及存储介质,方法包括:在监测到待发送至第一应用的用户请求的情况下,将所述用户请求发送至所述第一应用并复制所述用户请求,其中所述用户请求携带有标识信息,所述标识信息用于指示对所述用户请求进行读取或对所述用户请求进行迁移;根据所述标识信息,控制第二应用对所复制的用户请求进行读取或者将所复制的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库,所述目标数据库包括所述第一应用所对应的源数据库的全量数据。本实施例实现了在数据迁移的过程中保证业务的连续性。
The present application discloses a data migration method, device, electronic device, and storage medium. The method includes: when monitoring a user request to be sent to the first application, sending the user request to the first application and copying the user request, wherein the user request carries identification information, and the identification information is used to indicate to read the user request or migrate the user request; according to the identification information, control the second application Reading the copied user request or sending the copied user request to a third application and writing it into a target database corresponding to the third application, where the target database includes the source database corresponding to the first application full amount of data. This embodiment ensures service continuity during data migration.
Description
技术领域technical field
本申请属于数据迁移技术领域,具体涉及一种数据迁移方法、装置、电子设备及存储介质。The present application belongs to the technical field of data migration, and in particular relates to a data migration method, device, electronic equipment and storage medium.
背景技术Background technique
数据迁移是应用系统重构、技术改造过程中的难点。目前在数据库迁移场景中,通常是一次性将源库的数据迁移到目标库,但是需要业务停机窗口,这个窗口的大小取决于全量数据迁移的时间。Data migration is a difficult point in the process of application system reconstruction and technical transformation. At present, in the database migration scenario, the data in the source database is usually migrated to the target database at one time, but a business downtime window is required, and the size of this window depends on the time for full data migration.
在上述方案中,在数据量较大时,整个迁移过程可能需要几天的时间,这导致业务停机时间较长,不能保证业务连续性。In the above solution, when the amount of data is large, the entire migration process may take several days, which results in long business downtime and cannot guarantee business continuity.
发明内容Contents of the invention
本申请实施例提供一种数据迁移方法、装置、电子设备及存储介质,以解决相关技术中数据迁移过程不能保证业务连续性的问题。Embodiments of the present application provide a data migration method, device, electronic equipment, and storage medium, so as to solve the problem in the related art that the data migration process cannot guarantee business continuity.
第一方面,本申请实施例提供了一种数据迁移方法,包括:In the first aspect, the embodiment of the present application provides a data migration method, including:
在监测到待发送至第一应用的用户请求的情况下,将所述用户请求发送至所述第一应用并复制所述用户请求,其中所述用户请求携带有标识信息,所述标识信息用于指示对所述用户请求进行读取或对所述用户请求进行迁移;When a user request to be sent to the first application is detected, the user request is sent to the first application and the user request is copied, wherein the user request carries identification information, and the identification information uses Instructing to read the user request or migrate the user request;
根据所述标识信息,控制第二应用对所复制的用户请求进行读取或者将所复制的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库,所述目标数据库包括所述第一应用所对应的源数据库的全量数据。According to the identification information, control the second application to read the copied user request or send the copied user request to a third application and write it into a target database corresponding to the third application, the target database includes The full data of the source database corresponding to the first application.
第二方面,本申请实施例另提供了一种数据迁移装置,包括:In the second aspect, the embodiment of the present application further provides a data migration device, including:
发送模块,用于在监测到待发送至第一应用的用户请求的情况下,将所述用户请求发送至所述第一应用并复制所述用户请求,其中所述用户请求携带有标识信息,所述标识信息用于指示对所述用户请求进行读取或对所述用户请求进行迁移;a sending module, configured to send the user request to the first application and copy the user request when monitoring a user request to be sent to the first application, wherein the user request carries identification information, The identification information is used to indicate to read the user request or to migrate the user request;
处理模块,用于根据所述标识信息,控制第二应用对所复制的用户请求进行读取或者将所复制的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库,所述目标数据库包括所述第一应用所对应的源数据库的全量数据。A processing module, configured to control the second application to read the copied user request or send the copied user request to a third application and write it into a target database corresponding to the third application according to the identification information, The target database includes all data of the source database corresponding to the first application.
第三方面,本申请实施例提供了一种电子设备,该电子设备包括处理器、存储器及存储在所述存储器上并可在所述处理器上运行的程序或指令,所述程序或指令被所述处理器执行时实现如第一方面所述的方法的步骤。In a third aspect, an embodiment of the present application provides an electronic device, the electronic device includes a processor, a memory, and a program or instruction stored in the memory and operable on the processor, and the program or instruction is The processor implements the steps of the method described in the first aspect when executed.
第四方面,本申请实施例提供了一种可读存储介质,所述可读存储介质上存储程序或指令,所述程序或指令被处理器执行时实现如第一方面所述的方法的步骤。In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or an instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented .
本申请实施例提供的方案,在监测到待发送至第一应用的用户请求的情况下,将所述用户请求发送至所述第一应用并复制所述用户请求,其中所述用户请求携带有标识信息,所述标识信息用于指示对所述用户请求进行读取或对所述用户请求进行迁移;根据所述标识信息,控制第二应用对所复制的用户请求进行读取,或者将所复制的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库,所述目标数据库包括所述第一应用所对应的源数据库的全量数据,实现了在不间断将用户请求发送至第一应用进行处理的同时,对用户请求进行复制,并根据需求对复制的用户请求进行读取或者写入目标数据库中,从而实现了将增量数据迁移至目标数据库中的同时,保证了业务处理的连续性,解决了数据迁移过程不能保证业务连续性的问题。In the solution provided by the embodiment of this application, when a user request to be sent to the first application is detected, the user request is sent to the first application and the user request is copied, wherein the user request carries Identification information, where the identification information is used to indicate to read the user request or to migrate the user request; according to the identification information, control the second application to read the copied user request, or to The copied user request is sent to the third application and written into the target database corresponding to the third application, and the target database includes the full amount of data of the source database corresponding to the first application, which realizes uninterrupted processing of user requests While sending to the first application for processing, the user request is copied, and the copied user request is read or written into the target database according to the requirements, thereby realizing the migration of incremental data to the target database while ensuring It ensures the continuity of business processing and solves the problem that the data migration process cannot guarantee business continuity.
附图说明Description of drawings
图1是本申请实施例中数据迁移方法的流程示意图;Fig. 1 is a schematic flow chart of the data migration method in the embodiment of the present application;
图2是本申请实施例中数据迁移方法的过程示意图;Fig. 2 is a schematic diagram of the process of the data migration method in the embodiment of the present application;
图3是本申请实施例中数据迁移装置的结构示意图;FIG. 3 is a schematic structural diagram of a data migration device in an embodiment of the present application;
图4是本申请实施例提供的电子设备的结构示意图。FIG. 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of this application.
本申请的说明书和权利要求书中的术语“第一”、“第二”等是用于区别类似的对象,而不用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施,且“第一”、“第二”等所区分的对象通常为一类,并不限定对象的个数,例如第一对象可以是一个,也可以是多个。此外,说明书以及权利要求中“和/或”表示所连接对象的至少其中之一,字符“/”,一般表示前后关联对象是一种“或”的关系。The terms "first", "second" and the like in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific sequence or sequence. It should be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application can be practiced in sequences other than those illustrated or described herein, and that references to "first," "second," etc. distinguish Objects are generally of one type, and the number of objects is not limited. For example, there may be one or more first objects. In addition, "and/or" in the specification and claims means at least one of the connected objects, and the character "/" generally means that the related objects are an "or" relationship.
下面结合附图,通过具体的实施例及其应用场景对本申请实施例提供的数据迁移方法进行详细地说明。The data migration method provided by the embodiment of the present application will be described in detail below through specific embodiments and application scenarios with reference to the accompanying drawings.
图1示出了本发明的一个实施例提供的数据迁移方法,该方法可以由电子设备执行,该电子设备可以包括:服务器和/或终端设备。换言之,该方法可以由安装在该电子设备的软件或硬件来执行,该方法包括如下步骤:Fig. 1 shows a data migration method provided by an embodiment of the present invention, the method may be executed by an electronic device, and the electronic device may include: a server and/or a terminal device. In other words, the method can be executed by software or hardware installed in the electronic device, and the method includes the following steps:
步骤101:在监测到待发送至第一应用的用户请求的情况下,将所述用户请求发送至所述第一应用并复制所述用户请求。Step 101: In a case where a user request to be sent to a first application is detected, send the user request to the first application and copy the user request.
具体的,用户请求可以是超文本传输协议(Hyper Text Transfer Protocol,HTTP)请求。Specifically, the user request may be a hypertext transfer protocol (Hyper Text Transfer Protocol, HTTP) request.
在监测到待发送至第一应用的用户请求的情况下,可以将用户请求发送至第一应用,从而实现通过第一应用对用户请求进行处理。其中,第一应用对应有源数据库,源数据库中存储有截止当前时间的全量数据。When a user request to be sent to the first application is detected, the user request may be sent to the first application, so that the user request can be processed by the first application. Wherein, the first application corresponds to an active database, and the source database stores all data up to the current time.
此外,在将用户请求发送至第一应用的同时,还需要复制该用户请求,且所述用户请求携带有标识信息,所述标识信息用于指示对所述用户请求进行读取或对所述用户请求进行迁移。这样使得能够通过用户请求所携带的标识信息对所复制的用户请求进行读取或迁移。In addition, when the user request is sent to the first application, the user request needs to be copied, and the user request carries identification information, and the identification information is used to indicate that the user request is read or the user request is read. A user requested a migration. In this way, the copied user request can be read or migrated through the identification information carried by the user request.
步骤102:根据所述标识信息,控制第二应用对所复制的用户请求进行读取,或者将所复制的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库。Step 102: According to the identification information, control the second application to read the copied user request, or send the copied user request to a third application and write it into a target database corresponding to the third application.
具体的,若标识信息用于指示对用户请求进行读取,则可以控制第二应用对所复制的用户请求进行读取;若标识信息用于指示对用户请求进行迁移,则可以将所复制的用户请求发送至第三应用并写入第三应用所对应的目标数据库,从而实现在业务无感知的情况下将新增的用户请求平滑迁移至目标数据库中。并且,通过标识信息所指示的不同信息实现了数据的读或写处理过程,满足了不同业务需求。Specifically, if the identification information is used to indicate to read the user request, the second application can be controlled to read the copied user request; if the identification information is used to indicate to migrate the user request, the copied The user request is sent to the third application and written into the target database corresponding to the third application, so that the newly added user request can be smoothly migrated to the target database without business awareness. Moreover, the process of reading or writing data is realized through different information indicated by the identification information, and different service requirements are met.
此外,第二应用可以为测试应用,当然测试应用对应有测试数据库,此时可以通过第二应用实现系统的压力测试或功能验证。In addition, the second application may be a test application. Of course, the test application corresponds to a test database. In this case, the stress test or function verification of the system may be implemented through the second application.
第三应用与第一应用的业务属性可以相同,这使得第三应用所反馈的请求结果与第一应用所反馈的请求结果能够相同,进而能够实现应用系统的重构。The business attributes of the third application and the first application may be the same, so that the request result fed back by the third application can be the same as the request result fed back by the first application, thereby realizing the reconstruction of the application system.
需要说明的是,所述目标数据库包括所述第一应用所对应的源数据库的全量数据,这使得在将新增的用户请求迁移至目标数据库中后,能够完整目标数据库的数据完整性。It should be noted that the target database includes the full amount of data of the source database corresponding to the first application, which makes it possible to complete the data integrity of the target database after the newly added user request is migrated to the target database.
这样本实施例在监测到待发送至第一应用的用户请求的情况下,将用户请求发送至第一应用并复制该用户请求,并根据用户请求携带的标识信息,控制第二应用对所复制的用户请求进行读取,或者将所复制的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库,目标数据库包括所述第一应用所对应的源数据库的全量数据,实现了在不间断将用户请求发送至第一应用进行处理的同时,对用户请求进行复制,并根据需求对复制的用户请求进行读取In this way, when a user request to be sent to the first application is detected in this embodiment, the user request is sent to the first application and the user request is copied, and the second application is controlled to copy the copied user request according to the identification information carried by the user request. user request to read, or send the copied user request to a third application and write it into the target database corresponding to the third application, the target database includes the full amount of data in the source database corresponding to the first application, It realizes copying the user request while continuously sending the user request to the first application for processing, and reads the copied user request according to the requirement
或者写入目标数据库中,从而实现了将新增的数据迁移至目标数据库中的同时,5保证了业务处理的连续性,解决了数据迁移过程不能保证业务连续性的问题。Or write it into the target database, so as to realize the migration of newly added data to the target database, 5 to ensure the continuity of business processing, and solve the problem that the data migration process cannot guarantee business continuity.
此外,本实施例可以通过应用层的openrestry+lua+kafka的方式实现用户请求的复制过程。具体的,在一个实施例中,将所述用户请求发送至所述第一应用并复制所述用户请求,包括如下步骤:In addition, in this embodiment, the duplication process requested by the user can be realized by means of openrestry+lua+kafka at the application layer. Specifically, in one embodiment, sending the user request to the first application and copying the user request includes the following steps:
通过OpenResty将所述用户请求发送至所述第一应用,并根据所述标识信0息将所述用户请求发送至Kafka中的第一主题Topic或第二Topic,其中第一Topic用于存储待进行读取的用户请求,所述第二Topic用于存储待进行迁移的用户请求。The user request is sent to the first application through OpenResty, and the user request is sent to the first Topic or the second Topic in Kafka according to the identification information, wherein the first Topic is used to store the Read user requests, and the second Topic is used to store user requests to be migrated.
具体的,OpenResty是一个基于Nginx与Lua的高性能全球广域网(World WideWeb,Web)平台,其内部集成了大量精良的Lua库、第三方模块以及大5多数的依赖项,用于方便地搭建能够处理超高并发、扩展性极高的动态Web应用、Web服务和动态网关。Specifically, OpenResty is a high-performance global wide area network (World WideWeb, Web) platform based on Nginx and Lua. Handle dynamic web applications, web services, and dynamic gateways with ultra-high concurrency and high scalability.
在nginx系统中本实施例可以配置openrestry的ngx.location.capture_multi实现同一个用户请求的并发复制。其中,本实施例可以在openrestry的配置文In this embodiment, in the nginx system, ngx.location.capture_multi of openrestry can be configured to implement concurrent replication of the same user request. Among them, this embodiment can be in the configuration file of openrestry
件中设置相关参数,例如连接超时时间、发送超时时间、读取超时时间、保持0高可用的超时时间、连接池的大小、缓存的大小等,并获取用户请求的报文头和报文体,利用capture_multi API实现请求报文体的复制,并将用户请求转发至第一应用。Set relevant parameters in the file, such as connection timeout, send timeout, read timeout, timeout for maintaining 0 high availability, connection pool size, cache size, etc., and obtain the header and body of the user request. The capture_multi API is used to copy the request message body, and forward the user request to the first application.
此外,本实施例还可以创建openrestry的Kafka生产者,制定生产者的消In addition, this embodiment can also create the Kafka producer of openrestry, and formulate the producer's message
息格式、Kafka集群的消息代理清单(broker list),并创建用于存储待进行读取5的用户请求的第一Topic和用于存储待进行迁移的用户请求的第二Topic。这使得本实施例能够通过OpenResty将用户请求发送至第一应用,并通过OpenResty将标识信息指示进行读取的用户请求发送至Kafka中的第一Topic,将标识信息指示进行迁移的用户请求发送至第二Topic中,从而实现了通过OpenResty+lua+kafka的方式实现数据的复制过程。information format, the message broker list (broker list) of the Kafka cluster, and create a first Topic for storing user requests to be read 5 and a second Topic for storing user requests to be migrated. This enables this embodiment to send the user request to the first application through OpenResty, and send the user request indicating the identification information to be read to the first topic in Kafka through OpenResty, and send the user request indicating the identification information to be migrated to In the second Topic, the data replication process is realized through OpenResty+lua+kafka.
此外,在一个实施例中,根据所述标识信息,控制第二应用对所复制的用户请求进行读取或者将所复制的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库,包括:In addition, in an embodiment, according to the identification information, the second application is controlled to read the copied user request or send the copied user request to a third application and write it into the corresponding Target database, including:
控制所述第二应用从所述第一Topic中读取所述用户请求,或将所述第二Topic中的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库。Controlling the second application to read the user request from the first Topic, or sending the user request in the second Topic to a third application and writing it into a target database corresponding to the third application.
具体的,由于第一Topic用于存储待进行读取的用户请求,第二Topic用于存储待进行迁移的用户请求,因此可以控制第二应用从第一Topic中读取用户请求,或将第二Topic中的用户请求发送至第三应用并写入第三应用所对应的目标数据库中,从而实现了从不同的Topic中获取不同指示类型的用户请求,避免了将待进行读取的用户请求写入目标数据库或将待进行迁移的用户请求读取至第二应用。Specifically, since the first Topic is used to store user requests to be read, and the second Topic is used to store user requests to be migrated, the second application can be controlled to read user requests from the first Topic, or the second Topic The user request in the second topic is sent to the third application and written into the target database corresponding to the third application, so that user requests of different indication types can be obtained from different topics, and user requests to be read are avoided. Write to the target database or read user requests to be migrated to the second application.
此外,为了保证同一业务主键的请求的处理顺序,在一个实施例中,所述第一Topic和所述第二Topic均预先按照业务主键信息进行分区,且所述用户请求还携带有用户的业务主键信息;In addition, in order to ensure the processing order of requests for the same business master key, in one embodiment, both the first topic and the second topic are pre-partitioned according to the business master key information, and the user request also carries the user's business primary key information;
此时,所述根据所述标识信息将所述用户请求发送至Kafka中的第一主题Topic或第二Topic,包括:根据所述业务主键信息将所述用户请求发送至所述第一Topic或所述第二Topic中所述业务主键信息对应的分区内。At this time, the sending the user request to the first Topic or the second Topic in Kafka according to the identification information includes: sending the user request to the first Topic or the second Topic according to the business master key information In the partition corresponding to the business primary key information in the second Topic.
具体的,业务主键信息可以包括用户标识、用户业务单号等,当然每个用户所对应的业务主键信息具有唯一性。Specifically, the service primary key information may include a user identifier, a user service order number, etc. Of course, the service primary key information corresponding to each user is unique.
通过根据业务主键信息将用户请求发送至第一Topic或第二Topic中业务主键信息对应的分区内,使得每个分区中仅存储一个业务主键对应的业务请求,从而使得能够通过分区内消息先进先出的特点,保证同一业务主键的请求的处理顺序。By sending the user request to the partition corresponding to the business master key information in the first Topic or the second Topic according to the business master key information, only one business request corresponding to the business master key is stored in each partition, so that the messages in the partition can be passed first Out of features, to ensure the processing order of the request of the same business primary key.
下面通过图2对本实施例进行具体说明。The present embodiment will be specifically described below with reference to FIG. 2 .
如图2所示,假设应用系统为nginx系统,在nginx系统接收到用户请求时,可以通过OpenResty将用户请求发送至第一应用,当然此时第一应用可以从源数据库中查询用户请求的请求结果;As shown in Figure 2, assume that the application system is the nginx system. When the nginx system receives a user request, it can send the user request to the first application through OpenResty. Of course, the first application can query the user request from the source database at this time. result;
本实施例可以创建openrestry的Kafka生产者,制定生产者的消息格式、Kafka集群的broker list、Kafka消费者,并创建用于存储待进行读取的用户请求的第一Topic和用于存储待进行迁移的用户请求的第二Topic。用户请求携带有标识信息,标识信息用于指示对所述用户请求进行读取或对用户请求进行迁移,此时可以通过OpenResty将用户请求复制至Kafka中的第一Topic或第二Topic,并根据标识信息,控制第二应用从第一Topic中读取用户请求,或通过Kafka消息者,调用第三应用相关的应用程序界面(ApplicationProgram Interface,API),将第二Topic中的用户请求发送至第三应用并写入第三应用所对应的目标数据库。具体的,第二应用可以为测试应用,且对应有测试数据库,从而实现重构应用系统的压力或功能测试。This embodiment can create the Kafka producer of openrestry, formulate the message format of the producer, the broker list of the Kafka cluster, and the Kafka consumer, and create the first Topic for storing the user request to be read and the first topic for storing the user request to be read The second topic requested by the migrated user. The user request carries identification information, and the identification information is used to indicate to read the user request or migrate the user request. At this time, the user request can be copied to the first or second topic in Kafka through OpenResty, and according to Identification information, control the second application to read the user request from the first Topic, or call the application program interface (Application Program Interface, API) related to the third application through the Kafka messenger, and send the user request in the second Topic to the second Topic The third application is written into the target database corresponding to the third application. Specifically, the second application may be a test application, and corresponds to a test database, so as to implement stress or function testing of the reconfigured application system.
需要说明的是,目标数据库包括源数据库的全量数据,从而保证了目标数据库的完整性。It should be noted that the target database includes all data of the source database, thereby ensuring the integrity of the target database.
这样,本实施例实现了在不间断将用户请求发送至第一应用进行处理的同时,对用户请求进行复制,并根据需求对复制的用户请求进行读取或者写入目标数据库中,从而实现了将增量数据迁移至目标数据库中的同时,保证了业务处理的连续性,能够自动适应应用系统重构、数据迁移等过程中数据模型变动、应用逻辑优化,从而解决了数据迁移过程中数据链路冗余和数据加工逻辑重复的问题。In this way, in this embodiment, the user request is copied while the user request is continuously sent to the first application for processing, and the copied user request is read or written into the target database according to the requirement, thereby realizing While migrating incremental data to the target database, it ensures the continuity of business processing, and can automatically adapt to data model changes and application logic optimization in the process of application system refactoring and data migration, thereby solving the problem of data chain in the process of data migration. The problem of road redundancy and data processing logic duplication.
图3示出本发明的一个实施例提供的一种数据迁移装置的结构示意图。如图3所示,数据迁移装置包括:Fig. 3 shows a schematic structural diagram of a data migration device provided by an embodiment of the present invention. As shown in Figure 3, the data migration device includes:
发送模块301,用于在监测到待发送至第一应用的用户请求的情况下,将所述用户请求发送至所述第一应用并复制所述用户请求,其中所述用户请求携带有标识信息,所述标识信息用于指示对所述用户请求进行读取或对所述用户请求进行迁移;A sending
处理模块302,用于根据所述标识信息,控制第二应用对所复制的用户请求进行读取,或者将所复制的用户请求发送至第三应用并写入所述第三应用所5对应的目标数据库,所述目标数据库包括所述第一应用所对应的源数据库的全量数据。The
在一个实施例中,所述发送模块301用于,通过OpenResty将所述用户请求发送至所述第一应用,并根据所述标识信息将所述用户请求发送至Kafka中In one embodiment, the sending
的第一主题Topic或第二Topic,其中第一Topic用于存储待进行读取的用户请0求,所述第二Topic用于存储待进行迁移的用户请求。The first Topic or the second Topic, wherein the first Topic is used to store user requests to be read, and the second Topic is used to store user requests to be migrated.
在一个实施例中,所述第一Topic和所述第二Topic均预先按照业务主键信息进行分区,且所述用户请求还携带有用户的业务主键信息;In one embodiment, both the first Topic and the second Topic are pre-partitioned according to the business master key information, and the user request also carries the user's business master key information;
所述发送模块用于,根据所述业务主键信息将所述用户请求发送至所述第一Topic或所述第二Topic中所述业务主键信息对应的分区内。The sending module is configured to send the user request to the partition corresponding to the service master key information in the first Topic or the second Topic according to the service master key information.
5在一个实施例中,所述处理模块用于,控制所述第二应用从所述第一Topic中读取所述用户请求,或将所述第二Topic中的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库。5 In an embodiment, the processing module is configured to control the second application to read the user request from the first Topic, or send the user request in the second Topic to a third application And write into the target database corresponding to the third application.
本申请实施例提供的数据迁移装置能够实现图1-2的方法实施例实现的各个过程,为避免重复,这里不再赘述。The data migration device provided in the embodiment of the present application can realize each process realized in the method embodiment in Fig. 1-2, and to avoid repetition, details are not repeated here.
0需要说明的是,本说明书中关于数据迁移装置的实施例与本说明书中关于数据迁移方法的实施例基于同一发明构思,因此关于数据迁移装置实施例的具体实施可以参见前述对应的关于数据迁移方法实施例的实施,重复之处不再赘述。0 It should be noted that the embodiment of the data migration device in this specification is based on the same inventive concept as the embodiment of the data migration method in this specification, so for the specific implementation of the embodiment of the data migration device, please refer to the above corresponding data migration The implementation of the method embodiment will not be described repeatedly.
本申请实施例中的数据迁移装置可以是装置,也可以是终端中的部件、集5成电路、或芯片。该装置可以是移动电子设备,也可以为非移动电子设备。示例性的,移动电子设备可以为手机、平板电脑、笔记本电脑、掌上电脑、车载电子设备、可穿戴设备、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本或者个人数字助理(personaldigital assistant,PDA)等,非移动电子设备可以为服务器、网络附属存储器(NetworkAttached Storage,NAS)、个人计算机(personal computer,PC)、电视机(television,TV)、柜员机或者自助机等,本申请实施例不作具体限定。The data migration device in the embodiment of the present application may be a device, or a component, an integrated circuit, or a chip in a terminal. The device may be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device may be a mobile phone, tablet computer, notebook computer, palmtop computer, vehicle electronic device, wearable device, ultra-mobile personal computer (ultra-mobile personal computer, UMPC), netbook or personal digital assistant (personal digital assistant) , PDA), etc., the non-mobile electronic device can be a server, a network attached storage (NetworkAttached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., the embodiment of the present application Not specifically limited.
本申请实施例中的数据迁移装置可以为具有操作系统的装置。该操作系统可以为安卓(Android)操作系统,可以为ios操作系统,还可以为其他可能的操作系统,本申请实施例不作具体限定。The data migration device in the embodiment of the present application may be a device with an operating system. The operating system may be an Android (Android) operating system, an ios operating system, or other possible operating systems, which are not specifically limited in this embodiment of the present application.
基于相同的技术构思,本申请实施例还提供了一种电子设备,该电子设备用于执行上述的数据迁移方法,图4为实现本申请各个实施例的一种电子设备的结构示意图。电子设备可因配置或性能不同而产生比较大的差异,可以包括处理器(processor)410、通信接口(Communications Interface)420、存储器(memory)430和通信总线440,其中,处理器410,通信接口420,存储器430通过通信总线440完成相互间的通信。处理器410可以调用存储在存储器430上并可在处理器410上运行的计算机程序,以执行下述步骤:Based on the same technical concept, an embodiment of the present application also provides an electronic device, which is used to execute the above-mentioned data migration method. FIG. 4 is a schematic structural diagram of an electronic device implementing various embodiments of the present application. Electronic equipment may have relatively large differences due to different configurations or performances, and may include a processor (processor) 410, a communication interface (Communications Interface) 420, a memory (memory) 430, and a
在监测到待发送至第一应用的用户请求的情况下,将所述用户请求发送至所述第一应用并复制所述用户请求,其中所述用户请求携带有标识信息,所述标识信息用于指示对所述用户请求进行读取或对所述用户请求进行迁移;When a user request to be sent to the first application is detected, the user request is sent to the first application and the user request is copied, wherein the user request carries identification information, and the identification information uses Instructing to read the user request or migrate the user request;
根据所述标识信息,控制第二应用对所复制的用户请求进行读取,或者将所复制的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库,所述目标数据库包括所述第一应用所对应的源数据库的全量数据。According to the identification information, control the second application to read the copied user request, or send the copied user request to a third application and write it into a target database corresponding to the third application, and the target database It includes all data of the source database corresponding to the first application.
在一个实施例中,所述将所述用户请求发送至所述第一应用并复制所述用户请求,包括:通过OpenResty将所述用户请求发送至所述第一应用,并根据所述标识信息将所述用户请求发送至Kafka中的第一主题Topic或第二Topic,其中第一Topic用于存储待进行读取的用户请求,所述第二Topic用于存储待进行迁移的用户请求。In one embodiment, the sending the user request to the first application and copying the user request includes: sending the user request to the first application through OpenResty, and copying the user request according to the identification information The user request is sent to the first Topic or the second Topic in Kafka, wherein the first Topic is used to store the user request to be read, and the second Topic is used to store the user request to be migrated.
在一个实施例中,所述第一Topic和所述第二Topic均预先按照业务主键信息进行分区,且所述用户请求还携带有用户的业务主键信息;In one embodiment, both the first Topic and the second Topic are pre-partitioned according to the business master key information, and the user request also carries the user's business master key information;
所述根据所述标识信息将所述用户请求发送至Kafka中的第一主题Topic或第二Topic,包括:根据所述业务主键信息将所述用户请求发送至所述第一Topic或所述第二Topic中所述业务主键信息对应的分区内。The sending the user request to the first Topic or the second Topic in Kafka according to the identification information includes: sending the user request to the first Topic or the second Topic according to the business master key information In the partition corresponding to the business primary key information described in Topic 2.
在一个实施例中,所述根据所述标识信息,控制第二应用对所复制的用户请求进行读取,或者将所复制的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库,包括:根据所述标识信息,控制所述第二应用从所述第一Topic中读取所述用户请求,或将所述第二Topic中的用户请求发送至第三应用并写入所述第三应用所对应的目标数据库。In one embodiment, according to the identification information, the second application is controlled to read the copied user request, or send the copied user request to a third application and write it into the corresponding The target database includes: controlling the second application to read the user request from the first Topic according to the identification information, or sending the user request in the second Topic to a third application and writing Enter the target database corresponding to the third application.
具体执行步骤可以参见上述数据迁移方法实施例的各个步骤,且能达到相同的技术效果,为避免重复,这里不再赘述。For specific execution steps, please refer to the steps in the above embodiments of the data migration method, and the same technical effect can be achieved. To avoid repetition, details are not repeated here.
需要说明的是,本申请实施例中的电子设备包括:服务器、终端或除终端之外的其他设备。It should be noted that the electronic device in the embodiment of the present application includes: a server, a terminal or other devices except the terminal.
以上电子设备结构并不构成对电子设备的限定,电子设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置,例如,输入单元,可以包括图形处理器(Graphics Processing Unit,GPU)和麦克风,显示单元可以采用液晶显示器、有机发光二极管等形式来配置显示面板。用户输入单元包括触控面板以及其他输入设备中的至少一种。触控面板也称为触摸屏。其他输入设备可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆,在此不再赘述。The above electronic device structure does not constitute a limitation to the electronic device, and the electronic device may include more or fewer components than shown in the illustration, or combine certain components, or arrange different components, for example, an input unit may include a graphics processor (Graphics Processing Unit, GPU) and a microphone, and the display unit may be configured with a display panel in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit includes at least one of a touch panel and other input devices. A touch panel is also called a touch screen. Other input devices may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, switch buttons, etc.), trackballs, mice, and joysticks, which will not be repeated here.
存储器可用于存储软件程序以及各种数据。存储器可主要包括存储程序或指令的第一存储区和存储数据的第二存储区,其中,第一存储区可存储操作系统、至少一个功能所需的应用程序或指令(比如声音播放功能、图像播放功能等)等。此外,存储器可以包括易失性存储器或非易失性存储器,或者,存储器可以包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDRSDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DRRAM)。The memory can be used to store software programs as well as various data. The memory may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, application programs or instructions required by at least one function (such as sound playback function, image playback function, etc.) etc. Also, memory may include volatile memory or nonvolatile memory, or memory may include both volatile and nonvolatile memory. Wherein, the non-volatile memory may be a read-only memory (Read-Only Memory, ROM), a programmable read-only memory (Programmable ROM, PROM), an erasable programmable read-only memory (Erasable PROM, EPROM), an electronically programmable Erase Programmable Read-Only Memory (Electrically EPROM, EEPROM) or Flash. Volatile memory can be random access memory (Random Access Memory, RAM), static random access memory (Static RAM, SRAM), dynamic random access memory (Dynamic RAM, DRAM), synchronous dynamic random access memory (Synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (Double Data Rate SDRAM, DDRSDRAM), enhanced synchronous dynamic random access memory (Enhanced SDRAM, ESDRAM), synchronous connection dynamic random access memory (Synchlink DRAM, SLDRAM) and Direct Memory Bus Random Access Memory (Direct Rambus RAM, DRRAM).
处理器可包括一个或多个处理单元;可选的,处理器集成应用处理器和调制解调处理器,其中,应用处理器主要处理涉及操作系统、用户界面和应用程序等的操作,调制解调处理器主要处理无线通信信号,如基带处理器。可以理解的是,上述调制解调处理器也可以不集成到处理器中。The processor may include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly handles operations related to the operating system, user interface, and application programs, and the modem The tone processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the foregoing modem processor may not be integrated into the processor.
本申请实施例还提供一种可读存储介质,所述可读存储介质上存储有程序或指令,该程序或指令被处理器执行时实现上述数据迁移方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。The embodiment of the present application also provides a readable storage medium, the readable storage medium stores a program or an instruction, and when the program or instruction is executed by a processor, the various processes of the above-mentioned data migration method embodiment are realized, and the same To avoid repetition, the technical effects will not be repeated here.
其中,所述处理器为上述实施例中所述的电子设备中的处理器。所述可读存储介质,包括计算机可读存储介质,如计算机只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等。Wherein, the processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and the like.
本申请实施例另提供了一种芯片,所述芯片包括处理器和通信接口,所述通信接口和所述处理器耦合,所述处理器用于运行程序或指令,实现上述方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。The embodiment of the present application further provides a chip, the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above method embodiments , and can achieve the same technical effect, in order to avoid repetition, it will not be repeated here.
应理解,本申请实施例提到的芯片还可以称为系统级芯片、系统芯片、芯片系统或片上系统芯片等。It should be understood that the chips mentioned in the embodiments of the present application may also be called system-on-chip, system-on-chip, system-on-a-chip, or system-on-a-chip.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。此外,需要指出的是,本申请实施方式中的方法和装置的范围不限按示出或讨论的顺序来执行功能,还可包括根据所涉及的功能按基本同时的方式或按相反的顺序来执行功能,例如,可以按不同于所描述的次序来执行所描述的方法,并且还可以添加、省去、或组合各种步骤。另外,参照某些示例所描述的特征可在其他示例中被组合。It should be noted that, in this document, the term "comprising", "comprising" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article or apparatus comprising a set of elements includes not only those elements, It also includes other elements not expressly listed, or elements inherent in the process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising that element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved. Functions are performed, for example, the described methods may be performed in an order different from that described, and various steps may also be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general-purpose 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 the present application can be embodied in the form of a software product in essence or the part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM/RAM, disk, CD) contains several instructions to enable a terminal (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in various embodiments of the present application.
上面结合附图对本申请的实施例进行了描述,但是本申请并不局限于上述的具体实施方式,上述的具体实施方式仅仅是示意性的,而不是限制性的,本领域的普通技术人员在本申请的启示下,在不脱离本申请宗旨和权利要求所保护的范围情况下,还可做出很多形式,均属于本申请的保护之内。The embodiments of the present application have been described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementations. The above-mentioned specific implementations are only illustrative and not restrictive. Those of ordinary skill in the art will Under the inspiration of this application, without departing from the purpose of this application and the scope of protection of the claims, many forms can also be made, all of which belong to the protection of this application.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211666296.1A CN116226080A (en) | 2022-12-23 | 2022-12-23 | Data migration method, device, electronic equipment and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211666296.1A CN116226080A (en) | 2022-12-23 | 2022-12-23 | Data migration method, device, electronic equipment and storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN116226080A true CN116226080A (en) | 2023-06-06 |
Family
ID=86590144
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202211666296.1A Pending CN116226080A (en) | 2022-12-23 | 2022-12-23 | Data migration method, device, electronic equipment and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN116226080A (en) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US10157214B1 (en) * | 2014-11-19 | 2018-12-18 | Amazon Technologies, Inc. | Process for data migration between document stores |
| CN110321339A (en) * | 2019-07-04 | 2019-10-11 | 深圳乐信软件技术有限公司 | A kind of data migration method, device, equipment and storage medium |
| CN110874354A (en) * | 2019-10-23 | 2020-03-10 | 支付宝(杭州)信息技术有限公司 | Database migration method and device, electronic equipment and storage medium |
| CN113987045A (en) * | 2021-10-29 | 2022-01-28 | 深圳市优必选科技股份有限公司 | Big data business system and construction method of big data business system |
-
2022
- 2022-12-23 CN CN202211666296.1A patent/CN116226080A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US10157214B1 (en) * | 2014-11-19 | 2018-12-18 | Amazon Technologies, Inc. | Process for data migration between document stores |
| CN110321339A (en) * | 2019-07-04 | 2019-10-11 | 深圳乐信软件技术有限公司 | A kind of data migration method, device, equipment and storage medium |
| CN110874354A (en) * | 2019-10-23 | 2020-03-10 | 支付宝(杭州)信息技术有限公司 | Database migration method and device, electronic equipment and storage medium |
| CN113987045A (en) * | 2021-10-29 | 2022-01-28 | 深圳市优必选科技股份有限公司 | Big data business system and construction method of big data business system |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11847438B2 (en) | Offline capabilities for live applications in a cloud collaboration platform | |
| JP6553822B2 (en) | Dividing and moving ranges in distributed systems | |
| JP6159338B2 (en) | Real-time document presentation data synchronization through general-purpose services | |
| US20170068469A1 (en) | Remote Shared Virtual Disk Snapshot Creation | |
| CN114925084A (en) | Distributed transaction processing method, system, device and readable storage medium | |
| CN106462631B (en) | Consistent view of partitioned data in a final consistent system | |
| US20150032690A1 (en) | Virtual synchronization with on-demand data delivery | |
| JP2016529599A (en) | Content clipboard synchronization | |
| US11487397B2 (en) | Multiple windows for a group-based communication system | |
| KR20140101370A (en) | Autonomous network streaming | |
| WO2022062888A1 (en) | Document editing method and apparatus, computer device and storage medium | |
| US9313239B2 (en) | Information processing apparatus, electronic meeting system, and program | |
| WO2015153528A1 (en) | Data view exposure mechanisms | |
| CN106446114A (en) | Data migration method and device | |
| US9990192B2 (en) | Remotable project | |
| CN108140043B (en) | Read-write protocol for attaching only distributed database | |
| CN110083467B (en) | Method and device for processing applet message and computer storage medium | |
| CN107220388A (en) | A kind of method and apparatus of upper transmitting file | |
| US20180060009A1 (en) | Managing secondary views for meeting management applications in multi-display environments | |
| US9805011B2 (en) | High-performance editing of large remote files in client-server architecture | |
| CN116226080A (en) | Data migration method, device, electronic equipment and storage medium | |
| CN114489857B (en) | Page configuration method and device based on general configuration platform and computer system | |
| US20180074867A1 (en) | Provide copy of notebook document | |
| US20180341717A1 (en) | Providing instant preview of cloud based file | |
| CN115510016A (en) | A client response method, device and medium based on directory fragmentation |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |