Database data migration method, device, equipment and storage medium

By calculating the HASH value of the user ID and virtual node, the targeted migration of database data is achieved, which solves the problem of abnormal load in traditional database migration, improves query efficiency and reduces data redundancy.

CN115757335BActive Publication Date: 2025-09-19深圳开鸿数字产业发展有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211384963.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-07
Publication Date
2025-09-19
Estimated Expiration
2042-11-07

AI Technical Summary

Technical Problem

Traditional database data migration cannot be targeted, resulting in virtual nodes with abnormal loads being unable to bear the query pressure, causing increased network latency and query failures, affecting query efficiency.

Method used

By calculating the HASH value of the user ID and the load status and storage HASH value of the target database virtual node, it is determined whether the load status is normal. When the storage HASH value is greater than the HASH value of the user ID, the database data is written to the virtual node with normal load to achieve targeted migration.

Benefits of technology

Ensure that database data is written to virtual nodes with normal load, avoid long query times and query failures, reduce data redundancy, and improve query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115757335B_ABST
    Figure CN115757335B_ABST
Patent Text Reader

Abstract

The present application discloses a database data migration method, apparatus, device and storage medium, the method comprising: obtaining database data and user ID to be migrated, calculating the HASH value of the user ID; obtaining the load status and storage HASH value of the virtual node in the target database; judging whether the load status is normal; when the load status is normal, judging whether the storage HASH value is greater than the HASH value of the user ID; when the storage HASH value is greater than the HASH value of the user ID, writing the database data into the virtual node to migrate the database data to the target database. The present application has two beneficial effects. On the one hand, the whole process ensures that the virtual node is in a normal state. Therefore, the database data to be migrated will be written into the virtual node with normal load, which is conducive to improving the query efficiency of the data. On the other hand, it can reduce the redundancy of the data and further improve the query efficiency of the data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a database data migration method, apparatus, device, and storage medium. Background Art

[0002] In the current field of Internet technology, database data migration is a popular research direction. Database data migration is a horizontal storage solution used to solve the bottleneck of database data storage.

[0003] However, traditional database data migration cannot be targeted because traditional database data migration only writes database data to all storage nodes of the database, and does not distinguish whether the database storage node is a virtual node with normal load or a virtual node with abnormal load. Therefore, when the database data is migrated to the virtual node with abnormal load, the virtual node with abnormal load will find it difficult to bear the pressure of querying the database data, which will bring about a large network delay, resulting in excessively long query time and query failure, which is not conducive to improving data query efficiency. Summary of the Invention

[0004] The embodiments of the present application provide a database data migration method, apparatus, device, and storage medium to solve the above-mentioned technical problem that database data cannot be migrated in a targeted manner, which is not conducive to improving data query efficiency.

[0005] In a first aspect, an embodiment of the present application provides a database data migration method, the database data migration method comprising:

[0006] Obtain the database data to be migrated and the user ID, and calculate the HASH value of the user ID;

[0007] Obtain the load status and storage HASH value of the virtual node in the target database;

[0008] Determining whether the load state is normal;

[0009] When the load state is normal, determining whether the stored HASH value is greater than the HASH value of the user ID;

[0010] When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the virtual node to directionally migrate the database data to the target database.

[0011] In a second aspect, an embodiment of the present application further provides a database data migration device, which includes a processor and a memory, wherein a computer program is stored in the memory, and the processor executes the above-mentioned database data migration method when calling the computer program in the memory.

[0012] In a third aspect, an embodiment of the present application further provides a device, which includes the database data migration device as described above.

[0013] In a fourth aspect, an embodiment of the present application further provides a storage medium, which is used to store a computer program. When the computer program is executed by a processor, the processor implements the above-mentioned database data migration method.

[0014] The embodiment of the present application provides a database data migration method, device, equipment and storage medium, which obtains the database data to be migrated and the user ID, calculates the HASH value of the user ID; obtains the load status and storage HASH value of the virtual node in the target database; determines whether the load status is normal; when the load status is normal, determines whether the storage HASH value is greater than the HASH value of the user ID; when the storage HASH value is greater than the HASH value of the user ID, writes the database data into the virtual node to migrate the database data to the target database. The beneficial effects of the present application are two-fold. On the one hand, the whole process ensures that the virtual node is in a normal state. Therefore, the database data to be migrated will be written into the virtual node with normal load. Therefore, there will be no query time being too long and query failure, which is conducive to improving the query efficiency of the data. On the other hand, when the storage HASH value is greater than the HASH value of the user ID, the database data will be written into the virtual node. In this way, the database data will not be written to all the storage nodes of the database, thereby reducing data redundancy and further improving the query efficiency of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0016] Figure 1 This is a flowchart of a database data migration method provided in an embodiment of the present application;

