Configuration updating method, equipment, system and storage medium
By obtaining and merging the local and server-side configurations of application services, and automatically updating the configuration center, the problem of high cost and high error rate of configuration updates under the multi-application shared configuration center is solved, and efficient and accurate configuration management is achieved.
Patent Information
- Application Number
- CN202411797756.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-01-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the case where multiple applications share a configuration center, configuration updates need to be done manually, resulting in high maintenance costs and error-proneness.
By obtaining the local configuration and server configuration of the application service, merge and sending it to the configuration center, automatic configuration updates are achieved, and the frequency and error rate of manual updates are reduced.
Automatic updates of configurations are realized, maintenance costs are reduced, manual operations of configuration personnel are reduced, and update accuracy and efficiency are improved.
Smart Images

Figure CN119271310A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of application management, and in particular to a configuration update method, device, system and storage medium. Background Art
[0002] In the application development scenario, developers usually need to change the configuration of the application. However, the general configuration update method is for developers to manually change the configuration of the application in the configuration center. Especially when multiple applications share a configuration center, every time the configuration of an application needs to be changed, the configuration personnel have to enter the configuration center to make manual adjustments. This process greatly increases the maintenance cost. Summary of the invention
[0003] The main technical problem solved by the present application is to provide a configuration update method, device, system and storage medium, which can reduce maintenance costs.
[0004] To solve the above technical problems, a technical solution adopted in the present application is: to provide a configuration update method, the method comprising: obtaining the local configuration of the application service; and obtaining the server-side configuration of the application service from the configuration center; merging the local configuration and the server-side configuration to obtain the current configuration of the application service; sending the current configuration to the configuration center, so that the configuration center updates the server-side configuration of the application service to the current configuration.
[0005] In order to solve the above technical problems, another technical solution adopted by the present application is: to provide an electronic device, the electronic device includes a memory and a processor, the memory stores program instructions, and the processor is used to execute the program instructions to implement the above configuration update method.
[0006] To solve the above technical problems, another technical solution adopted by the present application is: to provide a configuration system for an application service, the configuration system includes a device for running the application service, and a configuration center, the device and the configuration center can communicate with each other; wherein the configuration center is used to manage the server-side configuration of each application service; the device includes a memory and a processor, the memory stores program instructions, and the processor is used to execute the program instructions to implement the above configuration update method.
[0007] In order to solve the above technical problems, another technical solution adopted by the present application is: providing a computer-readable storage medium, which is used to store program instructions, and the program instructions can be executed to implement the above configuration update method.
[0008] The above solution obtains the local configuration of the application service, obtains the server-side configuration of the application service, merges the local configuration with the server-side configuration, and obtains the current configuration of the application service. The current configuration is sent to the configuration center so that the configuration center updates the server-side configuration of the application service to the current configuration. On the one hand, automatic configuration updates are achieved, and there is no need for configuration personnel to perform manual updates, which effectively reduces the mistakes that may be caused by manual updates. On the other hand, when subsequent developers update the local configuration of the application service, there is no need for configuration personnel to manually update the local configuration items to the configuration center again, nor is there a need to frequently go to the configuration center to update the configuration. Through automatic configuration updates, maintenance costs are reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 It is a flowchart of an embodiment of a configuration update method provided by the present application; Figure 2 This is a configuration update method provided by the present application - a configuration merging schematic diagram; Figure 3 This is a schematic diagram of the overall design architecture of the configuration update method provided by this application; Figure 4 This is a flow chart of a specific embodiment of a configuration update method provided by the present application; Figure 5 It is a flowchart of an embodiment of a configuration update device of the present application; Figure 6 It is a schematic diagram of the framework of an embodiment of the electronic device of the present application; Figure 7 It is a schematic diagram of the framework of an embodiment of a configuration system of an application service of the present application; Figure 8 It is a schematic diagram of a framework of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0010] In order to make the purpose, technical solution and effect of the present application clearer and more specific, the present application is further described in detail below with reference to the accompanying drawings and examples.
[0011] It should be noted that the term "and / or" is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of types. For example, at least one of A, B, and C can represent any one or more elements selected from the set consisting of A, B, and C.
[0012] See also Figure 1 , Figure 1 is a flow chart of an embodiment of a configuration update method provided by the present application. It should be noted that if there are substantially the same results, this embodiment is not based on Figure 1 The process sequence shown is limited. Figure 1 As shown, this embodiment includes: Step S11: Obtain the local configuration of the application service.
[0013] The local configuration of an application service in this article refers to the configuration information used to specify the behavior, parameters, and properties of an application service when the application service is running in a local environment (such as a developer's personal computer or a local server, etc.). The local configuration in this article can exist in the form of a configuration set to make configuration management more modular and easier to manage. Among them, a configuration set refers to a collection of related or unrelated configuration items. A configuration set can contain configuration items related to data sources, thread pools, schedule levels, etc.
[0014] The configuration information in these local configurations can usually be stored in local files (target files), environment variables, databases, or other external storage systems. For example, the local configuration corresponding to the application service can be obtained from a local file. In a specific embodiment, obtaining the local configuration of the application service includes: obtaining a target file whose file identifier is the service identifier of the application service. Reading the local configuration of the application service from the target file. For example, using the provided file operation interface, traverse the specified directory and its subdirectories. During the traversal process, check whether the file identifier of each file matches the service identifier of the application service. Once a matching file is found, use the file as the target file, open the target file and read its content. According to the format of the file (such as INI, JSON, YAML, properties, etc.), use the corresponding parsing method to extract the local configuration.
[0015] In this embodiment, the file identifier corresponding to the target file can be used to quickly locate the target file containing the configuration required by the application service from among many files, thereby ensuring accurate acquisition and efficient management of configuration information. In a specific embodiment, the target file is stored in the file directory of the configuration center of the application service.
[0016] The service identifier of the application service also has an identification function. The service identifier can be used as a unique identity mark of the application service, and can indicate the specific application service corresponding to the identifier. The above identification mechanism can ensure that when facing multiple target files or multiple application services, they can be accurately identified and distinguished. Among them, the service identifier can be obtained by splicing the unique identifier. In a specific implementation, the service identifier of the application service is obtained by splicing the namespace and service name of the application service.
[0017] Take the confirmation of the target file as an example. The target file is saved in the / resource / nacos / directory of the application service, where this directory is the file directory for the configuration center. The service name of the application service is demo-test, and the namespace is prod, then the corresponding service identifier is demo-test-prod.properties. Among them, ".properties" is a file extension, which is usually used to represent a properties file. Find the file identified as demo-test-prod.properties in the / resource / nacos / directory as the corresponding target file.
[0018] It should be noted that the local configuration obtained in this article refers to the latest configuration saved in the target file. In one embodiment, before obtaining the local configuration of the application service, at least one of the following steps is also included: in response to the user's creation operation, create and save the local configuration of the application service. In response to the user's modification operation, modify the saved local configuration of the application service. After performing at least one of the above steps, the latest configuration saved in the target file is obtained as the local configuration for use in subsequent operations.
[0019] Step S12: Obtain the server configuration of the application service from the configuration center.
[0020] The configuration center in this article refers to a common component in the microservice architecture, which is mainly used to centrally manage the configuration information of the application. The configuration center is usually used to pull configuration information from the configuration center when the application starts to start the application service. Among them, the configuration center includes Spring Cloud Config, Nacos, Zookeeper, Apollo, etc. In one embodiment, the configuration center is Nacos.
[0021] The server configuration can be obtained through a variety of methods such as preset interfaces, SDKs, consoles, monitoring configuration change events, and integrated frameworks. In one embodiment, obtaining the server configuration of the application service from the configuration center includes: obtaining the server configuration corresponding to the service identifier of the application service from the configuration center through a preset interface. For example, in the case where the configuration center is Nacos, the preset interface provided by Nacos allows the corresponding server configuration information to be obtained through an HTTP request. A GET request can be sent to a specific URL of the Nacos server with necessary request parameters (such as a service identifier) to obtain the corresponding server configuration.
[0022] It should be noted that the server configuration obtained in this article refers to the latest configuration saved in the configuration center. For specific instructions, please refer to the relevant description in step S11.
[0023] Step S13: Merge the local configuration and the server configuration to obtain the current configuration of the application service.
[0024] The merging of local configuration and server configuration in this article can effectively integrate modifications made to both local configuration and server configuration. Modifications in local configuration are conducive to local maintenance. Developers can add and delete configuration items in local configuration according to actual needs. After the configuration items of the local configuration are updated, the local configuration and the server configuration are merged, and the current configuration is obtained and sent to the configuration center. There is no need for configuration personnel to frequently synchronize or update with the configuration center, or even to enter the configuration center for manual updates. Secondly, the server configuration is also flexible. In some scenarios, only some configuration items may need to be fine-tuned. At this time, they can be modified directly in the server configuration without rewriting or redeploying the entire configuration.
[0025] In one embodiment, the local configuration and the server configuration respectively include configuration information of at least one configuration item; the current configuration includes at least one of the configuration information of the common configuration items in the server configuration and the configuration information of the first unique configuration item in the local configuration, the common configuration item is a configuration item that exists in both the server configuration and the local configuration, and the first unique configuration item is a configuration item that exists in the local configuration but not in the server configuration.
[0026] In a specific implementation, merging the local configuration and the server configuration to obtain the current configuration of the application service includes: deleting the configuration information of the common configuration item in the local configuration to obtain a first configuration to be merged; and deleting the configuration information of the second unique configuration item in the server configuration to obtain a second configuration to be merged, where the second unique configuration item is a configuration item that exists in the server configuration but does not exist in the local configuration; and combining the first configuration to be merged and the second configuration to be merged to obtain the current configuration.
[0027] In this embodiment, the local configuration and the server configuration each contain configuration information of a configuration item. In a specific embodiment, the configuration item and the corresponding configuration information are recorded in the local configuration and the server configuration in a key-value pair. For example, a configuration item can be a specific configurable key and its value, usually in the form of KEY=VALUE (KEY is a configurable key, and VALUE is its corresponding value). For example, the log output level (logLevel=INFO|WARN|ERROR) used to configure the system is a configuration item.
[0028] Combination Figure 2 To illustrate with an example, Figure 2 This is a configuration merging diagram of the configuration update method provided by the present application. The local configuration is K1=V11, K4=V4, and the server configuration is K1=V1, K2=V2. Among them, the first unique configuration item unique to the local configuration is K4=V4, the second unique configuration item unique to the server configuration is K2=V2, the configuration information of the common configuration items in the local configuration is K1=V11, and the configuration information of the common configuration items in the server configuration is K1=V1. The configuration information K1=V11 of the common configuration items in the local configuration is deleted to obtain the first configuration to be merged K4=V4. The configuration information K2=V2 of the second unique configuration item in the server configuration is deleted to obtain the second configuration to be merged K1=V1. The first configuration to be merged K4=V4 and the second configuration to be merged K1=V1 are combined to obtain the current configuration K1=V1, K4=V4.
[0029] Step S14: Send the current configuration to the configuration center, so that the configuration center updates the server configuration of the application service to the current configuration.
[0030] In one implementation, the steps of obtaining the local configuration of the application service to sending the current configuration to the configuration center are performed when the application service is started and the local configuration is created or modified.
[0031] In another embodiment, after sending the current configuration to the configuration center so that the configuration center updates the server configuration of the application service to the current configuration, at least one of the following steps is further included: receiving a configuration update notification from the configuration center, the configuration update notification being sent after the configuration center updates the server configuration of the application service. In response to the application service startup, the current server configuration of the application service is obtained from the configuration center, and the startup of the application service is completed based on the current server configuration of the application service.
[0032] Combination Figure 3 To illustrate with an example, Figure 3It is a schematic diagram of the overall design architecture of the configuration update method provided by the present application. Among them, the configuration center includes a configuration center server and a configuration center client. The configuration publishing and updating module in the application service is used to obtain the local configuration and the server configuration, and merge the local configuration with the server configuration to generate the corresponding current configuration, and publish the current configuration to the configuration center server. When the application service is started and the local configuration is created or modified, step S31 is executed for the configuration publishing and updating module to obtain the local configuration and the server configuration to obtain the corresponding current configuration, and publish the current configuration to the configuration center server. After the configuration center server updates the server configuration of the application service to the current configuration, it also includes at least one of the following steps: step S32 The configuration center client obtains the current configuration from the configuration center server to complete the startup of the application service. Step S33 The configuration center client receives the configuration update notification from the configuration center server. When the server configuration is modified, at least one of step S32 and step S33 is executed.
[0033] See also Figure 4 , Figure 4 1 is a flow chart of a specific embodiment of the configuration update method provided by the present application. Among them, the configuration center of this embodiment is exemplarily Nacos. Figure 4 As shown, the configuration update method provided in this embodiment may include the following steps: Step S41: Read the namespace and service space of the application service and obtain the corresponding service identifier. Step S42: Determine the target file corresponding to the file identifier that matches the service identifier and obtain the local configuration corresponding to the application service in the target text. Step S43: Obtain the server configuration of the application service on the Nacos server. After obtaining the local configuration in step S42 and the server configuration in step S43, execute step S44: Merge the local configuration and the server configuration to obtain the current configuration. Step S45: Publish the current configuration to the Nacos server.
[0034] In some application scenarios, the configuration update method provided by the present application can be applied to the field of intelligent control technology of the Internet of Things, etc. The execution subject for implementing the configuration update method described in the present application can be a configuration update device, an electronic device, etc. For example, the configuration update device can be set in a terminal device or a server or other processing device, wherein the terminal device can be a computing device, a vehicle-mounted device, a wearable device, etc. In some possible implementations, the configuration update method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0035] See also Figure 5 , Figure 5It is a flow chart of an embodiment of the configuration updating device of the present application. The configuration updating device 500 includes a local configuration acquisition module 510, a server configuration acquisition module 520, a current configuration acquisition module 530, and a configuration publishing module 540. The local configuration acquisition module 510 is used to obtain the local configuration of the application service. The server configuration acquisition module 520 is used to obtain the server configuration of the application service from the configuration center. The current configuration acquisition module 530 is used to merge the local configuration and the server configuration to obtain the current configuration of the application service. The configuration publishing module 540 is used to send the current configuration to the configuration center so that the configuration center updates the server configuration of the application service to the current configuration.
[0036] In some embodiments, the local configuration and the server configuration respectively include configuration information of at least one configuration item; the current configuration includes at least one of the configuration information of the common configuration items in the server configuration and the configuration information of the first unique configuration item in the local configuration, the common configuration item is a configuration item that exists in both the server configuration and the local configuration, and the first unique configuration item is a configuration item that exists in the local configuration but not in the server configuration.
[0037] In some embodiments, the current configuration acquisition module 530 executes a merge of the local configuration and the server configuration to obtain the current configuration of the application service, including: deleting the configuration information of the common configuration items in the local configuration to obtain a first configuration to be merged; and deleting the configuration information of the second unique configuration item in the server configuration to obtain a second configuration to be merged, where the second unique configuration item is a configuration item that exists in the server configuration but does not exist in the local configuration; combining the first configuration to be merged and the second configuration to be merged to obtain the current configuration.
[0038] In some embodiments, configuration items and corresponding configuration information are recorded in the local configuration and the server configuration in the form of key-value pairs.
[0039] In some embodiments, the local configuration acquisition module 510 acquires the local configuration of the application service by: acquiring a target file whose file identifier is the service identifier of the application service; and reading the local configuration of the application service from the target file.
[0040] In some embodiments, the server configuration acquisition module 520 acquires the server configuration of the application service from the configuration center, including: acquiring the server configuration corresponding to the service identifier of the application service from the configuration center through a preset interface.
[0041] In some embodiments, the service identifier of the application service is obtained by concatenating the namespace and service name of the application service.
[0042] In some embodiments, the target file is stored in a file directory of the application service for the configuration center.
[0043] In some embodiments, the configuration updating device 500 also includes a local configuration modification module, which is specifically used to perform at least one of the following steps before obtaining the local configuration of the application service: in response to the user's creation operation, create and save the local configuration of the application service; in response to the user's modification operation, modify and save the saved local configuration of the application service.
[0044] In some embodiments, the steps of obtaining the local configuration of the application service and sending the current configuration to the configuration center are performed when the application service is started and the local configuration is created or modified.
[0045] In some embodiments, the configuration update device 500 also includes an application startup module and a notification module. After sending the current configuration to the configuration center so that the configuration center updates the server-side configuration of the application service to the current configuration, it also includes at least one of the following steps: the notification module is used to receive the configuration update notification from the configuration center, and the configuration update notification is sent after the configuration center updates the server-side configuration of the application service; the application startup module is used to obtain the current server-side configuration of the application service from the configuration center in response to the startup of the application service, and complete the startup of the application service based on the current server-side configuration of the application service.
[0046] In some embodiments, the configuration center is Nacos.
[0047] See also Figure 6 , Figure 6 : is a schematic diagram of a framework of an embodiment of an electronic device of the present application. The electronic device 60 includes a memory 61 and a processor 62 coupled to each other, and the processor 62 is used to execute program instructions stored in the memory 61 to implement the steps in any of the above configuration update method embodiments. In a specific implementation scenario, the electronic device 60 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 60 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0048] Specifically, the processor 62 is used to control itself and the memory 61 to implement the steps in any of the above configuration update method embodiments. The processor 62 can also be called a CPU (Central Processing Unit). The processor 62 may be an integrated circuit chip with signal processing capabilities. The processor 62 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 62 can be implemented by an integrated circuit chip.
[0049] See also Figure 7 , Figure 7 It is a schematic diagram of the framework of an embodiment of the configuration system of the application service of the present application. The configuration system 70 of the application service includes a device 71 for running the application service and a configuration center 72. The device 71 and the configuration center 72 can communicate with each other. Among them, the configuration center 72 is used to manage the server-side configuration of each application service. The configuration center 72 is usually used to pull configuration information from the configuration center when the application starts to start the application service. Among them, the configuration center includes Spring Cloud Config, Nacos, Zookeeper, Apollo, etc. Device 71 is Figure 6 The electronic device 60 described in.
[0050] See also Figure 8 , Figure 8 The computer-readable storage medium 80 stores program instructions 81 that can be executed by a processor, and the program instructions 81 are used to implement the steps in any of the above configuration update method embodiments.
[0051] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0052] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0053] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0054] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0055] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
Claims
1. A configuration update method, characterized in that: The method comprises: Get the local configuration of the application service; Obtain the server configuration of the application service from the configuration center; Merging the local configuration and the server configuration to obtain the current configuration of the application service; The current configuration is sent to the configuration center, so that the configuration center updates the server configuration of the application service to the current configuration.
2. The method according to claim 1, characterized in that The local configuration and the server configuration respectively include configuration information of at least one configuration item; the current configuration includes at least one of the configuration information of the common configuration items in the server configuration and the configuration information of the first unique configuration item in the local configuration, the common configuration item is a configuration item that exists in both the server configuration and the local configuration, and the first unique configuration item is a configuration item that exists in the local configuration but not in the server configuration.
3. The method according to claim 2, characterized in that The merging of the local configuration and the server configuration to obtain the current configuration of the application service includes: Deleting the configuration information of the common configuration item in the local configuration to obtain a first configuration to be merged; and Deleting configuration information of a second unique configuration item in the server configuration to obtain a second configuration to be merged, where the second unique configuration item is a configuration item that exists in the server configuration but does not exist in the local configuration; Combining the first configuration to be merged and the second configuration to be merged to obtain the current configuration; And / or, the configuration items and corresponding configuration information are recorded in the local configuration and the server configuration in a key-value pair manner.
4. The method according to claim 1, characterized in that The obtaining of the local configuration of the application service includes: Acquire a target file whose file identifier is the service identifier of the application service; Reading from the target file to obtain the local configuration of the application service; And / or, obtaining the server configuration of the application service from the configuration center includes: Obtain the server-side configuration corresponding to the service identifier of the application service from the configuration center through a preset interface.
5. The method according to claim 4, characterized in that The service identifier of the application service is obtained by concatenating the namespace and service name of the application service; And / or, the target file is stored in a file directory of the application service for the configuration center.
6. The method according to claim 1, characterized in that Before obtaining the local configuration of the application service, at least one of the following steps is also included: In response to a creation operation by a user, creating and saving a local configuration of the application service; In response to the modification operation of the user, the saved local configuration of the application service is modified.
7. The method according to claim 1, characterized in that The steps of obtaining the local configuration of the application service to sending the current configuration to the configuration center are performed when the application service is started and the local configuration is created or modified; And / or, after sending the current configuration to the configuration center so that the configuration center updates the server configuration of the application service to the current configuration, at least one of the following steps is further included: receiving a configuration update notification from the configuration center, wherein the configuration update notification is sent after the configuration center updates the server configuration of the application service; In response to the application service being started, obtaining the current server-side configuration of the application service from the configuration center, and completing the startup of the application service based on the current server-side configuration of the application service; And / or, the configuration center is Nacos.
8. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores program instructions, and the processor is used to execute the program instructions to implement the configuration update method according to any one of claims 1 to 7.
9. A configuration system for application services, characterized in that: It includes a device for running an application service and a configuration center, wherein the device and the configuration center can communicate with each other; The configuration center is used to manage the server configuration of each application service; The device is the electronic device according to claim 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program instructions, and the program instructions can be executed to implement the configuration update method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Configuration information pushing method and device
CN107241204A
Service request processing method and device, electronic equipment and storage medium
CN114629883A
Implementation method and device for incremental distribution and automatic upgrade of application configuration
CN114895943A
Configuration modification method, device and equipment and readable storage medium
CN114996209A
Application configuration publishing system, method, device and equipment
CN115543411A