Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to" determining "or" in response to detecting ". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing a relative importance or importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
With the development of network technology, computers are gradually clustered. However, because the number of computers in the computer cluster is huge, when performing operation maintenance, it is impossible to manually log in each device to perform command configuration.
In the conventional technology, the computer cluster is often divided into a plurality of nodes, and the management node sends the configuration to the child nodes in a centralized manner, so as to implement uniform configuration of the computer cluster. However, after the configuration is issued to the child node, it is inevitable that the configuration in the computer cluster is not consistent due to artificial modification or damage of the configuration command on the child node.
In view of this, embodiments of the present application provide a method, a system, a terminal device, and a computer-readable storage medium for managing a configuration, which can solve the technical problem that configurations in a computer cluster cannot be kept consistent because artificial modification or damage to a configuration file on a child node cannot be avoided after the configuration is issued to the child node.
Referring to fig. 1, fig. 1 shows a schematic flow chart of a management method for a configuration provided in the present application.
As shown in fig. 1, the management method may include the steps of:
step 101, calculating a first hash value of a current configuration file, wherein the current configuration file refers to a file formed by a set of currently running configuration commands.
The configuration command is an instruction for specifying a computer to perform a specific action, and includes a timed task (Crontab) command and the like.
Since the number of configuration commands contained in the local computer is large, if each configuration command is compared one by one, the calculation efficiency is low. Therefore, the present embodiment forms the current configuration file by aggregating a plurality of configuration commands. And then calculating a first hash value of the current configuration file, and determining whether to update the current configuration file according to the first hash value without comparing a plurality of configuration commands one by one.
The hash value is a value corresponding to the target file calculated by using a hash algorithm, and the hash algorithm maps a binary value with any length into a smaller binary value with a fixed length, wherein the binary value is the hash value. The Hash algorithms include Message Digest Algorithm second version (Message Digest Algorithm 2, MD2), Message Digest Algorithm fourth version (Message Digest Algorithm 4, MD4), Message Digest Algorithm fifth version (Message Digest Algorithm 5, MD5), and Hash function encryption Algorithm (Secure Hash Algorithm, SHA-1), among others. In the embodiment, the current configuration file is represented by the first hash value, so that the operation efficiency is greatly optimized.
And 102, acquiring a second hash value of a pre-stored historical configuration file, wherein the historical configuration file is a unified configuration file issued by a management node.
The historical configuration file may be a unified configuration file issued by the management node, may also be an updated configuration file, and may also be a configuration file with the same hash value. Wherein the historical configuration file is stored in a database. When the second hash value of the historical configuration file needs to be obtained, the second hash value of the pre-stored historical configuration file only needs to be obtained in the memory of the local computer, and the historical configuration file does not need to be obtained from the database.
As an embodiment of the application, when the second hash value of the historical configuration file needs to be obtained, the historical configuration file in the database may be directly obtained, and then the second hash value of the historical configuration file is calculated through a hash algorithm.
As another embodiment of the present application, when the second hash value of the historical configuration file needs to be obtained, the historical configuration file in the memory may be directly obtained, and then the second hash value of the historical configuration file is calculated through a hash algorithm.
As another embodiment of the present application, when the second hash value of the history configuration file needs to be obtained, the second hash value pre-stored in the database may be directly obtained.
And 103, if the first hash value and the second hash value are different, updating the current configuration file according to the historical configuration file.
And if the first hash value and the second hash value are different, indicating that one or more configuration commands in the current configuration file are changed. The current configuration file needs to be updated according to the historical configuration file so as to keep the configuration files in the computer cluster consistent.
Specifically, the updating the current configuration file according to the historical configuration file includes the following steps, please refer to fig. 2, and fig. 2 shows a specific schematic flowchart of step 103 in a management method for configuration provided by the present application.
Step 1031, traversing the first configuration command set in the history configuration file and the second configuration command set in the current configuration file.
Since the historical configuration file and the current configuration file both contain a plurality of configuration commands. Therefore, each configuration command of the historical configuration file and the current configuration file needs to be traversed.
Step 1032, updating the second configuration command set according to the first configuration command set to obtain the updated current configuration file.
And searching different and same configuration commands in the first configuration command set and the second configuration command set, and replacing the configuration commands in the second configuration command set with the corresponding configuration commands in the first configuration command set to obtain the updated current configuration file.
In the embodiment, a first hash value of the current configuration file is calculated; acquiring a second hash value of a pre-stored historical configuration file, wherein the historical configuration file is a unified configuration file issued by a management node or a configuration file obtained after the unified configuration file is updated; and if the first hash value and the second hash value are different, updating the current configuration file according to the historical configuration file. And judging whether the current configuration file is changed or not according to the second hash value of the historical configuration file, and further updating the current configuration file to ensure that the computer configuration in the computer cluster is kept consistent.
Optionally, on the basis of the embodiment shown in fig. 1, before the current configuration file is updated according to the historical configuration file, the following steps are further included, please refer to fig. 3, and fig. 3 shows a schematic flowchart of another configuration management method provided by the present application. In this embodiment, steps 301 to 302 are the same as steps 101 to 102 in the embodiment shown in fig. 1, and specific reference is made to the description related to steps 101 to 102 in the embodiment shown in fig. 1, which is not repeated herein.
Step 301, calculating a first hash value of a current configuration file, where the current configuration file is a file formed by a configuration command set currently running.
Step 302, obtaining a second hash value of a pre-stored historical configuration file, where the historical configuration file is a unified configuration file issued by a management node.
Step 303, if the first hash value and the second hash value are different, acquiring a local internet protocol address.
And when the historical configuration file is stored in a local database, directly acquiring the historical configuration file in the local database.
When the historical configuration file is stored in a non-local database (such as a management node database), the historical configuration file is obtained according to a local internet protocol address.
Step 304, obtaining the historical configuration file in a database according to the local internet protocol address.
Step 305, updating the current configuration file according to the historical configuration file.
In this embodiment, the historical configuration file is obtained in the database by obtaining a local internet protocol address and according to the local internet protocol address. And updating the current configuration file by acquiring the historical configuration file, so as to ensure that the configuration commands in the computer cluster are kept consistent.
Optionally, on the basis of the embodiment shown in fig. 1, the method further includes the following steps, please refer to fig. 4, and fig. 4 shows a schematic flowchart of a management method of another configuration provided in the present application. In this embodiment, steps 401 to 403 are the same as steps 101 to 103 in the embodiment shown in fig. 1, and specific reference is made to the related description of steps 101 to 103 in the embodiment shown in fig. 1, which is not repeated herein.
Step 401, calculating a first hash value of a current configuration file, where the current configuration file is a file formed by a configuration command set currently running.
Step 402, obtaining a second hash value of a pre-stored historical configuration file, where the historical configuration file is a unified configuration file issued by a management node.
Step 403, if the first hash value and the second hash value are different, updating the current configuration file according to the historical configuration file.
In step 404, a command to be executed and an execution log in a preset period are obtained.
In order to check whether the updated configuration command in the current configuration file can be executed normally. Therefore, after the current configuration file is updated, the command and the execution log which need to be executed in the preset period need to be acquired, so as to detect whether the configuration command in the updated current configuration file can be normally executed.
Step 405, if the command does not exist in the execution log, sending alarm information to an external device or a management node.
If the command exists in the execution log, it indicates that the updated configuration command in the current configuration file can be normally executed.
If the command does not exist in the execution log, it indicates that the updated configuration command in the current configuration file cannot be normally executed, and an alarm message needs to be sent to external equipment or a management node to remind a user of configuration updating.
In this embodiment, by obtaining a command to be executed and an execution log in a preset period, if the command does not exist in the execution log, sending alarm information to an external device or a management node. Whether the configuration command in the updated current configuration file is normally executed is determined through the method, so that an error configuration instruction is prevented from being generated after updating, and the accuracy of updating the configuration command is ensured.
Optionally, on the basis of the embodiment shown in fig. 1, the method further includes the following steps, please refer to fig. 5, and fig. 5 shows a schematic flowchart of a management method of another configuration provided in the present application. In this embodiment, steps 501 to 503 are the same as steps 101 to 103 in the embodiment shown in fig. 1, and specific reference is made to the description related to steps 101 to 104 in the embodiment shown in fig. 1, which is not repeated herein.
Step 501, calculating a first hash value of a current configuration file, where the current configuration file is a file formed by a configuration command set currently running.
Step 502, obtaining a second hash value of a pre-stored historical configuration file, where the historical configuration file is a unified configuration file issued by a management node.
Step 503, if the first hash value is different from the second hash value, updating the current configuration file according to the historical configuration file.
Step 504, repeatedly executing step 501 to step 503 every preset time.
In the present embodiment, steps 501 to 503 are repeatedly executed every preset time period. The method realizes the periodic update of the current configuration file, and ensures that the configuration commands in the computer cluster are kept consistent.
Optionally, on the basis of the embodiment shown in fig. 1, the method further includes the following steps, please refer to fig. 6, and fig. 6 shows a schematic flowchart of a management method of another configuration provided in the present application. In this embodiment, steps 601 to 603 are the same as steps 101 to 103 in the embodiment shown in fig. 1, and specific reference is made to the related description of steps 101 to 104 in the embodiment shown in fig. 1, which is not repeated herein.
Step 601, calculating a first hash value of a current configuration file, where the current configuration file is a file formed by a configuration command set currently running.
Step 602, obtaining a second hash value of a pre-stored historical configuration file, where the historical configuration file is a unified configuration file issued by a management node.
Step 603, if the first hash value and the second hash value are different, updating the current configuration file according to the historical configuration file, and sending alarm information to external equipment or a management node.
If the first hash value and the second hash value are different, the configuration command in the current configuration file is changed or damaged in the child node, the current configuration file needs to be updated according to the historical configuration file, and alarm information is sent to external equipment or a management node.
In this embodiment, when the first hash value and the second hash value are different, the current configuration file is updated according to the historical configuration file, and an alarm message is sent to an external device or a management node. Through the method, the user is prompted to carry out other measures, and the configuration command in the current configuration file is prevented from being changed or damaged.
Referring to fig. 7, fig. 7 is a schematic diagram illustrating a management system according to one configuration provided in the present application.
As shown in fig. 7, the management system 7 includes: the system comprises a detection configuration module, an operating system module, a management node database module and a child node database module.
And the detection configuration module is used for detecting whether the current configuration file is the same as the unified configuration file. And the operating system module is used for acquiring a local internet protocol address. And the management node database module is used for storing the historical configuration file. And the child node database module is used for storing an update log of the configuration command set in the current configuration file.
The processing flow of the management system 7 is as follows:
the operating system module sends a detection configuration instruction to a detection configuration module (which may be a detection configuration program or a script, etc.) according to a preset period. The detection configuration module sets a file exclusive lock in the current configuration file, calculates a first hash value of the current configuration file and a second hash value of the historical configuration file, and if the first hash value is different from the second hash value, calculates a second hash value of the historical configuration file. And the operating system module acquires a local IP address and acquires a historical configuration file in the management node database module according to the IP address. And the detection configuration module updates different configurations of the local configuration file according to the historical configuration file. The management node database module stores the updated local configuration file. The child node database module stores a configuration update log. And the detection configuration module takes the third hash value of the modified current configuration file as the second hash value of the historical configuration file.
Referring to fig. 8, fig. 8 is a schematic diagram illustrating a detection configuration module in a configured management system according to the present application.
Wherein, the detection configuration module 8 includes:
the calculatingunit 81 is configured to calculate a first hash value of a current configuration file, where the current configuration file is a file formed by a set of configuration commands currently running.
The obtainingunit 82 is configured to obtain a second hash value of a pre-stored historical configuration file, where the historical configuration file is a unified configuration file issued by the management node.
And the judgingunit 83 is configured to update the current configuration file according to the historical configuration file if the first hash value is different from the second hash value.
According to the management system for configuration, a first hash value of a current configuration file is calculated; acquiring a second hash value of a pre-stored historical configuration file, wherein the historical configuration file is a unified configuration file issued by a management node or a configuration file obtained after the unified configuration file is updated; and if the first hash value and the second hash value are different, updating the current configuration file according to the historical configuration file. And judging whether the current configuration file is changed or not according to the second hash value of the historical configuration file, and further updating the current configuration file to ensure that the configuration commands in the computer cluster are kept consistent.
Fig. 9 shows a schematic diagram of a terminal device according to an embodiment of the present application. As shown in fig. 9, aterminal device 9 of this embodiment includes: aprocessor 90, amemory 91, and acomputer program 92, such as a configured hypervisor, stored in thememory 91 and operable on theprocessor 90. Theprocessor 90, when executing thecomputer program 92, implements the steps in each of the above-described configured management method embodiments, such as the steps 101 to 103 shown in fig. 1. Alternatively, theprocessor 90, when executing thecomputer program 92, implements the functions of the modules in the above device embodiments, such as the modules shown in fig. 8.
Illustratively, thecomputer program 92 may be partitioned into one or more modules that are stored in thememory 91 and executed by theprocessor 90 to accomplish the present application. The one or more modules may be a series of computer program instruction segments capable of performing specific functions for describing the execution of thecomputer program 92 in the oneterminal device 9. For example, thecomputer program 92 may be divided into modules with specific functions as follows:
the detection configuration module is used for detecting whether the current configuration file is the same as the unified configuration file or not;
the operating system module is used for acquiring a local Internet protocol address;
the management node database module is used for storing the historical configuration file;
and the child node database module is used for storing an update log of the configuration command set in the current configuration file.
Theterminal device 9 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, aprocessor 90, amemory 91. Those skilled in the art will appreciate that fig. 9 is merely an example of one type ofterminal device 9 and does not constitute a limitation of one type ofterminal device 9, and may include more or fewer components than shown, or combine certain components, or different components, e.g., the one type of terminal device may also include input-output devices, network access devices, buses, etc.
TheProcessor 90 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Thememory 91 may be an internal storage module of theterminal device 9, such as a hard disk or a memory of theterminal device 9. Thememory 91 may also be an external storage device of theterminal device 9, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) and the like provided on theterminal device 9. Further, thememory 91 may also include both an internal memory module and an external memory device of theterminal device 9. Thememory 91 is used for storing the computer program and other programs and data required by the kind of terminal equipment. Thememory 91 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned functional modules and modules are illustrated as examples, and in practical applications, the above-mentioned functional allocation may be performed by different functional modules and modules according to requirements, that is, the internal structure of the apparatus is divided into different functional modules or modules to perform all or part of the above-mentioned functions. In the embodiments, each functional module and each module may be integrated into one processing module, or each module may exist alone physically, or two or more modules are integrated into one module, and the integrated modules may be implemented in a form of hardware or a form of software functional modules. In addition, specific names of the functional modules and modules are only used for distinguishing the functional modules and the modules from each other, and are not used for limiting the protection scope of the present application. The modules and the specific working processes of the modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative modules and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed terminal device and method may be implemented in other ways. For example, the above-described terminal device embodiments are merely illustrative, and for example, the modules or the division of the modules is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of modules or components may be combined or may be integrated into another system, or some features may be omitted or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, functional modules in the embodiments of the present application may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode.
The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.