System Configuration Method, Device, Electronic Device, and Storage Medium
Through the locking and unlocking mechanisms between cluster system devices, the problem of inflexible configuration of cluster system is solved, and configuration consistency and operational convenience between devices are achieved.
Patent Information
- Application Number
- CN202111352277.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-16
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2041-11-16
AI Technical Summary
In cluster systems, the prior art requires manual operation and configuration using central equipment, resulting in inflexible configuration and inconvenient operation.
Broadcast lock application messages through any cluster system device, lock target resources, avoid reading of other devices, add preset configuration files and unlock them, ensure configuration consistency and avoid specifying central devices.
It realizes the flexibility of cluster configuration and operational convenience, ensures configuration consistency between devices, and avoids configuration conflicts.
Smart Images

Figure CN114003263B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cluster technology, and more particularly, to a system configuration method, apparatus, electronic device, and storage medium. Background Art
[0002] In a cluster system, it is usually composed of multiple devices. When configuring a cluster system, currently, to ensure the consistency of the configuration among devices, manual operations are usually required and the central device in the cluster system is used for configuration, and only the central device can be used for cluster configuration. Among them, the central device is the device pre-specified in the cluster system. Thus, the configuration of the cluster system is not flexible and not convenient to operate. Summary of the Invention
[0003] The purpose of the embodiments of this application is to provide a system configuration method, apparatus, electronic device, and storage medium, which can improve the problem that the configuration of the cluster system is not flexible and not convenient to operate.
[0004] To achieve the above purpose, the embodiments of this application are implemented as follows:
[0005] In a first aspect, the embodiments of this application provide a system configuration method, which is applied to any device in a cluster system. The method includes: broadcasting a lock application message to all other devices in the cluster system except this device; when receiving the confirmation replies sent by all other devices based on the lock application message, locking the target resources of a specified type in this device according to the lock application message, where the locked target resources cannot be read by all other devices; obtaining a preset configuration file and adding the preset configuration file to the target resources; when a preset unlocking condition is met, unlocking the target resources, where the target resources after unlocking are allowed to be read by any device in the cluster system.
[0006] In the above implementation, any device in the cluster system is used to broadcast a lock application message, then lock the target resources, avoid other devices in the cluster system from reading the target resources, then add the preset configuration file to the target resources, and then unlock the target resources. In this way, during the distribution process of the preset configuration file, other devices in the cluster system will not read the configuration file, so as to ensure the consistency of the cluster configuration. After the target resources are unlocked, the configuration of the cluster can be completed. Based on this, there is no need to specify a central device in the cluster system, and the cluster configuration can be flexibly realized and the configuration operation is convenient.
[0007] In combination with the first aspect, in some alternative embodiments, before unlocking the target resource, the method further includes: determining whether the preset configuration file is added to the target resource, and if so, it indicates that the preset unlocking condition is met.
[0008] In combination with the first aspect, in some alternative embodiments, before unlocking the target resource, the method further includes: determining whether the duration of locking the target resource exceeds a preset duration, and if so, it indicates that the preset unlocking condition is met.
[0009] In combination with the first aspect, in some alternative embodiments, before unlocking the target resource, the method further includes: when receiving an operation command for resetting the locking duration, re-recording the duration of locking the target resource.
[0010] In the above embodiments, by means of the operation command for resetting the locking duration, it is beneficial for the management personnel to flexibly change the locking of the target resource.
[0011] In combination with the first aspect, in some alternative embodiments, when the preset unlocking condition is met and before unlocking the target resource, the method further includes: broadcasting a lock release message to all other devices; correspondingly, unlocking the target resource includes: when receiving an acknowledgment reply sent by all other devices based on the lock release message, unlocking the target resource.
[0012] In the above embodiments, by broadcasting a lock release message to all other devices, it is beneficial for all other devices to quickly know that this device is about to unlock the target resource.
[0013] In combination with the first aspect, in some alternative embodiments, the method further includes: sharing the preset configuration file to all other devices.
[0014] In combination with the first aspect, in some alternative embodiments, locking a specified type of target resource in this device in the cluster system includes:
[0015] When the specified type includes multiple types, for the target resources corresponding to each type in the specified type in this device, locks with different identity identifiers are used for locking.
[0016] In the above embodiments, this device can use different locks to lock different types of target resources. In this way, lock conflicts can be avoided. In addition, different locks are independent of each other and can be unlocked separately, which is beneficial for the flexible locking and unlocking of resources.
[0017] In a second aspect, the present application further provides a system configuration device, which is applied to any device in a cluster system. The device includes:
[0018] A broadcast unit, configured to broadcast a lock application message to all other devices in the cluster system except the device itself;
[0019] A locking unit, configured to lock a target resource of a specified type in the device itself according to the lock application message when receiving confirmation replies sent by all other devices based on the lock application message, wherein the locked target resource cannot be read by all other devices;
[0020] A configuration acquisition unit, configured to acquire a preset configuration file and add the preset configuration file to the target resource;
[0021] An unlocking unit, configured to unlock the target resource when a preset unlocking condition is met, wherein the target resource after unlocking is permitted to be read by any device in the cluster system.
[0022] In a third aspect, the present application further provides an electronic device, which includes a processor and a memory coupled to each other. The memory stores a computer program, and when the computer program is executed by the processor, the electronic device executes the above method.
[0023] In a fourth aspect, the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program runs on a computer, the computer executes the above method. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0025] Figure 1 It is a schematic diagram of the communication connection of the cluster system provided by the embodiment of the present application.
[0026] Figure 2 It is a schematic diagram of the structure of the electronic device provided by the embodiment of the present application.
[0027] Figure 3 It is a schematic diagram of the flow of the system configuration method provided by the embodiment of the present application.
[0028] Figure 4Block diagram of the system configuration device provided by the embodiments of the present application.
[0029] Icons: 10 - Cluster system; 11 - Electronic device; 12 - Electronic device; 13 - Electronic device; 20 - Electronic device; 21 - Processing module; 22 - Storage module; 200 - System configuration device; 210 - Broadcasting unit; 220 - Locking unit; 230 - Configuration acquisition unit; 240 - Unlocking unit. Detailed implementation manners
[0030] Next, the technical solutions in the embodiments of the present application will be described with reference to the accompanying drawings in the embodiments of the present application. It should be noted that the terms "first", "second", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance. Without conflict, the following embodiments and the features in the embodiments can be combined with each other.
[0031] Please refer to Figure 1 , the present application provides a cluster system 10, which may include multiple electronic devices. The electronic device may be, but is not limited to, devices such as personal computers and servers. Each electronic device in the cluster system 10 can be used to store data or process data to provide business services well-known to those skilled in the art. The electronic devices can communicate based on Corosync.
[0032] Corosync is a part of the cluster management suite. When Corosync transmits information, it can define the information transmission method, protocol, etc. through a simple configuration file, which is a component well-known to those skilled in the art.
[0033] Understandably, the number of electronic devices included in the cluster system 10 can be flexibly determined according to the actual situation. Exemplarily, please refer to Figure 1 again, the cluster system 10 may include an electronic device 11, an electronic device 12, and an electronic device 13. Of course, in other implementation manners, the cluster system 10 may further include a greater number of devices, which are not specifically limited here.
[0034] In this embodiment, when configuration maintenance or update of the cluster system 10 is required, any electronic device in the cluster system 10 can be used to implement configuration maintenance or update.
[0035] Please refer to Figure 2 , the present application further provides an electronic device 20, which can be used as any device in the cluster system 10. The electronic device 20 may include a processing module 21 and a storage module 22. A computer program is stored in the storage module 22. When the computer program is executed by the processing module 21, the electronic device 20 can execute the steps in the following system configuration method.
[0036] Please refer to Figure 3 In addition, this application also provides a system configuration method, which can be applied to the above-mentioned electronic device 20 and executed or implemented by the electronic device 20 for each step in the method. The method may include the following steps:
[0037] Step S110: Broadcast a lock application message to all other devices in the cluster system 10 except this device;
[0038] Step S120: When receiving the confirmation replies sent by all the other devices based on the lock application message, lock the target resources of the specified type in this device according to the lock application message, where the locked target resources cannot be read by all the other devices;
[0039] Step S130: Obtain a preset configuration file and add the preset configuration file to the target resources;
[0040] Step S140: When a preset unlocking condition is met, unlock the target resources, where the target resources after unlocking are allowed to be read by any device in the cluster system 10.
[0041] In the above implementation, any device in the cluster system 10 is used to broadcast a lock application message, then lock the target resources, preventing other devices in the cluster system 10 from reading the target resources, then add the preset configuration file to the target resources, and then unlock the target resources. In this way, during the process of distributing the preset configuration file, other devices in the cluster system 10 will not read this configuration file, thus ensuring the consistency of the cluster configuration. After the target resources are unlocked, the configuration of the cluster can be completed. Based on this, there is no need to specify a central device in the cluster system 10, and the cluster configuration can be flexibly implemented, facilitating the configuration operation.
[0042] The following will elaborate on each step in the method in detail as follows:
[0043] In step S110, when it is necessary to maintain and update the configuration in the cluster, the user can select any electronic device in the cluster system 10 as the object to be configured, that is, this device. For example, please refer to again Figure 1 , among the electronic device 11, the electronic device 12, and the electronic device 13, select the electronic device 11 as the object to be pre-configured. Then, use this device to broadcast a lock application message to all other devices in the cluster system 10 except this device. Among them, the lock application message prompts other devices that this device intends to lock the target resources of the specified type stored in itself.
[0044] In step S120, when this device receives the confirmation replies sent by all other devices based on the lock application message, it indicates that this device can lock the target resource. Among them, locking the target resource can be locking the folder where the target resource is located or locking the target resource itself.
[0045] In addition, the target resources of the specified type can be flexibly determined according to the actual situation. After the target resource is locked, it cannot be read by all other devices. In this way, it can be ensured that the preset configuration file cannot be read by other devices during the period when it is added to the target resource, so that the configuration of the cluster system 10 can continue to maintain consistency.
[0046] When any one of all other devices does not send a confirmation reply to this device, or the response times out (for example, does not send a confirmation reply to this device within the set duration after sending the lock application message), the lock application fails. At this time, this device does not need to lock the target resource.
[0047] It should be noted that after the target resource is locked, it can be read by this device or cannot be read by this device, which is not specifically limited here.
[0048] In this embodiment, the lock used to lock the target resource can be a distributed lock based on Corosync. In this way, any device in the cluster system 10 can perform configuration operations, and Corosync is responsible for communication between devices.
[0049] In this embodiment, step S120 may include:
[0050] When the specified type includes multiple types, the target resources corresponding to each type in the specified type in this device are locked using locks with different identity identifiers.
[0051] Understandably, this device can use different locks to lock different types of target resources. In this way, lock conflicts can be avoided. In addition, different locks are independent of each other and can be unlocked separately, which is beneficial to the flexible locking and unlocking of resources. The target resources of the same type can be locked using one lock, and different locks can have different identity identifiers. This identity identifier can be flexibly set according to the actual situation.
[0052] In step S130, after the target resource is locked, the user can enter the preset configuration file into this device, and then this device adds the preset configuration file to the target resource. Among them, "adding the preset configuration file to the target resource" can be understood as: adding the preset configuration file to the folder where the target resource is located or adding it to the file of the target resource.
[0053] Among them, the preset configuration file can be flexibly determined according to the actual situation and is usually a configuration file that any device in the cluster system 10 can share.
[0054] In step S140, the preset unlocking condition can be flexibly determined according to the actual situation.
[0055] As an optional implementation manner, between step S130 and step S140, the method may further include:
[0056] Determine whether the preset configuration file is added to the target resource. If so, it indicates that the preset unlocking condition is satisfied.
[0057] As an optional implementation manner, between step S130 and step S140, the method may further include:
[0058] Determine whether the duration of locking the target resource exceeds a preset duration. If so, it indicates that the preset unlocking condition is satisfied.
[0059] Understandably, this device can detect whether the preset configuration file is added to the target resource, or this device can detect whether the duration of locking the target resource exceeds the preset duration. The preset duration can be flexibly set according to the actual situation. If the duration of locking the target resource exceeds the preset duration, it means that the unlocking condition is satisfied and there is no need to wait any longer. At this time, this device can directly unlock the target resource so that any device in the cluster system 10 can read the unlocked target resource.
[0060] As an optional implementation manner, before unlocking the target resource, the method further includes:
[0061] When receiving an operation command for resetting the locking duration, re-record the duration of locking the target resource.
[0062] Understandably, during the period when the target resource is locked, if the user has other configuration operations, at this time, the user can input an operation command for resetting the locking duration to this device so that this device re-records the duration of locking the target resource based on this operation command. After resetting the locking duration, this device can determine again whether the duration of locking the target resource exceeds the preset duration. If so, it indicates that the preset unlocking condition is satisfied. In this way, it is convenient for the user to perform configuration maintenance and update on the target resource midway.
[0063] As an optional implementation manner, when the preset unlocking condition is satisfied and before unlocking the target resource, the method may further include:
[0064] Broadcast a lock release message to all other devices;
[0065] Correspondingly, unlocking the target resource includes:
[0066] When confirmation replies sent by all other devices based on the lock release message are received, the lock on the target resource is released.
[0067] Understandably, in this embodiment, when the preset unlocking condition is met, the device broadcasts a lock release message to other devices, so that other devices can be notified that the device intends to unlock the target resource. After receiving the lock release message, any device can send a confirmation reply to the device, indicating that the lock release message has been received. When all other devices reply with a confirmation reply, the device unlocks the target resource.
[0068] After step S140, the method may further include: sharing the preset configuration file to all other devices.
[0069] After the target resource is unlocked, based on the cluster configuration, other devices in the cluster system 10 can share the preset configuration file added in the target resource to achieve cluster configuration consistency and avoid conflicts caused by inconsistent configuration. Based on this, configuration operations performed on any device in the cluster system 10 can also maintain consistency in configuration between devices.
[0070] Please refer to Figure 4 The embodiment of the present application also provides a cluster configuration device, which can be applied to the above-mentioned electronic device to execute each step in the method. The cluster configuration device includes at least one software function module that can be stored in the storage module 22 in the form of software or firmware or solidified in the operating system (OS) of the electronic device. The processing module 21 is used to execute the executable module stored in the storage module 22, such as the software function module and computer program included in the cluster configuration device.
[0071] The cluster configuration device may include a broadcast unit 210, a locking unit 220, a configuration acquisition unit 230, and an unlocking unit 240. The functions that each unit may implement are as follows:
[0072] The broadcast unit 210 is used to broadcast the lock application message to all other devices in the cluster system 10 except the current device;
[0073] The locking unit 220 is configured to lock a target resource of a specified type in the device according to the lock application message when receiving a confirmation reply sent by all other devices based on the lock application message, wherein the locked target resource cannot be read by all other devices;
[0074] A configuration acquisition unit 230, configured to acquire a preset configuration file and add the preset configuration file to the target resource;
[0075] An unlocking unit 240, configured to unlock the target resource when a preset unlocking condition is satisfied. After unlocking, the target resource is permitted to be read by any device in the cluster system 10.
[0076] Optionally, the locking unit 220 may also be configured to: when the specified type includes multiple types, lock the target resources corresponding to each type in the specified type in this device with locks having different identity identifiers.
[0077] Optionally, the system configuration device 200 may further include a sharing unit, configured to share the preset configuration file to all other devices.
[0078] Optionally, the system configuration device 200 may further include a judging unit. Before the unlocking unit 240 unlocks the target resource, the judging unit is configured to judge whether the preset configuration file has been added to the target resource. If so, it indicates that the preset unlocking condition is satisfied. Alternatively, the judging unit is configured to judge whether the duration of locking the target resource exceeds a preset duration. If so, it indicates that the preset unlocking condition is satisfied.
[0079] Optionally, the system configuration device 200 may further include a timing initialization unit. Before the unlocking unit 240 unlocks the target resource, the timing initialization unit is configured to re-record the duration of locking the target resource when receiving an operation command for resetting the locking duration.
[0080] Optionally, when the preset unlocking condition is satisfied and before the unlocking unit 240 unlocks the target resource, the broadcasting unit 210 is further configured to broadcast a lock release message to all other devices; correspondingly, the unlocking unit 240 is further configured to unlock the target resource when receiving an acknowledgment reply sent by all other devices based on the lock release message.
[0081] In this embodiment, the processing module 21 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processing module 21 may be a general-purpose processor. For example, the processor may be a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.
[0082] The storage module 22 may be, but is not limited to, a random access memory, a read-only memory, a programmable read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, etc. In this embodiment, the storage module 22 may be used to store network resources, configuration files, etc. Of course, the storage module 22 may also be used to store programs, and after receiving an execution instruction, the processing module 21 executes the program.
[0083] It can be understood that Figure 2 the structure shown is only a schematic structural diagram of an electronic device, and the electronic device may also include more components than Figure 2 shown. Figure 2 Each component shown in may be implemented by hardware, software, or a combination thereof.
[0084] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described electronic device can refer to the corresponding processes of the various steps in the foregoing method, and will not be elaborated herein.
[0085] The embodiments of the present application also provide a computer-readable storage medium. A computer program is stored in the computer-readable storage medium, and when the computer program runs on a computer, the computer is caused to execute the cluster configuration method as described in the above embodiments.
[0086] Through the description of the above embodiments, those skilled in the art can clearly understand that this application can be implemented through hardware, or by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of this application can be embodied in the form of a software product, and this software product can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various implementation scenarios of this application.
[0087] In summary, in this solution, any device in the cluster system is used to broadcast a lock application message, then lock the target resource to prevent other devices in the cluster system from reading the target resource, then add a preset configuration file to the target resource, and then unlock the target resource. In this way, during the process of distributing the preset configuration file, other devices in the cluster system will not read this configuration file, thus ensuring the consistency of the cluster configuration. After the target resource is unlocked, the configuration of the cluster can be completed. Based on this, there is no need to specify a central device in the cluster system, which can flexibly implement the cluster configuration and facilitate the configuration operation.
[0088] In the embodiments provided in this application, it should be understood that the disclosed devices, systems, and methods can also be implemented in other ways. The device, system, and method embodiments described above are only illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of systems, methods, and computer program products according to multiple embodiments of this application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions. In addition, the functional modules in various embodiments of this application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.
[0089] The above description is only for the embodiments of this application and is not intended to limit the protection scope of this application. For those skilled in the art, this application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included in the protection scope of this application.
Claims
1. A system configuration method, characterized in that, Applied to any device in a cluster system, the method includes: Broadcasting a lock application message to all other devices in the cluster system except the device itself; When receiving the confirmation replies sent by all other devices based on the lock application message, locking the target resources of a specified type in the device itself according to the lock application message, where the locked target resources cannot be read by all other devices; Obtaining a preset configuration file and adding the preset configuration file to the target resources; When a preset unlocking condition is met, unlocking the target resources, where the target resources after unlocking are permitted to be read by any device in the cluster system; if the preset configuration file is added to the target resources, or the duration of locking the target resources exceeds a preset duration, it indicates that the preset unlocking condition is met.
2. The method according to claim 1, wherein Before unlocking the target resources, the method further includes: When receiving an operation command for resetting the locking duration, re-recording the duration of locking the target resources.
3. The method according to claim 1, characterized in that, When a preset unlocking condition is met and before unlocking the target resources, the method further includes: Broadcasting a lock release message to all other devices; Correspondingly, unlocking the target resources includes: When receiving the confirmation replies sent by all other devices based on the lock release message, unlocking the target resources.
4. The method according to claim 1, characterized in that, The method further includes: Sharing the preset configuration file with all other devices.
5. The method according to claim 1, wherein Locking the target resources of a specified type in the device itself in the cluster system includes: When the specified type includes multiple types, locking the target resources corresponding to each type in the specified type in the device itself with locks having different identity identifiers.
6. A system configuration device, characterized in that, Applied to any device in a cluster system, the device includes: A broadcasting unit for broadcasting a lock application message to all other devices in the cluster system except the device itself; A locking unit for, when receiving the confirmation replies sent by all other devices based on the lock application message, locking the target resources of a specified type in the device itself according to the lock application message, where the locked target resources cannot be read by all other devices; A configuration obtaining unit for obtaining a preset configuration file and adding the preset configuration file to the target resources; An unlocking unit for unlocking the target resources when a preset unlocking condition is met, where the target resources after unlocking are permitted to be read by any device in the cluster system; if the preset configuration file is added to the target resources, or the duration of locking the target resources exceeds a preset duration, it indicates that the preset unlocking condition is met.
7. The device according to claim 6, characterized in that, The system configuration device further includes a timing initialization unit; before the unlocking unit unlocks the target resources, the timing initialization unit is used to re-record the duration of locking the target resources when receiving an operation command for resetting the locking duration.
8. The device according to claim 6, characterized in that, When the preset unlocking condition is satisfied and before the unlocking unit releases the lock on the target resource, the broadcasting unit is further configured to broadcast a lock release message to all the other devices; Correspondingly, the unlocking unit is further configured to release the lock on the target resource when receiving the confirmation replies sent by all the other devices based on the lock release message.
9. The device according to claim 6, characterized in that, The system configuration device further includes a sharing unit configured to share the preset configuration file with all the other devices.
10. The device according to claim 6, characterized in that, The locking unit is further configured to: when the specified type includes multiple types, lock the target resources corresponding to each type in the specified type in the device with locks having different identity identifiers.
11. An electronic device, characterized in that, The electronic device includes a processor and a memory coupled to each other, and a computer program is stored in the memory. When the computer program is executed by the processor, the electronic device is caused to execute the method according to any one of claims 1-5.
12. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium. When the computer program runs on a computer, the computer is caused to execute the method according to any one of claims 1-5.
Citation Information
Patent Citations
Container updating method, control node and edge node
CN110569109A
Resource processing method, apparatus and device, and storage medium
CN111143388A