[0017] Figure 2 This is a sample diagram of a HASH ring provided in an embodiment of the present application;

[0018] Figure 3 This is a schematic diagram of the load balancing process provided by an embodiment of the present application;

[0019] Figure 4This is a flowchart of modifying a database provided by an embodiment of the present application;

[0020] Figure 5 This is another schematic diagram of the load balancing process provided in an embodiment of the present application;

[0021] Figure 6 is a schematic block diagram of the middleware provided in an embodiment of the present application;

[0022] Figure 7 A schematic block diagram of a database data migration device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] In order to make the purpose, technical solutions and advantages of this application more clear, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0024] It should be noted that the terms "first," "second," etc., in this application are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, features specified as "first" or "second" may explicitly or implicitly include at least one of these features.

[0025] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of the present application include a particular feature, structure, or characteristic described in conjunction with that embodiment. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in some embodiments" appearing in different places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

[0026] In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the fact that ordinary technicians in this field can implement them. When the combination of technical solutions is mutually contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0027] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.

[0028] See also Figure 1 , Figure 1 This is a flow chart of the database data migration method provided in the embodiment of the present application. The method can be applied to devices, wherein the device can be any one of a mobile phone, a camera, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, a personal computer (PC), a netbook, and a personal digital assistant (PDA). This embodiment of the present application does not impose any restrictions. Figure 1 As shown, the database data migration method provided in the embodiment of the present application includes steps S101 to S105.

[0029] S101, obtaining the database data to be migrated and the user ID, and calculating the HASH value of the user ID;

[0030] Among them, S101 has two implementation methods, which are detailed as follows:

[0031] The first method is to obtain the virtual nodes reduced in the current database, identify the database data stored in the reduced virtual nodes as the database data to be migrated, obtain the database data to be migrated and the user ID, and calculate the HASH value of the user ID.

[0032] There is a corresponding relationship between database data and user IDs, and the user ID corresponding to the database data to be migrated is obtained from a pre-stored data table.

[0033] The second method is to read the retention period of the database data and initiate a data migration request before the retention period expires; according to the data migration request, obtain the database data to be migrated and the user ID of the database data, and calculate the HASH value of the user ID.

[0034] The retention period can be set by the user or by the system default, and there is no restriction here.

[0035] The database data to be migrated and the user ID are obtained, and a preset HASH function is used to calculate the HASH value of the user ID. The preset HASH function can be set by the user or by the system default, and is not limited here.

[0036] S102, obtaining the load status and storage HASH value of the virtual node in the target database;

[0037] The method of obtaining the load status of the virtual node in the target database and storing the HASH value is as follows:

[0038] Obtain addresses of multiple virtual nodes in the target database, and calculate storage HASH values ​​of the multiple virtual nodes;

[0039] The stored HASH values ​​of the plurality of virtual nodes are sorted from small to large or from large to small to form a HASH ring, and the load status of the virtual nodes and the stored HASH values ​​are sequentially obtained in a clockwise direction or a counterclockwise direction in the HASH ring.

[0040] The steps of obtaining the addresses of multiple virtual nodes in the target database and calculating the stored HASH values ​​of the multiple virtual nodes are as follows:

[0041] The addresses of multiple virtual nodes in the target database are obtained, and the storage HASH values ​​of the virtual nodes are calculated using a consistent HASH algorithm and the addresses of the virtual nodes.

[0042] S103, determining whether the load state is normal;

[0043] The step of determining whether the load state is normal is as follows:

[0044] Obtaining parameters of the load state, the parameters including one or a combination of space occupancy, CPU occupancy, and memory occupancy;

[0045] Determining whether the parameters of the load state are within a preset range;

[0046] When the parameter of the load state is within a preset range, the load state is identified as a normal state; when the parameter of the load state is not within the preset range, the load state is identified as a non-normal state.

