Node upgrading method and device, equipment and storage medium
By creating target nodes and establishing master-slave relationships during the PostgreSQL database node upgrade process, synchronizing log data and configuring virtual Internet protocol addresses, the downtime problem caused by node upgrade is solved, seamless upgrade is achieved, and business continuity and availability are improved.
Patent Information
- Application Number
- CN202510621942.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-08-08
AI Technical Summary
The existing technology requires downtime and maintenance when upgrading PostgreSQL database nodes, resulting in long-term service outages, affecting business continuity and availability.
By creating a target node, establishing a master-slave relationship between the node to be upgraded and the target node, synchronizing the log data, and configuring the target node based on the virtual Internet protocol address, and finally switching the database service to the target node, achieving seamless upgrade.
It shortens the service downtime, improves the continuity and availability of services, reduces the risk of manual operation errors, and improves the accuracy and efficiency of operations.
Smart Images

Figure CN120447927A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a node upgrade method, apparatus, device, and storage medium. Background Art
[0002] PostgreSQL is an open-source relational database management system that supports the writing and installation of custom plug-ins. Its powerful functionality and rich features make it widely used across industries. However, upgrading and updating existing PostgreSQL database nodes requires prior notification of maintenance downtime. Operations and maintenance personnel then manually add configuration information within a specified timeframe, regenerate the image file, replace the existing image file with the newly generated one, and restart the database service. This results in lengthy service downtime and has a direct impact on business operations. Therefore, how to upgrade PostgreSQL database nodes to improve business continuity is a technical challenge that needs to be addressed. Summary of the Invention
[0003] In order to solve the above technical problems, the present disclosure provides a node upgrade method, device, equipment and storage medium.
[0004] A first aspect of an embodiment of the present disclosure provides a node upgrade method, the method comprising:
[0005] Creating a target node based on a pre-acquired target image file, a target configuration file, and node backup data of the node to be upgraded, wherein the target image file and the target configuration file include information for implementing a target function to be upgraded;
[0006] Establishing a first master-slave relationship between the node to be upgraded and the target node, and synchronizing target log data generated by the node to be upgraded after the target node is created to the target node based on the first master-slave relationship;
[0007] Configuring the target node based on the pre-acquired virtual Internet Protocol address of the node to be upgraded;
[0008] Switch the database service from the node to be upgraded to the target node.
[0009] A second aspect of an embodiment of the present disclosure provides a node upgrade device, the device comprising:
[0010] a first creation module, configured to create a target node based on a pre-acquired target image file, a target configuration file, and node backup data of the node to be upgraded, wherein the target image file and the target configuration file include information for realizing a target function to be upgraded;
[0011] A first synchronization module is configured to establish a first master-slave relationship between the node to be upgraded and the target node, and synchronize target log data generated by the node to be upgraded after the target node is created to the target node based on the first master-slave relationship;
[0012] a configuration module, configured to configure the target node based on the pre-acquired virtual Internet Protocol address of the node to be upgraded;
[0013] The switching module is used to switch the database service from the node to be upgraded to the target node.
[0014] A third aspect of an embodiment of the present disclosure provides a computer device comprising a memory, a processor, and a computer program, wherein the computer program is stored in the memory, and when the computer program is executed by the processor, the node upgrade method as described in the first aspect above is implemented.
[0015] A fourth aspect of an embodiment of the present disclosure provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the node upgrade method as described in the first aspect above is implemented.
[0016] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art:
[0017] In the node upgrade method, apparatus, device and storage medium provided in the embodiments of the present disclosure, a target node is created based on a pre-acquired target image file, a target configuration file and node backup data of the node to be upgraded, the target image file and the target configuration file include information for realizing the target function to be upgraded, a first master-slave relationship is established between the node to be upgraded and the target node, and the target log data generated by the node to be upgraded after the target node is created is synchronized to the target node based on the first master-slave relationship, the target node is configured based on the pre-acquired virtual Internet Protocol address of the node to be upgraded, the database service is switched from the node to be upgraded to the target node, a target node including the target function to be upgraded can be created, data synchronization and network address configuration are performed on the target node based on the node to be upgraded that originally provided the service, so that the target node has the ability to provide database services instead of the node to be upgraded, and then the node providing the database service is switched from the node to be upgraded to the target node, so that when the node needs to be upgraded, the service is only stopped when the node is switched, which shortens the service downtime and improves the continuity and availability of customer services. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0019] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0020] Figure 1 This is a flowchart of a node upgrade method provided by an embodiment of the present disclosure;
[0021] Figure 2 This is a flowchart of a method for switching a service node provided by an embodiment of the present disclosure;
[0022] Figure 3 is a flow chart of a method for verifying data consistency provided by an embodiment of the present disclosure;
[0023] Figure 4 is a flowchart of another method for verifying data consistency provided by an embodiment of the present disclosure;
[0024] Figure 5 This is a flowchart of a method for setting a standby node provided by an embodiment of the present disclosure;
[0025] Figure 6 This is a schematic diagram of the structure of a node upgrade device provided by an embodiment of the present disclosure;
[0026] Figure 7 It is a structural diagram of a computer device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.
[0028] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0029] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0030] Figure 1This is a flowchart of a node upgrade method provided by an embodiment of the present disclosure. The method can be executed by a node upgrade device. The node upgrade device can be implemented in software and / or hardware. The node upgrade device can be configured in an electronic device, such as a server or a terminal, wherein the terminal specifically includes a mobile phone, a computer or a tablet computer. Figure 1 As shown, the node upgrade method provided in this embodiment includes the following steps:
[0031] S101: Create a target node based on a pre-acquired target image file, a target configuration file, and node backup data of a node to be upgraded. The target image file and the target configuration file include information for realizing a target function to be upgraded.
[0032] In the embodiments of the present disclosure, an image file can be understood as a complete snapshot or clone of a virtual machine, including the operating system, applications, and all data. This image file is used to create a new virtual machine instance, which can then be used as a service node. A target image file can be understood as an image file containing information for implementing a target function when the target function needs to be upgraded. Nodes created based on the target image file can implement the target function.
[0033] The configuration file in the embodiment of the present disclosure can be understood as a file used to store various parameters required for node operation, and the target configuration file can be understood as a configuration file that contains operating parameters related to implementing the target function to be upgraded when the target function to be upgraded needs to be upgraded.
[0034] The node backup data in the embodiment of the present disclosure can be understood as data recorded by the node to be upgraded in the process of providing database services. The backup data is stored in a specific directory, and the node backup data of the node to be upgraded can be located and obtained through the specific directory.
[0035] The target functions in the embodiments of the present disclosure may include slow logs, advanced monitoring tools, backup and recovery tools, other functional plug-ins, etc., which are not limited here.
[0036] In the embodiment of the present disclosure, when it is necessary to perform a functional upgrade or version update on the node to be upgraded, the node upgrade device can obtain the target image file and target configuration file required for this upgrade and update from the image library and configuration file library, and obtain the node backup data of the node to be upgraded that originally provided the database service, and create a target node based on the pre-acquired target image file, target configuration file and node backup data of the node to be upgraded. Specifically, the target node can be created using Linux Containers (LUC) technology.
[0037] In an exemplary implementation of the disclosed embodiment, the node upgrade device may, after creating the target node, assign an initial virtual Internet Protocol address to the target node, initialize system parameters, install and configure PostgreSQL dependent components and tools and library files related to the target function to be upgraded.
[0038] In some embodiments, before creating a target node, the node upgrade device may determine a target configuration template corresponding to the version number based on the version number of the target image file; update the configuration file to be upgraded corresponding to the node to be upgraded based on the target configuration template to obtain the target configuration file.
[0039] The target configuration file can be obtained by updating the configuration file using the target configuration template corresponding to the target function to be upgraded. The target configuration template can be understood as a configuration template set up specifically for the target function to be upgraded. For example, when a user wants to upgrade a node to support the slow log function, in addition to supporting the slow log binary, the target configuration template needs to set the parameter log_destination = 'stderr,csvlog,syslog,slowlog'.
[0040] Specifically, after determining the target image file used for this upgrade, the node upgrade device can obtain the version number of the target image file, and determine the target configuration template corresponding to the version number based on the version number. Optionally, the target configuration template can be determined by the correspondence between the pre-acquired version number and the configuration template, or the target configuration template whose name contains the version number can be searched based on the file name of the configuration template. After determining the target configuration template, the node upgrade device can use the target configuration template to update the configuration file to be upgraded corresponding to the node to be upgraded. During the update process, the node upgrade device can first back up the configuration file to be upgraded, and then modify the parameters. After the modification is completed, a syntax check is performed to ensure that the configuration file is correct and then determine it as the target configuration file. By setting the target configuration template and updating the configuration file, the configuration file can be managed independently during each upgrade to avoid configuration confusion, thereby maintaining system stability.
[0041] S102: Establish a first master-slave relationship between the node to be upgraded and the target node, and synchronize target log data generated by the node to be upgraded after the target node is created to the target node based on the first master-slave relationship.
[0042] The target log data in the embodiment of the present disclosure can be understood as the log data generated by the node to be upgraded continuing to provide data services normally after the target node is created (that is, after the generation time of the latest data in the node backup data).
[0043] In an embodiment of the present disclosure, the node upgrading device can establish a first master-slave relationship between the node to be upgraded and the target node after the target node is created, with the node to be upgraded as the master node and the target node as the slave node of the node to be upgraded. Based on the first master-slave relationship, the target log data generated by the node to be upgraded after the target node is created is sent to the target node, so that the target node synchronizes the target log data.
[0044] In an exemplary implementation of the disclosed embodiments, a node upgrade device can synchronize target log data through streaming replication. During the streaming replication process, target log data is continuously transmitted from the node to be upgraded to the target node, which receives and applies the data to ensure data consistency with the node to be upgraded. The data transmission can be processed concurrently by multiple threads, and a heartbeat detection mechanism can be set to ensure the reliability of data synchronization.
[0045] S103: Configure the target node based on the pre-acquired virtual Internet Protocol address of the node to be upgraded.
[0046] In the embodiment of the present disclosure, after the data synchronization between the node to be upgraded and the target node is completed, the node upgrading device can set and configure the VIP address of the target node based on the pre-acquired Virtual Internet Protocol (VIP) address of the node to be upgraded. Specifically, the VIP address of the target node can be set to the VIP address of the node to be upgraded, so that the client that originally accessed the node to be upgraded through the VIP address of the node to be upgraded can access the target node through the same VIP address after the subsequent service node is switched. At this time, although the target node has a VIP that can provide database services, it cannot perform write operations.
[0047] S104: Switch the database service from the node to be upgraded to the target node.
[0048] In the embodiment of the present disclosure, the node upgrade device can switch the database service from the original node to be upgraded to the target node after the data synchronization between the node to be upgraded and the target node is completed and the VIP address of the target node is also configured, so that the client can access the target node through the VIP address originally used to obtain the database service, and the target node continues to provide the database service.
[0049] In some embodiments, the node upgrading apparatus may shut down the database service of the node to be upgraded and set the target node to the master node state.
[0050] Specifically, when switching service nodes, the node upgrade device can send a service shutdown instruction to the node to be upgraded. After receiving the instruction, the node to be upgraded performs relevant operations to shut down the database service, and after the database service is completely shut down, it feedbacks status information to the node upgrade device. After receiving the status information fed back by the node to be upgraded, the node upgrade device confirms that the node to be upgraded has shut down the database service based on the status information, and then sends a status change instruction to the target node to upgrade the target node to a master state where data can be written. The target node changes from its original read-only state to a state that supports data reading and writing, and takes over the database service of the node to be upgraded.
[0051] Optionally, before the node to be upgraded shuts down the database service, the node to be upgraded processes the database access request, and the request forwarding agent records the key information of the database access request in the message queue. After the target node is set to the master node state, the target node processes the unprocessed database access requests in the message queue to realize the switching of the service node.
[0052] In an exemplary implementation of the embodiment of the present disclosure, the node upgrading device may delete the node to be upgraded after completing the switching of the service node, and update the metadata database information to restore the normal state of the database service.
[0053] The disclosed embodiment creates a target node based on a pre-acquired target image file, a target configuration file, and node backup data of the node to be upgraded, wherein the target image file and the target configuration file include information for implementing the target function to be upgraded, establishes a first master-slave relationship between the node to be upgraded and the target node, and synchronizes the target log data generated by the node to be upgraded after the target node is created to the target node based on the first master-slave relationship, configures the target node based on the pre-acquired virtual Internet Protocol address of the node to be upgraded, switches the database service from the node to be upgraded to the target node, and is able to create a target node containing the target function to be upgraded, synchronizes data and configures the network address of the target node based on the node to be upgraded that originally provided the service, so that the target node has the ability to provide database services instead of the node to be upgraded, and then switches the node providing the database service from the node to be upgraded to the target node, so that when the node needs to be upgraded, the service is only stopped when the node is switched, shortening the service downtime and improving the continuity and availability of customer services. At the same time, compared with the traditional manual operation method, the automated process of minor version upgrade avoids the risk of human error, improves the accuracy and efficiency of operation, and thus reduces the error rate and operational risk in the operation and maintenance process.
[0054] Figure 2 This is a flow chart of a method for switching a service node provided by an embodiment of the present disclosure. Figure 2 As shown, based on the above embodiment, the service node can be switched by the following method.
[0055] S201: Verify whether the log data of the node to be upgraded is consistent with that of the target node.
[0056] In the disclosed embodiment, the node upgrade device may first verify the data synchronization between the target node and the node to be upgraded before switching the database service to the target node. Specifically, it may verify whether the log data of the node to be upgraded is consistent with that of the target node.
[0057] In an exemplary implementation of the disclosed embodiment, the node upgrade apparatus may verify whether the log data of the node to be upgraded is consistent with that of the target node by comparing the checksum of the log data, the consistency of key data, and the like.
[0058] S202: In response to the log data of the node to be upgraded being consistent with the log data of the target node, executing the step of switching the database service from the node to be upgraded to the target node.
[0059] In the embodiment of the present disclosure, the node upgrading apparatus may execute the step of switching the database service from the node to be upgraded to the target node in S104 after determining that the log data of the node to be upgraded is consistent with the log data of the target node, thereby switching the service node.
[0060] In an exemplary implementation of the embodiment of the present disclosure, the node upgrade device can perform an initial verification on whether the log data of the node to be upgraded and the target node are consistent after executing S102. If the verification is passed, the operation of configuring VIP in S103 is executed. After the configuration is completed, the consistency of the log data of the node to be upgraded and the target node is verified again. If the verification is passed, the operation of switching the service node in S104 is executed. The verification standards used in the two verifications may be the same or different, and are not limited here.
[0061] The disclosed embodiment verifies whether the log data of the node to be upgraded is consistent with the target node. In response to the consistency of the log data of the node to be upgraded and the target node, the step of switching the database service from the node to be upgraded to the target node is executed. This can effectively troubleshoot problems that may occur during the data synchronization process, such as data loss, data corruption, etc., thereby improving service reliability and ensuring that users can continue to obtain stable and reliable database services after switching the service node.
[0062] Figure 3 This is a flow chart of a method for verifying data consistency provided by an embodiment of the present disclosure. Figure 3 As shown, based on the above embodiment, data consistency can be verified by the following method.
[0063] S301: When the database version corresponding to the node to be upgraded is lower than the preset version, obtain the first log position of the node to be upgraded, the second log position of the target node, and the timestamp of the last transaction replay of the target node.
[0064] In the embodiment of the present disclosure, when the node upgrade device needs to verify the data synchronization status of the node to be upgraded and the target node, different methods can be used to implement the verification according to the database version providing database services on the node to be upgraded. Specifically, after obtaining the database version corresponding to the node to be upgraded, it can be compared with the preset version. If the database version corresponding to the node to be upgraded is lower than the preset version, the verification parameters required to verify data synchronization are determined to be the first log position of the node to be upgraded, the second log position of the target node, and the timestamp of the last transaction replay of the target node, and the above verification parameters are obtained.
[0065] In an exemplary implementation of the embodiments of the present disclosure, the node upgrade device can control the node to be upgraded to execute "select pg_current_xlog_location()" to obtain the first log location of the Write-Ahead Logging (WAL) of the node to be upgraded, control the target node to execute "select pg_last_xact_replay_timestamp()" to obtain the second log location of the WAL log of the target node, and execute "select pg_last_xlog_replay_location()" to obtain the timestamp of the last transaction replay of the target node.
[0066] S302. When the first log position and the second log position are the same, and / or the format of the timestamp of the last transaction replay of the target node is not a preset format, it is determined that the log data of the node to be upgraded is consistent with that of the target node; otherwise, it is determined that the log data of the node to be upgraded is inconsistent with that of the target node.
[0067] The preset format in the embodiment of the present disclosure can be understood as a commonly used format for timestamp data.
[0068] In the embodiment of the present disclosure, the node upgrade device can determine whether the first log position and the second log position are the same, and whether the format of the timestamp of the last transaction replay of the target node is a preset format after obtaining the first log position of the node to be upgraded, the second log position of the target node, and the timestamp of the last transaction replay of the target node. If at least one of the following conditions is met, it is determined that the log data of the node to be upgraded is consistent with that of the target node, and the data consistency verification is passed: the first log position and the second log position are the same, and the format of the timestamp of the last transaction replay of the target node is not the preset format (indicating that the transaction may not be replayed). Otherwise, if the first log position and the second log position are different, and the format of the timestamp of the last transaction replay of the target node is the preset format, it is determined that the log data of the node to be upgraded is inconsistent with that of the target node, and the data consistency verification is not passed.
[0069] In an exemplary implementation of the embodiments of the present disclosure, the node upgrade device can set the value of the parameter used to characterize the verification result to True when it is determined that the log data of the node to be upgraded is consistent with that of the target node and passes the data consistency verification, and return a delay time of 0; when it is determined that the log data of the node to be upgraded is inconsistent with that of the target node and fails the data consistency verification, further query the difference between the current time of the target node and the time of the last transaction replay, that is, calculate the data synchronization delay time by executing "select EXTRACT(EPOCH FROM now()-pg_last_xact_replay_timestamp())", and then perform data synchronization between the node to be upgraded and the target node again according to the synchronization delay time.
[0070] The disclosed embodiment obtains the first log position of the node to be upgraded, the second log position of the target node, and the timestamp of the last transaction replay of the target node when the database version corresponding to the node to be upgraded is lower than the preset version. When the first log position is the same as the second log position and / or the format of the timestamp of the last transaction replay of the target node is not in the preset format, it is determined that the log data of the node to be upgraded and the target node are consistent. Otherwise, it is determined that the log data of the node to be upgraded and the target node are inconsistent. Differentiated master-slave synchronization detection strategies can be executed according to the version of the PostgreSQL database providing database services on the node to be upgraded. For low-version databases, the data synchronization status can be more accurately verified through multi-dimensional detection methods, ensuring that the data of the target node is fully synchronized before providing database services, thereby avoiding service interruptions caused by delays or data inconsistencies.
[0071] Figure 4 This is a flow chart of another method for verifying data consistency provided by an embodiment of the present disclosure. Figure 4As shown, based on the above embodiment, data consistency can be verified by the following method.
[0072] S401: When the database version corresponding to the node to be upgraded is higher than or equal to the preset version, query the replication delay time of the target node.
[0073] In an embodiment of the present disclosure, the node upgrade device can obtain the database version providing database services on the node to be upgraded, and then compare it with a preset version. If the database version corresponding to the node to be upgraded is higher than or equal to the preset version, it is determined that the node to be upgraded can provide the built-in view pg_stat_replication, and the replication delay information of the target node can be directly obtained through the built-in view. Therefore, the replication delay information is determined as a verification parameter that needs to be obtained and obtained.
[0074] In an exemplary implementation of the disclosed embodiment, the node upgrade apparatus may control the node to be upgraded to execute "select replay_lag from pg_stat_replication where client_addr='%s'"%get_listen_host()" to query the replication delay time of the target node.
[0075] S402: When the query result of the replication delay time is empty, it is determined that the log data of the node to be upgraded is consistent with that of the target node; otherwise, it is determined that the log data of the node to be upgraded is inconsistent with that of the target node.
[0076] In the embodiment of the present disclosure, the node upgrade device can determine that the log data of the node to be upgraded is consistent with that of the target node when the query result of the replication delay time is empty, and the data synchronization progress of the target node has completely caught up with the node to be upgraded, and return the delay time as 0; otherwise, the query result of the replication delay time is parsed and converted into the total number of seconds, and returned as the data synchronization delay time, and then the data synchronization between the node to be upgraded and the target node is performed again according to the synchronization delay time.
[0077] The embodiment of the present disclosure queries the replication delay time of the target node when the database version corresponding to the node to be upgraded is higher than or equal to the preset version. When the query result of the replication delay time is empty, it is determined that the log data of the node to be upgraded is consistent with that of the target node. Otherwise, it is determined that the log data of the node to be upgraded is inconsistent with that of the target node. Differentiated master-slave synchronization detection strategies can be executed according to the version of the PostgreSQL database providing database services on the node to be upgraded. For high-version databases, the replication delay time of the target node is directly queried, which simplifies the verification process and ensures that the data of the target node is fully synchronized before providing database services, thereby avoiding service interruptions caused by delays or data inconsistencies.
[0078] Figure 5 This is a flow chart of a method for setting a standby node provided by an embodiment of the present disclosure. Figure 5 As shown, based on the above embodiment, the backup node can be set by the following method.
[0079] S501: Create a standby node based on a target image file, a target configuration file, and node backup data.
[0080] The standby node in the embodiment of the present disclosure can be understood as being used to back up the target node. When a problem occurs in the target node, causing the database service to fail to operate normally, the standby node can take over the target node to provide database services.
[0081] In the embodiment of the present disclosure, the node upgrade device can create a standby node based on the target image file, target configuration file and node backup data used when creating the target node before switching the service node. The specific creation method is similar to S101 and will not be repeated here.
[0082] Optionally, the node upgrade device may simultaneously create a target node and a standby node based on the target image file, the target configuration file, and the node backup data.
[0083] S502: Establish a second master-slave relationship between the node to be upgraded and the standby node, and synchronize target log data generated by the node to be upgraded after the target node is created to the standby node based on the second master-slave relationship.
[0084] In the embodiment of the present disclosure, the node upgrading device can establish a second master-slave relationship between the node to be upgraded and the standby node after the standby node is created, with the node to be upgraded as the master node and the standby node as the slave node of the node to be upgraded. Based on the second master-slave relationship, the target log data generated by the node to be upgraded after the standby node is created is sent to the standby node, so that the standby node synchronizes the target log data. The specific synchronization method is similar to S102 and will not be repeated here.
[0085] S503: Establish a third master-slave relationship between the target node and the backup node.
[0086] In the embodiment of the present disclosure, the node upgrading device can establish a third master-slave relationship between the target node and the backup node after completing the switching of the service node, with the target node as the master node and the backup node as the slave node of the target node.
[0087] The embodiment of the present disclosure creates a backup node based on the target image file, the target configuration file and the node backup data, establishes a second master-slave relationship between the node to be upgraded and the backup node, and synchronizes the target log data generated by the node to be upgraded after the target node is created to the backup node based on the second master-slave relationship, and establishes a third master-slave relationship between the target node and the backup node, thereby improving the disaster recovery capability of the target node.
[0088] Figure 6 This is a schematic diagram of the structure of a node upgrade device provided by an embodiment of the present disclosure. Figure 6 As shown, the node upgrade device 600 includes: a first creation module 610, a first synchronization module 620, a configuration module 630, and a switching module 640, wherein the first creation module 610 is used to create a target node based on a pre-acquired target image file, a target configuration file, and the node backup data of the node to be upgraded, and the target image file and the target configuration file include information for realizing the target function to be upgraded; the first synchronization module 620 is used to establish a first master-slave relationship between the node to be upgraded and the target node, and synchronize the target log data generated by the node to be upgraded after the target node is created to the target node based on the first master-slave relationship; the configuration module 630 is used to configure the target node based on the pre-acquired virtual Internet Protocol address of the node to be upgraded; and the switching module 640 is used to switch the database service from the node to be upgraded to the target node.
[0089] Optionally, the node upgrade device 600 also includes: a verification module for verifying whether the log data of the node to be upgraded is consistent with that of the target node; the switching module 640 is specifically used to execute the step of switching the database service from the node to be upgraded to the target node in response to the log data of the node to be upgraded being consistent with that of the target node.
[0090] Optionally, the verification module includes: an acquisition unit, used to obtain the first log position of the node to be upgraded, the second log position of the target node, and the timestamp of the last transaction replay of the target node when the database version corresponding to the node to be upgraded is lower than the preset version; a first determination unit, used to determine that the log data of the node to be upgraded is consistent with that of the target node when the first log position is the same as the second log position and / or the format of the timestamp of the last transaction replay of the target node is not a preset format; otherwise, determine that the log data of the node to be upgraded is inconsistent with that of the target node.
[0091] Optionally, the verification module includes: a query unit, used to query the replication delay time of the target node when the database version corresponding to the node to be upgraded is higher than or equal to a preset version; a second determination unit, used to determine that the log data of the node to be upgraded is consistent with that of the target node when the query result of the replication delay time is empty, otherwise determine that the log data of the node to be upgraded is inconsistent with that of the target node.
[0092] Optionally, the switching module 640 is specifically configured to shut down the database service of the node to be upgraded and set the target node to a master node state.
[0093] Optionally, the node upgrade device 600 also includes: a determination module, used to determine the target configuration template corresponding to the version number based on the version number of the target image file; an update module, used to update the configuration file to be upgraded corresponding to the node to be upgraded based on the target configuration template to obtain the target configuration file.
[0094] Optionally, the node upgrade device 600 also includes: a second creation module, used to create a backup node based on the target image file, the target configuration file and the node backup data; a second synchronization module, used to establish a second master-slave relationship between the node to be upgraded and the backup node, and based on the second master-slave relationship, synchronize the target log data generated by the node to be upgraded after the target node is created to the backup node; an establishment module, used to establish a third master-slave relationship between the target node and the backup node.
[0095] The node upgrade device provided in this embodiment can execute the method described in any of the above embodiments. Its execution method and beneficial effects are similar and will not be described in detail here.
[0096] Figure 7 It is a structural diagram of a computer device provided by an embodiment of the present disclosure.
[0097] like Figure 7 As shown, the computer device may include a processor 710 and a memory 720 storing computer program instructions.
[0098] Specifically, the processor 710 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0099] Memory 720 may include a large-capacity memory for information or instructions. By way of example, and not limitation, memory 720 may include a hard disk drive (HDD), a floppy disk drive, flash memory, an optical disk, a magneto-optical disk, magnetic tape, or a Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 720 may include removable or non-removable (or fixed) media. Where appropriate, memory 720 may be internal or external to the integrated gateway device. In certain embodiments, memory 720 is non-volatile solid-state memory. In certain embodiments, memory 720 includes read-only memory (ROM). Where appropriate, the ROM may be mask-programmed ROM, programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable PROM (EEPROM), electrically alterable ROM (EAROM), or flash memory, or a combination of two or more of these.
[0100] The processor 710 reads and executes the computer program instructions stored in the memory 720 to perform the steps of the node upgrade method provided in the embodiment of the present disclosure.
[0101] In one example, the computer device may further include a transceiver 730 and a bus 740. Figure 7 As shown, the processor 710 , the memory 720 and the transceiver 730 are connected via a bus 740 and communicate with each other.
[0102] The bus 740 includes hardware, software, or both. By way of example and not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, the bus 740 may include one or more buses. Although embodiments herein describe and illustrate a particular bus, this application contemplates any suitable bus or interconnect.
[0103] The embodiments of the present disclosure further provide a computer-readable storage medium, which may store a computer program. When the computer program is executed by a processor, the processor implements the node upgrade method provided by the embodiments of the present disclosure.
[0104] The above-mentioned storage medium may, for example, include a memory 720 of computer program instructions, and the above-mentioned instructions may be executed by the processor 710 of the node upgrade device to complete the node upgrade method provided by the embodiment of the present disclosure. Optionally, the storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a ROM, a random access memory (Random Access Memory, RAM), a compact disc read-only memory (Compact Disc ROM, CD-ROM), a magnetic tape, a floppy disk, and an optical data storage device, etc. The above-mentioned computer program may be written in any combination of one or more programming languages to write a program code for performing the operation of the embodiment of the present disclosure, and the programming language includes an object-oriented programming language, such as Java, C++, etc., and also includes a conventional procedural programming language, such as "C" language or similar programming language. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device, partially on the remote computing device, or entirely on the remote computing device or server.
[0105] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0106] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.
Claims
1. A node upgrade method, characterized in that: The method comprises: Creating a target node based on a pre-acquired target image file, a target configuration file, and node backup data of the node to be upgraded, wherein the target image file and the target configuration file include information for implementing a target function to be upgraded; Establishing a first master-slave relationship between the node to be upgraded and the target node, and synchronizing target log data generated by the node to be upgraded after the target node is created to the target node based on the first master-slave relationship; Configuring the target node based on the pre-acquired virtual Internet Protocol address of the node to be upgraded; Switch the database service from the node to be upgraded to the target node.
2. The method according to claim 1, characterized in that Before switching the database service from the node to be upgraded to the target node, the method further includes: Verify whether the log data of the node to be upgraded is consistent with that of the target node; The switching of the database service from the node to be upgraded to the target node includes: In response to the log data of the node to be upgraded being consistent with the log data of the target node, a step of switching the database service from the node to be upgraded to the target node is executed.
3. The method according to claim 2, characterized in that The verifying whether the log data of the node to be upgraded is consistent with the log data of the target node includes: When the database version corresponding to the node to be upgraded is lower than the preset version, obtaining the first log position of the node to be upgraded, the second log position of the target node, and the timestamp of the last transaction replay of the target node; When the first log position is the same as the second log position, and / or the format of the timestamp of the last transaction replay of the target node is not a preset format, it is determined that the log data of the node to be upgraded is consistent with that of the target node; otherwise, it is determined that the log data of the node to be upgraded is inconsistent with that of the target node.
4. The method according to claim 2, characterized in that The verifying whether the log data of the node to be upgraded is consistent with the log data of the target node includes: When the database version corresponding to the node to be upgraded is higher than or equal to the preset version, query the replication delay time of the target node; When the query result of the replication delay time is empty, it is determined that the log data of the node to be upgraded is consistent with that of the target node; otherwise, it is determined that the log data of the node to be upgraded is inconsistent with that of the target node.
5. The method according to claim 1, wherein The switching of the database service from the node to be upgraded to the target node includes: Shut down the database service of the node to be upgraded, and set the target node to the master node state.
6. The method according to claim 1, characterized in that Before creating the target node based on the pre-acquired target image file, target configuration file, and node backup data of the node to be upgraded, the method further includes: Determine, based on the version number of the target image file, a target configuration template corresponding to the version number; The configuration file to be upgraded corresponding to the node to be upgraded is updated based on the target configuration template to obtain the target configuration file.
7. The method according to claim 1, characterized in that Before switching the database service from the node to be upgraded to the target node, the method further includes: Creating a standby node based on the target image file, the target configuration file, and the node backup data; Establishing a second master-slave relationship between the node to be upgraded and the standby node, and synchronizing target log data generated by the node to be upgraded after the target node is created to the standby node based on the second master-slave relationship; After switching the database service from the node to be upgraded to the target node, the method further includes: A third master-slave relationship is established between the target node and the backup node.
8. A node upgrade device, characterized in that: The device comprises: a first creation module, configured to create a target node based on a pre-acquired target image file, a target configuration file, and node backup data of the node to be upgraded, wherein the target image file and the target configuration file include information for realizing a target function to be upgraded; A first synchronization module is configured to establish a first master-slave relationship between the node to be upgraded and the target node, and synchronize target log data generated by the node to be upgraded after the target node is created to the target node based on the first master-slave relationship; a configuration module, configured to configure the target node based on the pre-acquired virtual Internet Protocol address of the node to be upgraded; The switching module is used to switch the database service from the node to be upgraded to the target node.
9. A computer device, characterized in that: include: Memory; processor; and a computer program; wherein the computer program is stored in the memory and is configured to be executed by the processor to implement the node upgrade method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and when the computer program is executed by the processor, the node upgrade method according to any one of claims 1 to 7 is implemented.