Method and apparatus for upgrading distributed database, electronic device and storage medium
By automatically building upgrade scripts and determining system information differences based on the topology file of the distributed database, the inefficiency caused by manually writing upgrade scripts in existing technologies is solved, and efficient automated upgrades of distributed databases are achieved.
Patent Information
- Application Number
- CN202511220855.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2045-08-29
AI Technical Summary
Existing methods for upgrading distributed database versions rely on manually written upgrade scripts, resulting in low upgrade efficiency and requiring extensive testing, which affects the stability and performance of the database.
By identifying system information discrepancies based on the topology file of the distributed database, an upgrade script is automatically constructed to achieve automated upgrades of the distributed database.
It reduces labor costs, lowers the complexity of version upgrades, and improves the upgrade efficiency of distributed databases.
Smart Images

Figure CN120723286B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to a method, apparatus, electronic device, and storage medium for upgrading a distributed database. Background Technology
[0002] Distributed database version upgrades are a critical function in database system management, significant not only for acquiring new features but also for optimizing core aspects such as performance, security, and stability. Therefore, achieving rapid and stable automated version upgrades is particularly important in database development and operations.
[0003] Currently, the general method for upgrading distributed databases is as follows: based on the current database version and the version to be upgraded, a script is selected from a prepared upgrade script library, executed on the distributed database, and the incompatible configuration changes are completed, thus achieving the upgrade effect. However, the upgrade script library needs to be prepared in advance, relies on manual writing by developers, and requires extensive testing for upgrade operations between any two versions, significantly impacting the upgrade efficiency of distributed databases. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for upgrading a distributed database, so as to realize automatic configuration of upgrade scripts for distributed database upgrades and improve the upgrade efficiency of distributed databases.
[0005] According to one aspect of the present invention, a method for upgrading a distributed database is provided, the method comprising:
[0006] Based on the topology file of the first distributed database, the first system information of the first node is determined; the first distributed database is a distributed database to be upgraded, and the first distributed database is in normal operating condition; the first node is one of all nodes in the first distributed database.
[0007] Run the second node of the second distributed database and determine the second system information of the second node; the second distributed database is the upgrade target of the first distributed database; the second node is one of all nodes in the second distributed database;
[0008] Determine the comparison result between the first system information and the second system information; the comparison result is used to describe the system configuration differences between the first distributed database and the second distributed database.
[0009] Based on the comparison results, script information for the second distributed database is constructed, and the first distributed database is upgraded based on the script information.
[0010] According to another aspect of the present invention, an upgrade apparatus for a distributed database is provided, the apparatus comprising:
[0011] The first information determination module is used to determine the first system information of the first node based on the topology file of the first distributed database; the first distributed database is a distributed database to be upgraded and the first distributed database is in normal operating condition; the first node is one of all nodes in the first distributed database.
[0012] The second information determination module is used to run the second node of the second distributed database and determine the second system information of the second node; the second distributed database is the upgrade target of the first distributed database; the second node is one of all nodes in the second distributed database;
[0013] The result determination module is used to determine the comparison result between the first system information and the second system information; the comparison result is used to describe the system configuration differences between the first distributed database and the second distributed database.
[0014] The upgrade module is used to construct script information for the second distributed database based on the comparison results, and to upgrade the first distributed database based on the script information.
[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0016] At least one processor; and
[0017] A memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the distributed database upgrade method according to any embodiment of the present invention.
[0019] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the distributed database upgrade method according to any embodiment of the present invention.
[0020] The technical solution of this invention, based on the topology file of a first distributed database, determines the first system information of a first node; the first distributed database is a distributed database to be upgraded, and the first distributed database is in normal operating condition; the first node is one of all nodes in the first distributed database; a second node running a second distributed database determines the second system information of the second node; the second distributed database is the upgrade target of the first distributed database; the second node is one of all nodes in the second distributed database; so as to accurately determine the comparison result describing the system configuration differences between the first and second distributed databases based on the first and second system information, thereby constructing script information for the second distributed database based on the comparison result, realizing automatic configuration of the upgrade script for the distributed database upgrade, saving manpower costs, and further upgrading the first distributed database based on the script information, reducing the complexity of version upgrade operations, and improving the upgrade efficiency of the distributed database.
[0021] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a flowchart of a distributed database upgrade method provided by an embodiment of the present invention;
[0024] Figure 2 This is a schematic diagram illustrating the operation of the first and second distributed databases applicable to embodiments of the present invention.
[0025] Figure 3 This is a flowchart of another method for upgrading a distributed database according to an embodiment of the present invention;
[0026] Figure 4 This is a schematic diagram of the structure of an upgrade device for a distributed database according to an embodiment of the present invention;
[0027] Figure 5 This is a schematic diagram of the structure of an electronic device that implements the distributed database upgrade method of the present invention, according to an embodiment of the present invention. Detailed Implementation
[0028] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] Example 1
[0031] Figure 1 This is a flowchart illustrating a distributed database upgrade method provided in an embodiment of the present invention. This embodiment is applicable to upgrading distributed databases. The method can be executed by a distributed database upgrade device, which can be implemented in hardware and / or software. This distributed database upgrade device can be configured in any electronic device with network communication capabilities. Figure 1 As shown, the upgrade method for the distributed database of the present invention includes the following process:
[0032] S110. Based on the topology file of the first distributed database, determine the first system information of the first node; the first distributed database is a distributed database to be upgraded, and the first distributed database is in normal operating condition; the first node is one of all nodes in the first distributed database.
[0033] The first system information can be understood as the information of all system objects contained in the first distributed database.
[0034] Specifically, determining the first system information of the first node based on the topology file of the first distributed database may include: parsing the topology file of the first distributed database to obtain the parsing result; the parsing result includes multiple nodes and node system information; selecting a node from the parsing result as the first node, and determining the node system information associated with the first node as the first system information of the first node.
[0035] For example, such as Figure 2 As shown, the distributed database to be upgraded is the first distributed database of this invention, and the multiple nodes may include CN nodes, DN nodes, DN backup nodes, DN master nodes and GTM backup nodes; the CN node can be selected as the first node from the multiple nodes.
[0036] S120. Run the second node of the second distributed database and determine the second system information of the second node; the second distributed database is the upgrade target of the first distributed database; the second node is one of the nodes in the second distributed database.
[0037] The second system information can be understood as the information of all system objects contained in the second distributed database. The second node can be understood as a special state after the initialization of the second distributed database. For example, ... Figure 2 As shown, the minimalist distributed database is the second distributed database of this invention, and the minimalist node is the second node of this invention.
[0038] Specifically, the second distributed database is run in a simplified manner. The simplified manner can be understood as running on one of the nodes in the second distributed database, and the node of the second distributed database running in the simplified manner is used as the second node. At the same time, the second system information of the second node is obtained.
[0039] S130. Determine the comparison result of the first system information and the second system information; the comparison result is used to describe the system configuration differences between the first distributed database and the second distributed database.
[0040] Specifically, the data of the same type in the first system information and the second system information are compared to determine the system configuration differences between the first distributed database and the second distributed database. The system configuration differences between the first distributed database and the second distributed database are used as the comparison result of the first system information and the second system information, so as to facilitate the subsequent construction of script information for the second distributed database based on the comparison result.
[0041] Furthermore, the first system information can be used to describe the first object information of the system objects in the first distributed database. The second system information can be used to describe the second object information of the system objects in the second distributed database. System objects may include system namespaces, system types, system functions, system tables, and system views.
[0042] Optionally, determining the comparison result of the first system information and the second system information may include: associating and comparing the first object information and the second object information to determine the comparison result of the first system information and the second system information; each association comparison process involves comparing the same system objects in the first distributed database and the second distributed database.
[0043] Specifically, by comparing the object information of the same system objects in the first distributed database and the second distributed database, the differences in system configuration between the first and second distributed databases can be effectively distinguished, thus better determining the differences in system configuration between the first and second distributed databases and ensuring the accuracy of the comparison results.
[0044] S140. Based on the comparison results, construct the script information for the second distributed database, and upgrade the first distributed database based on the script information.
[0045] Specifically, based on the system configuration differences between the first and second distributed databases in the comparison results, script description data is determined; this script description data then guides the script data configuration tool to construct the script information for the second distributed database. The script description data describes the descriptive information used by the script data configuration tool to construct various script information.
[0046] Optionally, the script information for constructing the second distributed database based on the comparison results may include: script information for constructing the second distributed database according to preset rules for each system object in the comparison results; script information for constructing the second distributed database one by one according to the preset order of each type of system object; and script information for constructing the second distributed database system object for the same type of system object according to the corresponding identification information or parameter information of the system object.
[0047] Specifically, since various system objects may have dependencies on each other, the script information needs to be sorted according to the following preset rules when constructing the script. The preset rules can be as follows:
[0048] A. Construct the script information of the second distributed database one by one according to the preset sorting of system objects of each type. The preset sorting can be system namespace, system type, system function, system table and system view.
[0049] B. Script information for constructing a second distributed database system object based on the identification information or parameter information corresponding to the system object for the same type of system object.
[0050] 1. If the system object is a system namespace, it can be sorted alphabetically by the name of the system namespace as the order of the build script information for each system namespace.
[0051] 2. If the system object is a system function, the order of the script information for each system function can be sorted according to the number of parameters of the system function.
[0052] 3. The system object identification information can be sorted, and the sorting result can be used as the order of the system object construction script information.
[0053] Furthermore, after the above sorting process is completed, if a dependency relationship is detected between system objects, the script information of the dependent system objects will be constructed first.
[0054] In this embodiment of the invention, the script information of the second distributed database is constructed for each system object in the comparison results according to a preset rule. The preset rule is to construct the script information of the second distributed database one by one according to the preset order of each type of system object, and to construct the script information of the second distributed database system object according to the corresponding identification information or parameter information of the system object for the same type of system object, so as to ensure the accuracy of the script information during the construction process, and further ensure the accuracy of the complete script information of the finally determined second distributed database.
[0055] Furthermore, optionally, upgrading the first distributed database based on script information may include: uninstalling the started second distributed database, and performing a smooth upgrade of the first distributed database according to the topology file of the first distributed database and the script information of the second distributed database. The specific smooth upgrade may include the following process:
[0056] Step 1. Preparations before the upgrade
[0057] a) Check the health status of the first distributed database.
[0058] b) Analyze the topology file of the first distributed database to identify each node.
[0059] c) Analyze the dependencies between each node.
[0060] d) Construct a smooth upgrade strategy and critical path. The smooth upgrade strategy is mainly formulated according to the node order principle (CN->DN->GTM), the critical business principle (low business load priority), and the principle of backup nodes before primary nodes.
[0061] Step 2. Smooth Upgrade
[0062] a) Step 1: Upgrade 1 CN node and 1 DN node to verify basic functions.
[0063] b) Second step: Upgrade all remaining CN nodes.
[0064] c) Third step: Upgrade all remaining DN nodes in batches, using a chessboard-style upgrade method.
[0065] d) Step 4: Upgrade the GTM node.
[0066] Step 3. Verify after upgrading. Once verification is successful, confirm that the upgrade was successful.
[0067] The technical solution of this invention, based on the topology file of a first distributed database, determines the first system information of a first node; the first distributed database is a distributed database to be upgraded, and the first distributed database is in normal operating condition; the first node is one of all nodes in the first distributed database; a second node running a second distributed database determines the second system information of the second node; the second distributed database is the upgrade target of the first distributed database; the second node is one of all nodes in the second distributed database; so as to accurately determine the comparison result describing the system configuration differences between the first and second distributed databases based on the first and second system information, thereby constructing script information for the second distributed database based on the comparison result, realizing automatic configuration of the upgrade script for the distributed database upgrade, saving manpower costs, and further upgrading the first distributed database based on the script information, reducing the complexity of version upgrade operations, and improving the upgrade efficiency of the distributed database.
[0068] Example 2
[0069] Figure 3 This is a flowchart illustrating another method for upgrading a distributed database according to an embodiment of the present invention. The technical solution of this embodiment further optimizes the process of the distributed database upgrade method described in the foregoing embodiments based on the above embodiments. This embodiment can be combined with various optional solutions in one or more of the above embodiments. Figure 3 As shown, the upgrade method for a distributed database includes the following process:
[0070] S210. Based on the topology file of the first distributed database, determine the first system information of the first node; the first distributed database is a distributed database to be upgraded, and the first distributed database is in normal operating condition; the first node is one of all nodes in the first distributed database; the first system information is used to describe the first object information of the system object of the first distributed database; the system object is a system function.
[0071] S220. Run the second node of the second distributed database and determine the second system information of the second node; the second distributed database is the upgrade target of the first distributed database; the second node is one of the nodes in the second distributed database; the second system information is used to describe the second object information of the system objects of the second distributed database; the system objects are system functions.
[0072] S230. The first object information and the second object information are compared and correlated to determine the comparison result of the first system information and the second system information; the first object information of the system function is the system configuration information of the object identifier of the system function of the first distributed database within the first preset identifier; the second object information of the system function is the system configuration information of the object identifier of the system function of the second distributed database within the first preset identifier; the object identifier of the system function within the first preset identifier is fixed.
[0073] The first preset identifier is determined based on the configuration information of the system functions of the distributed database. For example, the first preset identifier can be 10000.
[0074] Specifically, comparing and associating the first object information and the second object information to determine the comparison result of the first system information and the second system information may include steps A1-A4:
[0075] Step A1: For the same system function, if the object identifier of the first object information is different from the object identifier of the second object information, then determine the first comparison result. The first comparison result is used to describe the object identifier change of the system function of the first distributed database and the system function of the second distributed database belonging to the same system function.
[0076] Specifically, it can be determined whether they are the same system function by the definition information of the system function. Since the object identifier of the system function in the first preset identifier is fixed, the same system function may have different object identifiers for different distributed systems. Thus, the first comparison result is determined based on the different object identifiers.
[0077] Step A2: For the same system function, if the object identifier of the first object information is the same as the object identifier of the second object information, but the function information of the same system function is different, then determine the second comparison result; the second comparison result is used to describe the function information changes of the system functions of the first distributed database and the system functions of the second distributed database that belong to the same system function.
[0078] Specifically, for the same system function, the object identifier of the first object information is the same as the object identifier of the second object information. However, for different distributed databases, the function information of the same system function may be different. Therefore, the second comparison result is determined based on the difference in the function information of the same system function.
[0079] Step A3: If the first system function exists in the first object information but does not exist in the second object information, then determine the third comparison result; the third comparison result is used to describe the first system function for deleting the first distributed database.
[0080] Specifically, if the first system function exists in the first object information but not in the second object information, it means that the first system function does not exist in the second distributed database. Therefore, the first system function needs to be deleted from the first distributed database, and the third comparison result needs to be determined.
[0081] Step A4: If the second system function exists in the second object information but not in the first object information, then the fourth comparison result is determined; the third comparison result is used to describe the addition of the second system function to the first distributed database.
[0082] Specifically, the second system function exists in the second object information but not in the first object information, indicating that the second system function exists in the second distributed database. Therefore, the second system function needs to be added to the first distributed database, and the fourth comparison result needs to be determined.
[0083] S240. The first object information and the second object information are compared and associated to determine the comparison result of the first system information and the second system information; the first object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function of the first distributed database; the second object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function of the second distributed database.
[0084] The second preset identifier is determined based on the configuration information of the system functions of the distributed database. For example, the second preset identifier can be 16384. Preset identifiers between the first and second preset identifiers can be randomly modified.
[0085] Specifically, comparing and associating the first object information and the second object information to determine the comparison result of the first system information and the second system information may include steps B1-B3:
[0086] Step B1: If the function information of the same system function is different, then determine the fifth comparison result; the fifth comparison result is used to describe the changes in function information of the system functions of the first distributed database and the system functions of the second distributed database that belong to the same system function.
[0087] Specifically, the different function information for the same system function indicates that the second distributed database modifies the function information for the same system function compared to the first distributed database, thus requiring modification of the system function in the first distributed database.
[0088] Step B2: If the third system function exists in the first object information but not in the second object information, then determine the sixth comparison result; the sixth comparison result is used to describe the deletion of the third system function of the first distributed database.
[0089] Specifically, if the third system function exists in the first object information but not in the second object information, it means that the third system function does not exist in the second distributed database. Therefore, the third system function in the first distributed database needs to be deleted, and the sixth comparison result needs to be determined.
[0090] Step B3: If the fourth system function exists in the second object information but not in the first object information, then the seventh comparison result is determined; the seventh comparison result is used to describe the addition of the fourth system function to the first distributed database.
[0091] Specifically, the fourth system function exists in the second object information but not in the first object information, indicating that the fourth system function exists in the second distributed database. Therefore, the fourth system function needs to be added to the first distributed database, and the seventh comparison result needs to be determined.
[0092] S250. Based on the comparison results, construct the script information for the second distributed database, and upgrade the first distributed database based on the script information.
[0093] Specifically, for system functions, the script information for constructing the second distributed database based on the comparison results can include script information for constructing system functions in the second distributed database based on the first comparison result, the second comparison result, the third comparison result, and the fourth comparison result; and script information for constructing system functions in the second distributed database based on the fifth comparison result, the sixth comparison result, and the seventh comparison result.
[0094] The specific process of constructing the script information for system functions in the second distributed database based on the first, second, third, and fourth comparison results may include: For the first comparison result, constructing script statements for the object identifiers of the system functions corresponding to the first comparison result; For the second and fourth comparison results, constructing script statements for the system functions corresponding to the second and fourth comparison results; For the third comparison result, constructing script statements for deleting the first system function.
[0095] Specifically, based on the fifth, sixth, and seventh comparison results, script information for system functions in the second distributed database is constructed. This process may include: constructing script statements for the system functions corresponding to the fifth and seventh comparison results; and constructing script statements to delete the third system function based on the sixth comparison result.
[0096] The technical solution of this invention addresses the construction process of script information for system functions as system objects. On one hand, the first object information of the system function is the system configuration information within a first preset identifier of the system function's object identifier in the first distributed database; the second object information of the system function is the system configuration information within the first preset identifier of the system function's object identifier in the second distributed database. The object identifier of the system function within the first preset identifier is fixed. Based on this, the first object information and the second object information are correlated and compared to determine the comparison result between the first system information and the second system information. On the other hand, the first object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function's object identifier in the first distributed database; the second object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function's object identifier in the second distributed database. Based on this, the first object information and the second object information are correlated and compared to determine the comparison result between the first system information and the second system information. In other words, this invention divides system functions using a first preset identifier and a second preset identifier, thereby preparing to compare the differences in system functions between the first distributed database and the second distributed database. This facilitates the construction of script information for the second distributed database based on the comparison results, and the upgrading of the first distributed database based on the script information. This achieves automatic configuration of the upgrade script for the distributed database, saving manpower costs, reducing the complexity of version upgrade operations, and improving the upgrade efficiency of the distributed database.
[0097] Example 3
[0098] Figure 4This is a schematic diagram of a distributed database upgrade device provided in an embodiment of the present invention. This embodiment is applicable to upgrading distributed databases. The distributed database upgrade device can be implemented in hardware and / or software, and can be configured in any electronic device with network communication capabilities. Figure 4 As shown, the upgrade device for the distributed database of the present invention includes:
[0099] The first information determination module 310 is used to determine the first system information of the first node based on the topology file of the first distributed database; the first distributed database is a distributed database to be upgraded and the first distributed database is in normal operating condition; the first node is one of all nodes in the first distributed database.
[0100] The second information determination module 320 is used to run the second node of the second distributed database and determine the second system information of the second node; the second distributed database is the upgrade target of the first distributed database; the second node is one of all nodes in the second distributed database;
[0101] The result determination module 330 is used to determine the comparison result between the first system information and the second system information; the comparison result is used to describe the system configuration differences between the first distributed database and the second distributed database.
[0102] Upgrade module 340 is used to construct script information for the second distributed database based on the comparison results, and to upgrade the first distributed database based on the script information.
[0103] Based on the above embodiments, optionally, the first system information of the first node is determined based on the topology file of the first distributed database, including:
[0104] The topology file of the first distributed database is parsed to obtain the parsing result; the parsing result includes multiple nodes and node system information;
[0105] Select a node from the parsing results as the first node, and determine the node system information associated with the first node as the first system information of the first node.
[0106] Based on the above embodiments, optionally, the first system information is used to describe the first object information of the system object of the first distributed database; the second system information is used to describe the second object information of the system object of the second distributed database.
[0107] Accordingly, the comparison result between the first system information and the second system information is determined, including:
[0108] The first object information and the second object information are correlated and compared to determine the comparison result of the first system information and the second system information; each correlation and comparison process is to compare the same system objects in the first distributed database and the second distributed database.
[0109] Based on the above embodiments, optionally, the system object includes a system namespace, system type, system function, system table, and system view.
[0110] Based on the above embodiments, optionally, the system object is a system function, the first object information of the system function is the system configuration information of the system function object identifier of the first distributed database within the first preset identifier; the second object information of the system function is the system configuration information of the system function object identifier of the second distributed database within the first preset identifier; the object identifier of the system function within the first preset identifier is fixed;
[0111] Accordingly, the first object information and the second object information are correlated and compared to determine the comparison result of the first system information and the second system information, including:
[0112] For the same system function, if the object identifier of the first object information is different from the object identifier of the second object information, then the first comparison result is determined. The first comparison result is used to describe the object identifier change of the system function of the first distributed database and the system function of the second distributed database belonging to the same system function.
[0113] For the same system function, if the object identifier of the first object information is the same as the object identifier of the second object information, but the function information of the same system function is different, then the second comparison result is determined; the second comparison result is used to describe the function information changes of the system functions of the first distributed database and the system functions of the second distributed database that belong to the same system function.
[0114] If the first system function exists in the first object information but not in the second object information, then a third comparison result is determined; the third comparison result is used to describe the first system function for deleting the first distributed database.
[0115] If the second system function exists in the second object information, but does not exist in the first object information, then a fourth comparison result is determined; the third comparison result is used to describe the addition of a second system function to the first distributed database.
[0116] Based on the above embodiments, optionally, the script information for constructing the second distributed database based on the comparison results includes:
[0117] For the first comparison result, construct the script statement of the object identifier of the system function corresponding to the first comparison result;
[0118] For the second comparison result and the fourth comparison result, construct script statements for the system functions corresponding to the second comparison result and the fourth comparison result;
[0119] Based on the third comparison result, a script statement is constructed to delete the first system function.
[0120] Based on the above embodiments, optionally, the system object is a system function, the first object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function of the first distributed database; the second object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function of the second distributed database.
[0121] Accordingly, the first object information and the second object information are correlated and compared to determine the comparison result of the first system information and the second system information, including:
[0122] If the function information of the same system function is different, then the fifth comparison result is determined; the fifth comparison result is used to describe the changes in function information of the system functions of the first distributed database and the system functions of the second distributed database that belong to the same system function.
[0123] If the first object information contains a third system function, but the second object information does not contain a third system function, then a sixth comparison result is determined; the sixth comparison result is used to describe the third system function for deleting the first distributed database.
[0124] If the second object information contains a fourth system function, but the first object information does not contain a fourth system function, then the seventh comparison result is determined; the seventh comparison result is used to describe the addition of a fourth system function to the first distributed database.
[0125] Based on the above embodiments, optionally, the script information for constructing the second distributed database based on the comparison results includes:
[0126] For the fifth comparison result and the seventh comparison result, construct the script statements of the system functions corresponding to the fifth comparison result and the seventh comparison result;
[0127] Based on the sixth comparison result, a script statement is constructed to delete the third system function.
[0128] Based on the above embodiments, optionally, the script information for constructing the second distributed database based on the comparison results includes:
[0129] The script information for constructing the second distributed database for each system object in the comparison results is constructed according to a preset rule. The preset rule is to construct the script information for constructing the second distributed database one by one according to the preset order of each type of system object, and to construct the script information for constructing the second distributed database system object according to the corresponding identification information or parameter information of the system object for the same type of system object.
[0130] The distributed database upgrade device provided in this embodiment of the invention can execute the distributed database upgrade method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.
[0131] Example 4
[0132] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0133] Figure 5 A schematic diagram of an electronic device is shown that can be used to implement the distributed database upgrade method of embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0134] like Figure 5As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0135] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0136] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the upgrade method for a distributed database.
[0137] In some embodiments, the distributed database upgrade method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the distributed database upgrade method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the distributed database upgrade method by any other suitable means (e.g., by means of firmware).
[0138] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0139] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0140] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0141] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0142] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0143] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0144] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0145] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for upgrading a distributed database, characterized in that, The method includes: Based on the topology file of the first distributed database, the first system information of the first node is determined; the first distributed database is a distributed database to be upgraded, and the first distributed database is in normal operating condition; the first node is one of all nodes in the first distributed database. Run the second node of the second distributed database and determine the second system information of the second node; the second distributed database is the upgrade target of the first distributed database; the second node is one of all nodes in the second distributed database; Determine the comparison result between the first system information and the second system information; the comparison result is used to describe the system configuration differences between the first distributed database and the second distributed database. The script information for constructing the second distributed database for each system object in the comparison results is built according to preset rules, and the first distributed database is upgraded based on the script information. The preset rules are: constructing the script information for the second distributed database one by one according to a preset order of each type of system object, and constructing the script information for the second distributed database system object according to the corresponding identification information or parameter information of the system object for the same type of system object; the system object includes system namespace, system type, system function, system table and system view; the preset order is system namespace, system type, system function, system table and system view. The script information for constructing the second distributed database system object based on the identification information or parameter information corresponding to the system object for the same type of system object includes: If the system object is a system namespace, it is sorted alphabetically according to the names of the system namespaces, which serves as the order of the system namespace construction script information. If the system object is a system function, sort the order of the system function's construction script information according to the number of parameter information of the system function; The identification information of the same system object is sorted, and the sorting result is used as the order of the construction script information of the same system object. The script information for constructing the second distributed database according to preset rules for each system object in the comparison results also includes: If a dependency relationship is detected between the system objects, the script information of the dependent system object is constructed first. Wherein, the first system information is used to describe the first object information of the system object of the first distributed database; the second system information is used to describe the second object information of the system object of the second distributed database; determining the comparison result of the first system information and the second system information includes: The first object information and the second object information are correlated and compared to determine the comparison result of the first system information and the second system information; each correlation and comparison process is to compare the same system objects in the first distributed database and the second distributed database. Wherein, if the system object is a system function, the first object information of the system function is the system configuration information of the system function object identifier of the first distributed database within the first preset identifier; the second object information of the system function is the system configuration information of the system function object identifier of the second distributed database within the first preset identifier; the object identifier of the system function within the first preset identifier is fixed; Accordingly, the first object information and the second object information are correlated and compared to determine the comparison result of the first system information and the second system information, including: For the same system function, if the object identifier of the first object information is different from the object identifier of the second object information, then the first comparison result is determined. The first comparison result is used to describe the object identifier change of the system function of the first distributed database and the system function of the second distributed database belonging to the same system function. For the same system function, if the object identifier of the first object information is the same as the object identifier of the second object information, but the function information of the same system function is different, then the second comparison result is determined; the second comparison result is used to describe the function information changes of the system functions of the first distributed database and the system functions of the second distributed database that belong to the same system function. If the first system function exists in the first object information but not in the second object information, then a third comparison result is determined; the third comparison result is used to describe the first system function for deleting the first distributed database. If the second system function exists in the second object information, but does not exist in the first object information, then a fourth comparison result is determined; the third comparison result is used to describe the addition of a second system function to the first distributed database. Wherein, if the system object is a system function, the first object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function of the first distributed database; the second object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function of the second distributed database; the preset identifier between the first preset identifier and the second preset identifier is not fixed; Accordingly, the first object information and the second object information are correlated and compared to determine the comparison result of the first system information and the second system information, including: If the function information of the same system function is different, then the fifth comparison result is determined; the fifth comparison result is used to describe the changes in function information of the system functions of the first distributed database and the system functions of the second distributed database that belong to the same system function. If the first object information contains a third system function, but the second object information does not contain a third system function, then a sixth comparison result is determined; the sixth comparison result is used to describe the third system function for deleting the first distributed database. If the second object information contains a fourth system function, but the first object information does not contain a fourth system function, then the seventh comparison result is determined; the seventh comparison result is used to describe the addition of a fourth system function to the first distributed database.
2. The method according to claim 1, characterized in that, Based on the topology file of the first distributed database, the first system information of the first node is determined, including: The topology file of the first distributed database is parsed to obtain the parsing result; the parsing result includes multiple nodes and node system information; Select a node from the parsing results as the first node, and determine the node system information associated with the first node as the first system information of the first node.
3. The method according to claim 1, characterized in that, The script information for constructing the second distributed database based on the comparison results includes: For the first comparison result, construct the script statement of the object identifier of the system function corresponding to the first comparison result; For the second comparison result and the fourth comparison result, construct script statements for the system functions corresponding to the second comparison result and the fourth comparison result; Based on the third comparison result, a script statement is constructed to delete the first system function.
4. The method according to claim 1, characterized in that, The script information for constructing the second distributed database based on the comparison results includes: For the fifth comparison result and the seventh comparison result, construct the script statements of the system functions corresponding to the fifth comparison result and the seventh comparison result; Based on the sixth comparison result, a script statement is constructed to delete the third system function.
5. An upgrade device for a distributed database, characterized in that, The device includes: The first information determination module is used to determine the first system information of the first node based on the topology file of the first distributed database; the first distributed database is a distributed database to be upgraded and the first distributed database is in normal operating condition; the first node is one of all nodes in the first distributed database. The second information determination module is used to run the second node of the second distributed database and determine the second system information of the second node; the second distributed database is the upgrade target of the first distributed database; the second node is one of all nodes in the second distributed database; The result determination module is used to determine the comparison result between the first system information and the second system information; the comparison result is used to describe the system configuration differences between the first distributed database and the second distributed database. The upgrade module is used to construct script information for the second distributed database for each system object in the comparison results according to preset rules, and to upgrade the first distributed database based on the script information. The preset rules are to construct script information for the second distributed database one by one according to a preset order of system objects of each type, and to construct script information for the second distributed database system objects of the same type according to the corresponding identifier information or parameter information of the system objects. The system objects include system namespaces, system types, system functions, system tables, and system views. The preset order is system namespaces, system types, system functions, system tables, and system views. The script information for constructing the second distributed database system object based on the identification information or parameter information corresponding to the system object for the same type of system object includes: If the system object is a system namespace, it is sorted alphabetically according to the names of the system namespaces, which serves as the order of the system namespace construction script information. If the system object is a system function, sort the order of the system function's construction script information according to the number of parameter information of the system function; The identification information of the same system object is sorted, and the sorting result is used as the order of the construction script information of the same system object. The script information for constructing the second distributed database according to preset rules for each system object in the comparison results also includes: If a dependency relationship is detected between the system objects, the script information of the dependent system object is constructed first. Wherein, the first system information is used to describe the first object information of the system object of the first distributed database; the second system information is used to describe the second object information of the system object of the second distributed database; determining the comparison result of the first system information and the second system information includes: associating and comparing the first object information and the second object information to determine the comparison result of the first system information and the second system information; each association comparison process is to compare the same system objects of the first distributed database and the second distributed database; Wherein, if the system object is a system function, the first object information of the system function is the system configuration information of the system function object identifier of the first distributed database within the first preset identifier; the second object information of the system function is the system configuration information of the system function object identifier of the second distributed database within the first preset identifier; the object identifier of the system function within the first preset identifier is fixed; Accordingly, the first object information and the second object information are compared and correlated to determine the comparison result of the first system information and the second system information, including: for the same system function, if the object identifier of the first object information is different from the object identifier of the second object information, a first comparison result is determined, which is used to describe the change of the object identifier of the system function of the first distributed database and the system function of the second distributed database belonging to the same system function; for the same system function, if the object identifier of the first object information is the same as the object identifier of the second object information, but the function information of the same system function is different, a second comparison result is determined; the second comparison result is used to describe the change of the function information of the system function of the first distributed database and the system function of the second distributed database belonging to the same system function; if the first system function exists in the first object information, but does not exist in the second object information, a third comparison result is determined; the third comparison result is used to describe the deletion of the first system function of the first distributed database; if the second system function exists in the second object information, but does not exist in the first object information, a fourth comparison result is determined; the third comparison result is used to describe the addition of the second system function to the first distributed database. Wherein, if the system object is a system function, the first object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function of the first distributed database; the second object information of the system function is the system configuration information between the first preset identifier and the second preset identifier of the system function of the second distributed database. Accordingly, the first object information and the second object information are compared and correlated to determine the comparison result of the first system information and the second system information, including: if the function information of the same system function is different, then a fifth comparison result is determined; the fifth comparison result is used to describe the function information change of the system functions of the first distributed database and the system functions of the second distributed database belonging to the same system function; if the first object information contains a third system function, but the second object information does not contain a third system function, then a sixth comparison result is determined; the sixth comparison result is used to describe the deletion of the third system function of the first distributed database; if the second object information contains a fourth system function, but the first object information does not contain a fourth system function, then a seventh comparison result is determined; the seventh comparison result is used to describe the addition of a fourth system function to the first distributed database.
6. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the upgrade method of the distributed database according to any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the method for upgrading the distributed database as described in any one of claims 1-4.
Citation Information
Patent Citations
Database updating method and device, electronic device and storage medium
CN118733604A