[0047] S104, when the load state is normal, determining whether the stored HASH value is greater than the HASH value of the user ID;

[0048] When the load status is normal, it indicates that the virtual node is a virtual node with a normal load, thereby ensuring that the database data to be migrated will be written into the virtual node with a normal load.

[0049] S105 : When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the virtual node to directionally migrate the database data to the target database.

[0050] When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the virtual node to migrate the database data to the target database, specifically:

[0051] When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the first virtual node whose stored HASH value is greater than the HASH value of the user ID in a clockwise or counterclockwise direction in the HASH ring to directionally migrate the database data to the target database.

[0052] The beneficial effects of the embodiments of the present application lie in two aspects. On the one hand, the entire process ensures that the virtual node is in a normal state. Therefore, the database data to be migrated will be written to the virtual node with normal load. Therefore, there will be no situation where the query time is too long or the query fails, which is beneficial to improving the query efficiency of the data; on the other hand, when the stored HASH value is greater than the HASH value of the user ID, the database data will be written to the virtual node. In this way, the database data will not be written to all the storage nodes of the database, thereby reducing data redundancy and further improving the query efficiency of the data.

[0053] See also Figure 2 , Figure 2 This is a sample diagram of a HASH ring provided in an embodiment of the present application, which is described in detail as follows:

[0054] The HASH ring has virtual node 1, virtual node 2, virtual node 3, virtual node 4, virtual node 5, and virtual node N, where N is a positive integer.

[0055] For ease of explanation, the HASH ring with 6 virtual nodes is used as an example. The details are as follows:

[0056] The distribution of virtual nodes in the HASH ring is as follows: virtual node 1, virtual node 2, virtual node 3, virtual node 4, virtual node 5, virtual node 6.

[0057] The load status and stored HASH values ​​of virtual node 1, virtual node 2, virtual node 3, virtual node 4, virtual node 5, and virtual node 6 can be obtained in a clockwise direction or a counterclockwise direction in the HASH ring.

[0058] For ease of explanation, we take the HASH ring in the clockwise direction as an example and describe it in detail as follows:

[0059] When moving clockwise in the HASH ring, obtain the load status of virtual node 1 and store the HASH value;

[0060] Determine whether virtual node 1 is in a normal state. When the load state of virtual node 1 is normal, determine whether the storage HASH value of virtual node 1 is greater than the HASH value of the user ID. When the load state of virtual node 1 is normal and the storage HASH value is greater than the HASH value of the user ID, write the database data into virtual node 1 to migrate the database data to virtual node 1 of the target database.

[0061] When the load status of virtual node 1 is not normal, obtain the load status and storage HASH value of virtual node 2; determine whether virtual node 2 is in normal status. When the load status of virtual node 2 is normal, determine whether the storage HASH value of virtual node 2 is greater than the HASH value of the user ID. When the load status of virtual node 2 is normal and the storage HASH value is greater than the HASH value of the user ID, write the database data into virtual node 2 to migrate the database data to the virtual node 2 of the target database.

[0062] For ease of explanation, the counterclockwise direction of the HASH ring is used as an example. The details are as follows:

[0063] When moving counterclockwise in the HASH ring, obtain the load status of virtual node 6 and store the HASH value;

[0064] Determine whether the virtual node 6 is in a normal state. When the load state of the virtual node 6 is normal, determine whether the stored HASH value of the virtual node 6 is greater than the HASH value of the user ID. When the load state of the virtual node 6 is normal and the stored HASH value is greater than the HASH value of the user ID, write the database data into the virtual node 6 to migrate the database data to the virtual node 6 of the target database.

[0065] When the load status of virtual node 6 is not normal, obtain the load status and storage HASH value of virtual node 5; determine whether virtual node 5 is in normal status. When the load status of virtual node 5 is normal, determine whether the storage HASH value of virtual node 5 is greater than the HASH value of user ID. When the load status of virtual node 5 is normal and the storage HASH value is greater than the HASH value of user ID, write the database data into virtual node 5 to migrate the database data to the virtual node 5 of the target database.

[0066] In the embodiment of the present application, the database data is written into the virtual node only when the stored HASH value is greater than the HASH value of the user ID. This will not write the database data to all the storage nodes of the database, thereby reducing data redundancy and further improving data query efficiency.

