Database migration method, device and system, computer equipment and storage medium
By controlling the read and write status of multiple databases in the target data server and gradually switching from the source database to the target database, the problem of traditional database migration methods requiring service suspension is solved, and efficient non-stop database migration is achieved.
Patent Information
- Application Number
- CN202311246754.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-25
- Publication Date
- 2025-03-25
AI Technical Summary
Traditional database migration methods require service suspension, resulting in low migration efficiency.
By starting multiple database read and write states in the target data server, gradually switch from the source database to the target database to achieve non-stop database migration. The specific steps include starting the first double-write single-read state, switching to the second double-write single-read state, and finally switching to the second single-write single-read state.
It realizes database migration without affecting the normal operation of the target service, improves database migration efficiency and avoids downtime migration.
Smart Images

Figure CN119690937A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a database migration method, apparatus, system, computer equipment, storage medium and computer program product. Background Art
[0002] With the development of computer technology, databases have emerged. Databases are one of the most widely used data management systems. They can be used for large-scale data processing and are widely used in various data services. During the use of databases, database migration can be performed as needed. Database migration refers to migrating data from a source database to a target database.
[0003] In traditional technology, the service is usually shut down for a period of time. During the service shutdown process, the service database migration is performed to transfer data from the source database to the target database. However, during the database migration process, the service needs to be suspended and the migration needs to be stopped, which leads to low database migration efficiency. Summary of the invention
[0004] Based on this, it is necessary to provide a database migration method, apparatus, system, computer equipment, computer-readable storage medium and computer program product that can improve the efficiency of database migration in response to the above technical problems.
[0005] This application provides a database migration method, including:
[0006] For database migration of a target service, a first dual-write single-read state of a target data server corresponding to the target service is started; the first dual-write single-read state is used to indicate that data is written to a source database and a target database corresponding to the target service through the target data server, and data is read from the source database;
[0007] When it is determined that the data write operation to the target database is executed normally, switching from the first dual-write single-read state to the second dual-write single-read state; the second dual-write single-read state is used to indicate that data is written to the source database and the target database through the target data server, and data is read from the target database; when it is determined that the data write operation to the target database is executed normally, the data in the source database is consistent with the data in the target database;
[0008] When it is determined that the data write operation and the data read operation for the target database are both executed normally, switch from the second dual-write single-read state to a second single-write single-read state; the second single-write single-read state is used to indicate reading and writing data from the target database through the target data server.
[0009] The present application also provides a database migration device, including:
[0010] A startup module, used for starting a first dual-write single-read state of a target data server corresponding to the target service for database migration; the first dual-write single-read state is used to indicate writing data to a source database and a target database corresponding to the target service through the target data server, and reading data from the source database;
[0011] a switching module, configured to switch from the first dual-write single-read state to a second dual-write single-read state when it is determined that the data write operation to the target database is executed normally; the second dual-write single-read state is configured to indicate that data is written to the source database and the target database through the target data server, and data is read from the target database; when it is determined that the data write operation to the target database is executed normally, the data in the source database is consistent with the data in the target database;
[0012] The switching module is also used to switch from the second dual-write single-read state to the second single-write single-read state when it is determined that the data write operation and the data read operation for the target database are performed normally; the second single-write single-read state is used to indicate reading and writing data from the target database through the target data server.
[0013] The present application also provides a database migration system, the system comprising a target data server corresponding to a target service, a source database, and a target database;
[0014] The target data server is used for database migration of a target service and starts a first dual-write single-read state of the target data server corresponding to the target service;
[0015] In the first dual-write single-read state, the source database and the target database are used to respond to the data write operation sent by the target data server, and the source database is also used to respond to the data read operation sent by the target data server;
[0016] The target data server is further configured to switch from the first dual-write single-read state to the second dual-write single-read state when it is determined that the data write operation to the target database is executed normally; when it is determined that the data write operation to the target database is executed normally, the data in the source database is consistent with the data in the target database;
[0017] In the second dual-write single-read state, the source database and the target database are used to respond to the data write operation sent by the target data server, and the target database is also used to respond to the data read operation sent by the target data server;
[0018] The target data server is further configured to switch from the second dual-write single-read state to a second single-write single-read state when it is determined that the data write operation and the data read operation for the target database are both performed normally;
[0019] In the second single-write and single-read state, the target database is used to respond to data writing operations and data reading operations sent by the target data server.
[0020] The present application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps described in the above database migration method when executing the computer program.
[0021] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned database migration method are implemented.
[0022] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned database migration method when executed by a processor.
[0023] The above-mentioned database migration method, apparatus, computer equipment, storage medium and computer program product, for database migration of a target service, start the first dual-write single-read state of the target data server corresponding to the target service; the first dual-write single-read state is used to indicate that data is written to the source database and the target database corresponding to the target service through the target data server, and data is read from the source database; when it is determined that the data write operation to the target database is executed normally, switch from the first dual-write single-read state to the second dual-write single-read state; the second dual-write single-read state is used to indicate that data is written to the source database and the target database through the target data server, and data is read from the target database; when it is determined that the data write operation to the target database is executed normally, the data in the source database is consistent with the data in the target database; when it is determined that the data write operation and the data read operation to the target database are both executed normally, switch from the second dual-write single-read state to the second single-write single-read state; the second single-write single-read state is used to indicate that data is read and written from the target database through the target data server. In this way, for the database migration of the target service, in the target data server, the read and write state of the database is controlled, and the read and write of the service is gradually switched from the source database to the target database through the state switching, so that the database migration can be performed without affecting the normal operation of the target service, and the migration without downtime is realized, which effectively improves the efficiency of database migration. It can be understood that the first double-write single-read state is started first, and the data is written to the source database and the target database at the same time, and the data is read from the source database as usual to ensure that the service operation is not affected. When it is determined that the target data server can write data to the target database normally, it is switched to the second double-write single-read state, and the data is still written to the source database and the target database at the same time. At this time, the data is read from the target database. Because the data write operation for the target database is executed normally, the service operation is still not affected. When it is determined that the target data server can read and write data from the target database normally, it is switched to the second single-write single-read state. At this time, the data is completely read and written from the target database. Because the data write operation and data read operation for the target database are executed normally, the service operation is still not affected. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0025] Figure 1 An application environment diagram of a database migration method in an embodiment;
[0026] Figure 2A schematic diagram of a process of a database migration method in one embodiment;
[0027] Figure 3 A schematic diagram of switching from reading and writing data through a source data server to reading and writing data through a target data server in one embodiment;
[0028] Figure 4 A schematic diagram of a process of database migration in one embodiment;
[0029] Figure 5 It is a flowchart of database migration in another embodiment;
[0030] Figure 6 is a schematic diagram of the architecture of a public access platform in one embodiment;
[0031] Figure 7 A schematic diagram of switching from reading and writing data through a source data server to reading and writing data through a target data server for a public access platform in one embodiment;
[0032] Figure 8 A system schematic diagram of a database migration system in one embodiment;
[0033] Fig. 9 A system schematic diagram of a database migration system in another embodiment;
[0034] Fig.10 A system schematic diagram of a database migration system in another embodiment;
[0035] Fig.11 A system schematic diagram of a database migration system in another embodiment;
[0036] Fig.12 A schematic diagram of a flow chart of a database migration method in another embodiment;
[0037] Fig.13 A schematic diagram of data processing in the read and write state of each database in one embodiment;
[0038] Fig.14 A schematic diagram of an interface of a game match in one embodiment;
[0039] Fig.15 is a structural block diagram of a database migration device in one embodiment;
[0040] Fig.16 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0042] The database migration method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the terminal 102 communicates with the target data server 104 corresponding to the target service through the network, and the target data server 104 communicates with the source database 106 and the target database 108 corresponding to the target service through the network. The source database 106 and the target database 108 are located on different servers.
[0043] It is understood that the terminal may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices and portable wearable devices. IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server may be implemented as an independent server or a server cluster consisting of multiple servers or a cloud server.
[0044] Specifically, the target service can be accessed through the terminal 102, and the relevant data of the target service can be read and written from the corresponding database through the target data server 104. For the database migration of the target service, the target data server 104 starts the first dual-write single-read state, and the first dual-write single-read state is used to indicate that data is written to the source database and the target database corresponding to the target service through the target data server, and data is read from the source database. When it is determined that the data write operation for the target database is performed normally, the target data server 104 switches from the first dual-write single-read state to the second dual-write single-read state, and the second dual-write single-read state is used to indicate that data is written to the source database and the target database through the target data server, and data is read from the target database. And, when it is determined that the data write operation for the target database is performed normally, the data in the source database is consistent with the data in the target database. When it is determined that the data write operation and the data read operation for the target database are both performed normally, the target data server 104 switches from the second dual-write single-read state to the second single-write single-read state, and the second single-write single-read state is used to indicate that data is read and written from the target database through the target data server.
[0045] In one embodiment, Figure 2 As shown, a database migration method is provided, which is applied to Figure 1 The target data server in the example is used as an example to illustrate the process, including the following steps:
[0046] Step S202, for the database migration of the target service, start the first dual-write single-read state of the target data server corresponding to the target service; the first dual-write single-read state is used to indicate writing data to the source database and target database corresponding to the target service through the target data server, and reading data from the source database.
[0047] The target service refers to the data service for which the database is to be migrated. The data service refers to the service that requires data reading and writing, and the data service can be a variety of services such as security services and application services.
[0048] The target data server corresponding to the target service is a server for accessing the database corresponding to the target service. The source database corresponding to the target service refers to the old database corresponding to the target service. The target database corresponding to the target service refers to the new database corresponding to the target service. Database migration for the target service includes migrating the data corresponding to the target service from the old database to the new database.
[0049] It can be understood that during database migration, each data service has its own corresponding target data server, source database and target database.
[0050] The first dual-write single-read state of the target data server is a database read-write state of the target data server. The first dual-write single-read state refers to writing data to the corresponding source database and target database through the target data server, and reading data from the source database. That is, if the target data server is in the first dual-write single-read state, during the operation of the target service, the data that needs to be written to the database will be written to the source database and the target database respectively, and the data that needs to be read from the database will be read from the source database. For example, if the target service is a game service, during the operation of the game service, it is necessary to query historical game match data for data analysis or data display, and it is necessary to store current game match data for subsequent data analysis or data query. If the target data server is in the first dual-write single-read state, and the source database stores complete game data, when querying historical game match data, the target data server reads historical game match data from the source database, and when storing current game match data, the target data server writes the current game match data generated in real time into the source database and the target database respectively.
[0051] Specifically, the goal of database migration for the target service is to read and write data from the target database corresponding to the target service through the target data server corresponding to the target service. In order to perform database migration without affecting the operation of the target service, the database read and write status for the target service is controlled, and the old database is gradually switched to the new database through state switching.
[0052] When performing database migration for the target service, for the target data server corresponding to the target service, first start the first dual-write single-read state, write the data that needs to be written to the database during the operation of the target service to the source database and the target database respectively, and read the data that needs to be read from the database during the operation of the target service from the source database. It can be understood that the source database is the old database, and the target service reads and writes data from the old database before the database migration. After starting the database migration, data is still read and written from the old database to ensure the operation of the target service, and the data is synchronously written to the new database.
[0053] In one embodiment, the first dual-write single-read state corresponding to the target data server may be actively started by the target data server, for example, when a preset condition is met, the target data server automatically starts the first dual-write single-read state. The first dual-write single-read state corresponding to the target data server may also be passively started by the target data server, for example, an operation and maintenance personnel sends a start instruction for the first dual-write single-read state to the target data server through a terminal, and the target data server responds to the start instruction for the first dual-write single-read state and starts the first dual-write single-read state.
[0054] Step S204, when it is determined that the data write operation to the target database is executed normally, switch from the first dual-write single-read state to the second dual-write single-read state; the second dual-write single-read state is used to indicate writing data to the source database and the target database through the target data server, and reading data from the target database; when it is determined that the data write operation to the target database is executed normally, the data in the source database and the data in the target database are consistent.
[0055] The data writing operation for the target database refers to the operation of the target data server writing data to the target database. In the first dual-write single-read state, the target data server needs to write data to the target database. If no abnormality occurs when the target data server writes data to the target database, that is, the target data server performs the data writing operation for the target database normally, then the state is switched from the first dual-write single-read state to the second dual-write single-read state.
[0056] The second dual-write single-read state of the target data server is a database read-write state of the target data server. The second dual-write single-read state refers to writing data to the corresponding source database and target database through the target data server, and reading data from the target database. That is, if the target data server is in the second dual-write single-read state, during the operation of the target service, the data that needs to be written to the database is written to the source database and the target database respectively, and the data that needs to be read from the database is read from the target database.
[0057] It can be understood that when it is determined that the target data server executes the data write operation on the target database normally, the data in the target database is consistent with the data in the source database, thereby switching to the second dual-write and single-read state, and the data that needs to be read from the database during the operation of the target service can be successfully read.
[0058] For example, if the target service is a game service, when it is determined that the target data server's data write operation on the target database is executed normally, the target database and the source database store the same game data, that is, the target database stores complete game data. If the target data server is in the second double-write single-read state, then when querying historical game match data, the target data server reads the historical game match data from the target database, and when storing current game match data, the target data server writes the current game match data generated in real time into the source database and the target database respectively.
[0059] Specifically, the source database is an old database that stores all the data, and the target database is a new database. In the first dual-write single-read state, in addition to reading and writing data from the source database to ensure the normal operation of the target service, the target data server also needs to write data to the target database. When it is determined that the target data server performs data writing operations on the target database normally, the target data server switches from the first dual-write single-read state to the second dual-write single-read state. When it is determined that the target data server performs data writing operations on the target database normally, the source database and the target database store the same data, so the target database can also support the operation of the target service, so that in the second dual-write single-read state, the target data server reads data from the target database to ensure the normal operation of the target service.
[0060] Step S206, when it is determined that the data write operation and the data read operation for the target database are both executed normally, switch from the second dual-write single-read state to the second single-write single-read state; the second single-write single-read state is used to indicate reading and writing data from the target database through the target data server.
[0061] The data reading operation for the target database refers to the operation of the target data server reading data from the target database. In the second dual-write single-read state, the target data server needs to read and write data from the target database. If no abnormality occurs when the target data server writes data to the target database or reads data from the target database, that is, the target data server performs both the data writing operation and the data reading operation for the target database normally, then the state is switched from the second dual-write single-read state to the second dual-write single-read state.
[0062] The second single-write single-read state of the target data server is a database read-write state of the target data server. The second single-write single-read state refers to reading and writing data to the corresponding target database through the target data server. That is, if the target data server is in the second single-write single-read state, then during the operation of the target service, the data that needs to be written to the database will be written to the target database, and the data that needs to be read from the database will be read from the target database. For example, for game services, if the target data server is in the second single-write single-read state, when storing the current game match data, the target data server will write the current game match data generated in real time into the target database, and when querying historical game match data, the target data server will read the historical game match data from the target database.
[0063] Specifically, the source database is an old database, and the target database is a new database. In the second dual-write single-read state, the target data server needs to write data to the source database in addition to reading and writing data from the target database, to ensure that the source database always stores all the data, so that when an exception occurs in the database migration, it can promptly restore the reading and writing of data from the source database to ensure the normal operation of the target service. When it is determined that the target data server performs both the data writing operation and the data reading operation on the target database normally, the target data server switches from the second dual-write single-read state to the second single-write single-read state, thereby completely switching to reading and writing data from the target database.
[0064] In the above database migration method, for the database migration of the target service, in the target data server, the read and write state of the database is controlled, and the read and write of the service is gradually switched from the source database to the target database through the state switching, so that the database migration can be performed without affecting the normal operation of the target service, and the migration without downtime is realized, which effectively improves the efficiency of database migration. It can be understood that the first double-write single-read state is started first, and the data is written to the source database and the target database at the same time, and the data is read from the source database as usual to ensure that the service operation is not affected. When it is determined that the target data server can write data to the target database normally, it is switched to the second double-write single-read state, and the data is still written to the source database and the target database at the same time. At this time, the data is read from the target database. Because the data write operation for the target database is executed normally, the service operation is still not affected. When it is determined that the target data server can read and write data from the target database normally, it is switched to the second single-write single-read state. At this time, the data is completely read and written from the target database. Because the data write operation and data read operation for the target database are executed normally, the service operation is still not affected.
[0065] In one embodiment, starting a first dual-write single-read state of a target data server corresponding to a target service includes:
[0066] Establish connections between the target data server corresponding to the target service and the source database and target database corresponding to the target service respectively; after the connections between the target data server and the source database and target database are stable, start the first dual-write single-read state of the target data server corresponding to the target service.
[0067] Among them, the source data server corresponding to the target service is also a server used to access the database corresponding to the target service. The source database corresponding to the target service refers to the old database corresponding to the target service. The target database corresponding to the target service refers to the new database corresponding to the target service. Similarly, the source data server corresponding to the target service refers to the old data server corresponding to the target service, and the target data server corresponding to the target service refers to the new data server corresponding to the target service. Database migration for the target service includes migrating the data corresponding to the target service from the old database to the new database, and migrating from reading data from the old database through the old data server to reading and writing data from the new database through the new data server.
[0068] It can be understood that each data service has its own corresponding source data server. Before the database migration, the source data server communicates with the source database, and the target service reads and writes data from the source database through the source data server.
[0069] Before starting the first dual-write single-read state, the source data server corresponding to the target service is in a first single-write single-read state. The first single-write single-read state is used to indicate reading and writing data from the source database through the source data server. The first single-write single-read state of the source data server is a database read and write state of the source data server. The first single-write single-read state refers to reading and writing data to the corresponding source database through the source data server. That is, if the source data server is in the first single-write single-read state, then during the operation of the target service, the data that needs to be written to the database will be written to the source database, and the data that needs to be read from the database will be read from the source database. For example, for a game service, if the source data server is in the first single-write single-read state, then when storing the current game match data, the source data server will write the current game match data generated in real time into the source database, and when querying historical game match data, the source data server will read the historical game match data from the source database.
[0070] Specifically, before the database migration, the source data server corresponding to the target service is in the first single-write single-read state. In order to migrate from reading data from the old database through the old data server to reading and writing data from the new database through the new data server, the target data server corresponding to the target service is first deployed, and the target data server corresponding to the target service establishes communication connections with the source database and the target database corresponding to the target service respectively. After the target data server and the source database and the target database are all connected stably, the target data server starts the first dual-write single-read state.
[0071] It can be understood that when deploying the target data server, the server addresses of the servers where the source database and the target database are located can be stored in the target data server, so that the target data server can establish a communication connection with the source database based on the server address of the server where the source database is located, and establish a communication connection with the target database based on the server address of the server where the target database is located.
[0072] refer to Figure 3 Before starting the database migration, the source data server corresponding to the target service is in the first single-write single-read state. During the operation of the target service, data is read and written from the source database through the source data server. After starting the database migration, the source data server is suspended, the target data server corresponding to the target service is enabled, and the first dual-write single-read state of the target data server is started. During the operation of the target service, data is read from the source database through the target data server and data is written to the source database and the target database. After starting the first dual-write single-read state, monitor whether the target data server can write data to the target source database normally. After determining that the target data server can write data to the target database normally and successfully, and the data in the target database is consistent with the data in the source database, the target data server switches from the first dual-write single-read state to the second dual-write single-read state. During the operation of the target service, data is read from the target database through the target data server and data is written to the source database and the target database. After starting the second dual-write single-read state, monitor whether the target data server can read and write data from the target source database normally. After determining that the target data server can normally and successfully read and write data from the target database, the target data server switches from the second dual-write single-read state to the second single-write single-read state. During the operation of the target service, data is read and written from the target database through the target data server, and the communication connection between the target data server and the source database is cut off.
[0073] In the above embodiment, connections are first established between the target data server corresponding to the target service and the source database and the target database corresponding to the target service, respectively. After the connections between the target data server and the source database and the target database are stable, the first dual-write and single-read state of the target data server corresponding to the target service is started, which can ensure stable and successful startup of the first dual-write and single-read state.
[0074] In one embodiment, the database migration method further includes:
[0075] Before starting the first dual-write single-read state, obtain the initial full data exported from the source database, and before switching to the first dual-write single-read state, import the initial full data into the target database; after starting the first dual-write single-read state, obtain the incremental data generated from exporting the initial full data to starting the first dual-write single-read state, and write the incremental data into the target database.
[0076] The initial full data refers to the full data exported from the source database before the first dual-write single-read state is started. The full data of the database refers to all the data in the database. The incremental data refers to the newly generated data.
[0077] Specifically, before database migration, the target service reads and writes data from the source database, so complete data is stored in the source database. In order to perform database migration, before starting the first dual-write single-read state of the target data server, first export the full data in the source database, and export the full data from the source database as the initial full data through the data export tool. Before switching to the first dual-write single-read state, the target data server obtains the initial full data, and imports the initial full data into the target database through the data import tool, so that the target database holds the full data of the source database before starting the first dual-write single-read state. After exporting the initial full data, because the target service is still running, data that needs to be written to the database corresponding to the target service may be generated. In order to ensure the integrity of the data in the target database, after starting the first dual-write single-read state, the target data server needs to obtain the data that needs to be written to the database corresponding to the target service generated in the process from exporting the initial full data to starting the first dual-write single-read state as incremental data, and write the incremental data into the target database.
[0078] In one embodiment, before starting the first dual-write single-read state, the target service may read and write data from the source database through the source data server. Therefore, before starting the first dual-write single-read state, the source data server may export the initial full data from the source database through a data export tool. The target data server may obtain the exported initial full data directly from the source data server, or obtain the exported initial full data from the source data server through an intermediate device.
[0079] In the above embodiment, before starting the first dual-write single-read state, the initial full data exported from the source database is obtained, and before switching to the first dual-write single-read state, the initial full data is imported into the target database, and after starting the first dual-write single-read state, the incremental data generated from exporting the initial full data to starting the first dual-write single-read state is obtained, and the incremental data is written to the target database, so that the target database can hold the same data as the source database.
[0080] In one embodiment, when it is determined that the data write operation to the target database is performed normally, switching from the first dual-write single-read state to the second dual-write single-read state includes:
[0081] After determining that the incremental data in the target database is consistent with the incremental data in the source database, the first dual-write single-read state is switched to the second dual-write single-read state.
[0082] The incremental data in the source database is written in real time based on the data write request for the target service during the process from exporting the initial full data to starting the first dual-write single-read state. Before starting the first dual-write single-read state, the target service reads and writes data from the source database, and the data that needs to be stored during the operation of the target service is written to the source database in real time. When data that needs to be stored is generated, a data write request is generated to request that the generated data be written to the source database.
[0083] It can be understood that the incremental data in the source database is written in real time, and the incremental data in the target database is written once.
[0084] Specifically, after starting the first dual-write single-read state, the target data server obtains the incremental data generated from exporting the initial full data to starting the first dual-write single-read state, and writes the incremental data to the target database, while the incremental data in the source database is written in real time from exporting the initial full data to starting the first dual-write single-read state. The incremental data in the source database is used as a benchmark to compare the incremental data in the target database with the incremental data in the source database. If the incremental data in the target database is consistent with the incremental data in the source database, it means that after starting the first dual-write single-read state, the incremental data generated from exporting the initial full data to starting the first dual-write single-read state can be successfully written to the target database, indicating that the data write operation of the target data server for the target database is executed normally and successfully, indicating that there is no abnormality in the data write function of the target data server for the target database, so the target data server can switch from the first dual-write single-read state to the second dual-write single-read state.
[0085] In one embodiment, when the incremental data in the target database is inconsistent with the incremental data in the source database, the target data server can adjust the incremental data in the target database based on the incremental data in the source database, with the purpose of adjusting the incremental data in the target database to be consistent with the incremental data in the source database. For example, write the data missing in the target database to the target database. If the adjustment is successful to be consistent, the target data server is switched from the first dual-write single-read state to the second dual-write single-read state. If it cannot be adjusted to be consistent, the first dual-write single-read state is maintained or rolled back to the first single-read single-write state. When it cannot be adjusted to be consistent, the operation and maintenance personnel can check the target data server and the target database, locate the problem, and fix the problem.
[0086] In the above embodiment, the incremental data in the source database is written in real time from the process of exporting the initial full data to starting the first dual-write single-read state, and the incremental data in the target database is written once after starting the first dual-write single-read state by obtaining the incremental data generated in the process of exporting the initial full data to starting the first dual-write single-read state. If the incremental data in the target database is consistent with the incremental data in the source database, it can be indicated that the write function of the target data server for the target database is normal. Further, before switching to the first dual-write single-read state, the initial full data in the source database is imported into the target database, so that the target database and the source database have the same initial full data. If the incremental data in the target database is also consistent with the incremental data in the source database, it can be indicated that the target database and the source database have the same data. In this case, switching the target data server from the first dual-write single-read state to the second dual-write single-read state can ensure that during the operation of the target service, even if the target data server is in the second dual-write single-read state, if the target service has a need to read data, the target data server can also read the correct data.
[0087] In one embodiment, the database migration method further includes:
[0088] In the process of starting the first single-write single-read state and switching to the second single-write single-read state, the data in the source database and the data in the target database are compared regularly, and the difference data missing from the target database is supplemented and written into the target database according to the comparison result.
[0089] Specifically, the source database is an old database that stores complete data required by the target service. The target database is a new database. Before completely migrating to the new database, the data in the source database and the data in the target database are regularly compared. Once it is found that the target database is missing data, the missing difference data in the target database is supplemented and written into the target database, thereby ensuring the data consistency between the source database and the target database.
[0090] In the above embodiment, in the process of starting the first single-write single-read state and switching to the second single-write single-read state, the data in the source database and the data in the target database are compared regularly, and the difference data missing from the target database is supplemented and written into the target database according to the comparison result, thereby ensuring the data consistency between the source database and the target database and ensuring the accuracy of database migration.
[0091] In one embodiment, when it is determined that the data writing operation and the data reading operation on the target database are both performed normally, switching from the second dual-write single-read state to the second single-write single-read state includes:
[0092] After determining that the target service runs normally in the second dual-write single-read state and the current full data in the target database is consistent with the current full data in the source database, switch from the second dual-write single-read state to the second single-write single-read state.
[0093] The current full data refers to the full data in the database at the current time. The current time may refer to the time when the target service runs normally in the second dual-write single-read state.
[0094] Specifically, after switching to the second dual-write single-read state, monitor the operation of the target service in the second dual-write single-read state. If the operation is normal and stable, it means that the target data server can read and write data from the target database normally. When it is determined that the target service is operating normally in the second dual-write single-read state, if the current full data in the target database is consistent with the current full data in the source database, it means that the target database stores the complete data required by the target service, and the reading and writing of the target database can be performed normally, so that the target data server can switch from the second dual-write single-read state to the second single-write single-read state, and completely read and write data from the target database.
[0095] It can be understood that monitoring indicators for the target service can be set in advance, and the values of the monitoring indicators can be observed during the operation of the target service. When the target data server is in the second dual-write single-read state, if the values of the monitoring indicators are within the preset range or tend to be stable, it is determined that the target service is operating normally in the second dual-write single-read state.
[0096] In the above embodiment, after determining that the target service is operating normally in the second dual-write single-read state and the current full data in the target database is consistent with the current full data in the source database, switching from the second dual-write single-read state to the second single-write single-read state can ensure that the target service can read and write data normally in the second single-write single-read state, and ensure the normal operation of the target service after database migration.
[0097] In one embodiment, the database migration method further includes:
[0098] When the fluctuation trend of the service quality curve corresponding to the target service in the second dual-write single-read state is a preset stable trend, it is determined that the target service operates normally in the second dual-write single-read state.
[0099] Among them, the service quality curve is a curve reflecting the service quality. Monitoring indicators for the target service can be pre-set, and during the operation of the target service, the values of the monitoring indicators are observed, and the service quality curve is generated based on the observation results. The service quality curve is a curve indicating that the values of the monitoring indicators change over time. The service quality curve includes at least one of a first curve corresponding to the data dimension and a second curve corresponding to the hardware dimension. The first curve is used to indicate the execution of the target service for data reading and writing during operation. For example, the first curve can be the success rate of the target service reading data from the corresponding database during operation, and the first curve can be the success rate of the target service writing data to the corresponding database during operation; the first curve can be the timeout rate of the target service reading data from the corresponding database during operation, and the first curve can be the timeout rate of the target service writing data to the corresponding database during operation; and so on. The second curve is used to indicate the occupation of the hardware resources of the target service during operation. For example, the second curve can be the occupancy rate of the CPU of the target data server during operation of the target service; the second curve can be the occupancy rate of the memory of the target data server during operation of the target service; and so on.
[0100] The fluctuation trend of the service quality curve refers to the fluctuation trend of the value of the monitoring indicator over time. The preset stable trend refers to a pre-set fluctuation trend indicating the stability of the value of the monitoring indicator. It can be understood that in the service quality curve, if the value of the monitoring indicator fluctuates violently over time, it means that the operation of the target service is unstable. If the operation of the target service is unstable, it is considered that the target service is not operating normally. In the service quality curve, if the value of the monitoring indicator fluctuates slightly over time and tends to be stable, it means that the operation of the target service is stable. If the operation of the target service is stable, it is considered that the target service is operating normally.
[0101] Specifically, the operation status of the target service in the second dual-write single-read state can be reflected by the service quality curve corresponding to the target service in the second dual-write single-read state. If the fluctuation trend of the service quality curve corresponding to the target service in the second dual-write single-read state is a preset stable trend, it can be determined that the target service is operating normally in the second dual-write single-read state.
[0102] In the above embodiment, the service quality curve includes at least one of a first curve corresponding to the data dimension and a second curve corresponding to the hardware dimension. The first curve and the second curve can reflect the running stability of the service from different angles, which helps to improve the accuracy of judging whether the service is running normally. The fluctuation trend of the service quality curve corresponding to the target service in the second dual-write single-read state is a preset stable trend, indicating that the target service is running stably in the second dual-write single-read state. In this case, switching from the second dual-write single-read state to the second single-write single-read state can ensure the security and stability of database migration.
[0103] In one embodiment, the database migration method further includes:
[0104] During the database migration process, if an abnormality is detected in the database migration, the state switching is suspended or rolled back to the preset state until the database migration returns to normal, and then the state switching is resumed or continued from the preset state.
[0105] Among them, pausing state switching means temporarily stopping the switching of database read-write state, and temporarily not switching to the next database read-write state. Resuming state switching means resuming the switching of database read-write state, and if the corresponding conditions are currently met, switching to the next database read-write state.
[0106] Rolling back to the preset state means restoring the current database read-write state to the previous preset state. The preset state can be set according to actual needs. For example, the preset state can be the previous database read-write state of the current database read-write state; the preset state can be the first single-write single-read state. Continuing state switching from the preset state means starting from the preset state, and switching to the next database read-write state if the corresponding conditions are currently met.
[0107] Specifically, during the database migration process, the database migration is monitored in real time or on demand to see if there is an abnormality. Once an abnormality is detected in the database migration, the state switching is suspended until the database migration is detected to be back to normal, and the state switching is resumed. Alternatively, once an abnormality is detected in the database migration, it is rolled back to a preset state until the database migration is detected to be back to normal, and the state switching is continued from the preset state.
[0108] It can be understood that database migration exceptions specifically refer to database read and write exceptions.
[0109] In the above embodiment, during the database migration process, if an abnormality is detected in the database migration, the state switching is promptly suspended or rolled back to the preset state, which can reduce or avoid the loss caused by the abnormality in the database migration. After monitoring that the database migration has returned to normal, the state switching is promptly restored or the state switching is continued from the preset state to continue executing the database migration.
[0110] In one embodiment, the database migration for the target service includes migrating the data corresponding to the target service from the old database to the new database, and migrating from reading data from the old database through the old data server to reading and writing data from the new database through the new data server. Figure 4Before database migration, prepare data export tools, data import tools, and data detection and verification tools. The data export tool is used to export the old data (i.e., the initial full data) in the old database, and the data import tool is used to import the exported old data into the new database. Before database migration, the new data server needs to be deployed, the new database needs to be deployed, the monitoring alarm is fully in place, the test environment is prepared and the drill is completed, and an abnormal situation plan is prepared. For the database migration of the target service, the read and write of the target service needs to be switched from the old data server to the new data server, and the old data in the old database needs to be fully exported. During the database migration process, control the database read and write status, and gradually switch from reading data from the old database through the old data server to reading and writing data from the new database through the new data server through the switching of four states. In the middle, it will be necessary to import old data, supplement incremental data, and supplement differential data to ensure high data consistency. During the database migration process, when an exception occurs, you can stop switching or roll back at any time. If no exception occurs, you do not need to stop switching or roll back.
[0111] refer to Figure 5 Before starting the database migration, the old data server exports the old data from the old database through the data export tool. After starting the database migration, enter the first single-write single-read state first, or read the data from the old database through the old data server first. Then, decouple the old data server, switch from the old data server to the new data server, and establish connections between the new data server and the old database and the new database. After the connection is stable, switch to the first dual-write single-read state, write data to the new and old databases through the new data server, read data from the old database, and supplement and update the incremental data generated from exporting the old data to starting the first dual-write single-read state to the new database. After determining that the incremental data in the new database is consistent with the incremental data in the old database, switch to the second dual-write single-read state, write data to the new and old databases through the new data server, and read data from the new database. After determining that the data in the new and old databases are consistent and the target service is stable, switch to the second single-write single-read state, cut off the link to write to the old database, and completely switch to reading and writing data from the new database. In the first dual-write single-read state, the second dual-write single-read state, and the second single-write single-read state, the data consistency check between the new and old databases is performed regularly, and the difference parts are supplemented and updated to the new database. Later, the data in the new database can be further verified to ensure the operation of the target service.
[0112] In this way, by switching between the four states, the database migration can be efficiently implemented during the operation of the target service, that is, the database can be efficiently migrated without stopping the service. During the migration process, the user's normal access to the target service is not affected, and the user is unaware of the database migration of the target service.
[0113] In one embodiment, the target service is any one of the data services corresponding to the various value-added functions provided by the public access platform; the public access platform is used to support the target application to access the login channel set, so that the target application supports account login using each login channel in the login channel set; the value-added functions provided by the public platform are used to increase the application functions of the target application based on the login channel set in addition to the application functions provided by the target application itself; the database corresponding to the data service is used to store the account data of the target application's login account in the target application for the value-added functions.
[0114] Among them, the public access platform is a public platform that helps the target application access the login channel set, and is used to support the target application to access the login channel set, so that the target application supports the use of each login channel in the login channel set for account login. It can be understood that the login channel set includes at least one login channel, and a login channel represents a login method, and different login channels correspond to different login platforms. For example, if the login platform corresponding to login channel 1 is social application A, the public access platform is used to support the target application to access login channel 1, so that the target application can use social application A for account login, and the user can use the account in social application A to log in to the account in the target application; if the login platform corresponding to login channel 2 is social application B, the public access platform is used to support the target application to access login channel 2, so that the target application can use social application B for account login, and the user can use the account in social application B to log in to the account in the target application. The public access platform links the login platform corresponding to the target application and the login channel, so that the target application can quickly and conveniently access the login platform corresponding to the login channel, so that the target application can use the login capability corresponding to the login channel.
[0115] The target application is an application that needs to use the login capability corresponding to the login channel. The target application can be selected as needed. For example, the target application can be a game application, which uses the login capability corresponding to the login channel by accessing the public access platform; the target application can be a music application, which uses the login capability corresponding to the login channel by accessing the public access platform.
[0116] The application function provided by the target application itself refers to the application function independently provided by the target application itself. The application function provided by the target application itself is generally the main application function of the target application. For example, if the target application is a game application, the application function provided by the game application itself is the game function; if the target application is a music application, the application function provided by the music application itself is the music function.
[0117] In order to enrich the application functions of the target application, the target application can also use various value-added functions provided by the public access platform by accessing the public access platform. The value-added functions provided by the public platform are used to increase the application functions of the target application and enrich the application functions of the target application based on the login channel set in addition to the application functions provided by the target application itself. The value-added functions provided by the public platform are used to associate the target application with the login platform corresponding to the login channel. For example, the value-added function can be a login function, and the target application can use the corresponding login channel to log in to the account by accessing the public access platform; the value-added function can be a sharing function, and the target application can share the information in the target application to the login platform corresponding to the corresponding login channel by accessing the public access platform; the value-added function can be a friend function, and the target application can add friends in the target application to the login platform corresponding to the corresponding login channel by accessing the public access platform, thereby adding friends in the target application as friends in the login platform.
[0118] The database corresponding to the data service corresponding to the value-added function is used to store the account data of the target application's login account in the target application related to the value-added function. For example, for the login function, the corresponding database is used to store the login information of the target application's login account in the target application, and the login information may include login device information, login time information, etc.; for the sharing function, the corresponding database is used to store the sharing information of the target application's login account in the target application, and the sharing information may include sharing content, sharing tags, etc.
[0119] Specifically, the method of the present application can be applied to a public access platform. When the data service corresponding to the value-added function provided by the public access platform requires database migration, the database read and write status is switched by controlling the switching of the old database to the new database, thereby achieving efficient migration without downtime. During the migration process, the user's normal use of the value-added function through the target application is not affected, and the user is unaware.
[0120] In one embodiment, reference Figure 6The system architecture of the public access platform includes a router server, a logic server, a data server, and a database (DB). When a user accesses a target application in a terminal, a data processing request for the target service is generated in the process of accessing the target application. The router server is used to route the data processing request sent by the terminal to the logic server corresponding to the corresponding data service. The logic server is used to perform logical processing on the data processing request, obtain a data read and write request, and send the data read and write request to the corresponding data server. The logic server is also used to return the data read by the data server to the terminal through the router server. The data server is used to process operations related to the database, including reading, writing, and other interactive operations related to the database. The database is used to store relevant data of the user in the target application. It can be understood that each data service provided by the public access platform has a corresponding logic server, each logic server has a corresponding data server, and each data server has a corresponding database.
[0121] For the public access platform, when performing database migration, the data is mainly controlled by upgrading and switching the data server from the source database to the target database. The migration process is non-stop to ensure high data consistency and high service availability. Figure 7Before database migration, the logical server communicates with the old data server, and the database read-write state is the first single-write single-read state. For the data read-write request sent by the logical server, the old data server reads and writes data from the old database. After the database migration is started, the first single-write single-read state can be maintained. At the same time, the old data server exports the old data from the old database, the logical server establishes a communication connection with the new data server, and the new data server establishes a communication connection with the old database and the new database. After the connection is stable, the logical server no longer communicates with the old data server, and the logical server communicates with the new data server. The database read-write state is switched to the first dual-write single-read state. For the data read-write request sent by the logical server, the new data server reads and writes data from the old database, and the new data server also synchronously writes the data to the new database. At the same time, the new data server imports the old data obtained from the old data server into the new database. After the incremental data in the old database is consistent with the incremental data in the new database, the database read-write state is switched to the second dual-write single-read state. For the data read-write request sent by the logical server, the new data server reads and writes data from the new database, and the new data server also synchronously writes the data to the old database. After the data in the old database is consistent with the data in the new database and the data service is stable, the database read-write state is switched to the second dual-write single-read state. In response to the data read-write requests sent by the logical server, the new data server reads and writes data from the new database. All data reads and writes are completely switched to the new database, and the new data server disconnects from the old database.
[0122] It can be understood that the new and old databases can adopt a master-slave mode database, which includes a master database and a slave database. The master database is used to handle all read and write operations, and the slave database is used as a backup of the master database to provide data recovery and disaster recovery capabilities when the master database fails. For a master-slave mode database, data synchronization is performed regularly between the master database and the slave database.
[0123] In one embodiment, the database may be a KV database (Key-value database), which is a database that stores data in key-value pairs.
[0124] In one embodiment, Figure 8 As shown, a database migration system is provided, which includes a target data server 802 corresponding to a target service, a source database 804, and a target database 806.
[0125] The target data server is used to migrate the database of the target service and start the first dual-write single-read state of the target data server corresponding to the target service. In the first dual-write single-read state, the source database and the target database are used to respond to the data write operation sent by the target data server, and the source database is also used to respond to the data read operation sent by the target data server.
[0126] The target data server is further configured to switch from the first dual-write single-read state to the second dual-write single-read state when it is determined that the data write operation to the target database is executed normally; when it is determined that the data write operation to the target database is executed normally, the data in the source database and the data in the target database are consistent. In the second dual-write single-read state, the source database and the target database are configured to respond to the data write operation sent by the target data server, and the target database is further configured to respond to the data read operation sent by the target data server.
[0127] The target data server is further configured to switch from the second dual-write single-read state to the second single-write single-read state when determining that the data write operation and the data read operation for the target database are both executed normally. In the second single-write single-read state, the target database is configured to respond to the data write operation and the data read operation sent by the target data server.
[0128] Specifically, in order to perform database migration without affecting the operation of the target service, the database read and write state for the target service is controlled, and the state is switched from the old database to the new database step by step. When performing database migration for the target service, for the target data server corresponding to the target service, the first double-write single-read state is first started, and the data that needs to be written to the database generated during the operation of the target service is written to the source database and the target database respectively, and the data that needs to be read from the database during the operation of the target service is read from the source database. It can be understood that the source database is an old database, and the target service reads and writes data from the old database before the database migration. After starting the database migration, data is still read and written from the old database to ensure the operation of the target service, and the data is synchronously written to the new database. When it is determined that the target data server performs the data write operation for the target database normally, the target data server switches from the first double-write single-read state to the second double-write single-read state. When it is determined that the data write operation of the target data server for the target database is performed normally, the data stored in the source database and the target database are the same, so the target database can also support the operation of the target service, so that in the second double-write single-read state, the target data server reads data from the target database to ensure the normal operation of the target service. When it is determined that the target data server performs both data write operations and data read operations on the target database normally, the target data server switches from the second dual-write single-read state to the second single-write single-read state, thereby completely switching to reading and writing data from the target database.
[0129] The above database migration system controls the read and write state of the database for the target service in the target data server, and gradually switches the read and write of the service from the source database to the target database through the state switching, so that the database migration can be performed without affecting the normal operation of the target service, realizing non-stop migration, and effectively improving the efficiency of database migration. It can be understood that the first double-write single-read state is started first, and the data is written to the source database and the target database at the same time, and the data is read from the source database as usual to ensure that the service operation is not affected. When it is determined that the target data server can write data to the target database normally, it is switched to the second double-write single-read state, and the data is still written to the source database and the target database at the same time. At this time, the data is read from the target database. Because the data write operation for the target database is executed normally, the service operation is still not affected. When it is determined that the target data server can read and write data from the target database normally, it is switched to the second single-write single-read state. At this time, the data is completely read and written from the target database. Because the data write operation and data read operation for the target database are executed normally, the service operation is still not affected.
[0130] In one embodiment, Fig. 9As shown, the database migration system also includes a logic server 902 and a source data server 904 corresponding to the target service.
[0131] The logical server is used to receive data processing requests for the target service during the operation of the target service, perform logical processing on the data processing requests, obtain data read and write requests, and send the data read and write requests to the current data server corresponding to the target service; the current data server is the target data server or the source data server.
[0132] The current data server is also used to respond to data read and write requests, read and write data from the database corresponding to the current read and write status, and return the read and write results to the logic server.
[0133] The data processing request for the target service refers to the data processing request generated by triggering the target service. For example, if the target service is a data service corresponding to a login function, the data processing request may be a login request; if the target service is a data service corresponding to a sharing function, the data processing request may be a sharing request.
[0134] The logical server corresponding to the target service is a server used to perform logical processing on the data processing request for the target service. Logical processing can be judgment, verification, calculation and other processing to determine whether it is necessary to read and write data from the database. For example, if the data processing request is a login request, the logical processing can be to determine whether it is the first login. If it is the first login, it is necessary to record the current login information carried by the login request. If it is not the first login, it is necessary not only to record the current login information, but also to query the historical login information. The logical processing can also verify whether the login is successful or perform other login-related processing. If the data processing request is a sharing request, the logical processing can be to determine whether the sharing object is an active user. If it is an active user, it is necessary to query the sharing template for the active user. If it is an inactive user, it is necessary to query the sharing template for the inactive user.
[0135] The logic server performs logic processing on the received data processing request to determine whether data needs to be read from the database or written to the database, thereby obtaining a data read / write request. The data read / write request includes at least one of a data read request and a data write request. It can be understood that if the data read / write request is a data read request, the read / write result is the read data, and if the data read / write request is a data write request, the read / write result is the data write result.
[0136] The source data server corresponding to the target service refers to the old data server corresponding to the target service.
[0137] Specifically, during the operation of the target service, when a user accesses and triggers the target service through a terminal, a data processing request for the target service is generated, and the terminal sends the data processing request for the target service to the logic server corresponding to the target service. The logic server performs logic processing on the data processing request, obtains a data read / write request, and sends the data read / write request to the current data server corresponding to the target service. The current data server responds to the received data read / write request, reads and writes data from the database corresponding to the current read / write state, and returns the read / write result to the logic server.
[0138] For example, if the target service is a data service corresponding to the login function, the data processing request may be a login request. After receiving the login request, the logic server determines whether the login can be successful. If the login can be successful, it determines whether it is the first login. If it is the first login, it is necessary to record the current login information carried by the login request, generate a data write request carrying the current login information, send the data write request to the current data server, and the current data server writes the current login information into the database corresponding to the current read-write state. If it is not the first login, it is necessary not only to record the current login information, but also to query the historical login information, then generate a data write request carrying the current login information and a data read request for querying the historical login information, send the data write request and the data read request to the current data server, the current data server writes the current login information into the database corresponding to the current read-write state, and reads the historical login information from the database corresponding to the current read-write state. The current data server can notify the logic server whether the data is written successfully. The current data server can return the historical login information to the logic server, and the logic server can return the historical login information to the terminal. The terminal can perform further operations based on the historical login information, for example, information can be pushed based on the historical login information.
[0139] In one embodiment, there may be multiple logical servers corresponding to the target service. A load balancing algorithm may be used to determine the logical server currently receiving the data processing request from the multiple logical servers.
[0140] In the above embodiment, the logic server is used to perform logic processing, and the data server is used to read and write data. The logic server and the data server cooperate with each other to achieve stable operation of the target service.
[0141] In one embodiment, before the target data server starts the first dual-write single-read state, the current data server is the source data server, the source database, which is used to respond to data write operations and data read operations sent by the source data server; after the target data server starts the first dual-write single-read state, the current data server is the target data server.
[0142] The logical server is further used to establish a connection with the target data server based on a database migration startup notification for the target service, and to interrupt a connection with the source data server based on a startup notification for the first dual-write single-read state.
[0143] The database migration start notification refers to a message or instruction for notifying the start of database migration. The start notification for the first dual-write single-read state refers to a message or instruction for starting the first dual-write single-read state.
[0144] Specifically, before the target data server starts the first dual-write single-read state, the current data server is the source data server, the logical server communicates with the source data server, the source data server is in the first single-write single-read state, the logical server sends data read and write requests to the source data server, and the source data server reads and writes data from the source database.
[0145] After the target data server starts the first dual-write single-read state, the current data server is the target data server, the logical server communicates with the target data server, the logical server sends a data read and write request to the target data server, and the target data server reads and writes data from the database corresponding to the current read and write state.
[0146] Before starting the database migration, the logical server communicates with the source data server and reads and writes data from the source database through the source data server. If the database migration is started, the operation and maintenance personnel can send a database migration start notification to the logical server through the device, and the logical server establishes a connection with the target data server based on the database migration start notification to prepare for subsequent data reading and writing through the target data server. It can be understood that the database migration start notification can carry the server address of the target data server, and the logical server establishes a connection with the target data server based on the server address.
[0147] After starting the database migration, if the target data server starts the first dual-write single-read state, the source data server is temporarily ineffective, and the logical server can disconnect from the source data server in time. If the target data server starts the first dual-write single-read state, the operation and maintenance personnel can send a startup notification for the first dual-write single-read state to the logical server through the device, or the target data server sends a startup notification for the first dual-write single-read state to the logical server, and the logical server disconnects from the source data server based on the startup notification for the first dual-write single-read state.
[0148] In the above embodiment, during the database migration process, the logic server switches from connecting with the source data server to connecting with the target data server in a timely manner based on the corresponding notification, which helps to ensure that the database migration is performed without affecting the normal operation of the target service.
[0149] In one embodiment, Fig.10 As shown, the database migration system also includes a terminal 1002 corresponding to the target application and a routing server 1004 corresponding to the public access platform.
[0150] The public access platform is used to support the target application to access the login channel set, so that the target application supports account login using each login channel in the login channel set; the target service is any one of the data services corresponding to each value-added function provided by the public access platform.
[0151] The terminal is used to generate a data processing request for the target service based on a service triggering event for the target service in the target application, and send the data processing request to the routing server; the data processing request carries a service identifier corresponding to the target service.
[0152] The routing server is used to send data processing requests to the logic server based on the service identifier.
[0153] The terminal corresponding to the target application refers to a terminal that can access the target application, for example, the terminal has the target application installed. The target application uses the login capability corresponding to the login channel by accessing the public access platform. The public access platform provides multiple value-added functions for the target application. When the user accesses the target application through the terminal, the value-added function can be used as needed. If the user uses a value-added function, the terminal will generate a data processing request corresponding to the value-added function, and the data processing request carries the service identifier corresponding to the data service corresponding to the value-added function.
[0154] The target service is any one of the data services corresponding to each value-added function provided by the public access platform. The service trigger event for the target service in the target application refers to the event generated by triggering and using the value-added function corresponding to the target service in the target application. For example, if the value-added function is a login function, after the user opens the target application on the terminal, if the login operation is performed, a service trigger event for the data service corresponding to the login function is generated; if the value-added function is a sharing function, after the user opens the target application on the terminal and completes the login, if the sharing operation is performed, a service trigger event for the data service corresponding to the sharing function is generated.
[0155] The public access platform provides multiple value-added functions for the target application. The terminal will send each data processing request for the data service of the value-added function to the routing server corresponding to the public access platform. The routing server is used to route the data processing request sent by the terminal to the corresponding logical server based on the service identifier carried in the data processing request.
[0156] Specifically, the user can open the target application on the terminal and use the value-added functions provided by the public access platform for the target application in the target application. If the user uses the value-added functions corresponding to the target service, the terminal will generate a data processing request for the target service, and the data processing request carries the service identifier corresponding to the target service. The terminal sends the data processing request to the routing server corresponding to the public access platform. The routing server searches for the logical server corresponding to the target service based on the service identifier carried in the data processing request, and sends the data processing request to the logical server corresponding to the target service.
[0157] In the above embodiment, the public access platform provides multiple value-added functions for the target application. The terminal can generate data processing requests corresponding to the value-added functions on demand. The routing server corresponding to the public access platform routes the data processing requests sent by the terminal to the corresponding logic server for logical processing, which helps to ensure the stable operation of the data services corresponding to each value-added function and avoid interference between various data services.
[0158] In one embodiment, Fig.11 As shown, the database migration system also includes a service monitoring device 1102 .
[0159] A service monitoring device is used to collect a service feedback set for a target service after switching to a second single-write single-read state, and to generate a logout notification for a source data server corresponding to the target service when the proportion of positive feedback in the service feedback set is greater than a first preset proportion, and to generate a rollback notification for the second single-write single-read state when the proportion of negative feedback in the service feedback set is greater than a second preset proportion.
[0160] Among them, the service feedback set for the target service includes multiple service feedbacks for the target service. Service feedback refers to the feedback from users who use the target service on the target service. Service feedback is divided into positive feedback and negative feedback. Positive feedback is used to indicate that the target service runs normally, and negative feedback is used to indicate that the target service runs abnormally. For example, a service feedback collection window can be displayed to the user on the terminal, and the user can select positive feedback or negative feedback in the service feedback collection window; the user's comments on the target service can be obtained, and the comments can be semantically analyzed, and the comments can be divided into positive feedback or negative feedback according to the semantics of the comments.
[0161] It can be understood that the first preset ratio and the second preset ratio can be set according to actual needs.
[0162] Specifically, after switching to the second single-write single-read state, the target service continues to run, and the user can publish service feedback for the target service when using the target service. The service monitoring device collects a service feedback set for the target service, and determines whether most of the service feedback in the service feedback set is positive feedback or most of the service feedback is negative feedback. If the proportion of positive feedback in the service feedback set is greater than the first preset proportion, indicating that after switching to the second single-write single-read state, the target service is running normally, then the service monitoring device can generate a deregistration notification for the source data server corresponding to the target service, and send the deregistration notification to the device corresponding to the operation and maintenance personnel, so as to promptly notify the operation and maintenance personnel to deregister the source data server corresponding to the target service, thereby reducing or avoiding resource waste. If the proportion of negative feedback in the service feedback set is greater than the second preset proportion, indicating that after switching to the second single-write single-read state, the target service is running abnormally, then the service monitoring device can generate a rollback notification for the second single-write single-read state, and send the rollback notification to the target data server or the source data server, so as to roll back to the preset state in time, thereby helping the target service to quickly resume normal operation.
[0163] In the above embodiment, the service monitoring device can generate corresponding notifications in a timely manner according to the service feedback of the user on the target service, which can help the normal operation of the target service and reduce or avoid data waste.
[0164] In a specific embodiment, Fig.12 As shown, a database migration method is provided, which is applied to Figure 1 The target data server in the example is used as an example to illustrate the process, including the following steps:
[0165] Step S1202, obtaining the initial full amount of data exported from the source database corresponding to the target service.
[0166] Step S1204, establish connections between the target data server corresponding to the target service and the source database and target database corresponding to the target service respectively, and after the connections between the target data server and the source database and target database are stable, start the first dual-write single-read state of the target data server corresponding to the target service; before starting the first dual-write single-read state, the source data server corresponding to the target service is in a first single-write single-read state, and the first single-write single-read state is used to indicate reading and writing data from the source database through the source data server.
[0167] Step S1206, obtaining incremental data generated from exporting the initial full data to starting the first dual-write single-read state, and writing the incremental data into the target database.
[0168] Step S1208, after determining that the incremental data in the target database is consistent with the incremental data in the source database, switch from the first dual-write single-read state to the second dual-write single-read state; the incremental data in the source database is written in real time based on the data write request for the target service during the process of exporting the initial full data to starting the first dual-write single-read state.
[0169] Step S1210, after the fluctuation trend of the service quality curve corresponding to the target service in the second dual-write single-read state is a preset stable trend and the current full data in the target database is consistent with the current full data in the source database, switch from the second dual-write single-read state to the second single-write single-read state.
[0170] Step S1212, during the process of starting the first single-write single-read state and switching to the second single-write single-read state, the data in the source database and the data in the target database are periodically compared, and the difference data missing from the target database is supplemented and written into the target database according to the comparison result.
[0171] Step S1214, during the database migration process, when an abnormality is detected in the database migration, the state switching is suspended or rolled back to a preset state until the database migration returns to normal, and the state switching is resumed or continued from the preset state.
[0172] In a specific embodiment, during the database migration process, the method of the present application controls and adjusts the database read and write status of the data server to ensure that the existing network services are provided normally to the outside world, performs detailed data verification, ensures high data consistency, and ensures that external users are not affected.
[0173] refer to Fig.13 Before starting the database migration, you need to make corresponding preparations, including data export tool preparation, data import tool preparation, data detection and verification tool preparation, new data server deployment preparation, new database deployment preparation, rollback switch preparation, monitoring and alarm in place, test environment preparation and exercise completion.
[0174] After starting the database migration, we first enter the first single-write and single-read state. At this time, we still read and write data from the old database through the old data server. For the upper-layer services, the underlying database remains unchanged and does not affect user usage. We also use the data export tool to fully export the data in the old database, start grayscale switching of data servers, switch the old data server to the new data server, establish connections between the new data server and the old and new databases, and pay attention to the stability of the new data server.
[0175] After the new data server is stable, start switching the database read-write state from the first single-write single-read state to the first dual-write single-read state. At this time, write two copies of the data through the new data server and write them to the old database and the new database at the same time. At this time, the new data server still reads data from the old database to ensure that existing network users are not affected. And use the data import tool to import the exported old data into the new database, and add the incremental data generated from exporting the data to switching to the first dual-write single-read state to the new database. In the first dual-write single-read state, sort out the error data and record the known error data for subsequent supplementary recording. For example, the known error data can be data with known import timeouts or data with known write timeouts. In the first dual-write single-read state, perform cold standby data supplementation and divide the new database into a master database and a slave database.
[0176] After the incremental data in the new database is consistent with the incremental data in the old database, the database read-write state is switched from the first dual-write single-read state to the second dual-write single-read state. At this time, the data is still written in duplicate through the new data server, and written to the old database and the new database at the same time. At this time, the data is read from the new database through the new data server. In the second dual-write single-read state, the consistency of the data in the new and old databases is verified by the data detection and verification tool, and the difference is supplemented and written into the new database. In the second dual-write single-read state, the new service quality is paid attention to, and the fluctuation trend of the service quality curve corresponding to the data service in the second dual-write single-read state is paid attention to.
[0177] After the data in the new and old databases are completely consistent and the service is running normally, gradually cut off the writing work of the old database in grayscale, switch from the second dual-write single-read state to the second single-write single-read state, and switch all data reading and writing to the new database. In the second single-write single-read state, pay attention to the call curve, and pay attention to the service calls of multiple terminals to the data service in the second single-write single-read state, such as the success rate, for subsequent operation and maintenance. In the second single-write single-read state, perform exception log processing and record the erroneous operations of the new data server for subsequent operation and maintenance. In the second single-write single-read state, pay attention to external network users and pay attention to the comments made by users on the data service for subsequent operation and maintenance. In the second single-write single-read state, if an abnormality is found, it can be rolled back at any time and repaired in time.
[0178] In the first dual-write single-read state, the second dual-write single-read state, and the second single-write single-read state, real-time monitoring and alarming are carried out to pay attention to the execution of data reading and writing in real time, and timely alarms are issued if abnormalities are found. In the first dual-write single-read state and the second dual-write single-read state, abnormal data proofreading is carried out to find the differences between the new and old databases. In the second dual-write single-read state, data is supplemented at a regular interval to supplement the differences missing from the new database into the new database in a timely manner.
[0179] During the above operations, since the intermediate states are all double-written, that is, writing to the new database and the old database, once an abnormality occurs, the switch can be terminated or rolled back at any time without affecting external users.
[0180] In a specific embodiment, the method of the present application can be applied to the server of MSDK (Multi-platform Game Software Development Kit). MSDK is a game common component and service library platform, that is, MSDK is a public access platform. MSDK has access to various mainstream login channels at home and abroad, and can provide game applications with login capabilities of various login channels. MSDK provides game applications with value-added functions including login, sharing, friends, groups, etc. Based on the direct and fast access of various channels and functions of MSDK, the development team of game applications can focus more on game content development and operation demand design, saving a lot of valuable development time for game applications. For the database migration corresponding to the value-added functions provided by MSDK, by switching the database read and write status, the first single write and single read state of the source data server is gradually and orderly switched to the second single write and single read state of the target data server, so as to realize the non-stop migration of the source database and the target database, and do not affect the use of the value-added functions by the game application. In addition, during the database migration process, data verification of the new and old databases is performed to ensure high consistency of data in the new and old databases. In addition, during the database migration process, if an exception occurs, the migration can be stopped at any time or rolled back in time to reduce losses.
[0181] In a specific embodiment, the method of the present application can be applied to the database migration of e-commerce applications. The database of the e-commerce application can be used to store activity information, order information, product information, user information, logistics information and other data. For the database migration of e-commerce applications, by switching the read-write state of the database, the first single-write and single-read state of the source data server is gradually and orderly switched to the second single-write and single-read state of the target data server, so as to achieve non-stop migration of the source database and the target database without affecting the online service of the e-commerce application. And during the database migration process, data verification of the new and old databases is performed to ensure high consistency of data in the new and old databases. Moreover, during the database migration process, if an exception occurs, the migration can be stopped at any time or rolled back in time to reduce losses.
[0182] In a specific embodiment, the method of the present application can be applied to the database migration of a game application. The database of the game application can be used to store data such as player information, game information of each round, log information, etc. For example, Fig.14This is a schematic diagram of a game match. Data such as player configuration, player operation, and match results of the game match can be stored in the database of the game application for subsequent data analysis or data query. For database migration of game applications, by switching the database read-write status, the first single-write single-read state of the source data server is gradually and orderly switched to the second single-write single-read state of the target data server, so as to achieve non-stop migration of the source database and the target database without affecting the online service of the game application. In addition, during the database migration process, data verification of the new and old databases is performed to ensure high consistency of data in the new and old databases. In addition, during the database migration process, if an exception occurs, the migration can be stopped at any time or rolled back in time to reduce losses.
[0183] It can be understood that the above application scenarios are only illustrative descriptions, and it can be understood that the application of the database migration method provided in each embodiment of the present application is not limited to the above scenarios.
[0184] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0185] Based on the same inventive concept, the embodiment of the present application also provides a database migration device for implementing the database migration method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more database migration device embodiments provided below can refer to the limitations on the database migration method above, and will not be repeated here.
[0186] In one embodiment, Fig.15 As shown, a database migration device is provided, including: a starting module 1502 and a switching module 1504, wherein:
[0187] Startup module 1502 is used to start the first dual-write single-read state of the target data server corresponding to the target service for database migration of the target service; the first dual-write single-read state is used to indicate writing data to the source database and target database corresponding to the target service through the target data server, and reading data from the source database.
[0188] The switching module 1504 is used to switch from a first dual-write single-read state to a second dual-write single-read state when it is determined that the data write operation to the target database is executed normally; the second dual-write single-read state is used to indicate that data is written to the source database and the target database through the target data server, and data is read from the target database; when it is determined that the data write operation to the target database is executed normally, the data in the source database is consistent with the data in the target database.
[0189] The switching module 1504 is also used to switch from the second dual-write single-read state to the second single-write single-read state when it is determined that the data write operation and the data read operation for the target database are executed normally; the second single-write single-read state is used to indicate reading and writing data from the target database through the target data server.
[0190] In one embodiment, the startup module 1502 is further configured to:
[0191] Establish connections between the target data server corresponding to the target service and the source database and target database corresponding to the target service respectively;
[0192] After the target data server is connected to the source database and the target database, the first dual-write and single-read state of the target data server corresponding to the target service is started;
[0193] Before starting the first dual-write single-read state, the source data server corresponding to the target service is in a first single-write single-read state; the first single-write single-read state is used to indicate reading and writing data from the source database through the source data server.
[0194] In one embodiment, the database migration apparatus is further used for:
[0195] Before starting the first dual-write single-read state, obtain the initial full data exported from the source database, and before switching to the first dual-write single-read state, import the initial full data into the target database;
[0196] After starting the first dual-write single-read state, incremental data generated from exporting the initial full data to starting the first dual-write single-read state is obtained, and the incremental data is written into the target database.
[0197] In one embodiment, the switching module 1504 is further configured to:
[0198] After determining that the incremental data in the target database is consistent with the incremental data in the source database, switching from the first dual-write single-read state to the second dual-write single-read state;
[0199] Among them, the incremental data in the source database is written in real time based on the data write request for the target service during the process from exporting the initial full data to starting the first dual-write and single-read state.
[0200] In one embodiment, the database migration apparatus is further used for:
[0201] In the process of starting the first single-write single-read state and switching to the second single-write single-read state, the data in the source database and the data in the target database are compared regularly, and the difference data missing from the target database is supplemented and written into the target database according to the comparison result.
[0202] In one embodiment, the switching module 1504 is further configured to:
[0203] After determining that the target service runs normally in the second dual-write single-read state and the current full data in the target database is consistent with the current full data in the source database, switch from the second dual-write single-read state to the second single-write single-read state.
[0204] In one embodiment, the switching module 1504 is further configured to:
[0205] When the fluctuation trend of the service quality curve corresponding to the target service in the second dual-write single-read state is a preset stable trend, it is determined that the target service operates normally in the second dual-write single-read state;
[0206] Among them, the service quality curve includes at least one of a first curve corresponding to the data dimension and a second curve corresponding to the hardware dimension; the first curve is used to indicate the execution status of data reading and writing of the target service during the operation process; the second curve is used to indicate the occupancy of hardware resources of the target service during the operation process.
[0207] In one embodiment, the database migration apparatus is further used for:
[0208] During the database migration process, if an abnormality is detected in the database migration, the state switching is suspended or rolled back to the preset state until the database migration returns to normal, and then the state switching is resumed or continued from the preset state.
[0209] In one embodiment, the target service is any one of the data services corresponding to the value-added functions provided by the public access platform;
[0210] The public access platform is used to support the target application to access the login channel set, so that the target application supports account login using each login channel in the login channel set;
[0211] The value-added function provided by the public platform is used to increase the application functions of the target application based on the login channel set in addition to the application functions provided by the target application itself;
[0212] The database corresponding to the data service is used to store the account data of the login account of the target application for the value-added functions in the target application.
[0213] The above-mentioned database migration device controls the read and write state of the database in the target data server for database migration of the target service, and gradually switches the read and write of the service from the source database to the target database through state switching, so that the database migration can be performed without affecting the normal operation of the target service, realizing non-stop migration, and effectively improving the efficiency of database migration. It can be understood that the first double-write single-read state is first started, and the data is written to the source database and the target database at the same time, and the data is read from the source database as usual to ensure that the service operation is not affected. When it is determined that the target data server can write data to the target database normally, it is switched to the second double-write single-read state, and the data is still written to the source database and the target database at the same time. At this time, the data is read from the target database. Because the data write operation for the target database is executed normally, the service operation is still not affected. When it is determined that the target data server can read and write data from the target database normally, it is switched to the second single-write single-read state. At this time, the data is completely read and written from the target database. Because the data write operation and data read operation for the target database are executed normally, the service operation is still not affected.
[0214] Each module in the above database migration device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0215] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.16 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store relevant data interacting with a source database and a target database. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a database migration method is implemented.
[0216] Those skilled in the art will understand that Fig.16 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0217] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0218] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0219] In one embodiment, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0220] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0221] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0222] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0223] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A database migration method, characterized in that: The method comprises: For database migration of a target service, a first dual-write single-read state of a target data server corresponding to the target service is started; the first dual-write single-read state is used to indicate that data is written to a source database and a target database corresponding to the target service through the target data server, and data is read from the source database; When it is determined that the data write operation to the target database is executed normally, switching from the first dual-write single-read state to the second dual-write single-read state; the second dual-write single-read state is used to indicate that data is written to the source database and the target database through the target data server, and data is read from the target database; when it is determined that the data write operation to the target database is executed normally, the data in the source database is consistent with the data in the target database; When it is determined that the data write operation and the data read operation for the target database are both executed normally, switch from the second dual-write single-read state to a second single-write single-read state; the second single-write single-read state is used to indicate reading and writing data from the target database through the target data server.
2. The method according to claim 1, characterized in that The starting of the first dual-write single-read state of the target data server corresponding to the target service includes: Establishing connections between the target data server corresponding to the target service and the source database and the target database corresponding to the target service respectively; After the target data server is connected to the source database and the target database stably, starting the first dual-write single-read state of the target data server corresponding to the target service; Before starting the first dual-write single-read state, the source data server corresponding to the target service is in a first single-write single-read state; the first single-write single-read state is used to indicate reading and writing data from the source database through the source data server.
3. The method according to claim 1, characterized in that: The method further comprises: Before starting the first dual-write single-read state, obtaining initial full data exported from the source database, and before switching to the first dual-write single-read state, importing the initial full data into the target database; After starting the first dual-write single-read state, incremental data generated from exporting the initial full data to starting the first dual-write single-read state is obtained, and the incremental data is written into the target database.
4. The method according to claim 3, characterized in that The switching from the first dual-write single-read state to the second dual-write single-read state when it is determined that the data write operation to the target database is performed normally includes: After determining that the incremental data in the target database is consistent with the incremental data in the source database, switching from the first dual-write single-read state to the second dual-write single-read state; Among them, the incremental data in the source database is written in real time based on the data write request for the target service during the process from exporting the initial full data to starting the first dual-write single-read state.
5. The method according to claim 1, characterized in that The method further comprises: In the process of starting the first single-write single-read state and switching to the second single-write single-read state, the data in the source database and the data in the target database are compared regularly, and the difference data missing from the target database is supplemented and written into the target database according to the comparison result.
6. The method according to claim 1, characterized in that The switching from the second dual-write single-read state to the second single-write single-read state when it is determined that the data write operation and the data read operation for the target database are both performed normally includes: After determining that the target service runs normally in the second dual-write single-read state and the current full data in the target database is consistent with the current full data in the source database, switch from the second dual-write single-read state to the second single-write single-read state.
7. The method according to claim 6, characterized in that The method further comprises: When the fluctuation trend of the service quality curve corresponding to the target service in the second dual-write single-read state is a preset stable trend, determining that the target service runs normally in the second dual-write single-read state; Among them, the service quality curve includes at least one of a first curve corresponding to the data dimension and a second curve corresponding to the hardware dimension; the first curve is used to indicate the execution status of the target service for data reading and writing during the operation process; the second curve is used to indicate the occupancy of hardware resources by the target service during the operation process.
8. The method according to claim 1, characterized in that The method further comprises: During the database migration process, when an abnormality is detected in the database migration, the state switching is suspended or rolled back to a preset state until the database migration returns to normal, and the state switching is resumed or continued from the preset state.
9. The method according to any one of claims 1 to 8, characterized in that The target service is any one of the data services corresponding to each value-added function provided by the public access platform; The public access platform is used to support the target application to access the login channel set, so that the target application supports account login using each login channel in the login channel set; The value-added function provided by the public platform is used to increase the application functions of the target application based on the login channel set in addition to the application functions provided by the target application itself; The database corresponding to the data service is used to store the account data of the login account of the target application for the value-added function in the target application.
10. A database migration system, characterized in that: The system includes a target data server, a source database, and a target database corresponding to the target service; The target data server is used for database migration of a target service and starts a first dual-write single-read state of the target data server corresponding to the target service; In the first dual-write single-read state, the source database and the target database are used to respond to the data write operation sent by the target data server, and the source database is also used to respond to the data read operation sent by the target data server; The target data server is further configured to switch from the first dual-write single-read state to a second dual-write single-read state when determining that the data write operation to the target database is performed normally; When it is determined that the data writing operation for the target database is performed normally, the data in the source database is consistent with the data in the target database; In the second dual-write single-read state, the source database and the target database are used to respond to the data write operation sent by the target data server, and the target database is also used to respond to the data read operation sent by the target data server; The target data server is further configured to switch from the second dual-write single-read state to a second single-write single-read state when it is determined that the data write operation and the data read operation for the target database are both performed normally; In the second single-write and single-read state, the target database is used to respond to data writing operations and data reading operations sent by the target data server.
11. The system according to claim 10, characterized in that The system also includes a logic server and a source data server corresponding to the target service; The logic server is used to receive a data processing request for the target service during the operation of the target service, perform logic processing on the data processing request to obtain a data read / write request, and send the data read / write request to a current data server corresponding to the target service; the current data server is the target data server or the source data server; The current data server is further used to respond to the data read and write request, read and write data from the database corresponding to the current read and write state, and return the read and write result to the logic server.
12. The system according to claim 11, characterized in that Before the target data server starts the first dual-write single-read state, the current data server is the source data server, and the source database is used to respond to data write operations and data read operations sent by the source data server; After the target data server starts the first dual-write single-read state, the current data server is the target data server; The logical server is further configured to establish a connection with the target data server based on a database migration startup notification for the target service, and to interrupt a connection with the source data server based on a startup notification for the first dual-write single-read state.
13. The system according to claim 11, characterized in that The system also includes a terminal corresponding to the target application and a routing server corresponding to the public access platform; The public access platform is used to support the target application to access the login channel set, so that the target application supports account login using each login channel in the login channel set; The target service is any one of the data services corresponding to the value-added functions provided by the public access platform; The terminal is used to generate a data processing request for the target service based on a service triggering event for the target service in the target application, and send the data processing request to the routing server; the data processing request carries a service identifier corresponding to the target service; The routing server is used to send the data processing request to the logic server based on the service identifier.
14. The system according to claim 10, characterized in that The system also includes a service monitoring device; The service monitoring device is used to collect a service feedback set for the target service after switching to the second single-write single-read state, and generate a deregistration notification for the source data server corresponding to the target service when the proportion of positive feedback in the service feedback set is greater than a first preset proportion, and generate a rollback notification for the second single-write single-read state when the proportion of negative feedback in the service feedback set is greater than a second preset proportion.
15. A database migration device, characterized in that: The device comprises: A startup module, used for starting a first dual-write single-read state of a target data server corresponding to the target service for database migration; the first dual-write single-read state is used to indicate writing data to a source database and a target database corresponding to the target service through the target data server, and reading data from the source database; a switching module, configured to switch from the first dual-write single-read state to a second dual-write single-read state when it is determined that the data write operation to the target database is executed normally; the second dual-write single-read state is configured to indicate that data is written to the source database and the target database through the target data server, and data is read from the target database; when it is determined that the data write operation to the target database is executed normally, the data in the source database is consistent with the data in the target database; The switching module is also used to switch from the second dual-write single-read state to the second single-write single-read state when it is determined that the data write operation and the data read operation for the target database are performed normally; the second single-write single-read state is used to indicate reading and writing data from the target database through the target data server.
16. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
18. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
Citation Information
Cited By
Data synchronization processing method and device
CN120429366A
Data migration method and device
CN121071044A