Server cluster management method and device, terminal equipment and storage medium
Create service nodes and implement encrypted communication and version checking and updates through ZooKeeper, which solves the complex and cumbersome configuration problems in server cluster management, improves management efficiency and compatibility, and supports batch management.
Patent Information
- Application Number
- CN202311369913.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-20
- Publication Date
- 2024-10-18
AI Technical Summary
Server cluster management in the existing technology has the problem of complex and cumbersome configuration, resulting in low management efficiency.
Create service nodes through the cluster module ZooKeeper, and use the service nodes to complete the management of the master terminal on the controlled terminal, send execution commands and obtain the final execution results, realizing encrypted communication and version checking and updating.
It improves the efficiency of server cluster management, simplifies the configuration process, has good compatibility, eliminates the need to manually maintain configuration information such as the IP address of the controlled terminal, and supports batch management.
Smart Images

Figure CN118802442A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed systems and cloud computing technology, and in particular to a server cluster management method, device, terminal equipment and storage medium. Background Art
[0002] Currently, many companies in the industry use Windows Server. Due to the growth in the scale of management, the number of Windows servers has reached hundreds or even thousands. At this time, the way to manage a large number of servers is usually to use Ansible.
[0003] To use Ansible (automated configuration management, application deployment, task coordination and orchestration tool), you need to install PowerShell (cross-platform command line interface and scripting language) and Management Framework on the client. After successful installation, change the group policy to remotesigned, and enable Windows remote management service (WS-Management, WinRM). Then, configure the server through the configuration file to successfully run Ansible for batch control and command execution deployment of Windows servers.
[0004] The above configuration is relatively complex and cumbersome, and a more efficient management method is needed to manage the server cluster.
[0005] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The main purpose of the present invention is to provide a server cluster management method, apparatus, terminal device and storage medium, aiming to solve the technical problem of complex and cumbersome configuration of server management.
[0007] To achieve the above object, the present invention provides a server cluster management method, which is applied to a master control end and includes the following steps:
[0008] Create a service node through the cluster module ZooKeeper;
[0009] According to the service node, an execution command is sent to the controlled end, and the controlled end executes the execution command to obtain a final execution result.
[0010] Optionally, before the step of sending an execution command to a controlled terminal according to the service node, and executing the execution command by the controlled terminal, and obtaining a final execution result, the step further includes:
[0011] Receiving a key application instruction sent by the controlled terminal;
[0012] Generate a key according to the key application instruction to obtain an encryption key;
[0013] The encryption key is sent to the controlled terminal through the service node for storage.
[0014] Optionally, the step of sending an execution command to a controlled terminal according to the service node, and having the controlled terminal execute the execution command, and obtaining a final execution result includes:
[0015] Generate an execution command and send it to the service node;
[0016] According to the execution command, encapsulation is performed through the service node to obtain a first encapsulation result;
[0017] The first encapsulation result is sent to the controlled end for instruction execution to obtain a final execution result.
[0018] Optionally, the step of performing encapsulation through the service node according to the execution command to obtain a first encapsulation result includes:
[0019] Encapsulating the execution instruction through the service node to obtain an initial encapsulation result;
[0020] Compressing the initial encapsulation result to obtain a compression result;
[0021] According to the compression result, encrypting is performed using the encryption key to obtain a first encryption result;
[0022] The first encryption result is encapsulated to obtain a first encapsulation result.
[0023] The present invention also provides a server cluster management method, which is applied to a controlled end and includes the following steps:
[0024] Connect to the pre-obtained service node;
[0025] According to the service node, the execution command sent by the main control end is received and executed to obtain the final execution result.
[0026] Optionally, the step of receiving and executing the execution command sent by the master control terminal according to the service node to obtain the final execution result includes:
[0027] Encapsulating the execution command through the service node to obtain a second encapsulation result;
[0028] Decrypting the second encapsulation result to obtain a first decryption result;
[0029] Extracting data from the first decryption result to obtain an execution value;
[0030] According to the execution value, execute the instruction and obtain the initial execution result;
[0031] The initial execution result is encapsulated to obtain a final execution result.
[0032] Optionally, after the step of receiving and executing the execution command sent by the master control terminal according to the service node and obtaining the final execution result, the step further includes:
[0033] Performing a version check on the controlled terminal and obtaining a check result;
[0034] Encrypting the inspection result to obtain a second encryption result;
[0035] According to the second encryption result, a version check instruction is generated and sent to the main control end, and the main control end performs version verification and obtains a verification result;
[0036] When the verification result is not passed, the update instruction sent by the main control end is received and updated to obtain the update result.
[0037] The embodiment of the present invention further provides a server cluster management device, which is applied to a master control end and includes:
[0038] Create a module to create a service node through the cluster module ZooKeeper;
[0039] The execution module is used to send an execution command to the controlled end according to the service node, and the controlled end executes the execution command to obtain a final execution result.
[0040] An embodiment of the present invention further proposes a terminal device comprising a memory, a processor, and a server cluster management program stored in the memory and executable on the processor. When the server cluster management program is executed by the processor, the steps of the server cluster management method described above are implemented.
[0041] The embodiment of the present invention further provides a computer-readable storage medium, on which a server cluster management program is stored. When the server cluster management program is executed by a processor, the steps of the server cluster management method described above are implemented.
[0042] The server cluster management method, device, terminal device and storage medium proposed in the embodiment of the present invention create a service node through the cluster module ZooKeeper; according to the service node, send an execution command to the controlled end, and the controlled end executes the execution command to obtain the final execution result. Thus, the service node is created through the cluster module ZooKeeper, and the service node is used to complete the management of the controlled end by the master end, which solves the problem of complex and cumbersome configuration of server management and improves the efficiency of server cluster management. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is a functional module diagram of a terminal device belonging to the server cluster management device of the present invention;
[0044] Figure 2 A flow chart of an exemplary embodiment of a server cluster management method of the present invention;
[0045] Figure 3 It is an overall schematic diagram of the server cluster management method of the present invention;
[0046] Figure 4 A schematic diagram of a service node involved in the server cluster management method of the present invention;
[0047] Figure 5 It is a schematic diagram of the server cluster management method of the present invention involving the master control end;
[0048] Figure 6 It is a schematic diagram of the server cluster management method of the present invention involving the controlled terminal;
[0049] Figure 7 A flow chart of another exemplary embodiment of the server cluster management method of the present invention;
[0050] Figure 8 A schematic diagram of obtaining an encryption key in the server cluster management method of the present invention;
[0051] Fig. 9 A flow chart of another exemplary embodiment of the server cluster management method of the present invention;
[0052] Fig.10 A schematic diagram of a process for obtaining a final execution result of the server cluster management method of the present invention;
[0053] Fig.11 A schematic diagram of a process of obtaining a first encapsulation result in the server cluster management method of the present invention;
[0054] Fig.12 A flow chart of another exemplary embodiment of the server cluster management method of the present invention;
[0055] Fig.13 A schematic diagram of a process of obtaining a final execution result through a controlled terminal in the server cluster management method of the present invention;
[0056] Fig.14 The present invention is a flow chart of the server cluster management method involving version updating of the controlled terminal.
[0057] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0058] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0059] The main solution of the embodiment of the present invention is: receiving the key application instruction sent by the controlled end; generating a key according to the key application instruction to obtain an encryption key; sending the encryption key to the controlled end for storage through the service node. Generate an execution command and send it to the service node; according to the execution command, encapsulate through the service node to obtain a first encapsulation result; send the first encapsulation result to the controlled end for instruction execution to obtain a final execution result. Encapsulate the execution instruction through the service node to obtain an initial encapsulation result; compress the initial encapsulation result to obtain a compression result; according to the compression result, encrypt through the encryption key to obtain a first encryption result; encapsulate the first encryption result to obtain a first encapsulation result. Connect to the pre-acquired service node; according to the service node, receive and execute the execution command sent by the master end to obtain the final execution result. The execution command is encapsulated by the service node to obtain a second encapsulation result; the second encapsulation result is decrypted to obtain a first decryption result; data is extracted from the first decryption result to obtain an execution value; according to the execution value, the instruction is executed to obtain an initial execution result; the initial execution result is encapsulated to obtain a final execution result. A version check is performed on the controlled end to obtain a check result; the check result is encrypted to obtain a second encryption result; according to the second encryption result, a version check instruction is generated and sent to the main control end, and the main control end performs version verification to obtain a verification result; when the verification result is not passed, the update instruction sent by the main control end is received and updated to obtain an update result. Thus, the problem of complex and cumbersome configuration of server management in server cluster management is solved, the management of server clusters is realized, and the efficiency of server cluster management is improved. Based on the scheme of the present invention, starting from the problem of complex and cumbersome configuration of server management in reality, a server cluster management method is designed, and the effectiveness of the server cluster management method of the present invention is verified when managing server clusters. Finally, the efficiency of server cluster management by the method of the present invention is significantly improved.
[0060] Technical terms involved in the embodiments of the present invention:
[0061] Zookeeper: Zookeeper (distributed coordination service) is an open source distributed coordination system. It is one of the important components of distributed systems such as Apache Hadoop and Apache Kafka. Zookeeper provides a simple and reliable distributed coordination framework for managing and coordinating the status, configuration, naming and other information of each node in a large-scale cluster. The core concept of Zookeeper is "Znode", which is similar to a node in a file system and can store data and monitor events. Znode has a hierarchical structure and is identified by a unique path (similar to a path in a file system). The controlled end can create, read, update and delete Znode on Zookeeper, and can obtain Znode change notifications through the monitoring mechanism.
[0062] Cluster: A cluster is a distributed computing environment consisting of multiple computer nodes or servers. In a cluster, multiple computers are connected through a network and work together to complete a task. Clusters usually have the characteristics of high availability, high performance, and scalability. Clusters can be divided into two types: symmetric clusters and asymmetric clusters. Symmetric clusters mean that all computers have the same capabilities and share the same resources, such as computing power, memory, storage, etc. Asymmetric clusters mean that each computer has different capabilities and resources, and can be flexibly configured according to the needs of the application.
[0063] Json: JSON (JavaScript Object Notation) is a lightweight data exchange format with the characteristics of readability, easy writing and parsing, and extensibility. It was originally proposed by Douglas Crockford in 2001 and has become one of the standards for data exchange on the Internet. It is widely used in Web applications and mobile applications.
[0064] Gzip: Gzip is a commonly used compression format that uses the DEFLATE algorithm to compress files. Gzip is usually used to transfer files on the network or save storage space. Gzip compressed files usually have the extension ".gz" and can be generated and decompressed in a variety of ways, such as the gzip command, zlib library, Java's GZIPOutputStream, etc. In the gzip format, the compressed file header contains information such as the original file name, timestamp, operating system type, etc., which can be restored during decompression.
[0065] AES: AES, the full name of which is Advanced Encryption Standard, is a symmetric encryption algorithm and one of the most popular encryption algorithms. It can process 128, 192 and 256-bit data blocks at the same time and use the same key for encryption and decryption. The AES algorithm is designed based on the Substitution-Permutation Network structure. It includes four operations: byte substitution, row shift, column confusion and round key addition. Among them, byte substitution and row shift are linear transformations, column confusion and round key addition are non-linear transformations. These operations make AES highly secure.
[0066] The embodiments of the present invention take into account that, when performing server cluster management, the related technology has the problem of complex and cumbersome configuration of server management due to restrictions on the versions of the server operating system and PowerShell, complex server configuration, and complex server information maintenance.
[0067] Therefore, the embodiment of the present invention starts from the problem that the configuration of server management is complex and cumbersome in reality, designs a server cluster management method, and verifies the effectiveness of the server cluster management method of the present invention when managing the server cluster. Finally, the efficiency of server cluster management performed by the method of the present invention is significantly improved.
[0068] Specifically, refer to Figure 1 , Figure 1 This is a schematic diagram of the functional modules of the terminal device to which the server cluster management device of the present invention belongs. The server cluster management device can be a device that is independent of the terminal device and can perform server cluster management, and it can be carried on the terminal device in the form of hardware or software. The terminal device can be a smart mobile device with data processing function such as a mobile phone or a tablet computer, or a fixed terminal device or server with data processing function.
[0069] In this embodiment, the terminal device to which the server cluster management apparatus belongs at least includes an output module 110 , a processor 120 , a memory 130 and a communication module 140 .
[0070] The memory 130 stores an operating system and a server cluster management program. The server cluster management device can create a service node through the cluster module ZooKeeper; according to the service node, an execution command is sent to the controlled end, and the controlled end executes the execution command to obtain the final execution result. The server cluster management is performed through the server cluster management program, and the management results and other information are stored in the memory 130; the output module 110 can be a display screen, etc. The communication module 140 can include a WIFI module, a mobile communication module, a Bluetooth module, etc., and communicates with an external device or server through the communication module 140.
[0071] The server cluster management program in the memory 130 implements the following steps when executed by the processor:
[0072] Create a service node through the cluster module ZooKeeper;
[0073] According to the service node, an execution command is sent to the controlled end, and the controlled end executes the execution command to obtain a final execution result.
[0074] Furthermore, when the server cluster management program in the memory 130 is executed by the processor, the following steps are also implemented:
[0075] Receiving a key application instruction sent by the controlled terminal;
[0076] Generate a key according to the key application instruction to obtain an encryption key;
[0077] The encryption key is sent to the controlled terminal through the service node for storage.
[0078] Furthermore, when the server cluster management program in the memory 130 is executed by the processor, the following steps are also implemented:
[0079] Generate an execution command and send it to the service node;
[0080] According to the execution command, encapsulation is performed through the service node to obtain a first encapsulation result;
[0081] The first encapsulation result is sent to the controlled end for instruction execution to obtain a final execution result.
[0082] Furthermore, when the server cluster management program in the memory 130 is executed by the processor, the following steps are also implemented:
[0083] Encapsulating the execution instruction through the service node to obtain an initial encapsulation result;
[0084] Compressing the initial encapsulation result to obtain a compression result;
[0085] According to the compression result, encrypting is performed using the encryption key to obtain a first encryption result;
[0086] The first encryption result is encapsulated to obtain a first encapsulation result.
[0087] Furthermore, when the server cluster management program in the memory 130 is executed by the processor, the following steps are also implemented:
[0088] Connect to the pre-obtained service node;
[0089] According to the service node, the execution command sent by the main control end is received and executed to obtain the final execution result.
[0090] Furthermore, when the server cluster management program in the memory 130 is executed by the processor, the following steps are also implemented:
[0091] Encapsulating the execution command through the service node to obtain a second encapsulation result;
[0092] Decrypting the second encapsulation result to obtain a first decryption result;
[0093] Extracting data from the first decryption result to obtain an execution value;
[0094] According to the execution value, execute the instruction and obtain the initial execution result;
[0095] The initial execution result is encapsulated to obtain a final execution result.
[0096] Furthermore, when the server cluster management program in the memory 130 is executed by the processor, the following steps are also implemented:
[0097] Performing a version check on the controlled terminal and obtaining a check result;
[0098] Encrypting the inspection result to obtain a second encryption result;
[0099] According to the second encryption result, a version check instruction is generated and sent to the main control end, and the main control end performs version verification and obtains a verification result;
[0100] When the verification result is not passed, the update instruction sent by the main control end is received and updated to obtain the update result.
[0101] This embodiment uses the above scheme to create a service node specifically through the cluster module ZooKeeper; according to the service node, an execution command is sent to the controlled end, and the controlled end executes the execution command to obtain the final execution result. By creating a service node through the cluster module ZooKeeper, and using the service node to complete the management of the controlled end by the master end, the problem of complex and cumbersome configuration of server management can be solved. Based on the scheme of the present invention, starting from the problem of complex and cumbersome configuration of server management in reality, a server cluster management method is designed, and the effectiveness of the server cluster management method of the present invention is verified when managing the server cluster. Finally, the efficiency of server cluster management performed by the method of the present invention is significantly improved.
[0102] Based on the above terminal device architecture but not limited to the above framework, an embodiment of the method of the present invention is proposed.
[0103] Reference Figure 2 , Figure 2 The flowchart of an exemplary embodiment of the server cluster management method of the present invention is shown in FIG. The server cluster management method is applied to the main control end and includes:
[0104] Step S01, creating a service node through the cluster module ZooKeeper;
[0105] The execution subject of the method of this embodiment can be a server cluster management device, or a server cluster management terminal device or server. This embodiment takes a server cluster management device as an example, and the server cluster management device can be integrated in a terminal device with data processing function.
[0106] First, the main problem solved by this embodiment is that the current server cluster management needs to be configured one by one, resulting in cumbersome operations;
[0107] Finally, the service node is created through the cluster module ZooKeeper. Zookeeper (distributed coordination service) is an open source distributed coordination system. It is one of the important components of distributed systems such as Apache Hadoop and Apache Kafka. Zookeeper provides a simple and reliable distributed coordination framework for managing and coordinating the status, configuration, naming and other information of each node in a large-scale cluster.
[0108] Step S05, sending an execution command to the controlled terminal according to the service node, and the controlled terminal executes the execution command to obtain a final execution result;
[0109] After creating the service node, complete the following steps to manage the controlled end from the master end:
[0110] First, register all controlled terminals to be managed into the service node;
[0111] Then, the number of service nodes in the service node can be used to obtain the currently registered controlled terminal;
[0112] Then, the service node is used to obtain the current status of the server cluster, that is, the number of online and offline controlled terminals;
[0113] Then, the execution command is sent to the service node through the master control terminal;
[0114] Then, the execution instruction is sent to the designated controlled terminal through the service node for instruction execution;
[0115] Finally, the command is executed through the controlled end to obtain the final execution result.
[0116] Specifically, Figure 3 As shown, Figure 3 It is an overall schematic diagram of the server cluster management method of the present invention.
[0117] First, after the connection is completed, the command is sent through the master terminal;
[0118] Then, the command is sent to the service node (Zookeeper) for processing and sent to the specified controlled Windows server (controlled end);
[0119] Finally, commands are received, executed, and results are sent through the controlled Windows server.
[0120] Furthermore, if Figure 4 As shown, Figure 4 The figure is a schematic diagram of the zookeeper node, where config is the ZooKeeper configuration file, which contains a series of attributes and corresponding values to control the behavior of the ZooKeeper server. Quota is a resource quota control mechanism used to limit the request frequency and resource utilization of the controlled end to ZooKeeper. By setting quota, the operation of the controlled end can be restricted to prevent excessive load from adversely affecting ZooKeeper. Figure 5 This is a schematic diagram of the master terminal, through which the controlled terminal can be specified and tasks can be sent. Figure 6 This is a schematic diagram of the controlled end.
[0121] This embodiment uses the above solution to create a service node through the cluster module ZooKeeper; according to the service node, an execution command is sent to the controlled end, and the controlled end executes the execution command to obtain the final execution result. In this way, the management of the server cluster is realized, the problem of complex and cumbersome configuration of server management is solved, and the efficiency of server cluster management is improved.
[0122] Reference Figure 7 , Figure 7 It is a flowchart of another exemplary embodiment of the server cluster management method of the present invention.
[0123] Based on the above Figure 2 In the embodiment shown, the step S05, according to the service node, sends an execution command to the controlled terminal, and the controlled terminal executes the execution command, and before the step of obtaining the final execution result, the step also includes:
[0124] Step S02, receiving a key application instruction sent by the controlled terminal;
[0125] Step S03, generating a key according to the key application instruction to obtain an encryption key;
[0126] Step S04: sending the encryption key to the controlled terminal through the service node for storage.
[0127] Specifically, after the master terminal completes the connection with the controlled terminal, the encryption key is obtained through the following steps:
[0128] First, the master end receives the key application instruction issued by the controlled end. The key instruction applied by each controlled end to the master end is different, so the encryption key returned by the master end can be one or more;
[0129] Then, according to the key application instruction, the key is generated through the main control end to obtain the encryption key;
[0130] Finally, the encryption key is sent to the corresponding controlled end through the master end for storage.
[0131] More specifically, the implementation example may be as follows:
[0132] First, use the key in the current configuration file to encrypt the key application command. The key application command is: {"cmd":"apply key","create_time":"1685946342541","key":""}, the cmd field is the key application command, and the encryption result is: 0470f043c6b9be03c300a5c95cb145f99d914460f52572619efdcb0a0a6e71f45c37d5b75b8476f0ec80242f7b22fe3025dbd303f125ef8651c90cbd87ebde29;
[0133] Then, the encrypted result is encapsulated as data in JSON format and written to the service node. The data is: {"data":"0470f043c6b9be03c300a5c95cb145f99d914460f52572619efdcb0a0a6e71f45c37d5b75b8476f0ec80242f7b22fe3025dbd303f125ef8651c90cbd87ebde29","expand":{}};
[0134] Then, after the master receives the command to apply for the key, it will use the key in the configuration file to decrypt the command. If it is a key application command, it will randomly generate a key and write the key into the key field. The data is: {"cmd":"applykey","create_time":"1685946342541","key":"16ac4e580a89e2961dc0b054a90a0334422a4a1500"}. Then, the same key is used to encrypt the data and write it to the service node. The data written to the service node is: {"data":"0470f043 c6b9be03c300a5c95cb145f99d914460f52572619efdcb0a0a6e71f45c37d5b75b8476f0ec80242f7b22fe30124b2230ca0304ed09e84463e71 8f38ecbaf5e3c0816c928a1cdec9fded43e06c27d857f373bcf7e1cb798a40f7493d1e4b468c63b109896b62b5d6010c4ab81","expand":{}};
[0135] Finally, after receiving the data, the controlled end decrypts the data, takes out the new key, and uses the new key to encrypt subsequent data interactions to complete the communication.
[0136] Furthermore, during the process of sending and receiving commands, the data is encrypted throughout the process, and is encrypted and decrypted using a dynamically generated key. Each time the controlled end connects to the service node, the master end will monitor that a new controlled end is online, and at this time the master end will assign a new key to the controlled end;
[0137] Then, the master and the controlled end will communicate through the new key. The command and the command execution results will be sent through the service node after encryption. If the key does not match, the command will fail to execute, preventing the leakage of sensitive information transmitted in the executed command and ensuring the security of data transmission.
[0138] Then, the key action application will only be executed when the controlled end is online, and the key is saved in the memory. If the service node is accidentally restarted, the key of the controlled end will become invalid. The controlled end needs to re-apply for the key when it comes back online;
[0139] Finally, the master's key is also stored in the memory. If the master accidentally exits, all keys will become invalid and the controlled end will need to reapply.
[0140] More specifically, if Figure 8 As shown, Figure 8 This is a schematic diagram of obtaining an encryption key in the server cluster management method of the present invention.
[0141] First, connect to ZK (service node) through the client (controlled end);
[0142] Then, notify the server (master control end) after the connection is successful;
[0143] Then, the master generates a key and sends it to the controlled end for storage through the service node;
[0144] Finally, when the instruction is executed, the operation is performed through the key.
[0145] This embodiment uses the above solution, specifically by receiving the key application instruction sent by the controlled terminal; generating the key according to the key application instruction to obtain the encryption key; and sending the encryption key to the controlled terminal for storage through the service node. The key acquisition is achieved, the problem of data leakage caused by no encryption method during communication is solved, and the security of data communication is improved.
[0146] Reference Fig. 9 , Fig. 9 It is a flowchart of another exemplary embodiment of the server cluster management method of the present invention.
[0147] Based on the above Figure 2 In the embodiment shown, the step S05, according to the service node, sends an execution command to the controlled terminal, and the controlled terminal executes the execution command, and the step of obtaining the final execution result includes:
[0148] Step S051, generating an execution command and sending it to the service node;
[0149] Step S052, encapsulating through the service node according to the execution command to obtain a first encapsulation result;
[0150] Step S053, sending the first encapsulation result to the controlled end for instruction execution to obtain a final execution result.
[0151] Specifically, in order to obtain the final execution result, the following steps are performed:
[0152] First, the execution command is generated by the master terminal and sent to the service node;
[0153] Then, the execution command is encapsulated through the service node to obtain a first encapsulation result, wherein the purpose of encapsulation is to make data transmission more secure, and the key used for unlocking is already obtained when the master terminal is connected to the controlled terminal;
[0154] Finally, the first encapsulation result is sent to the controlled end through the service node for instruction execution to obtain the final execution result. After the controlled end completes the execution, the initial execution result is obtained. At this time, the main control end does not know the execution result, and the initial execution result needs to be encapsulated by the controlled end and then returned to obtain the final execution result.
[0155] More specifically, if Fig.10 As shown, Fig.10 The present invention is a flow chart of the server cluster management method for obtaining the final execution result.
[0156] First, send the original command through the master;
[0157] Then, the original command is encapsulated into a JSON format to obtain a first encapsulation result, wherein JSON (JavaScript Object Notation) is a lightweight data exchange format with the characteristics of readability, easy writing and parsing, and extensibility;
[0158] Then, the first encapsulation result is gzip compressed to obtain a compressed result, wherein Gzip is a commonly used compression format, which uses the DEFLATE algorithm to compress files. Gzip is usually used to transmit files on the network or save storage space. Gzip compressed files usually have ".gz" as the extension;
[0159] Then, the encryption is performed using the key pre-issued by the master control end to obtain the encryption result;
[0160] Finally, the encrypted result is sent to the controlled end for instruction execution, and then the execution result is returned to the main control end through the same encryption packaging method to obtain the final execution result.
[0161] Furthermore, since some controlled terminals may be temporarily offline for maintenance, they may not receive batch maintenance commands or deployment commands in time. Therefore, when the server is temporarily offline, a persistent node needs to be provided to save the instructions that the offline controlled terminals need to execute. After the controlled terminals are online, they will automatically go to the corresponding nodes to pull out the unexecuted commands, execute the commands, and return the execution results after the execution is completed. This method can prevent the offline controlled terminals from missing the deployment or maintenance due to not receiving the deployment or maintenance commands, resulting in version inconsistency and production accidents.
[0162] The specific implementation method is: when issuing the command {"cmds":[{"id":1,"cmd":"ls","create_time":"1685946342541"}],"max_history":10,"outputs":{"id":1,"output":""}}, the offline command can be executed and saved by adding the command id in cmds and the currently executed command id in outputs. After startup, the controlled end will judge the size of the id in outputs and the id in cmds. If it is found that the id of the currently executed command is smaller than the id in cmds, it is determined that there are historical commands that have not been executed, and the historical commands will be executed in sequence until the historical commands are empty.
[0163] This embodiment uses the above solution to generate an execution command and send it to the service node; encapsulate the execution command through the service node to obtain a first encapsulation result; and send the first encapsulation result to the controlled end to execute the command and obtain the final execution result. In this way, the master end executes the command of the controlled end, and combined with the data encryption method, solves the problems of insecure data transmission and complex and cumbersome configuration of server management, and improves the efficiency of server cluster management.
[0164] Reference Fig.11 , Fig.11The present invention is a flow chart of the server cluster management method for obtaining a first encapsulation result.
[0165] Based on the above Fig. 9 In the embodiment shown, the step S052, according to the execution command, encapsulation is performed by the service node, and the step of obtaining a first encapsulation result includes:
[0166] Step S0521, encapsulating the execution instruction through the service node to obtain an initial encapsulation result;
[0167] Step S0522, compressing the initial encapsulation result to obtain a compression result;
[0168] Step S0523, encrypting by using the encryption key according to the compression result to obtain a first encryption result;
[0169] Step S0524, encapsulate the first encryption result to obtain a first encapsulation result.
[0170] Specifically, in order to obtain the first packaging result, the following steps are performed:
[0171] First, encapsulate the data into json format. For example, if the command to be executed is ls, the encapsulation result is: {"cmds":[{"id":1,"cmd":"ls","create_time":"1685946342541"}],"max_history":10,"outputs":{"id":1,"output":""}}, where the first cmds array in the json format is a command list, which stores all executed and unexecuted commands, and id is the unique identifier of the current command. max_history indicates the maximum number of commands saved. The number of commands is 10, which can be configured through the configuration file. Outputs indicates the result of command execution, where id is the unique id value of the currently executed command, corresponding to the id in cmds. The value of output is the result of command execution. During the command execution, the id value in output will change continuously, uniquely corresponding to the id value in cmds. Each time a command is issued for execution, a new record will be added to cmds and assigned a unique id. If the number of currently executed commands has reached 10, the latest command will be placed in the record with id=1, and the id in outputs will be changed to 0.
[0172] Then, after receiving the data, the controlled end will determine whether the current id is consistent with the id in cmds. If they are consistent, the command has been executed and the current data will not be processed. If they are inconsistent, if the number of entries in cmds is greater than the current id, and the id value in outputs is less than the latest id value in cmds, the command has not been executed. The command is executed, and the return value of the command is placed in the output field, and the value of the id in outputs is increased by 1, indicating that the command has been executed.
[0173] Then, gzip compression is performed on the data in json format. The encapsulated json format data is compressed using gzip to compress the data length. The results obtained in the above steps are compressed to obtain: \x1f\x8b\x08\x00P\x83}d\x02\xff\xabVJ\xceM)V\xb2R\x88\xaeV\xcaL\x01\xd2\x86:\n! K)\xa7X\t\xc4)JM,I\x8d / \xc9\xccM\x05\t\x1a\x9aY\x98Z\x9a\x98\x19\x9b\x18\x99\x9a\x18*\xd5\xc6\x02U\xe4&V\xc4gd\x1 6\x97\xe4\x17U\x82\x0c0\x00\n\xe5\x97\x96\x14\x94\x96\x00yH\xa6\xc2\xc5\x94\x94jk\x01\xbff\x1e\xd0x\x00\x00\x00, transfer After hexadecimal: 1f8b080050837d6402ffab564ace4d2956b25288ae56ca4c01d2863a0a2021204b29a75809c4294a4d2c498d2fc9cc4d05091a9a59985a9a98199b18999a182ad5c60255e42656c467641697e41755820c30000ae59796149496007948a6c2c594946a6b01bf661ed078000000;
[0174] Then, use the key sent by the server to encrypt the compressed binary data with AES. After converting to gzip, the data is still in plain text. Apply for the key from the master control end, and then encrypt it with AES. Use the CBC mode of AES encryption and pkcs7padding. The encrypted result is: 5ebb0ee226aa7d3ed2fd535e829754d9a13a389c75fa87d9e4e1b522676f8a4c24055fb6c5ec61e4e9dcdf8a96ce07d85442b9be49898ca9b2681c5c5a9c9ef258391938719fec14bb9c32cfa14cc2298019cba7e103 45bd841ddd02288d0fc63d98f6ede1d88fcc78825fc64966e53d14dc2d1a9839e35ed 4c17f10c504cd4ba2612814390fd64d6efd34d241e3f6e5e62159f77b81e7651eab7d 79796735e3d735c90f2937ce1470d60d057b4655d22469d28f292046fb75cbc8a3ebd d51dac1e88d3e84b347704519c1df3d6cc7f983a616b7639b07c22ba30bdc715ea370;
[0175] Finally, encapsulate the encrypted result in JSON format and write the encapsulated result to the service node corresponding to the server. After encapsulating the above encrypted result in JSON, the result is: {"data":"5ebb0ee226aa7d3ed2fd535e829754d9a13a389c75fa87d9e4e1b522676f8a4c24055fb6c5ec61e4e9dcdf8a96ce07d85442b9be49898ca9b2681c5c5a9c9ef258391938719fec14bb9c32cfa14cc2298019cba7e10345bd841ddd02288d0fc63d9 8f6ede1d88fcc78825fc64966e53d14dc2d1a9839e35ed4c17f10c504cd4ba26128 14390fd64d6efd34d241e3f6e5e62159f77b81e7651eab7d79796735e3d735c90f2 937ce1470d60d057b4655d22469d28f292046fb75cbc8a3ebdd51dac1e88d3e84b3 47704519c1df3d6cc7f983a616b7639b07c22ba30bdc715ea370","expand":{}}.
[0176] Through the above scheme, this embodiment specifically encapsulates the execution instruction through the service node to obtain an initial encapsulation result; compresses the initial encapsulation result to obtain a compression result; encrypts the compressed result through the encryption key to obtain a first encryption result; and encapsulates the first encryption result to obtain a first encapsulation result. Thus, the encryption and encapsulation of the execution instruction are realized, the problem of insecure data transmission is solved, and the efficiency of server cluster management is improved.
[0177] Reference Fig.12 , Fig.12 It is a flowchart of another exemplary embodiment of the server cluster management method of the present invention.
[0178] The server cluster management method is applied to a controlled end, and includes:
[0179] Step S06, connecting to the pre-acquired service node;
[0180] Step S07: receiving and executing the execution command sent by the main control end according to the service node, and obtaining the final execution result.
[0181] Specifically, in order to obtain the final execution result through the controlled end, the following steps are performed:
[0182] First, the controlled terminal is connected to a pre-acquired service node, wherein the service node corresponds to a master terminal, and the master terminal sends instructions to the controlled terminal through the service node and executes the instructions;
[0183] Then, the execution command of the master end is received through the service node, and the execution command is packaged and sent to the controlled end;
[0184] Finally, the controlled end decrypts and executes the encapsulated execution command to obtain the final execution result.
[0185] This embodiment uses the above solution to connect to the pre-acquired service node; according to the service node, receive and execute the execution command sent by the master control end to obtain the final execution result. Thus, the controlled end executes the command sent by the master control end and obtains the final execution result, which solves the problem of complex and cumbersome configuration of server management and improves the efficiency of server cluster management.
[0186] Reference Fig.13 , Fig.13 The present invention is a flow chart of the server cluster management method for obtaining the final execution result through the controlled terminal.
[0187] Based on the above Fig.12 In the embodiment shown, the step S07, according to the service node, receives and executes the execution command sent by the master control end, and the step of obtaining the final execution result includes:
[0188] Step S071, encapsulating the execution command through the service node to obtain a second encapsulation result;
[0189] Step S072, decrypting the second encapsulation result to obtain a first decryption result;
[0190] Step S073, extracting data from the first decryption result to obtain an execution value;
[0191] Step S074, executing the instruction according to the execution value to obtain an initial execution result;
[0192] Step S075, encapsulate the initial execution result to obtain the final execution result.
[0193] Specifically, in order to obtain the final execution result, the following steps are performed:
[0194] First, the execution command is encapsulated by the service node to obtain a second encapsulation result and send it to the controlled end;
[0195] Then, after receiving the second encapsulation result, the controlled end uses the key applied for from the control end to decrypt the second encapsulation result and judge the execution command;
[0196] Then, determine whether the command should be executed. If it needs to be executed, take out the value of the cmd field to execute the command. If the execution is successful, write the execution result to the output field and increase the value of id by 1.
[0197] Finally, the entire JSON is recompressed with gzip, encrypted with AES, and then encapsulated into JSON format data and written back to the service node to obtain the final execution result.
[0198] Furthermore, the data written back to the service node can be as follows:
[0199] The encapsulated json data is: {"cmds":[{"id":1,"cmd":"dir","create_time":"1685946342541"}],"max_history":10,"output":{"id":2,"output":"é ± \u008a¨ \u0099¨C \ \u009a\ \u008d· \u009c\ \ \u00ad \u0080\u0082\n \u008d· \u009a\ \ \u0088\ \u008f· \u00980E1B-FC36\n\n C:\\ \u009a\ \ \u0095\n\n2019 / 12 / 07 17:14 <dir>PerfLogs\n2023 / 03 / 3009:24 <dir>Program Files\n2023 / 04 / 11 10:19 <dir>ProgramFiles(x86)\n2023 / 03 / 23 21:48 <dir>Users\n2023 / 04 / 04 23:05 <dir>Windows\n0 \u0096\ 》0 \u00ad\u0097è\u008a\u0082\n5 \ \u0095 9,088,335,872 \u008f \u0094¨ \u00ad\u0097è\u008a\u0082\n"}};
[0200] The data after gzip compression is:
[0201] 1f8b0800e8a37d6402ff85535d4bc33014fd2b973e294c9aafb649111f9c0e041f44101fac8c744d67c1aed2763819fbefa6b763cde6e6ee439a9c9c73cf4d72bbf66665d67831bcadbd22b35f3a820eb2332f2b6aaf5bd546b766da16a5e9501aca4089900b1608ea6dde2da3d4abe947d1b455fdd3652016aa96edd7b2b5ab6d5ae6621e244b428cea468d634a1109ba516ac4e580a89e2961dc0b054a90a0334422a4a1500a2715eea6b86b429c3354d101513364aa01d1049168c8dcbba406118ebb3d87250b386177a2a4b44772478507519183e48765abfeb039907b7a7b3519f3305958eb719c2470c2ad4752d419c71f6b5441a767842a9f329f4400348aa9001bd7770fcf37b08b2753e78fd5bce9d88cfb84fb9c001015b3a3ecba9ad7ba8449f1697612e1536a0d484cd539095cac64783978310ec0682ce411e14b636ac783d87a188f497084fa5a2cb2eadb92613fc8df7ed2cea5874e1ff41cbcce343c9a25183a65fb98726867ec94fd084e999f79390035b24d33e23c18c988c161dfe8dcc9220effa5ff0af4369b5f04bf8a4210040000;
[0202] The data after AES encryption is:
[0203]
[0204] The data written to the service node is:
[0205]
[0206] Through the above scheme, this embodiment encapsulates the execution command through the service node to obtain the second encapsulation result; decrypts the second encapsulation result to obtain the first decryption result; extracts data from the first decryption result to obtain the execution value; executes the instruction according to the execution value to obtain the initial execution result; encapsulates the initial execution result to obtain the final execution result. In this way, the final execution result is obtained, the problem of complex and cumbersome configuration of server management is solved, and the efficiency of server cluster management is improved.
[0207] Reference Fig.14 , Fig.14 The present invention is a flow chart of the server cluster management method involving version updating of the controlled terminal.
[0208] Based on the above Fig.12 In the embodiment shown, the step S07, after receiving and executing the execution command sent by the master control terminal according to the service node, obtaining the final execution result, further includes:
[0209] Step S08, performing a version check on the controlled terminal and obtaining a check result;
[0210] Step S09, encrypting the inspection result to obtain a second encryption result;
[0211] Step S10, generating a version check instruction according to the second encryption result and sending it to the main control end, and the main control end performs version verification to obtain a verification result;
[0212] Step S11, when the verification result is not passed, receiving the update instruction sent by the main control end and performing the update to obtain the update result.
[0213] Specifically, in order to ensure the consistency of the controlled end version, the version update is completed through the following steps:
[0214] First, perform a version check on the controlled end to obtain the check result. The check method can be through the version check command: {"cmd":"update version","create_time":"1685946342541","key":"v0.1.1"}, where the cmd field is the version check instruction and the key field is the version of the current controlled end;
[0215] Then, the inspection result is encrypted by AES, and the encryption result is: d032aed91e55401b99a26fc52f107cdf24ec0b4e256d1949add4b4f5cdda426dd3eebab6bb4ab1385cca1fdf313740746e3c822a15a0e065f1b854afc83c63f4a99a49e5fdc5cf42c7ebc07cadd6356e;
[0216] Then, the encrypted result is encapsulated as data in JSON format and written to the service node. The data is: {"data":"d032aed91e55401b99a26fc52f107cdf24ec0b4e256d1949add4b4f5cdda426dd3eebab6bb4ab1385cca1fdf313740746e3c822a15a0e065f1b854afc83c63f4a99a49e5fdc5cf42c7ebc07cadd6356e","expand":{}};
[0217] Then, after receiving the version check command, the master will decrypt the data and compare it with the current latest version. If an update is required, the command issued is: {"cmd":"update version","create_time":"1685946342541","key":"new version download link"}; if an update is not required, the command issued is: {"cmd":"update version","create_time":"1685946342541","key":""}, and the encrypted data is written to the service node;
[0218] Then, through the above command interaction, the version check and automatic update functions can be realized, and the controlled end will use the dual-version coexistence method to reduce the probability of upgrade failure. After the new version is online, the master control end will detect that two versions with the same ID are online at the same time, and then send an uninstall command to the old version to uninstall the old version. The uninstall command is: {"cmd":"uninstall self","create_time":"1685946342541","key":""}, and the data is encrypted and written to the service node;
[0219] Then, the obtained encryption result is sent to the main control end for version verification to obtain the verification result;
[0220] Finally, when the verification result is not passed, the controlled end receives the update instruction sent by the master end to complete the version update of the controlled end.
[0221] Through the above scheme, this embodiment specifically performs a version check on the controlled end to obtain a check result; encrypts the check result to obtain a second encryption result; generates a version check instruction based on the second encryption result and sends it to the main control end, and the main control end performs version verification to obtain a verification result; when the verification result is not passed, receives an update instruction sent by the main control end and performs an update to obtain an update result. In this way, the version check and update are realized, the problem of complex and cumbersome configuration of server management is solved, and the efficiency of server cluster management is improved.
[0222] In addition, an embodiment of the present invention further provides a server cluster management device, the server cluster management device comprising:
[0223] Create a module to create a service node through the cluster module ZooKeeper;
[0224] The execution module is used to send an execution command to the controlled end according to the service node, and the controlled end executes the execution command to obtain a final execution result.
[0225] In addition, an embodiment of the present invention also proposes a terminal device, which includes a memory, a processor, and a server cluster management program stored in the memory and executable on the processor, and the server cluster management program implements the steps of the server cluster management method described above when executed by the processor.
[0226] Since the server cluster management program adopts all the technical solutions of all the aforementioned embodiments when executed by the processor, it has at least all the beneficial effects brought by all the technical solutions of all the aforementioned embodiments, which will not be described one by one here.
[0227] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a server cluster management program is stored. When the server cluster management program is executed by a processor, the steps of the server cluster management method described above are implemented.
[0228] Since the server cluster management program adopts all the technical solutions of all the aforementioned embodiments when executed by the processor, it has at least all the beneficial effects brought by all the technical solutions of all the aforementioned embodiments, which will not be described one by one here.
[0229] Compared with the prior art, the server cluster management method, device, terminal device and storage medium proposed in the embodiment of the present invention create a service node through the cluster module ZooKeeper; according to the service node, send an execution command to the controlled end, and the controlled end executes the execution command to obtain the final execution result. Thereby solving the problem of complex and cumbersome configuration of server management in server cluster management, realizing the management of server clusters and improving the efficiency of server cluster management. Based on the scheme of the present invention, starting from the problem of complex and cumbersome configuration of server management in reality, a server cluster management method is designed, and the effectiveness of the server cluster management method of the present invention is verified when managing the server cluster. Finally, the efficiency of server cluster management performed by the method of the present invention is significantly improved.
[0230] Compared with the existing technology, the embodiment of the present invention has the following advantages:
[0231] 1. The ZK-based master-end transfer solution can execute commands asynchronously without blocking the master end, use custom protocols, do not rely on the operating system, and have no restrictions on the operating system version and component version;
[0232] 2. Good compatibility, simple configuration, unlimited number of controlled terminals, no need to manually maintain configuration information such as the controlled terminal's IP address;
[0233] 3. The controlled end automatically reports and dynamically maintains without manual processing, which greatly improves the efficiency of server batch management.
[0234] It should be noted that, in this article, the term "includes", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0235] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0236] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as above, and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, a controlled terminal, or a network device, etc.) to execute the method of each embodiment of the present invention.
[0237] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.< / dir> < / dir> < / dir> < / dir> < / dir>
Claims
1. A server cluster management method, characterized in that: The server cluster management method is applied to the main control end, comprising the following steps: Create a service node through the cluster module ZooKeeper; According to the service node, an execution command is sent to the controlled end, and the controlled end executes the execution command to obtain a final execution result.
2. The server cluster management method according to claim 1, characterized in that: Before the step of sending an execution command to the controlled terminal according to the service node and executing the execution command by the controlled terminal and obtaining the final execution result, the step further includes: Receiving a key application instruction sent by the controlled terminal; Generate a key according to the key application instruction to obtain an encryption key; The encryption key is sent to the controlled terminal through the service node for storage.
3. The server cluster management method according to claim 2, characterized in that: The step of sending an execution command to a controlled terminal according to the service node, and having the controlled terminal execute the execution command to obtain a final execution result comprises: Generate an execution command and send it to the service node; According to the execution command, encapsulation is performed through the service node to obtain a first encapsulation result; The first encapsulation result is sent to the controlled end for instruction execution to obtain a final execution result.
4. The server cluster management method according to claim 3, characterized in that: The step of performing encapsulation through the service node according to the execution command to obtain a first encapsulation result comprises: Encapsulating the execution instruction through the service node to obtain an initial encapsulation result; Compressing the initial encapsulation result to obtain a compression result; According to the compression result, encrypting is performed using the encryption key to obtain a first encryption result; The first encryption result is encapsulated to obtain a first encapsulation result.
5. A server cluster management method, characterized in that: The server cluster management method is applied to the controlled end, comprising the following steps: Connect to the pre-obtained service node; According to the service node, the execution command sent by the main control end is received and executed to obtain the final execution result.
6. The server cluster management method according to claim 5, characterized in that: The step of receiving and executing the execution command sent by the master terminal according to the service node and obtaining the final execution result includes: Encapsulating the execution command through the service node to obtain a second encapsulation result; Decrypting the second encapsulation result to obtain a first decryption result; Extracting data from the first decryption result to obtain an execution value; According to the execution value, execute the instruction and obtain the initial execution result; The initial execution result is encapsulated to obtain a final execution result.
7. The server cluster management method according to claim 5, characterized in that: After the step of receiving and executing the execution command sent by the master terminal according to the service node and obtaining the final execution result, the following steps are further included: Performing a version check on the controlled terminal and obtaining a check result; Encrypting the inspection result to obtain a second encryption result; According to the second encryption result, a version check instruction is generated and sent to the main control end, and the main control end performs version verification and obtains a verification result; When the verification result is not passed, the update instruction sent by the main control end is received and updated to obtain the update result.
8. A server cluster management device, characterized in that: The server cluster management device is applied to the main control end, and the server cluster management device includes: Create a module to create a service node through the cluster module ZooKeeper; The execution module is used to send an execution command to the controlled end according to the service node, and the controlled end executes the execution command to obtain a final execution result.
9. A terminal device, characterized in that: The terminal device includes a memory, a processor, and a server cluster management program stored in the memory and executable on the processor. When the server cluster management program is executed by the processor, the steps of the server cluster management method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a server cluster management program, and when the server cluster management program is executed by the processor, the steps of the server cluster management method according to any one of claims 1 to 7 are implemented.