[0067] See also Figure 3 , Figure 3 is a schematic diagram of the load balancing process provided in an embodiment of the present application. Before or after obtaining the database data to be migrated and the user ID and calculating the HASH value of the user ID, the method further includes:

[0068] S301, obtaining a new weight value of the target database, and determining whether the new weight value is greater than the old weight value;

[0069] S302: If the new weight value is greater than the old weight value, calculate the absolute value between the new weight value and the old weight value, use the product of the absolute value and a preset coefficient as a node addition value, and add a new virtual node to the target database according to the node addition value;

[0070] S303: If the new weight value is smaller than the old weight value, calculate the absolute value between the new weight value and the old weight value, use the product value between the absolute value and the preset coefficient as the node deletion value, and delete the old virtual node from the target database according to the node deletion value.

[0071] In an embodiment of the present application, by modifying the weight value of the target database, virtual nodes are dynamically added or reduced to the target database, the data processing capacity of the target database is flexibly adjusted, and load balancing between the target database and other databases is achieved.

[0072] See also Figure 4 , Figure 4 is a flowchart of modifying a database provided by an embodiment of the present application. In some embodiments, before or after obtaining the database data to be migrated and the user ID and calculating the HASH value of the user ID, the method further includes:

[0073] S401, obtaining a modification operation of the target database in a preset visual management interface and identifying the content of the modification operation;

[0074] S402, when the modification operation is to modify the node name, obtain a new node name, replace the old node name with the new node name, and display the new node name in the visual management interface;

[0075] S403, when the modification operation is to modify the port number, obtaining a new port number, replacing the old port number with the new port number, and displaying the new port number in the visual management interface;

[0076] S404: When the modification operation is to modify a weight value, a new weight value is obtained, the old weight value is replaced by the new weight value, and the new weight value is displayed in the visual management interface.

[0077] In the embodiment of the present application, the visual management interface is simple and intuitive, which improves the efficiency of modifying the target database and improves the user operation experience.

[0078] See also Figure 5 , Figure 5 This is another schematic diagram of the load balancing process provided by the embodiment of the present application, which is detailed as follows:

[0079] Get the operation type in the visual management interface;

[0080] Identify the type of operation;

[0081] When the operation type is identified as modifying the weight of the database, a new weight value of the target database is obtained; and it is determined whether the new weight value is greater than the old weight value. If so, a new virtual node is added; otherwise, the old virtual node is deleted.

[0082] When the operation type is identified as adding a new database, a HASH value is calculated based on the MAC address or IP address, weight, and number of virtual nodes of the new database; the calculated HASH value is stored in the cache module.

[0083] When the identified operation type is to delete the database, the configured database is deleted; the value of the configured database in the cache module is deleted.

[0084] In the embodiment of the present application, obtaining the operation type in the visual management interface is simple and intuitive, convenient for user operation, and improves the user operation experience.

[0085] See also Figure 6 , Figure 6 This is a schematic block diagram of the middleware provided in the embodiment of the present application, which is described in detail as follows:

[0086] The middleware mainly provides three modules: load balancing module, data migration module, and a visual management interface for user operations.

[0087] The client modifies the weight values ​​of database A, database B, and database C through the load balancing module of the middleware, dynamically adds or reduces virtual nodes to database A, database B, and database C, flexibly adjusts the data processing capabilities of database A, database B, and database C, and realizes load balancing among database A, database B, and database C.

[0088] The client can migrate the database data of database A to

[0089] Database B and Database C can also migrate the database data of Database B to Database A and Database C, thus realizing the database data migration among Database A, Database B and Database C.

[0090] In the embodiments of the present application, the middleware can shorten the application development cycle and reduce code intrusion, improve the development quality of the application, and reduce the initial development cost and maintenance fee.

[0091] See also Figure 7 , Figure 7 A schematic block diagram of a database data migration device provided in an embodiment of the present application.

[0092] like Figure 7 As shown, the database data migration apparatus 200 may include a processor 211 and a memory 212 , and the processor 211 and the memory 212 are connected via a bus, such as an I2C (Inter-integrated Circuit) bus.

[0093] Specifically, the processor 211 may be a micro-controller unit (MCU), a central processing unit (CPU), or a digital signal processor (DSP).

[0094] Specifically, the memory 212 may be a Flash chip, a read-only memory (ROM) disk, an optical disk, a USB flash drive, or a mobile hard disk, etc. The memory 212 stores various computer programs for execution by the processor 211 .

[0095] The processor 211 is configured to run a computer program stored in the memory processor 211 and implement the following steps when executing the computer program:

[0096] Obtain the database data to be migrated and the user ID, and calculate the HASH value of the user ID;

[0097] Obtain the load status and storage HASH value of the virtual node in the target database;

[0098] Determining whether the load state is normal;

[0099] When the load state is normal, determining whether the stored HASH value is greater than the HASH value of the user ID;

[0100] When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the virtual node to directionally migrate the database data to the target database.

[0101] In some embodiments, the processor 211 is configured to implement:

[0102] Obtain addresses of multiple virtual nodes in the target database, and calculate storage HASH values ​​of the multiple virtual nodes;

[0103] The stored HASH values ​​of the plurality of virtual nodes are sorted from small to large or from large to small to form a HASH ring, and the load status of the virtual nodes and the stored HASH values ​​are sequentially obtained in a clockwise direction or a counterclockwise direction in the HASH ring.

[0104] In some embodiments, the processor 211 is configured to implement:

[0105] Obtaining parameters of the load state, the parameters including one or a combination of space occupancy, CPU occupancy, and memory occupancy;

[0106] Determining whether the parameters of the load state are within a preset range;

[0107] When the parameter of the load state is within a preset range, the load state is identified as a normal state; when the parameter of the load state is not within the preset range, the load state is identified as a non-normal state.

[0108] In some embodiments, the processor 211 is configured to implement:

[0109] When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the first virtual node whose stored HASH value is greater than the HASH value of the user ID in a clockwise or counterclockwise direction in the HASH ring to directionally migrate the database data to the target database.

[0110] In some embodiments, the processor 211 is configured to implement:

[0111] Obtaining a new weight value of the target database, and determining whether the new weight value is greater than the old weight value;

[0112] If the new weight value is greater than the old weight value, calculating the absolute value between the new weight value and the old weight value, taking the product of the absolute value and a preset coefficient as the node addition value, and adding a new virtual node to the target database according to the node addition value;

[0113] If the new weight value is smaller than the old weight value, the absolute value between the new weight value and the old weight value is calculated, the product value between the absolute value and the preset coefficient is used as the node deletion value, and the old virtual node is deleted from the target database according to the node deletion value.

[0114] In some embodiments, the processor 211 is configured to implement:

[0115] Obtaining modification operations of the target database in a preset visual management interface and identifying the content of the modification operations;

[0116] When the modification operation is to modify a node name, a new node name is obtained, the old node name is replaced by the new node name, and the new node name is displayed in the visual management interface;

[0117] When the content of the modification operation is to modify the port number, a new port number is obtained, the old port number is replaced by the new port number, and the new port number is displayed in the visual management interface;

[0118] When the content of the modification operation is to modify the weight value, a new weight value is obtained, the old weight value is replaced by the new weight value, and the new weight value is displayed in the visual management interface.

[0119] In some embodiments, the processor 211 is configured to implement:

[0120] The addresses of multiple virtual nodes in the target database are obtained, and the storage HASH values ​​of the virtual nodes are calculated using a consistent HASH algorithm and the addresses of the virtual nodes.

[0121] A device is also provided in an embodiment of the present application. The types of the device include but are not limited to mobile phones, cameras, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, personal computers (PCs), netbooks, personal digital assistants (PDAs), etc., and no restrictions are imposed in the embodiments of the present application.

[0122] The device includes a database data migration device. Exemplarily, the database data migration device may be the database data migration device 200 described in the above-mentioned embodiment. The device can execute any of the database data migration methods provided in the embodiments of the present application, and thus can achieve the beneficial effects achievable by any of the database data migration methods provided in the embodiments of the present application. For details, see the previous embodiments and will not be repeated here.

[0123] The present application also provides a storage medium that stores a computer program, which includes program instructions. The processor executes the program instructions to implement the steps of the database data migration method provided in the above embodiment. For example, the computer program is loaded by the processor and can execute the following steps:

