CN109976822B - Configuration method and device of distributed application and distributed system - Google Patents
Configuration method and device of distributed application and distributed system Download PDFInfo
- Publication number
- CN109976822B CN109976822B CN201711419029.3A CN201711419029A CN109976822B CN 109976822 B CN109976822 B CN 109976822B CN 201711419029 A CN201711419029 A CN 201711419029A CN 109976822 B CN109976822 B CN 109976822B
- Authority
- CN
- China
- Prior art keywords
- configuration
- agent
- file
- center
- application instance
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
- G06F9/4451—User profiles; Roaming
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
The invention provides a configuration method, a configuration device and a distributed system of distributed application, wherein the method comprises the following steps: the configuration Agent downloads and stores a configuration file corresponding to the application instance from the configuration center; and if the configuration file stored in the configuration center is determined to be changed, the configuration Agent downloads the updated configuration file, and executes the restarting operation of the application instance based on the preset application instance restarting strategy. According to the configuration method, the configuration device and the distributed system, the configuration agents independently operate, the configuration files are downloaded from the configuration center server side, the updating of the configuration files, the starting/stopping of application examples and the like are monitored, the maintenance cost is reduced, and the stability of the system is improved; for a heterogeneous system with a master-slave structure, the configuration can be automatically pulled only by slightly modifying the configuration of the configuration Agent; the method can be widely applied to large-scale distributed systems, and non-intrusive access configuration is realized for legacy systems and heterogeneous systems.
Description
Technical Field
The present invention relates to the field of distributed system technologies, and in particular, to a configuration method and apparatus for distributed applications, and a distributed system.
Background
Distributed systems (distributed systems) are software systems built on top of a network. The distributed system has various general physical and logical resources, can dynamically allocate tasks, and realizes information exchange by the dispersed physical and logical resources through a computer network. There is a distributed operating system in the system that manages computer resources in a global manner. In a distributed environment, many instances of the same type of service are often deployed, the instances use configurations, and a special configuration management platform, i.e. a configuration center, is needed to maintain the configurations better, and the configuration center can easily manage the configuration of hundreds of thousands of service instances. The configuration center is divided into a configuration center server and a configuration center client.
At present, a common implementation manner of a configuration center client is to embed a configuration center client component into an application, and automatically download configuration from a configuration center when the application is started, so as to implement decoupling of configuration and the application. The existing configuration scheme has the following problems: first, it is very intrusive, and an application needs to host a configuration file to a configuration center, and must rely on a client component of the configuration center. For a historical legacy system, a large amount of modified codes are needed, so that the maintenance cost is increased, and the stability of the system is reduced; second, for heterogeneous systems with master-slave architectures, the existing intrusive configuration management scheme cannot provide support.
Disclosure of Invention
One or more embodiments of the invention provide a configuration method and device of a distributed application and a distributed system.
According to an aspect of the present disclosure, there is provided a method for configuring a distributed application, including: starting a configuration Agent corresponding to the application example; the configuration Agent establishes connection with a configuration center, and downloads and stores a configuration file corresponding to the application instance from the configuration center; if the configuration Agent determines that the configuration file stored in the configuration center is changed, the configuration Agent establishes connection with the configuration center and downloads the updated configuration file; and the configuration Agent executes the restarting operation of the application instance based on a preset application instance restarting strategy.
Optionally, the configuration Agent obtains identification information of the application instance; and the configuration Agent downloads a configuration file corresponding to the application instance from the configuration center according to the identification information.
Optionally, the configuration Agent obtains preset configuration related information, where the configuration related information includes: configuring center information, the application instance starting strategy and the identification information; the configuration Agent checks the validity of the configuration related information, if the checking fails, the configuration Agent finishes the operation, and if the checking succeeds, the configuration Agent acquires command parameters for the application instance, wherein the command parameters comprise: a log file storage path; and the configuration Agent checks the validity of the command parameter, and if the checking is successful, a log refreshing thread is started for writing the log into the log file indicated by the log file storage path.
Optionally, the downloading the configuration file corresponding to the application instance from the configuration center includes: the configuration Agent acquires local information, wherein the local information comprises: IP address and host name of the local machine; the configuration Agent establishes connection with the configuration center based on the configuration center information and the local information; the configuration Agent judges that the connection is successfully established, and if so, the latest configuration file is downloaded; the configuration Agent creates a first Znode on a Zookeeper for identifying that the application instance is using the configuration file.
Optionally, if the configuration Agent determines that the connection establishment fails, reestablishing the connection with the configuration center; and when the connection establishment failure times reach a preset time threshold, the configuration Agent finishes running.
Optionally, the establishing, by the configuration Agent, a connection with the configuration center and downloading the updated configuration file includes: the configuration Agent monitors a second ZNode corresponding to the configuration file on the Zookeeper; and if the configuration file is determined to be changed and successfully published based on the second ZeNode, automatically downloading the updated configuration file from the configuration center to replace the original configuration file.
Optionally, the executing, by the configuration Agent, the restart operation on the application instance based on a preset application instance restart policy includes: the configuration Agent determines the modified parameters in the configuration file, judges whether the application instance needs to be restarted or not based on the application instance restarting strategy and the modified parameters, and if so, restarts the application instance.
Optionally, the configuration Agent and the application instance are set in a one-to-one correspondence manner, where the configuration Agent and the application instance corresponding to the configuration Agent are deployed in the same server or container.
Optionally, the configuration Agent runs as an independent process; and after the configuration Agent is started and downloads and stores the configuration file from the configuration center, the configuration Agent starts the application instance corresponding to the configuration file.
Optionally, the configuration Agent obtains a local specified directory of the configuration file, and stores the configuration file in the local specified directory.
According to another aspect of the present disclosure, there is provided a configuration apparatus of a distributed application, including: the Agent starting module is used for starting the configuration Agent corresponding to the application example; the configuration Agent comprises: the configuration downloading module is used for establishing connection with a configuration center, downloading a configuration file corresponding to the application example from the configuration center and storing the configuration file; the configuration updating module is used for establishing connection with the configuration center and downloading the updated configuration file if the configuration file stored in the configuration center is determined to be changed; and the instance processing module is used for executing the restarting operation of the application instance based on a preset application instance restarting strategy.
Optionally, the configuration downloading module is configured to obtain identification information of the application instance, and download, from the configuration center, a configuration file corresponding to the application instance according to the identification information.
Optionally, the configuration Agent includes: an information obtaining module, configured to obtain preset configuration related information, where the configuration related information includes: configuring center information, the application instance starting strategy and the identification information; checking the validity of the configuration related information, if the checking fails, the configuration Agent finishes the operation, and if the checking succeeds, the command parameters of the application instance are acquired, wherein the command parameters comprise: a log file storage path; and the log refreshing module is used for checking the validity of the command parameters, and if the checking is successful, starting a log refreshing thread for writing the log into the log file indicated by the log file storage path.
Optionally, the configuration downloading module is configured to obtain local information, where the local information includes: IP address and host name of the local machine; establishing a connection with the configuration center based on the configuration center information and the local information; judging that the connection is successfully established, and if so, downloading the latest configuration file; a first Znode is created on the Zookeeper to identify that the application instance is using the configuration file.
Optionally, the configuration downloading module is configured to reestablish the connection with the configuration center if it is determined that the connection establishment fails; and when the number of times of connection establishment failure is determined to reach a preset number threshold, the configuration Agent finishes running.
Optionally, the configuration updating module is configured to monitor a second ZNode corresponding to the configuration file on the Zookeeper; and if the configuration file is determined to be changed and successfully published based on the second ZeNode, automatically downloading the updated configuration file from the configuration center to replace the original configuration file.
Optionally, the instance processing module is configured to determine a modified parameter in the configuration file, determine whether the application instance needs to be restarted based on the application instance restart policy and the modified parameter, and if so, restart the application instance by the configuration Agent.
Optionally, the configuration Agent and the application instance are set in a one-to-one correspondence manner, where the configuration Agent and the application instance corresponding to the configuration Agent are deployed in the same server or container.
Optionally, the configuration Agent runs as an independent process; and after the configuration Agent is started and downloads and stores the configuration file from the configuration center, the configuration Agent starts the application instance corresponding to the configuration file.
Optionally, the configuration downloading module obtains a local specified directory of the configuration file, and stores the configuration file in the local specified directory.
According to yet another aspect of the present disclosure, there is provided a distributed system comprising: a configuration arrangement for a distributed application as claimed in any one of the preceding claims.
According to another aspect of the present disclosure, there is provided a configuration apparatus for a distributed application, including: a memory; and a processor coupled to the memory, the processor configured to perform the method of configuring a distributed application as described in any one of the above based on instructions stored in the memory.
According to yet another aspect of the disclosure, there is provided a computer-readable storage medium having stored thereon computer program instructions which, when executed by one or more processors, implement the steps of the method as recited in any of the above.
According to the configuration method, the device and the distributed system of the distributed application, the configuration Agent downloads the configuration file corresponding to the application instance from the configuration center and stores the configuration file; if the configuration file stored in the configuration center is determined to be changed, the configuration Agent downloads the updated configuration file, and executes the restarting operation of the application instance based on the preset application instance restarting strategy; the configuration agents independently run, the configuration files are downloaded from the configuration center server side, the updating of the configuration files, the starting/stopping of application examples and the like are monitored, the maintenance cost is reduced, and the stability of the system is improved; for a heterogeneous system with a master-slave structure, the configuration can be automatically pulled only by slightly modifying the configuration of the configuration Agent.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without inventive exercise.
FIG. 1 is a schematic flow chart diagram illustrating one embodiment of a method for configuring a distributed application in accordance with the present disclosure;
FIG. 2 is a schematic start-up flow diagram of another embodiment of a method for configuring a distributed application according to the present disclosure;
FIG. 3 is a schematic flow chart diagram illustrating operation of another embodiment of a method for configuring a distributed application according to the present disclosure;
FIG. 4 is a block diagram of one embodiment of a configuration apparatus for a distributed application according to the present disclosure;
fig. 5 is a block schematic diagram of one embodiment of a configuration apparatus of a distributed application according to the present disclosure.
Detailed Description
The present disclosure now will be described more fully hereinafter with reference to the accompanying drawings, in which exemplary embodiments of the disclosure are shown. The technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
The terms "first", "second", and the like are used hereinafter only for descriptive distinction and not for other specific meanings.
Fig. 1 is a schematic flow chart diagram of an embodiment of a configuration method of a distributed application according to the present disclosure, as shown in fig. 1:
And 102, establishing connection between the configuration Agent and a configuration center, downloading a configuration file corresponding to the application instance from the configuration center, and storing the configuration file.
The configuration center is a server or a host computer and the like which stores and manages configuration files of application instances in the distributed system. The configuration Agent can establish connection with the configuration center by adopting various existing methods for data transmission. The configuration Agent stores the configuration file into a specified directory, and usually, when the configuration file is uploaded by the configuration center, the directory for storing the configuration file needs to be specified, and the configuration Agent downloads the configuration file from the configuration center. A plurality of parameter values are set in the configuration file, and the application instance runs based on the parameter values.
And 103, if the configuration Agent determines that the configuration file stored in the configuration center is changed, the configuration Agent establishes connection with the configuration center and downloads the updated configuration file.
And 104, the configuration Agent executes the restarting operation of the application instance based on a preset application instance restarting strategy.
In one embodiment, the configuration agents and the application instances are set in a one-to-one correspondence manner, and the configuration agents and the application instances corresponding to the configuration agents are deployed in the same server or container, for example, the configuration agents and the application instances corresponding to the configuration agents are deployed in the same Docker or LXC. The configuration Agent runs as an independent process, the application instance also runs as an independent process, and after the configuration Agent is started and downloads the configuration file from the configuration center and stores the configuration file, the configuration Agent starts the application instance corresponding to the configuration Agent.
The configuration Agent obtains a local appointed directory of the configuration file and stores the configuration file in the local appointed directory. The application instance can acquire the configuration file downloaded or updated by the configuration Agent from the local specified directory and run based on the configuration file. The configuration Agent may perform the restart operation on the application instance in various ways based on a preset application instance restart policy. The configuration Agent determines the modified parameters in the configuration file, judges whether the application instance needs to be restarted or not based on the application instance restarting strategy and the modified parameters, and if so, the configuration Agent restarts the application instance.
For example, after the configuration Agent is started and downloads the configuration file from the configuration center and stores the configuration file, the configuration Agent starts the application instance corresponding to the configuration Agent. The application instance can obtain the configuration file from the local specified directory when starting, and run based on the configuration file.
And if the configuration Agent determines that the configuration file stored in the configuration center is changed, downloading the updated configuration file. And the configuration Agent compares the original configuration file with the updated configuration file, and if the modified parameters in the configuration file are determined to be the available memory parameters, the application instance does not need to be restarted based on the application instance restarting strategy and the available memory parameters. The application instance may obtain an updated configuration file from this locally specified directory during operation, and continue operation based on the values of the new available memory parameters.
And if the configuration Agent compares the original configuration file with the updated configuration file, determining that the modified parameters in the configuration file are database URL parameters, user name and password parameters, and determining that the application instance needs to be restarted based on the application instance restarting strategy and the database URL parameters, the user name and the password parameters. The application instance may obtain an updated configuration file from the locally specified directory upon reboot, and run based on the updated configuration file.
According to the configuration method of the distributed application in the embodiment, the latest configuration file is downloaded, the configuration update is monitored, the managed system is started and stopped and the like in a mode of adopting a resident daemon process (configuration Agent) of the host machine, so that the application instance has no perception on the access of the unified configuration center, and the system coupling degree is reduced.
In one embodiment, a configuration Agent obtains identification information for an application instance. For example, when the configuration Agent is started, the identifier of the application instance is read from the environment variable, and the configuration Agent downloads the configuration file corresponding to the application instance from the configuration center according to the identification information. For example, the configuration Agent obtains the identifier of the charging application instance as A1, and the configuration Agent downloads the configuration file corresponding to A1 from the configuration center.
The configuration Agent obtains preset configuration related information, the configuration related information can be stored in a file, and the configuration related information comprises: configuring center information, application instance starting strategies, identification information and the like; the configuration center information includes a URL, a user name, a password, etc. of the configuration center. The configuration Agent checks the validity of the configuration related information, if the check fails, the configuration Agent ends the operation, if the check succeeds, the configuration Agent obtains command parameters for the application instance, the command parameters can be parameters input by a user through a command line, and the command parameters include: log file storage path, etc. And the configuration Agent checks the validity of the command parameter, and if the checking is successful, a log refreshing thread is started for writing the log into the log file indicated by the log file storage path.
In one embodiment, the configuration Agent obtains native information, the native information comprising: the IP address and host name of the host. And the configuration Agent establishes connection with the configuration center based on the configuration center information and the local information. And the configuration Agent judges that the connection is successfully established, and if so, downloads the latest configuration file. The configuration Agent creates a first Znode on the Zookeeper to identify that the application instance is using the configuration file. And if the configuration Agent judges that the connection is failed to be established, reestablishing the connection with the configuration center, and if the connection establishment failure times reach a preset time threshold value, finishing the operation of the configuration Agent.
And the configuration Agent monitors a second ZNode corresponding to the configuration file on the Zookeeper. And if the configuration file is determined to be changed and successfully published based on the second ZeNode, automatically downloading the updated configuration file from the configuration center to replace the original configuration file.
The ZooKeeper is a distributed and open-source distributed application program coordination service, is an important component of Hadoop and Hbase, is software for providing a consistency service for distributed applications, and provides functions including: configuration maintenance, domain name service, distributed synchronization, group service, etc. In ZooKeeper, a node is also called a znode. Using zooKeeper can greatly simplify the implementation of distributed coordination services, called ZNeode for each Namespace (Namespace) developed in zooKeeper. Stored in each node (ZNode) is synchronization related data, and a ZNode maintains a state structure that includes: version number, ACL changes, timestamp. Each time ZNode data changes, the version number is incremented so that a client's read request can retrieve state-related data based on the version number. The configuration Agent can set a monitor on one ZNode corresponding to the configuration file, and if the ZNode data is changed, the ZooKeeper informs the configuration Agent. The configuration Agent may download the updated configuration file using a variety of existing methods.
Fig. 2 is a schematic start-up flow diagram of another embodiment of a configuration method of a distributed application according to the present disclosure, as shown in fig. 2:
The configuration Agent depends on the user-defined operation parameters during operation, and reads configuration center information, retry strategies, identifiers of application instances and the like by analyzing preset configuration file parameters.
And step 208, acquiring local information, and acquiring the IP address, the host name and the like of the local.
Step 209 initializes the main thread context information of the configuration Agent.
Fig. 3 is a schematic operation flow diagram of another embodiment of a configuration method of a distributed application according to the present disclosure, as shown in fig. 3:
in step 301, the configuration Agent starts the connector and starts to establish a connection for communication with the server (configuration center).
In step 303, the configuration Agent initiates a retry mechanism, which is configured in step 201, e.g., the retry mechanism is configured to retry every n seconds for a total of m retries.
And step 304, the configuration Agent judges whether to reconnect, if the reconnection is not needed, the operation is directly finished, and if the reconnection is needed, the step 305 is executed. Generally speaking, not reconnecting means that the number of retries has reached a preset threshold and no further retries are performed.
In step 305, the configuration Agent starts to reconnect to the configuration center in the same manner as the logic executed by the connection in step 301.
In step 308, the configuration Agent creates Znodes, one of which represents application instance information that is using the current configuration file. Through the Znode, a plurality of application instances can check that the current configuration file is used in an operation and maintenance window.
In step 310, the configuration Agent determines that the configuration has changed, and if the configuration file is modified, the configuration Agent starts to download the configuration again.
In one embodiment, as shown in fig. 4, the present disclosure provides a configuration apparatus for a distributed application, including a proxy startup module 41 and a configuration Agent 42. The configuration Agent comprises: a configuration download module 421, a configuration update module 422, an instance processing module 423, an information acquisition module 424, and a log refresh module 425.
The Agent startup module 41 starts a configuration Agent corresponding to the application instance. The configuration downloading module 421 establishes a connection with the configuration center, and downloads and stores the configuration file corresponding to the application instance from the configuration center. The configuration update module 422 establishes a connection with the configuration center and downloads the updated configuration file if it determines that the configuration file stored in the configuration center is changed. The instance processing module 423 performs a restart operation for the application instance based on a preset application instance restart policy.
The configuration agents and the application instances are arranged in a one-to-one correspondence mode, and the configuration agents and the application instances corresponding to the configuration agents are deployed in the same server or container. The configuration Agent operates as an independent process, and after the configuration Agent is started and downloads and stores the configuration file from the configuration center, the configuration Agent starts the corresponding application instance. The configuration downloading module 421 obtains the local specified directory of the configuration file, and stores the configuration file in the local specified directory.
In one embodiment, the configuration downloading module 421 obtains the identification information of the application instance, and downloads the configuration file corresponding to the application instance from the configuration center according to the identification information. The information obtaining module 424 obtains preset configuration related information, where the configuration related information includes: configuration center information, application instance start-up policies, identification information, etc.
The information obtaining module 424 checks validity of the configuration related information, if the check fails, the configuration Agent ends running, and if the check succeeds, obtains command parameters for the application instance, where the command parameters include: log file storage path, etc. The log refresh module 425 checks the validity of the command parameter, and if the checking is successful, opens a log refresh thread for writing the log into the log file indicated by the log file storage path.
The configuration downloading module 421 obtains the local information, which includes: the IP address, host name, etc. of the host. The configuration downloading module 421 establishes a connection with the configuration center based on the configuration center information and the local information, determines that the connection is successfully established, and if so, downloads the latest configuration file. Configuration download module 421 creates a first Znode on Zookeeper for identifying that the application instance is using the configuration file.
If the configuration downloading module 421 determines that the connection establishment fails, the connection with the configuration center is reestablished, and when it is determined that the number of times of the connection establishment failure reaches the preset number threshold, the configuration Agent ends the operation. The configuration updating module 422 monitors a second ZNode corresponding to the configuration file on the Zookeeper. If it is determined based on the second ZNode that the configuration file is changed and successfully published, the configuration update module 422 automatically downloads the updated configuration file from the configuration center to replace the original configuration file.
The instance processing module 423 determines the modified parameters in the configuration file, determines whether the application instance needs to be restarted based on the application instance restart policy and the modified parameters, and if so, configures the Agent to restart the application instance.
In one embodiment, the present disclosure provides a distributed system comprising a configuration apparatus for a distributed application as in any of the above embodiments.
Fig. 5 is a block diagram of another embodiment of a configuration apparatus for distributed applications according to the present disclosure. As shown in fig. 5, the apparatus may include a memory 51, a processor 52, a communication interface 53, and a bus 54. The memory 51 is used for storing instructions, the processor 52 is coupled to the memory 51, and the processor 52 is configured to execute a configuration method for implementing the distributed application described above based on the instructions stored in the memory 51.
The memory 51 may be a high-speed RAM memory, a nonvolatile memory (NoN-volatile memory), or the like, and the memory 51 may be a memory array. The storage 51 may also be partitioned and the blocks may be combined into virtual volumes according to certain rules. Processor 52 may be a central processing unit CPU, or an application Specific Integrated circuit asic, or one or more Integrated circuits configured to implement the configuration methods of the distributed application disclosed herein.
In one embodiment, the present disclosure also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the instructions, when executed by a processor, implement the configuration method of the distributed application related to any one of the above embodiments. As will be appreciated by one skilled in the art, embodiments of the present disclosure may be provided as a method, apparatus, or computer program product. Accordingly, the present disclosure may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable non-transitory storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present disclosure is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
Thus far, the present disclosure has been described in detail. Some details that are well known in the art have not been described in order to avoid obscuring the concepts of the present disclosure. It will be fully apparent to those skilled in the art from the foregoing description how to practice the presently disclosed embodiments.
According to the configuration method, the device and the distributed system for the distributed application, the configuration Agent downloads the configuration file corresponding to the application instance from the configuration center and stores the configuration file; if the configuration file stored in the configuration center is determined to be changed, the configuration Agent downloads the updated configuration file, and executes the restarting operation of the application instance based on the preset application instance restarting strategy; the configuration agents independently run, the configuration files are downloaded from the configuration center server side, the updating of the configuration files, the starting/stopping of application examples and the like are monitored, the maintenance cost is reduced, and the stability of the system is improved; for a heterogeneous system with a master-slave structure, the configuration can be automatically pulled only by slightly modifying the configuration of the configuration Agent; the method is not limited to homogeneous cluster systems, can be widely applied to large-scale distributed systems, and realizes non-intrusive access configuration to legacy systems and heterogeneous systems.
The method and system of the present disclosure may be implemented in a number of ways. For example, the methods and systems of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order for the steps of the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above unless specifically stated otherwise. Further, in some embodiments, the present disclosure may also be embodied as programs recorded in a recording medium, the programs including machine-readable instructions for implementing the methods according to the present disclosure. Thus, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
The description of the present disclosure has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the disclosure in the form disclosed. Many modifications and variations will be apparent to practitioners skilled in this art. The embodiment was chosen and described in order to best explain the principles of the disclosure and the practical application, and to enable others of ordinary skill in the art to understand the disclosure for various embodiments with various modifications as are suited to the particular use contemplated.
Claims (19)
1. A method of configuring a distributed application, comprising:
starting a configuration Agent corresponding to the application example;
the configuration Agent establishes connection with a configuration center, and downloads and stores a configuration file corresponding to the application instance from the configuration center;
if the configuration Agent determines that the configuration file stored in the configuration center is changed, the configuration Agent establishes connection with the configuration center and downloads the updated configuration file;
the configuration Agent executes restarting operation on the application instance based on a preset application instance restarting strategy;
the configuration Agent acquires preset configuration related information, wherein the configuration related information comprises: configuring center information, the application instance starting strategy and identification information;
the configuration Agent checks the validity of the configuration related information, if the checking fails, the configuration Agent finishes the operation, and if the checking succeeds, the configuration Agent acquires command parameters for the application instance, wherein the command parameters comprise: a log file storage path;
the configuration Agent checks the validity of the command parameter, and if the checking is successful, a log refreshing thread is started for writing a log into a log file indicated by the log file storage path;
the configuration Agent acquires identification information of the application example; and the configuration Agent downloads a configuration file corresponding to the application instance from the configuration center according to the identification information.
2. The method of claim 1, wherein the downloading the configuration file corresponding to the application instance from the configuration center comprises:
the configuration Agent acquires local information, wherein the local information comprises: IP address and host name of the local machine;
the configuration Agent establishes connection with the configuration center based on the configuration center information and the local information;
the configuration Agent judges that the connection is successfully established, and if so, the latest configuration file is downloaded;
the configuration Agent creates a first Znode on a Zookeeper for identifying that the application instance is using the configuration file.
3. The method of claim 2, further comprising:
if the configuration Agent judges that the connection establishment fails, reestablishing the connection with the configuration center;
and when the connection establishment failure times reach a preset time threshold, the configuration Agent finishes running.
4. The method of claim 2, wherein the configuration Agent establishing a connection with the configuration center and downloading the updated configuration file comprises:
the configuration Agent monitors a second ZNode corresponding to the configuration file on the Zookeeper;
and if the configuration file is determined to be changed and successfully published based on the second ZeNode, automatically downloading the updated configuration file from the configuration center to replace the original configuration file.
5. The method of claim 1, wherein the configuration Agent performing the restart operation for the application instance based on a preset application instance restart policy comprises:
the configuration Agent determines the modified parameters in the configuration file, judges whether the application instance needs to be restarted or not based on the application instance restarting strategy and the modified parameters, and if so, restarts the application instance.
6. The method of claim 1, wherein,
the configuration agents and the application instances are arranged in a one-to-one correspondence mode, wherein the configuration agents and the application instances corresponding to the configuration agents are deployed in the same server or container.
7. The method of claim 1, wherein,
the configuration Agent operates as an independent process; and after the configuration Agent is started and downloads and stores the configuration file from the configuration center, the configuration Agent starts the application instance corresponding to the configuration file.
8. The method of claim 1, wherein,
and the configuration Agent acquires a local appointed directory of the configuration file and stores the configuration file in the local appointed directory.
9. A configuration apparatus for a distributed application, comprising:
the Agent starting module is used for starting the configuration Agent corresponding to the application example;
the configuration Agent comprises:
the configuration downloading module is used for establishing connection with a configuration center, downloading a configuration file corresponding to the application example from the configuration center and storing the configuration file;
the configuration updating module is used for establishing connection with the configuration center and downloading the updated configuration file if the configuration file stored in the configuration center is determined to be changed;
the instance processing module is used for executing the restarting operation of the application instance based on a preset application instance restarting strategy;
an information obtaining module, configured to obtain preset configuration related information, where the configuration related information includes: configuring center information, the application instance starting strategy and identification information; checking the validity of the configuration related information, if the checking fails, the configuration Agent finishes the operation, and if the checking succeeds, the command parameters of the application instance are acquired, wherein the command parameters comprise: a log file storage path;
the log refreshing module is used for checking the validity of the command parameters, if the checking is successful, a log refreshing thread is started, and the log refreshing thread is used for writing the log into a log file indicated by the log file storage path;
and the configuration downloading module is used for acquiring the identification information of the application example and downloading the configuration file corresponding to the application example from the configuration center according to the identification information.
10. The apparatus of claim 9, wherein,
the configuration downloading module is configured to acquire local information, where the local information includes: IP address and host name of the local machine; establishing a connection with the configuration center based on the configuration center information and the local information; judging that the connection is successfully established, and if so, downloading the latest configuration file; a first Znode is created on the Zookeeper to identify that the application instance is using the configuration file.
11. The apparatus of claim 10, further comprising:
the configuration downloading module is used for reestablishing the connection with the configuration center if the connection establishment is judged to be failed; and when the number of times of connection establishment failure is determined to reach a preset number threshold, the configuration Agent finishes running.
12. The apparatus of claim 10, wherein,
the configuration updating module is used for monitoring a second ZNode corresponding to the configuration file on the Zookeeper; and if the configuration file is determined to be changed and successfully published based on the second ZeNode, automatically downloading the updated configuration file from the configuration center to replace the original configuration file.
13. The apparatus of claim 9, wherein,
the instance processing module is used for determining the modified parameters in the configuration file, judging whether the application instance needs to be restarted or not based on the application instance restarting strategy and the modified parameters, and if so, restarting the application instance by the configuration Agent.
14. The apparatus of claim 9, wherein,
the configuration agents and the application instances are arranged in a one-to-one correspondence mode, wherein the configuration agents and the application instances corresponding to the configuration agents are deployed in the same server or container.
15. The apparatus of claim 9, wherein,
the configuration Agent operates as an independent process; and after the configuration Agent is started and downloads and stores the configuration file from the configuration center, the configuration Agent starts the application instance corresponding to the configuration file.
16. The apparatus of claim 9, wherein,
and the configuration downloading module acquires a local appointed directory of the configuration file and stores the configuration file in the local appointed directory.
17. A distributed system, comprising:
a configuration arrangement for a distributed application according to any of claims 9 to 16.
18. A configuration apparatus for a distributed application, comprising:
a memory; and a processor coupled to the memory, the processor configured to perform the method of configuring a distributed application according to any one of claims 1 to 8 based on instructions stored in the memory.
19. A computer readable storage medium having stored thereon computer program instructions which, when executed by one or more processors, implement the steps of the method of any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711419029.3A CN109976822B (en) | 2017-12-25 | 2017-12-25 | Configuration method and device of distributed application and distributed system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711419029.3A CN109976822B (en) | 2017-12-25 | 2017-12-25 | Configuration method and device of distributed application and distributed system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109976822A CN109976822A (en) | 2019-07-05 |
CN109976822B true CN109976822B (en) | 2022-04-08 |
Family
ID=67070978
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711419029.3A Active CN109976822B (en) | 2017-12-25 | 2017-12-25 | Configuration method and device of distributed application and distributed system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109976822B (en) |
Families Citing this family (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110874263B (en) * | 2019-11-06 | 2022-07-29 | 北京宝兰德软件股份有限公司 | Method and device for monitoring instances of docker container |
CN111309390A (en) * | 2020-01-19 | 2020-06-19 | 维沃移动通信有限公司 | Method for acquiring configuration information and electronic equipment |
CN111338832A (en) * | 2020-02-17 | 2020-06-26 | 中国农业银行股份有限公司 | Data processing method and device |
CN111343026A (en) * | 2020-03-09 | 2020-06-26 | 杭州迪普科技股份有限公司 | Electronic device and configuration importing method thereof |
CN111654532B (en) * | 2020-05-08 | 2023-08-01 | 国云科技股份有限公司 | Centralized management system, method and device for configuration files |
CN111708557B (en) * | 2020-05-26 | 2024-01-26 | 北京金山云网络技术有限公司 | Method, device and storage medium for updating configuration file |
CN112003918B (en) * | 2020-08-14 | 2023-01-24 | 济南浪潮数据技术有限公司 | Method, device, equipment and medium for configuration synchronization between container application and client |
CN112835650A (en) * | 2021-03-18 | 2021-05-25 | 南威软件股份有限公司 | Method and system for realizing system parameter unified configuration real-time effect |
CN113157332A (en) * | 2021-03-24 | 2021-07-23 | 深圳依时货拉拉科技有限公司 | PHP dynamic configuration automatic validation method and system |
CN113626095A (en) * | 2021-06-29 | 2021-11-09 | 欧电云信息科技(江苏)有限公司 | Switching method and switching system of configuration center, electronic equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7228306B1 (en) * | 2002-12-31 | 2007-06-05 | Emc Corporation | Population of discovery data |
CN104243515A (en) * | 2013-06-13 | 2014-12-24 | 中兴通讯股份有限公司 | Method and device for processing configuration information |
CN105320527A (en) * | 2014-06-12 | 2016-02-10 | 中兴通讯股份有限公司 | Configuration file renewing method, device and system based on zookeeper distributed type search engine |
CN106371932A (en) * | 2013-10-11 | 2017-02-01 | 北京奇虎科技有限公司 | Information configuration method and device based on zookeeper |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
DE112010004772T8 (en) * | 2009-12-10 | 2013-03-14 | International Business Machines Corporation | Method and system for managing system management agent configurations in a distributed environment |
CN105592127B (en) * | 2014-11-20 | 2019-10-25 | 中国银联股份有限公司 | Application management system for cloud computing environment |
CN104536785B (en) * | 2014-12-23 | 2018-04-06 | 北京国双科技有限公司 | Real-time system update method and device |
US10182105B2 (en) * | 2014-12-31 | 2019-01-15 | Juniper Networks, Inc. | Policy based framework for application management in a network device having multiple packet-processing nodes |
US10536357B2 (en) * | 2015-06-05 | 2020-01-14 | Cisco Technology, Inc. | Late data detection in data center |
CN105867837A (en) * | 2015-12-02 | 2016-08-17 | 乐视体育文化产业发展(北京)有限公司 | Method, equipment and system for updating configurations of clients in distributed high-speed cache systems |
CN106815012A (en) * | 2016-12-14 | 2017-06-09 | 深圳中顺易金融服务有限公司 | Decentralized configuration Explore of Unified Management Ideas and system based on Zookeeper |
-
2017
- 2017-12-25 CN CN201711419029.3A patent/CN109976822B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7228306B1 (en) * | 2002-12-31 | 2007-06-05 | Emc Corporation | Population of discovery data |
CN104243515A (en) * | 2013-06-13 | 2014-12-24 | 中兴通讯股份有限公司 | Method and device for processing configuration information |
CN106371932A (en) * | 2013-10-11 | 2017-02-01 | 北京奇虎科技有限公司 | Information configuration method and device based on zookeeper |
CN105320527A (en) * | 2014-06-12 | 2016-02-10 | 中兴通讯股份有限公司 | Configuration file renewing method, device and system based on zookeeper distributed type search engine |
Also Published As
Publication number | Publication date |
---|---|
CN109976822A (en) | 2019-07-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109976822B (en) | Configuration method and device of distributed application and distributed system | |
CN108549580B (en) | Method for automatically deploying Kubernets slave nodes and terminal equipment | |
US20160335066A1 (en) | System and method for automatically deploying cloud | |
KR101728579B1 (en) | Effectively managing configuration drift | |
US20180145955A1 (en) | Methods and apparatus to manage credentials in hyper-converged infrastructures | |
US8296267B2 (en) | Upgrade of highly available farm server groups | |
CN110224860B (en) | Load balancing application creation method and device, computer equipment and storage medium | |
CN112506617B (en) | Mirror image updating method and device for side car containers in Kubernetes cluster | |
US8037289B1 (en) | Method and apparatus for cloning a configuration of a computer in a data center | |
US20150378743A1 (en) | Systems and Methods for Enhancing the Availability of Multi-Tier Applications on Cloud Computing Platforms | |
CN112860282B (en) | Cluster plug-in upgrading method, device and server | |
GB2505644A (en) | Managing network configurations | |
CN106657167B (en) | Management server, server cluster, and management method | |
CN110602136B (en) | Cluster access method and related product | |
EP4092524B1 (en) | Ota differential upgrade method and system of master-slave architecture | |
CN111459749A (en) | Prometous-based private cloud monitoring method and device, computer equipment and storage medium | |
US20150172093A1 (en) | Management apparatus, management method, and management program | |
WO2022028144A1 (en) | Blockchain management of provisioning failures | |
CN109361542A (en) | The fault handling method of client, device, system, terminal and server | |
CN112087516A (en) | Storage upgrading method and device based on Docker virtualization technology | |
CN104104701A (en) | Online service configuration updating method and system | |
CN108833169A (en) | A kind of online management method of node and node | |
US9973569B2 (en) | System, method and computing apparatus to manage process in cloud infrastructure | |
CN104348646A (en) | Configuration data processing method, device and system | |
CN116264572A (en) | Method, medium and electronic equipment for automatically upgrading system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20220126 Address after: 100007 room 205-32, floor 2, building 2, No. 1 and No. 3, qinglonghutong a, Dongcheng District, Beijing Applicant after: Tianyiyun Technology Co.,Ltd. Address before: No.31, Financial Street, Xicheng District, Beijing, 100033 Applicant before: CHINA TELECOM Corp.,Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |