A method and system for lossless upgrade and traffic migration of Nacos cluster based on double-center environment
By using traffic replication and switching methods with Nginx servers and load balancers in a dual-center environment, the cluster avalanche and instance issues during Nacos cluster upgrades were resolved, achieving lossless upgrades and expansions and ensuring high availability and stability of the application.
Patent Information
- Application Number
- CN202411774411.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-12-05
AI Technical Summary
When upgrading large-scale enterprise-level Nacos clusters, existing technologies cannot achieve lossless upgrades, which can easily lead to cluster avalanche, instance degradation and instance loss, affecting application transactions and user experience.
In a dual-center environment, first and second Nacos clusters are deployed, and traffic replication and switching are achieved through Nginx servers and load balancers to ensure that registration heartbeats and subscription traffic are migrated to the new cluster without affecting the application, thus completing the cluster expansion and upgrade.
It enables lossless upgrades and expansion of Nacos clusters, avoiding cluster avalanche and instance issues, ensuring high availability and stability, and improving the system's scalability and processing capabilities.
Smart Images

Figure CN119743487B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cluster management and traffic migration technology in cloud computing services, and in particular to a method, system, electronic device and computer-readable storage medium for lossless upgrade and traffic migration of Nacos clusters based on a dual-center environment. Background Technology
[0002] With the rapid development of cloud computing technology, microservice architecture has been widely adopted due to its advantages such as high availability and high scalability. In microservice architecture, service registration and discovery, and configuration management are core functions. Nacos, as a full-featured service discovery and configuration management platform, provides developers with convenient service management tools. However, in actual production environments, with the continuous growth of business volume, upgrading and expanding Nacos clusters has become an inevitable requirement.
[0003] For example, Chinese Invention Patent Publication CN 112069152 B discloses a database cluster upgrade method, including: establishing an upgrade process with the same number of nodes to be upgraded as the original database cluster; through each upgrade process, acquiring full snapshot files and real-time data of each node to be upgraded in parallel, parsing the full snapshot files of each node to be upgraded in parallel, sending the parsed full snapshot files to a preset target database cluster, and synchronizing the real-time data of each node to be upgraded to the preset target database cluster in parallel; when it is detected that each node to be upgraded meets the data synchronization completion condition, switching the client traffic of the original database cluster to the preset target database cluster, where the database version is higher than that of the original database cluster. However, this method cannot smoothly migrate traffic without affecting existing business operations.
[0004] Current technologies for upgrading Nacos typically rely on rolling upgrades based on container platform applications to achieve Nacos scaling and upgrades. However, in large-scale enterprise-level Nacos clusters with hundreds of thousands of applications registered and subscribed, upgrading Nacos nodes one by one using a rolling approach can lead to cluster avalanche and instances dropping or even being lost. Once a Nacos avalanche occurs, the entire cluster becomes unusable and can no longer provide registration and subscription services. Only restarting the entire cluster can resolve this, making it impossible to be seamless for applications and potentially causing application transactions to fail. On the other hand, a drop in instances may trigger application rate limiting. If instances are lost and cannot recover automatically, applications must be re-registered, which also fails to ensure seamless application operation and no impact on transactions. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention proposes a method, system, electronic device, and computer-readable storage medium for lossless upgrade and traffic migration of Nacos clusters based on a dual-center environment.
[0006] To achieve the above objectives, the technical solution adopted by the present invention includes:
[0007] A method for lossless upgrade and traffic migration of Nacos clusters based on a dual-center environment, characterized by comprising:
[0008] S1. In a dual-center environment, deploy a first Nacos cluster and a second Nacos cluster. Both the first Nacos cluster and the second Nacos cluster contain several nodes to form a logical cluster. Deploy a first Nginx server for each center of the first Nacos cluster and a second Nginx server for each center of the second Nacos cluster. The second Nacos cluster is used for dual-center upgrade and expansion of the Nacos cluster.
[0009] S2. Switch the traffic of the first Nacos cluster to the first Nginx server, and copy the registration heartbeat traffic to the second Nacos cluster through the first Nginx server, while proxying the subscription traffic to the first Nacos cluster.
[0010] S3. Switch the subscription traffic and the registration heartbeat traffic from the first Nginx server to the second Nginx server through the application load balancer, and forward the subscription traffic to the second Nacos cluster through the second Nginx server, while proxying the registration heartbeat traffic to the first Nacos cluster.
[0011] S4. After the number of instances in the first Nacos cluster and the second Nacos cluster has stabilized and become consistent, the subscription traffic and the registration heartbeat traffic are switched from the second Nginx server to the second Nacos cluster through the application load balancer.
[0012] Furthermore, step S1 also includes: updating the configuration information in the first Nginx server and the second Nginx server, and setting the first Nacos cluster to the initial state for the upgrade operation.
[0013] Furthermore, step S2 also includes:
[0014] Based on the target number of nodes in the second Nacos cluster, new nodes are added to the second Nacos cluster according to the target number of nodes to perform version upgrades.
[0015] Furthermore, after switching the traffic of the first Nacos cluster to the first Nginx server in step S2, the method further includes: the first Nacos cluster synchronizing the first instance information to the second Nacos cluster in real time, wherein the first instance information includes the service name, instance ID, IP address, port number and service metadata of the first Nacos cluster.
[0016] Furthermore, after switching the subscription traffic and the registration heartbeat traffic from the first Nginx server to the second Nginx server using an application load balancer in step S3, the method further includes:
[0017] The second Nacos cluster synchronizes the second instance information to the first Nacos cluster in real time. The second instance information includes the service name, instance ID, IP address, port number, and service metadata of the second Nacos cluster.
[0018] Optionally, step S2 further includes: performing an initialization operation on the new node, wherein the initialization operation includes loading configuration information, synchronizing cluster status and cluster data.
[0019] Optionally, step S4 may be followed by:
[0020] S5. Clean up and release the resources of the first Nacos cluster, the first Nginx server, and the second Nginx server.
[0021] Furthermore, this invention also relates to a lossless upgrade and traffic migration system for Nacos clusters based on a dual-center environment, characterized in that it includes:
[0022] The deployment module is used to deploy a first Nacos cluster and a second Nacos cluster in a dual-center environment. Both the first Nacos cluster and the second Nacos cluster contain several nodes to form a logical cluster. A first Nginx server is deployed for each center of the first Nacos cluster, and a second Nginx server is deployed for each center of the second Nacos cluster. The second Nacos cluster is used for dual-center upgrade and expansion of the Nacos cluster.
[0023] The traffic replication module is used to switch the traffic of the first Nacos cluster to the first Nginx server, replicate the registration heartbeat traffic to the second Nacos cluster through the first Nginx server, and at the same time proxy the subscription traffic to the first Nacos cluster.
[0024] The first traffic switching module is used to switch the subscription traffic and the registration heartbeat traffic from the first Nginx server to the second Nginx server through the application load balancer, and forward the subscription traffic to the second Nacos cluster through the second Nginx server, while proxying the registration heartbeat traffic to the first Nacos cluster.
[0025] The second traffic switching module is used to switch the subscription traffic and the registration heartbeat traffic from the second Nginx server to the second Nacos cluster through the application load balancer after the number of instances in the first Nacos cluster and the second Nacos cluster has stabilized and become consistent.
[0026] Furthermore, the deployment module is also used for:
[0027] Update the configuration information in the first Nginx server and the second Nginx server, and set the first Nacos cluster to the initial state to be upgraded.
[0028] Furthermore, the traffic replication module is also used for:
[0029] Based on the target number of nodes in the second Nacos cluster, new nodes are added to the second Nacos cluster according to the target number of nodes to perform version upgrades.
[0030] Furthermore, the traffic replication module is also used for:
[0031] The first Nacos cluster synchronizes the first instance information to the second Nacos cluster in real time. The first instance information includes the service name, instance ID, IP address, port number, and service metadata of the first Nacos cluster.
[0032] Furthermore, the first traffic switching module is also used for:
[0033] The second Nacos cluster synchronizes the second instance information to the first Nacos cluster in real time. The second instance information includes the service name, instance ID, IP address, port number, and service metadata of the second Nacos cluster.
[0034] Optionally, the traffic replication module is further configured to:
[0035] The new node is initialized by loading configuration information and synchronizing cluster status and cluster data.
[0036] Optionally, the system further includes:
[0037] The cleanup module is used to clean up and release the resources of the first Nacos cluster, the first Nginx server, and the second Nginx server.
[0038] Furthermore, the present invention also relates to an electronic device, characterized in that it includes a processor and a memory;
[0039] The memory is used to store operation instructions;
[0040] The processor is configured to execute the above-described method by invoking the operation instructions.
[0041] Furthermore, the present invention also relates to a computer-readable storage medium, characterized in that the storage medium stores a computer program, which, when executed by a processor, implements the above-described method.
[0042] The solution provided in this application firstly deploys a first Nacos cluster and a second Nacos cluster in a dual-center environment, configuring a corresponding Nginx server at the center of each cluster. Secondly, the first Nginx server replicates registration heartbeat traffic to the second Nacos cluster, while simultaneously proxying subscription traffic to the first Nacos cluster. Then, a load balancer switches traffic from the first Nginx server to the second Nginx server, and then forwards it to the second Nacos cluster. Once the number of instances in both clusters is stable and consistent, traffic is further switched directly from the second Nginx server to the second Nacos cluster. Therefore, by adopting the above technical solution, based on the Nginx server traffic replication and proxy functions and the intelligent scheduling of the load balancer, lossless upgrades and expansions of the Nacos cluster are achieved, avoiding cluster avalanche, instance degradation, and instance loss issues, ensuring high availability and stability of the Nacos cluster, and achieving seamless application and transaction operation during the upgrade process, effectively improving the system's scalability and processing capacity. Attached Figure Description
[0043] Figure 1 A schematic diagram of a method for lossless upgrade and traffic migration of a Nacos cluster based on a dual-center environment, provided for embodiments of this application;
[0044] Figure 2a A schematic diagram of the pre-upgrade deployment architecture provided in an embodiment of this application;
[0045] Figure 2b A schematic diagram illustrating the process of switching traffic to the first Nginx as provided in an embodiment of this application;
[0046] Figure 2c A schematic diagram illustrating the process of switching traffic to a second Nginx instance, provided as an embodiment of this application;
[0047] Figure 2d A schematic diagram illustrating the process of switching traffic to a second Nacos cluster, provided for an embodiment of this application;
[0048] Figure 3 A schematic diagram of a Nacos cluster lossless upgrade and traffic migration system based on a dual-center environment is provided for embodiments of this application;
[0049] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0050] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting the invention.
[0051] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. The terms “first,” “second,” etc., are merely for clarification of the subject matter and do not limit the subject matter itself. Of course, the subjects defined by “first” and “second” may be the same terminal, device, and user, or the same type of terminal, device, and user. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. The term “and / or” as used herein includes all or any unit and all combinations of one or more associated listed items.
[0052] The technical solutions of this application and how the technical solutions of this application solve the above-mentioned technical problems are described in detail below with specific embodiments. The following embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0053] Nginx is a high-performance HTTP and reverse proxy server, as well as an IMAP / POP3 / SMTP proxy server. It was developed by Igor Sysoev in 2004 for the Rambler.ru site and is known for its high performance, stability, and ease of use.
[0054] Nginx can function as a pure web server, handling static content such as HTML, CSS, JavaScript files, and images. Simultaneously, it's a powerful reverse proxy server, capable of forwarding client requests to backend application servers like Tomcat and Node.js, and processing responses from these servers. This reverse proxy capability makes Nginx an ideal choice for building load balancing and high-availability solutions.
[0055] In addition, starting with Nginx version 1.13.4, the ngx_http_mirror_module module was introduced. Through this module, developers and operations personnel can deploy Nginx and configure the nginx_conf in the Nginx yaml to achieve traffic replication between the old and new Nacos clusters.
[0056] like Figure 1 This paper illustrates a flowchart of a lossless upgrade and traffic migration method for a Nacos cluster based on a dual-center environment, as provided in an embodiment of this application. The method specifically includes:
[0057] S1. In a dual-center environment, deploy a first Nacos cluster and a second Nacos cluster. Both the first Nacos cluster and the second Nacos cluster contain several nodes to form a logical cluster. Deploy a first Nginx server for each center of the first Nacos cluster and a second Nginx server for each center of the second Nacos cluster. The second Nacos cluster is used for dual-center upgrade and expansion of the Nacos cluster.
[0058] Specifically, update the configuration information in the first Nginx server and the second Nginx server, and set the first Nacos cluster to the initial state to be upgraded.
[0059] S2. Switch the traffic of the first Nacos cluster to the first Nginx server, and copy the registration heartbeat traffic to the second Nacos cluster through the first Nginx server, while proxying the subscription traffic to the first Nacos cluster.
[0060] Specifically, based on the target number of nodes in the second Nacos cluster, new nodes are added to the second Nacos cluster according to the target number of nodes for version upgrade; the new nodes are initialized, which includes loading configuration information, synchronizing cluster status and cluster data.
[0061] S3. Switch the subscription traffic and the registration heartbeat traffic from the first Nginx server to the second Nginx server through the application load balancer, and forward the subscription traffic to the second Nacos cluster through the second Nginx server, while proxying the registration heartbeat traffic to the first Nacos cluster.
[0062] S4. After the number of instances in the first Nacos cluster and the second Nacos cluster has stabilized and become consistent, the subscription traffic and the registration heartbeat traffic are switched from the second Nginx server to the second Nacos cluster through the application load balancer.
[0063] Specifically, a stable and consistent number of instances includes the following: within a predetermined time window, the number of instances in the first Nacos cluster and the second Nacos cluster remains unchanged.
[0064] S5. Clean up and release the resources of the first Nacos cluster, the first Nginx server, and the second Nginx server.
[0065] In step S2, after switching the traffic of the first Nacos cluster to the first Nginx server, the method further includes: the first Nacos cluster synchronizing the first instance information to the second Nacos cluster in real time, wherein the first instance information includes the service name, instance ID, IP address, port number and service metadata of the first Nacos cluster.
[0066] After switching the subscription traffic and the registration heartbeat traffic from the first Nginx server to the second Nginx server using an application load balancer in step S3, the method further includes:
[0067] The second Nacos cluster synchronizes the second instance information to the first Nacos cluster in real time. The second instance information includes the service name, instance ID, IP address, port number, and service metadata of the second Nacos cluster.
[0068] By updating configuration information and backing up data, the subsequent upgrade process can be simplified, maintenance costs can be reduced, and data security and consistency can be ensured.
[0069] Therefore, by adopting the above technical solution, based on the traffic replication and proxy functions of Nginx server and the intelligent scheduling of load balancer, the Nacos cluster can be upgraded and expanded without loss, avoiding cluster avalanche, instance degradation and instance loss problems, ensuring the high availability and stability of the Nacos cluster, and achieving seamless application and transaction operation during the upgrade process, effectively improving the system's scalability and processing capacity.
[0070] like Figure 2a The deployment architecture before the upgrade is shown. Before the upgrade, the old Nacos cluster had a total of 7 nodes deployed in two centers: 3 nodes in the first center and 4 nodes in the second center, forming a logical cluster. In order to cope with the increasing performance pressure and fix existing high availability issues, it is necessary to deploy a new Nacos cluster and expand it to a total of 16 nodes in two centers, with 8 nodes in each center, and then migrate the traffic on the old Nacos cluster to the new Nacos cluster.
[0071] Switching process as follows Figure 2b , 2c As shown in 2d, in Figure 2b Before upgrading, you need to deploy a first Nginx server for the old Nacos cluster center and a second Nginx server for the new Nacos cluster center. The registration heartbeat traffic is copied to the new Nacos cluster through the first Nginx server, but the subscription traffic is still proxied to the old Nacos cluster.
[0072] exist Figure 2c In this process, after expanding the new Nacos cluster to 16 nodes in a dual-center configuration, the subscription traffic and registration heartbeat traffic are switched from the first Nginx server to the second Nginx server through the application load balancer (ALB). The second Nginx server then forwards the traffic to the new Nacos cluster. In addition, the registration heartbeat traffic is copied to the old Nacos cluster through the second Nginx server to ensure that residual traffic or other problems are avoided after the traffic is switched.
[0073] By deploying and expanding the new Nacos cluster, and combining it with the intelligent scheduling of the load balancer, smooth switching and balanced distribution of traffic were achieved, effectively improving scalability and processing capacity.
[0074] exist Figure 2d Once the number of instances in the old Nacos cluster and the new Nacos cluster has stabilized and become consistent, the subscription traffic and the registration heartbeat traffic will be switched from the second Nginx server to the new Nacos cluster through the application load balancer (ALB) to complete the entire upgrade process.
[0075] based on Figure 1The method for lossless upgrade and traffic migration of Nacos clusters based on a dual-center environment is shown. On the other hand, a system for lossless upgrade and traffic migration of Nacos clusters based on a dual-center environment is also involved, such as... Figure 3 As shown, it includes:
[0076] Deployment module 301 is used to deploy a first Nacos cluster and a second Nacos cluster in a dual-center environment. Both the first Nacos cluster and the second Nacos cluster contain several nodes to form a logical cluster. A first Nginx server is deployed for each center of the first Nacos cluster, and a second Nginx server is deployed for each center of the second Nacos cluster. The second Nacos cluster is used for dual-center upgrade and expansion of the Nacos cluster.
[0077] Traffic replication module 302 is used to switch the traffic of the first Nacos cluster to the first Nginx server, replicate the registration heartbeat traffic to the second Nacos cluster through the first Nginx server, and at the same time proxy the subscription traffic to the first Nacos cluster.
[0078] The first traffic switching module 303 is used to switch the subscription traffic and the registration heartbeat traffic from the first Nginx server to the second Nginx server through the application load balancer, and forward the subscription traffic to the second Nacos cluster through the second Nginx server, while proxying the registration heartbeat traffic to the first Nacos cluster.
[0079] The second traffic switching module 304 is used to switch the subscription traffic and the registration heartbeat traffic from the second Nginx server to the second Nacos cluster through the application load balancer after the number of instances in the first Nacos cluster and the second Nacos cluster has stabilized and become consistent.
[0080] Furthermore, the deployment module 301 is also used for:
[0081] Update the configuration information in the first Nginx server and the second Nginx server, and set the first Nacos cluster to the initial state to be upgraded.
[0082] Furthermore, the traffic replication module 302 is also used for:
[0083] Based on the target number of nodes in the second Nacos cluster, new nodes are added to the second Nacos cluster according to the target number of nodes to perform version upgrades.
[0084] Furthermore, the traffic replication module 302 is also used for:
[0085] The first Nacos cluster synchronizes the first instance information to the second Nacos cluster in real time. The first instance information includes the service name, instance ID, IP address, port number, and service metadata of the first Nacos cluster.
[0086] Furthermore, the first traffic switching module 303 is also used for:
[0087] The second Nacos cluster synchronizes the second instance information to the first Nacos cluster in real time. The second instance information includes the service name, instance ID, IP address, port number, and service metadata of the second Nacos cluster.
[0088] Optionally, the traffic replication module 302 is further configured to:
[0089] The new node is initialized by loading configuration information and synchronizing cluster status and cluster data.
[0090] Optionally, the system further includes:
[0091] The cleanup module 305 is used to clean up and release the resources of the first Nacos cluster, the first Nginx server, and the second Nginx server.
[0092] By using this system, the above methods can be executed and the corresponding technical effects can be achieved.
[0093] Embodiments of the present invention also provide an electronic device for performing the above-described method, which, as an implementation apparatus for the method, includes a processor and a memory;
[0094] Memory, used to store operation instructions;
[0095] The processor is used to execute the lossless upgrade and traffic migration method for Nacos clusters provided in any embodiment of this application by invoking operation instructions.
[0096] As an example, Figure 4 A schematic diagram of the structure of an electronic device to which this application embodiment applies is shown, such as... Figure 4As shown, the electronic device 400 includes a processor 401 and a memory 403. The processor 401 and the memory 403 are connected, for example, via a bus 402. Optionally, the electronic device 400 may also include a transceiver 404. It should be noted that in practical applications, the transceiver 404 is not limited to one. It is understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the specific structure of the electronic device 400. In other embodiments of this application, the electronic device 400 may include more or fewer components than illustrated, or combine some components, or split some components, or arrange different components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware. Optionally, the electronic device may also include a display screen 405 for displaying images or receiving user operation commands when needed.
[0097] In this embodiment, processor 401 is used to implement the method shown in the above method embodiment. Transceiver 404 may include a receiver and a transmitter. Transceiver 404 is used in this embodiment to enable the electronic device of this embodiment to communicate with other devices during execution.
[0098] Processor 401 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 401 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0099] Processor 401 may also include one or more processing units, such as an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units can be independent devices or integrated into one or more processors. The controller can serve as the central nervous system and command center of the electronic device 400. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution. Processor 401 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 401 is a cache memory. This memory can store instructions or data that processor 401 has just used or is repeatedly used. If processor 401 needs to reuse the instruction or data, it can directly retrieve it from the memory. This avoids repeated access, reduces the waiting time of processor 401, and thus improves system efficiency.
[0100] The processor 401 can run the Nacos cluster lossless upgrade and traffic migration method provided in the embodiments of this application, so as to reduce the user's operational complexity, improve the intelligence of terminal devices, and enhance the user experience. The processor 401 may include different devices. For example, when integrating a CPU and a GPU, the CPU and GPU can work together to execute the Nacos cluster lossless upgrade and traffic migration method provided in the embodiments of this application. Some algorithms are executed by the CPU, and other algorithms are executed by the GPU to achieve faster processing efficiency.
[0101] Bus 402 may include a pathway for transmitting information between the aforementioned components. Bus 402 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 402 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 4 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0102] The memory 403 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory), or high-speed random access memory. It may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), or other optical disc storage, optical disk storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto.
[0103] Optionally, the memory 403 is used to store application code that executes the scheme of this application, and the execution is controlled by the processor 401. The processor 401 is used to execute the application code stored in the memory 403 to implement the Nacos cluster lossless upgrade and traffic migration method provided in any embodiment of this application.
[0104] The memory 403 can be used to store computer executable program code, which includes instructions. The processor 401 executes various functional applications and data processing of the electronic device 400 by running the instructions stored in the memory 403. The memory 403 may include a program storage area and a data storage area. The program storage area can store the operating system, application code, etc. The data storage area can store data created during the use of the electronic device 400 (such as images and videos captured by a camera application).
[0105] The memory 403 may also store one or more computer programs corresponding to the Nacos cluster lossless upgrade and traffic migration method provided in the embodiments of this application. The one or more computer programs are stored in the memory 403 and configured to be executed by the one or more processors 401. The one or more computer programs include instructions that can be used to perform the various steps in the corresponding embodiments described above.
[0106] Of course, the code for the Nacos cluster lossless upgrade and traffic migration method provided in this application embodiment can also be stored in external storage.
[0107] The display screen 405 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a minimized LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 400 may include one or N displays 405, where N is a positive integer greater than 1. The display screen 405 can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces (GUIs). For example, the display screen 405 can display photos, videos, web pages, or documents.
[0108] The electronic device provided in this application is applicable to any of the above-described methods. Therefore, the beneficial effects it can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0109] Embodiments of the present invention also provide a computer-readable storage medium capable of implementing all the steps of the methods in the above embodiments, wherein the computer-readable storage medium stores a computer program that, when executed by a processor, implements all the steps of the methods in the above embodiments.
[0110] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0111] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A system that specifies functions in one or more boxes.
[0112] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including an instruction set implemented in a process. Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0113] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the functions specified in one or more boxes. Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the invention.
[0114] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for lossless upgrade and traffic migration of Nacos clusters based on a dual-center environment, characterized in that, include: S1. In a dual-center environment, deploy a first Nacos cluster and a second Nacos cluster. Both the first Nacos cluster and the second Nacos cluster contain several nodes to form a logical cluster. A first Nginx server is deployed for each center of the first Nacos cluster, and a second Nginx server is deployed for each center of the second Nacos cluster, wherein the second Nacos cluster is used for dual-center upgrade and expansion of the Nacos cluster. S2. Switch the traffic of the first Nacos cluster to the first Nginx server, and copy the registration heartbeat traffic to the second Nacos cluster through the first Nginx server, while proxying the subscription traffic to the first Nacos cluster. S3. Switch the subscription traffic and the registration heartbeat traffic from the first Nginx server to the second Nginx server through the application load balancer, and forward the subscription traffic to the second Nacos cluster through the second Nginx server, while proxying the registration heartbeat traffic to the first Nacos cluster. S4. After the number of instances in the first Nacos cluster and the second Nacos cluster has stabilized and become consistent, the subscription traffic and the registration heartbeat traffic are switched from the second Nginx server to the second Nacos cluster through the application load balancer.
2. The method according to claim 1, characterized in that, Step S1 further includes: Update the configuration information in the first Nginx server and the second Nginx server, and set the first Nacos cluster to the initial state to be upgraded.
3. The method according to claim 1 or 2, wherein step S2 further comprises: Based on the target number of nodes in the second Nacos cluster, new nodes are added to the second Nacos cluster according to the target number of nodes to perform version upgrades.
4. The method according to claim 1 or 2, wherein after switching the traffic of the first Nacos cluster to the first Nginx server in step S2, the method further includes: The first Nacos cluster synchronizes the first instance information to the second Nacos cluster in real time. The first instance information includes the service name, instance ID, IP address, port number, and service metadata of the first Nacos cluster.
5. The method according to claim 4, wherein after switching the subscription traffic and the registration heartbeat traffic from the first Nginx server to the second Nginx server by applying a load balancer in step S3, the method further includes: The second Nacos cluster synchronizes the second instance information to the first Nacos cluster in real time. The second instance information includes the service name, instance ID, IP address, port number, and service metadata of the second Nacos cluster.
6. The method according to claim 3, further comprising: The new node is initialized by loading configuration information and synchronizing cluster status and cluster data.
7. The method according to claim 1, characterized in that, The process following step S4 also includes: S5. Clean up and release the resources of the first Nacos cluster, the first Nginx server, and the second Nginx server.
8. A lossless upgrade and traffic migration system for Nacos clusters based on a dual-center environment, characterized in that, include: The deployment module is used to deploy a first Nacos cluster and a second Nacos cluster in a dual-center environment. Both the first Nacos cluster and the second Nacos cluster contain several nodes to form a logical cluster. A first Nginx server is deployed for each center of the first Nacos cluster, and a second Nginx server is deployed for each center of the second Nacos cluster, wherein the second Nacos cluster is used for dual-center upgrade and expansion of the Nacos cluster. The traffic replication module is used to switch the traffic of the first Nacos cluster to the first Nginx server, replicate the registration heartbeat traffic to the second Nacos cluster through the first Nginx server, and at the same time proxy the subscription traffic to the first Nacos cluster. The first traffic switching module is used to switch the subscription traffic and the registration heartbeat traffic from the first Nginx server to the second Nginx server through the application load balancer, and forward the subscription traffic to the second Nacos cluster through the second Nginx server, while proxying the registration heartbeat traffic to the first Nacos cluster. The second traffic switching module is used to switch the subscription traffic and the registration heartbeat traffic from the second Nginx server to the second Nacos cluster through the application load balancer after the number of instances in the first Nacos cluster and the second Nacos cluster has stabilized and become consistent.
9. An electronic device, characterized in that, Including processor and memory; The memory is used to store operation instructions; The processor is configured to execute the method of any one of claims 1-7 by invoking the operation instructions.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the method of any one of claims 1-7.
Citation Information
Patent Citations
A database cluster upgrade method, apparatus, device, and storage medium
CN112069152B
Database cluster upgrading method, device, equipment and storage medium
CN112069152A
Data migration method and device, electronic equipment and computer storage medium
CN112860670A