Multi-cluster service routing management control method and device based on nginx
By adopting a multi-cluster service routing management and control method based on nginx, the problems of security risks and high operation and maintenance costs in multi-cluster systems are solved. It realizes automated operation and maintenance and secure interaction, reduces operation and maintenance costs and error rates, and improves management efficiency.
Patent Information
- Application Number
- CN202111357165.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-11-09
- Filing Date
- 2021-11-16
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2041-11-16
AI Technical Summary
Existing technologies have security vulnerabilities, high operation and maintenance costs, and high error rates in multi-cluster systems. In particular, as system complexity increases, the workload of operation and maintenance personnel and the error rate increase exponentially.
A multi-cluster service routing management and control method based on nginx is adopted. By configuring management files in the same group, receiving periodic heartbeat information from the Agent, updating the configuration file version information, and generating update configuration commands, the system uses heartbeat interaction to achieve automated management of configuration files and serial or parallel execution of commands. A Server+Agent system composition is used for secure interaction.
It enables automated and visualized operation and maintenance in multi-cluster environments, reducing operation and maintenance costs and error rates, and improving server security and management efficiency.
Smart Images

Figure CN114070736B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of multi-cluster service routing management, and in particular to a multi-cluster service routing management control method and device based on nginx. Background Art
[0002] With the development of microservice technology, the interactions within the system and the interaction topology between systems are becoming more and more complex. When the same function needs to connect to multiple external systems at the same time, if there is no network forwarding mechanism, targeted coding work needs to be performed for each external system within the system, resulting in a waste of manpower costs and reducing the stability of the system. In addition, as the complexity of the system continues to increase, within a technical team, there may be multiple clusters with the above application scenarios. If the network forwarding strategy is maintained cluster by cluster, the workload of the operation and maintenance personnel will increase exponentially with the increase in clusters, and the possibility of errors during manual operation and maintenance will also increase.
[0003] Currently, existing operation and maintenance products mainly use the server mode, and remote interaction is carried out through ssh in terms of configuration delivery, etc. Since this method requires the server password to be exposed to the server, there are security risks. Summary of the invention
[0004] To this end, an embodiment of the present invention provides a multi-cluster service routing management and control method and device based on nginx to solve the security risks existing in the prior art and the problem that as the complexity of the system continues to increase, the workload and error rate of operation and maintenance personnel will also increase exponentially.
[0005] In order to achieve the above purpose, the embodiment of the present invention provides the following technical solutions:
[0006] In a first aspect, a multi-cluster service routing management and control method based on nginx is provided, wherein a management file is configured in the same Group, wherein the nginx.conf file in the original config directory is retained when configuring the management file, and a configuration file of the Server is added in the incloude directory, wherein the method comprises:
[0007] Receive the heartbeat sent periodically by the Agent, and update the Agent's most recent heartbeat registration time and instruction execution result information;
[0008] Compare the configuration file version information with the configuration file version information in the Agent;
[0009] If the version information of the configuration file in the Agent is lower, an update configuration instruction is generated;
[0010] All instructions to be executed are sent to the Agent for execution; after the Agent receives the instructions through the heartbeat, the instructions are placed in the execution queue and executed in sequence. After the execution is completed, the operation results are saved in the return queue and returned with the heartbeat.
[0011] Preferably, after placing the instruction into the execution queue, it is determined whether the instruction is the configuration update instruction, and if so, the configuration file is updated.
[0012] Preferably, the configuration file takes effect after the configuration file version is upgraded.
[0013] Preferably, the configuration file is in a split configuration manner.
[0014] Preferably, the method further comprises:
[0015] Regularly check whether the heartbeat information of the Agent is received;
[0016] If the heartbeat information of the Agent is not received at a fixed time, the Agent is offline and all the command running results not reported by the Agent are set to failure.
[0017] Preferably, the scheduled inspection is performed by a single node.
[0018] Preferably, the Agent executes multiple instructions in series.
[0019] Preferably, instructions can be created in the Server background.
[0020] Preferably, when creating instructions in the Server background, parallel execution or serial execution can be selected.
[0021] In a second aspect, a multi-cluster service routing management and control device based on nginx includes:
[0022] System management module, used to manage Group, Agent, configuration files, instructions and logs;
[0023] The Server service module is used to receive the heartbeats sent periodically by the Agent and update the Agent's most recent heartbeat registration time and instruction execution result information;
[0024] and comparing the configuration file version information with the configuration file version information in the Agent, and generating an update configuration instruction according to the comparison result;
[0025] And send all pending instructions to all Agents in the entire Group for execution or specify a few Agents for execution;
[0026] The Agent service module is used to receive the returned instructions, put the instructions into the execution queue and execute them in sequence, and save the running results into the return queue after the execution is completed, and return to the Server service module following the heartbeat.
[0027] The present invention has at least the following beneficial effects: the present invention provides a multi-cluster service routing management and control method and device based on nginx, configures management files in the same Group, retains the nginx.conf file in the original config directory when configuring the management files, adds a configuration file of the Server in the incloude directory, receives the heartbeat sent regularly by the Agent, and updates the Agent's most recent heartbeat registration time and instruction execution result information; compares the configuration file version information with the configuration file version information in the Agent; if the configuration file version information in the Agent is lower, generates an update configuration instruction; sends all instructions to be executed to the Agent for execution; after the Agent receives the instruction through the heartbeat, the Agent puts the instruction into the execution queue and executes it in sequence, and after the execution is completed, saves the operation result into the return queue and returns with the heartbeat; the multi-cluster service routing management and control method based on nginx of the present invention, with the increase of the number of clusters and the number of nodes, the visual and automatic operation and maintenance method will greatly reduce the operation and maintenance cost and the possibility of error, and improve the security of the server. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly explain the prior art and the present invention, the following briefly introduces the drawings required for describing the prior art and the embodiments of the present invention. Obviously, the drawings described below are only exemplary, and for those of ordinary skill in the art, other drawings can be derived from the provided drawings without creative work.
[0029] The structures, proportions, sizes, etc. illustrated in this specification are only used to match the contents disclosed in the specification so that people familiar with this technology can understand and read them. They are not used to limit the conditions under which the present invention can be implemented. Any structural modification, change in proportion or adjustment of size should still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.
[0030] Figure 1 A flow chart of configuration management files provided by an embodiment of the present invention;
[0031] Figure 2 A flow chart of a multi-cluster service routing management and control method based on nginx provided in an embodiment of the present invention;
[0032] Figure 3A flowchart of the execution judgment of the multi-cluster service routing management and control method based on nginx provided in an embodiment of the present invention;
[0033] Figure 4 The Agent provided in the embodiment of the present invention periodically sends a heartbeat flow chart to the Server end;
[0034] Figure 5 A flow chart of the server-side scheduled inspection provided by an embodiment of the present invention;
[0035] Figure 6 A flow chart of instruction distribution provided by an embodiment of the present invention;
[0036] Figure 7 An instruction execution flow chart provided for an embodiment of the present invention;
[0037] Figure 8 A block diagram of a multi-cluster service routing management and control device based on nginx provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0039] In the description of the present invention, unless otherwise specified, "plurality" means two or more. The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are intended to distinguish the objects referred to. For schemes with a sequential flow, this terminology does not have to be understood as describing a specific order or sequence. For schemes with device structures, this terminology does not distinguish between importance, positional relationships, etc.
[0040] In addition, the terms "comprises", "has" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that have been explicitly listed, but may also include other steps or units that are not explicitly listed but are inherent to these processes, methods, products or apparatuses, or steps or units that are added based on further optimization schemes conceived by the present invention.
[0041] An embodiment of the present invention provides a multi-cluster service routing management and control method based on nginx. Before implementing the method, a management file needs to be configured first.
[0042] See also Figure 1, configuration management files, configuration files all belong to a Group (each Group represents a cluster), that is, the configuration file is effective for an nginx cluster. The configuration file adds the concept of version number. If you want to make the modified configuration file effective, you must first upgrade the version number. At the same time, the background also provides the function of verifying whether the configuration file is available. After the configuration is added and modified, it is directly saved into the library. If necessary, you can click Verify Configuration File to verify whether the modification is available. After the upgrade version number operation is triggered, the version number is increased. In order to facilitate the tracking of the modification history of the configuration file and to quickly restore after the error modification, each modification of the configuration file will record the history record, which can be convenient for querying the configuration of the historical version. When configuring nginx on the client, the nginx configuration is updated by splitting the configuration. Keep the nginx.conf file in the original config directory, configure the incloude directory, and add the server configuration file to the directory. At this time, other configuration information of each nginx instance can be fixed under the premise of ensuring safety. When clicking Verify Configuration, the agent will copy the existing nginx.config and include directories to other directories, and output the configuration to be tested to the conf file in the include directory. Then verify according to the nginx–t–c command.
[0043] See also Figure 2 and Figure 3 An embodiment of the present invention provides a multi-cluster service routing management and control method based on nginx, the method comprising:
[0044] S1: Receive the heartbeat sent regularly by the Agent, and update the Agent's most recent heartbeat registration time and instruction execution result information;
[0045] See also Figure 4 Specifically, the Agent will send a heartbeat to the Server periodically, once every 5 seconds by default. The heartbeat content includes basic Agent information, such as IP, port, configuration file version information, etc., as well as unreported command execution result information. After receiving the heartbeat information, the Server will update the most recent Agent heartbeat registration time and command execution result information.
[0046] S2: Compare the configuration file version information with the configuration file version information in the Agent;
[0047] Specifically, the configuration file version information of the Agent and the Server are compared.
[0048] S3: If the version information of the configuration file in the Agent is lower, then generate an update configuration instruction;
[0049] S4: All instructions to be executed are sent to the Agent for execution; after the Agent receives the instructions through the heartbeat, the Agent puts the instructions into the execution queue and executes them in sequence. After the execution is completed, the running results are saved in the return queue and returned with the heartbeat.
[0050] Specifically, if the version information of the Agent configuration file is lower than that of the Server, the Server will generate an instruction to update the configuration and return other instructions waiting to be executed on the Server to the Agent.
[0051] See also Figure 5 In order to monitor the survival status of the Agent, the Server will start a scheduled inspection task, which defaults to 30S. If the heartbeat information of the Agent is not received within 30S, the Agent will be offline, and all the command running results that the current Agent has not reported will be set as failures. The scheduled inspection task needs to be executed on a single node. The production environment Server will be deployed on multiple nodes, and the scheduled inspection task needs to be scheduled with the help of a scheduled task trigger.
[0052] See also Figure 6 , instruction distribution, specifically, when the server issues instructions, the instructions have two sources, one is that the server automatically generates an instruction to update the configuration file when it finds that the Agent configuration file version is low, and the other is to create instructions in the background of the server. When actively creating instructions, you can select different execution strategies, that is, parallel or serial execution; you can also specify the Agent range for executing instructions, that is, all Agents under the entire Group execute or specify certain Agents to execute. For the serial execution strategy, when generating instructions, the instruction information that the instruction depends on will be added, so that it can be ensured that it will not be executed until the previous Agent instruction is executed. For instructions that have not returned execution results for a long time, add the function of manual triggering. Determine the success or failure of the instruction through manual triggering.
[0053] See also Figure 7 , instruction execution. Specifically, when the Agent executes instructions, the instructions are all operation and maintenance commands for the nginx instance, so multiple instructions must be executed serially on an Agent side. After receiving the instruction through the heartbeat, the Agent will add the instruction to the queue. The Agent will start a single-threaded listening queue. When there are instructions in the queue, it will execute the instructions in sequence. After the execution is completed, the running results will be saved in the return queue and returned to the Server side with the heartbeat, waiting for reporting. When sending the heartbeat information, the Agent will scan the unreported instruction result information in the return queue, and delete the information from the return queue after the report is successful.
[0054] See also Figure 8An embodiment of the present invention provides a multi-cluster service routing management and control device based on nginx.
[0055] The service forwarding function of the system in the present invention is mainly implemented by nginx, and in order to ensure the normal progress of management work in the whole system, three modules are mainly established: system management module, Server service module, and Agent service module.
[0056] System management module, used to manage Group, Agent, configuration files, instructions and logs;
[0057] The Server service module is used to receive the heartbeats sent periodically by the Agent and update the Agent's most recent heartbeat registration time and instruction execution result information;
[0058] and comparing the configuration file version information with the configuration file version information in the Agent, and generating an update configuration instruction according to the comparison result;
[0059] And send all pending instructions to all Agents in the entire Group for execution or specify a few Agents for execution;
[0060] The Agent service module is used to receive the returned instructions, put the instructions into the execution queue and execute them in sequence. After the execution is completed, the running results are saved in the return queue and returned to the Server service module following the heartbeat.
[0061] In the multi-cluster service routing management and control device based on nginx, nginx and Agent, and Agent and Server interact through heartbeats and instructions. Interaction between systems is mainly achieved through https requests, which are used to upload heartbeats and send instructions. The return of https requests is used to send control instructions. In order to ensure the management of multi-cluster nginx services, four main functions are required for interaction: configuration management files, heartbeat maintenance, instruction distribution, and instruction execution.
[0062] For configuration management files, instruction distribution and instruction execution, please refer to the above description in the multi-cluster service routing management and control method based on nginx; heartbeat maintenance is a multi-cluster service routing management and control method based on nginx, which is also the core technology of the present invention.
[0063] For the specific definition of the multi-cluster service routing management and control device based on nginx, please refer to the definition of the multi-cluster service routing management and control method based on nginx above, which will not be further elaborated here.
[0064] In summary, the present invention has the following advantages:
[0065] (1) Visualized O&M: As the number of clusters and nodes increases, visualized and automated O&M methods will greatly reduce O&M costs and the possibility of errors.
[0066] (2) Server+Agent system composition: The server+Agent deployment method and the interaction through https improve the security of the server;
[0067] (3) Cluster maintenance: Unify the nginx configuration information of multiple clusters through group management to achieve the goal of "unified configuration within the group and independent configuration between groups".
[0068] The above specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0069] The technical features of the above embodiments may be arbitrarily combined (as long as there is no contradiction in the combination of these technical features). To make the description concise, not all possible combinations of the technical features in the above embodiments are described; these embodiments that are not explicitly written should also be considered to be within the scope of this specification.
[0070] The present invention is described in more detail through general description and specific embodiments. It should be noted that, without departing from the concept of the present invention, it is obvious that several variations and improvements can be made to these specific embodiments, which all belong to the protection scope of this application. Therefore, the protection scope of the patent of this application shall be subject to the attached claims.
Claims
1. A multi-cluster service routing management and control method based on nginx, characterized in that: In the same Group, the management file is configured. When configuring the management file, the nginx.conf file in the original config directory is retained, and a new Server configuration file is added in the incloude directory. The method includes: Receive the heartbeat sent periodically by the Agent, and update the Agent's most recent heartbeat registration time and instruction execution result information; Compare the configuration file version information with the configuration file version information in the Agent; If the configuration file version information in the Agent is lower, then generate an update configuration instruction; All pending instructions are sent to the Agent for execution; after the Agent receives the instructions through the heartbeat, it puts the instructions into the execution queue and executes them in sequence. After the execution is completed, the running results are saved in the return queue and returned with the heartbeat; Regularly check whether the heartbeat information of the Agent is received; If the heartbeat information of the Agent is not received at a fixed time, the Agent is offline and all the command running results not reported by the Agent are set to failure.
2. The multi-cluster service routing management and control method based on nginx according to claim 1 is characterized in that: After placing the instruction into the execution queue, it is determined whether the instruction is the configuration update instruction. If so, the configuration file is updated.
3. The multi-cluster service routing management and control method based on nginx according to claim 2 is characterized in that: The configuration file takes effect after the configuration file version is upgraded.
4. The multi-cluster service routing management and control method based on nginx according to claim 1 is characterized in that: The configuration file adopts a split configuration method.
5. The multi-cluster service routing management and control method based on nginx according to claim 1 is characterized in that: The scheduled inspection is performed by a single node.
6. The multi-cluster service routing management and control method based on nginx according to claim 1 is characterized in that: The Agent executes multiple instructions in series.
7. The multi-cluster service routing management and control method based on nginx according to claim 1 is characterized in that: Ability to create instructions in the Server background.
8. The multi-cluster service routing management and control method based on nginx according to claim 7 is characterized in that: When creating instructions in the Server background, you can choose to execute them in parallel or in series.
9. A multi-cluster service routing management and control device based on nginx, characterized in that: include: System management module, used to manage Group, Agent, configuration files, instructions and logs; The Server service module is used to receive the heartbeats sent periodically by the Agent and update the Agent's most recent heartbeat registration time and instruction execution result information; and comparing the configuration file version information with the configuration file version information in the Agent, and generating an update configuration instruction according to the comparison result; And send all pending instructions to all Agents in the entire Group for execution or specify a few Agents for execution; And periodically check whether the heartbeat information of the Agent is received; If the heartbeat information of the Agent is not received at a fixed time, the Agent is offline and all the command running results not reported by the Agent are set to failure; The Agent service module is used to receive the returned instructions, put the instructions into the execution queue and execute them in sequence, and save the running results into the return queue after the execution is completed, and return to the Server service module following the heartbeat.
Citation Information
Patent Citations
Micro-service cluster configuration management method and device and computer equipment
CN110673881A
Proxy batch updating method and device in cloud environment, medium and electronic equipment
CN110730090A