[0124] Obtain the database data to be migrated and the user ID, and calculate the HASH value of the user ID;

[0125] Obtain the load status and storage HASH value of the virtual node in the target database;

[0126] Determining whether the load state is normal;

[0127] When the load state is normal, determining whether the stored HASH value is greater than the HASH value of the user ID;

[0128] When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the virtual node to directionally migrate the database data to the target database.

[0129] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.

[0130] The storage medium may be an internal storage unit of the database data migration device or apparatus of the aforementioned embodiment, such as a hard disk or memory of the database data migration device or apparatus. The storage medium may also be an external storage device of the database data migration device or apparatus, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped with the database data migration device or apparatus.

[0131] Since the computer program stored in the storage medium can execute any of the database data migration methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any of the database data migration methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0132] The above are only preferred embodiments of the present application and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the description and drawings of this application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A database data migration method, characterized in that: The database data migration method includes: Obtain the database data to be migrated and the user ID, and calculate the HASH value of the user ID; Obtain addresses of multiple virtual nodes in a target database, calculate stored HASH values ​​of the multiple virtual nodes, sort the stored HASH values ​​of the multiple virtual nodes from small to large or from large to small to form a HASH ring, and sequentially obtain the load status and the stored HASH values ​​of the virtual nodes in a clockwise or counterclockwise direction in the HASH ring; Determining whether the load state is normal; When the load state is normal, determining whether the stored HASH value is greater than the HASH value of the user ID; When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the virtual node to directionally migrate the database data to the target database; Obtaining a new weight value of the target database, and determining whether the new weight value is greater than the old weight value; If the new weight value is greater than the old weight value, calculating the absolute value of the difference between the new weight value and the old weight value, taking the product of the absolute value and a preset coefficient as a node addition value, and adding a new virtual node to the target database according to the node addition value; If the new weight value is smaller than the old weight value, the absolute value of the difference between the new weight value and the old weight value is calculated, the product value between the absolute value and the preset coefficient is used as the node deletion value, and the old virtual node is deleted from the target database according to the node deletion value.

2. The method according to claim 1, characterized in that Determine whether the load state is normal, specifically: Obtaining parameters of the load state, the parameters including one or a combination of space occupancy, CPU occupancy, and memory occupancy; Determining whether the parameters of the load state are within a preset range; When the parameter of the load state is within a preset range, the load state is identified as a normal state; when the parameter of the load state is not within the preset range, the load state is identified as a non-normal state.

3. The method according to claim 1, characterized in that When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the virtual node to migrate the database data to the target database, specifically: When the stored HASH value is greater than the HASH value of the user ID, the database data is written into the first virtual node whose stored HASH value is greater than the HASH value of the user ID in a clockwise or counterclockwise direction in the HASH ring to directionally migrate the database data to the target database.

4. The method according to claim 1, wherein Before or after obtaining the database data to be migrated and the user ID and calculating the HASH value of the user ID, the method further includes: Obtaining modification operations of the target database in a preset visual management interface and identifying the content of the modification operations; When the modification operation is to modify a node name, a new node name is obtained, the old node name is replaced by the new node name, and the new node name is displayed in the visual management interface; When the content of the modification operation is to modify the port number, a new port number is obtained, the old port number is replaced by the new port number, and the new port number is displayed in the visual management interface; When the content of the modification operation is to modify the weight value, a new weight value is obtained, the old weight value is replaced by the new weight value, and the new weight value is displayed in the visual management interface.

5. The method according to claim 1, wherein The acquiring of addresses of multiple virtual nodes in the target database and the calculation of storage HASH values ​​of the multiple virtual nodes are specifically as follows: The addresses of multiple virtual nodes in the target database are obtained, and the storage HASH values ​​of the virtual nodes are calculated using a consistent HASH algorithm and the addresses of the virtual nodes.

6. A database data migration device, characterized in that: The database data migration device includes a processor and a memory, wherein the memory stores a computer program executable by the processor, and when the computer program is executed by the processor, the database data migration method according to any one of claims 1 to 5 is implemented.

7. A device, characterized in that The device includes the database data migration apparatus according to claim 6.

8. A storage medium for computer-readable storage, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the database data migration method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and system for dynamic data access

    CN106503139A

  • Server load balancing method and device

    CN106559448A