CN112988168B - A method and device for building an environment - Google Patents
A method and device for building an environment Download PDFInfo
- Publication number
- CN112988168B CN112988168B CN201911202172.6A CN201911202172A CN112988168B CN 112988168 B CN112988168 B CN 112988168B CN 201911202172 A CN201911202172 A CN 201911202172A CN 112988168 B CN112988168 B CN 112988168B
- Authority
- CN
- China
- Prior art keywords
- module
- topology
- modules
- environment
- machine
- 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
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3698—Environments for analysis, debugging or testing of software
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/61—Installation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
本发明公开了一种环境搭建的方法和装置,涉及计算机技术领域。该方法的一具体实施方式包括:利用模块集合中的模块,建立拓扑;对所述拓扑中的模块分配机器;根据所述拓扑,将所述模块对应的配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新;根据更新后的配置文件,调用环境部署工具对所述模块进行环境搭建。该实施方式避免了现有技术人工进行环境搭建时所需要的维护成本高、资源利用率低的技术缺陷,进而能够实现自动配制上下游关系,不需要维护固定的环境,能自适应修改上下游端口文件,使得系统内的所有模块都能正常通信的技术效果。
The present invention discloses a method and device for environment building, and relates to the field of computer technology. A specific implementation of the method includes: using modules in a module set to establish a topology; assigning machines to the modules in the topology; according to the topology, replacing the labels in the configuration files corresponding to the modules with the addresses of the downstream machines they depend on, to update the configuration files; and calling the environment deployment tool to build the environment for the modules according to the updated configuration files. This implementation avoids the technical defects of high maintenance costs and low resource utilization required when manually building the environment in the prior art, and can achieve the technical effect of automatically configuring upstream and downstream relationships, without the need to maintain a fixed environment, and can adaptively modify upstream and downstream port files, so that all modules in the system can communicate normally.
Description
技术领域Technical Field
本发明涉及计算机技术领域,尤其涉及一种环境搭建的方法和装置。The present invention relates to the field of computer technology, and in particular to a method and device for environment construction.
背景技术Background Art
在测试人员资源有限的情况下,实现测试环境的搭建至为重要,尤其是拓扑比较复杂的系统。使上下游服务之间实现自动连接是环境搭建中较为复杂的一部分。现有技术较多采用每个模块维护多套环境,模块对应的机器和端口号固定,每次搭建环境时,搭建脚本里将下游端口文件中的下游地址、端口号等写死。With limited tester resources, it is very important to build a test environment, especially for systems with complex topologies. Automatically connecting upstream and downstream services is a relatively complex part of environment building. Existing technologies often use multiple environments for each module, with the corresponding machines and port numbers of the modules fixed. Each time an environment is built, the downstream address, port number, etc. in the downstream port file are hard-coded in the build script.
在实现本发明过程中,发明人发现现有技术中至少存在维护成本高、资源利用率低的技术问题。In the process of realizing the present invention, the inventors found that the prior art at least has the technical problems of high maintenance cost and low resource utilization.
发明内容Summary of the invention
有鉴于此,本发明实施例提供一种环境搭建的方法和装置,能够进而能够实现自动配制上下游关系,不需要维护固定的环境,不论选择哪一台机器进行搭建,都能自适应修改上下游端口文件,使得系统内的所有模块都能正常通信的技术效果。In view of this, an embodiment of the present invention provides a method and device for setting up an environment, which can further realize automatic configuration of upstream and downstream relationships, without the need to maintain a fixed environment. No matter which machine is selected for setting up, the upstream and downstream port files can be adaptively modified, so that all modules in the system can communicate normally. Technical effect.
为实现上述目的,根据本发明实施例的一个方面,提供了一种环境搭建的方法,包括:To achieve the above object, according to one aspect of an embodiment of the present invention, a method for setting up an environment is provided, comprising:
利用模块集合中的模块,建立拓扑;Use the modules in the module collection to build a topology;
对所述拓扑中的模块分配机器;assigning machines to modules in the topology;
根据所述拓扑,将所述模块对应的配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新;According to the topology, replace the label in the configuration file corresponding to the module with the address of the downstream machine on which it depends, so as to update the configuration file;
根据更新后的配置文件,调用环境部署工具对所述模块进行环境搭建。According to the updated configuration file, the environment deployment tool is called to build the environment for the module.
可选地,利用模块集合中的模块,建立拓扑之前,包括:Optionally, using modules from the module collection, before building the topology, include:
定义模块集合中的模块;Define modules in a module collection;
其中,所述模块的属性信息表至少包括:模块名、模块标签;所述模块标签包括该模块下游模块的标签;The module attribute information table at least includes: module name, module tag; the module tag includes the tag of the downstream module of the module;
所述属性信息表,还包括以下至少之一:CPU大小、内存大小、模块部署相关代码下载地址。The attribute information table also includes at least one of the following: CPU size, memory size, and module deployment related code download address.
可选地,所述建立拓扑包括:选择已有的拓扑进行建立,或自定义创建临时拓扑。Optionally, establishing the topology includes: selecting an existing topology to establish, or customizing and creating a temporary topology.
可选地,对所述拓扑对应的模块分配机器之后,包括:Optionally, after allocating machines to the modules corresponding to the topology, the method further includes:
判断所述拓扑是否仍存在空闲模块没有被分配机器;Determine whether there are still idle modules in the topology that have not been assigned to machines;
若是,则判断是否存在与所述空闲模块匹配的空闲适配机器;若存在所述空闲适配机器,则将所述空闲适配机器中配置最低的机器与所述空闲模型匹配;若不存在所述空闲适配机器,则等待空闲适配机器。If so, determine whether there is an idle adaptation machine that matches the idle model; if there is an idle adaptation machine, match the lowest-configured machine among the idle adaptation machines with the idle model; if there is no idle adaptation machine, wait for an idle adaptation machine.
可选地,根据所述拓扑,将所述模块对应配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新之前,包括:Optionally, according to the topology, the label in the configuration file corresponding to the module is replaced with the address of the downstream machine on which it depends, before the configuration file is updated, including:
在数据库表中记录分配机器的配置文件;Record the configuration files of the assigned machines in the database table;
其中,所述配置文件包括:所述模块所依赖的下游机器的地址、以及所述下游机器端口的属性信息。The configuration file includes: the address of the downstream machine on which the module depends, and the attribute information of the port of the downstream machine.
根据本发明实施例的再一个方面,提供了一种环境搭建的装置,包括:According to another aspect of an embodiment of the present invention, there is provided a device for setting up an environment, comprising:
拓扑建立模块,用于利用模块集合中的模块,建立拓扑;A topology building module is used to build a topology using modules in a module set;
机器分配模块,用于对所述拓扑中的模块分配机器;A machine allocation module, used for allocating machines to modules in the topology;
更新模块,用于根据所述拓扑,将所述模块对应的配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新;An update module, used to replace the label in the configuration file corresponding to the module with the address of the downstream machine on which it depends according to the topology, so as to update the configuration file;
环境搭建模块,用于根据更新后的配置文件,调用环境部署工具对所述模块进行环境搭建。The environment building module is used to call the environment deployment tool to build the environment for the module according to the updated configuration file.
可选地,利用模块集合中的模块,建立拓扑之前,包括:Optionally, using modules from the module collection, before building the topology, include:
定义模块集合中的模块;Define modules in a module collection;
其中,所述模块的属性信息表至少包括:模块名、模块标签;所述模块标签包括该模块下游模块的标签;The module attribute information table at least includes: module name, module tag; the module tag includes the tag of the downstream module of the module;
所述属性信息表,还包括以下至少之一:CPU大小、内存大小、模块部署相关代码下载地址。The attribute information table also includes at least one of the following: CPU size, memory size, and module deployment related code download address.
可选地,所述建立拓扑包括:选择已有的拓扑进行建立,或自定义创建临时拓扑。Optionally, establishing the topology includes: selecting an existing topology to establish, or customizing and creating a temporary topology.
可选地,对所述拓扑对应的模块分配机器之后,包括:Optionally, after allocating machines to the modules corresponding to the topology, the method further includes:
判断所述拓扑是否仍存在空闲模块没有被分配机器;Determine whether there are still idle modules in the topology that have not been assigned to machines;
若是,则判断是否存在与所述空闲模块匹配的空闲适配机器;若存在所述空闲适配机器,则将所述空闲适配机器中配置最低的机器与所述空闲模型匹配;若不存在所述空闲适配机器,则等待空闲适配机器。If so, determine whether there is an idle adaptation machine that matches the idle model; if there is an idle adaptation machine, match the lowest-configured machine among the idle adaptation machines with the idle model; if there is no idle adaptation machine, wait for an idle adaptation machine.
可选地,根据所述拓扑,将所述模块对应配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新之前,包括:Optionally, according to the topology, the label in the configuration file corresponding to the module is replaced with the address of the downstream machine on which it depends, before the configuration file is updated, including:
在数据库表中记录分配机器的配置文件;Record the configuration files of the assigned machines in the database table;
其中,所述配置文件包括:所述模块所依赖的下游机器的地址、以及所述下游机器端口的属性信息。The configuration file includes: the address of the downstream machine on which the module depends, and the attribute information of the port of the downstream machine.
根据本发明实施例的另一个方面,提供了一种环境搭建的电子设备,包括:According to another aspect of an embodiment of the present invention, an electronic device for environment construction is provided, including:
一个或多个处理器;one or more processors;
存储装置,用于存储一个或多个程序,a storage device for storing one or more programs,
当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现本发明提供的环境搭建的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the environment building method provided by the present invention.
根据本发明实施例的还一个方面,提供了一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现本发明提供的环境搭建的方法。According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method for setting up an environment provided by the present invention is implemented.
上述发明中的一个实施例具有如下优点或有益效果:One embodiment of the above invention has the following advantages or beneficial effects:
本申请通过对模块的配置文件的更新,实现环境的自动搭建,避免了现有技术人工进行环境搭建时所需要的维护成本高、资源利用率低的技术缺陷,进而能够实现自动配制上下游关系,不需要维护固定的环境,不论选择哪一台机器进行搭建,都能自适应修改上下游端口文件,使得系统内的所有模块都能实现正常通信的技术效果。The present application realizes automatic construction of the environment by updating the configuration files of the modules, thus avoiding the technical defects of high maintenance cost and low resource utilization required for manual construction of the environment in the prior art, and can realize automatic configuration of upstream and downstream relationships without maintaining a fixed environment. No matter which machine is selected for construction, the upstream and downstream port files can be adaptively modified, so that all modules in the system can achieve the technical effect of normal communication.
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
附图用于更好地理解本发明,不构成对本发明的不当限定。其中:The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
图1是根据本发明实施例的一种环境搭建的方法的主要流程的示意图;FIG1 is a schematic diagram of the main process of a method for setting up an environment according to an embodiment of the present invention;
图2是根据本发明具体实施例中模块的属性信息表的示意图;2 is a schematic diagram of an attribute information table of a module according to a specific embodiment of the present invention;
图3是根据本发明具体实施例中拓扑的示意图;FIG3 is a schematic diagram of a topology according to a specific embodiment of the present invention;
图4是根据本发明实施例的一种环境搭建的方法的具体流程的示意图;FIG4 is a schematic diagram of a specific process of a method for setting up an environment according to an embodiment of the present invention;
图5是根据本发明实施例的一种环境搭建的装置的主要模块的示意图;FIG5 is a schematic diagram of main modules of an environment building device according to an embodiment of the present invention;
图6是本发明实施例可以应用于其中的示例性系统架构图;FIG6 is a diagram of an exemplary system architecture in which an embodiment of the present invention may be applied;
图7是适于用来实现本发明实施例的终端设备或服务器的计算机系统的结构示意图。FIG. 7 is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention.
具体实施方式DETAILED DESCRIPTION
以下结合附图对本发明的示范性实施例做出说明,其中包括本发明实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本发明的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
图1是根据本发明实施例的一种环境搭建的方法的主要流程的示意图,如图1所示,包括:FIG. 1 is a schematic diagram of the main process of a method for setting up an environment according to an embodiment of the present invention, as shown in FIG. 1 , comprising:
步骤S101、利用模块集合中的模块,建立拓扑;利用模块集合中的模块,建立拓扑;Step S101, using modules in a module set to establish a topology; using modules in a module set to establish a topology;
其中,所述建立拓扑包括:选择已有的拓扑进行建立,或自定义创建临时拓扑。在实际应用中,一个系统可以由多个模块组成的,具体地,多个模块之间的上下游关系用拓扑来表示。图3是根据本发明具体实施例中拓扑的示意图。如图3所示,该系统共有四个模块(分别为模块1、模块2、模块3、模块4、模块5)。在建立拓扑时,可以预设该系统的依赖关系为模块2、模块3、模块4和模块5依赖模块1;模块2、模块3、和模块4之间不存在相互依赖的关系。通过上述关系进而可以确定图3中的拓扑。拓扑选定了之后就可以利用部署工具及各个机器的唯一标准id都会确定,进而执行步骤S102。Wherein, the establishment of the topology includes: selecting an existing topology to establish, or customizing the creation of a temporary topology. In practical applications, a system can be composed of multiple modules. Specifically, the upstream and downstream relationships between multiple modules are represented by topology. Figure 3 is a schematic diagram of the topology according to a specific embodiment of the present invention. As shown in Figure 3, the system has four modules (module 1, module 2, module 3, module 4, and module 5). When establishing the topology, the dependency relationship of the system can be preset as module 2, module 3, module 4, and module 5 depending on module 1; there is no mutual dependency relationship between module 2, module 3, and module 4. The topology in Figure 3 can be determined through the above relationship. After the topology is selected, it can be determined using the deployment tool and the unique standard ID of each machine, and then step S102 is executed.
步骤S102、对所述拓扑中的模块分配机器;Step S102: Allocate machines to modules in the topology;
步骤S103、根据所述拓扑,将所述模块对应的配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新;通过对所述配置文件的更新即可确定每台机器和所依赖的机器地址,进而方便后续环境搭建。Step S103, according to the topology, replace the label in the configuration file corresponding to the module with the address of the downstream machine it depends on, so as to update the configuration file; by updating the configuration file, the address of each machine and the dependent machine can be determined, thereby facilitating the subsequent environment construction.
步骤S104、根据更新后的配置文件,调用环境部署工具对所述模块进行环境搭建。Step S104: According to the updated configuration file, call the environment deployment tool to build the environment for the module.
本申请通过对模块的配置文件的更新,实现环境的自动搭建,避免了现有技术人工进行环境搭建时所需要的维护成本高、资源利用率低的技术缺陷,进而能够实现自动配制上下游关系,不需要维护固定的环境,不论选择哪一台机器进行搭建,都能自适应修改上下游端口文件,使得系统内的所有模块都能正常通信的技术效果。The present application realizes automatic construction of the environment by updating the configuration files of the modules, thereby avoiding the technical defects of high maintenance cost and low resource utilization required for manual construction of the environment in the prior art, and can realize automatic configuration of upstream and downstream relationships without maintaining a fixed environment. No matter which machine is selected for construction, the upstream and downstream port files can be adaptively modified, so that all modules in the system can communicate normally.
可选地,利用模块集合中的模块,建立拓扑之前,包括:Optionally, using modules from the module collection, before building the topology, include:
定义模块集合中的模块;Define modules in a module collection;
其中,所述模块的属性信息表至少包括:模块名、模块标签;所述模块标签包括该模块下游模块的标签;The module attribute information table at least includes: module name, module tag; the module tag includes the tag of the downstream module of the module;
所述属性信息表,还包括以下至少之一:CPU大小、内存大小、模块部署相关代码下载地址。The attribute information table also includes at least one of the following: CPU size, memory size, and module deployment related code download address.
所述模块也就是服务;通过对每个模块进行定义,确定每个模块的属性信息表的技术手段,可以方便后续方法步骤中进行分配机器时迅速地确定模块对应的机器,在环境搭建时提取参数更便捷。The module is also a service; by defining each module and determining the technical means of the attribute information table of each module, it is convenient to quickly determine the machine corresponding to the module when allocating the machine in the subsequent method steps, and it is more convenient to extract parameters when setting up the environment.
图2是根据本发明具体实施例中模块的属性信息表的示意图;如图2所示,所述属性信息表,还包括但不限于以下至少之一:CPU大小、内存大小、下载地址(例如,git地址以及git分支)、平台、core目录、最小磁盘大小、模块标签(tag标签)及其端口(port)、对适配的机器的限制条件;其中,所述模块标签包括该模块下游模块的标签。Figure 2 is a schematic diagram of the attribute information table of a module in a specific embodiment of the present invention; as shown in Figure 2, the attribute information table also includes but is not limited to at least one of the following: CPU size, memory size, download address (for example, git address and git branch), platform, core directory, minimum disk size, module label (tag label) and its port (port), and restrictions on adapted machines; wherein, the module label includes the label of the downstream module of the module.
可选地,根据所述拓扑,将所述模块对应配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新之前,包括:在数据库表中记录分配机器的配置文件;其中,所述配置文件包括但不限于:所述模块所依赖的下游机器的地址、以及所述下游机器端口的属性信息。所述数据表如下表1所示,所述表1是上述图3对应的数据库表:Optionally, according to the topology, the label in the configuration file corresponding to the module is replaced with the address of the downstream machine on which it depends, and before the configuration file is updated, it includes: recording the configuration file of the allocated machine in the database table; wherein the configuration file includes but is not limited to: the address of the downstream machine on which the module depends, and the attribute information of the port of the downstream machine. The data table is shown in Table 1 below, and Table 1 is the database table corresponding to Figure 3 above:
表1拓扑对应的数据库表Table 1 Database tables corresponding to the topology
如上表1所示,taskid代表该拓扑对应任务的唯一标识,在本实施例中为“123”,nodeid代表每个机器对应的唯一标识;Module_id代表机器唯一标识对应的模块唯一标识,attr代表模块对应的属性信息表。dependency_node_ids代表机器对应的唯一标识所依赖的其他机器的唯一标识,dependency_node_tags代表依赖的其他机器的唯一标识的TAG:PORT属性。As shown in Table 1 above, taskid represents the unique identifier of the task corresponding to the topology, which is "123" in this embodiment; nodeid represents the unique identifier corresponding to each machine; module_id represents the module unique identifier corresponding to the machine unique identifier; attr represents the attribute information table corresponding to the module. dependency_node_ids represents the unique identifiers of other machines on which the unique identifier corresponding to the machine depends; dependency_node_tags represents the TAG:PORT attribute of the unique identifiers of other dependent machines.
可选地,对所述模块集合中的模块分配机器,包括:Optionally, allocating machines to modules in the module set includes:
根据所述模块属性信息表中的下载地址(可以为git地址),下载所述模块对应的代码;Download the code corresponding to the module according to the download address (which can be a git address) in the module attribute information table;
获取每个模块所适配的机器类型,进而实现对所述模块集合中的模块分配机器。The machine type adapted by each module is obtained, and then machines are allocated to the modules in the module set.
可选地,对所述拓扑中模块分配机器之后,包括:Optionally, after allocating machines to the modules in the topology, the method further includes:
判断所述集合中是否仍存在空闲模块没有被分配机器;Determine whether there are still idle modules in the set that have not been assigned to a machine;
若是,则判断是否存在与所述空闲模块匹配的空闲适配机器;若存在所述空闲适配机器,则将所述空闲适配机器中配置最低的机器与所述空闲模型匹配;若不存在所述空闲适配机器,则等待空闲适配机器If yes, determine whether there is an idle adaptor matching the idle model; if there is an idle adaptor, match the lowest configured machine among the idle adaptors with the idle model; if there is no idle adaptor, wait for an idle adaptor
具体地,根据所述拓扑,将所述机器对应配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新,包括:Specifically, according to the topology, the label in the configuration file corresponding to the machine is replaced with the address of the downstream machine on which it depends, so as to update the configuration file, including:
在数据库中记录完信息之后,就要替换配置文件的标签(tag标签),达到连通上下游不同的机器,实现联通不同模块的技术效果。在本申请可选实施例中,将当前机器对应的唯一标识nodeid对应的所有配置文件中的tag标签替换为所依赖机器的地址(ip地址),若所依赖机器的地址存在端口(port)则在所述ip地址后加上所述端口信息。After recording the information in the database, the tag of the configuration file must be replaced to connect different machines upstream and downstream and achieve the technical effect of connecting different modules. In an optional embodiment of the present application, the tag in all configuration files corresponding to the unique identifier nodeid corresponding to the current machine is replaced with the address (IP address) of the dependent machine. If the address of the dependent machine has a port, the port information is added after the IP address.
具体地,如图3和上述表1所示:Specifically, as shown in Figure 3 and Table 1 above:
图3中所示的拓扑有5个模块(分别为模块1,模块2,模块3,模块4和模块5),当每个模块都分配了相应的机器之后,就会去替换机器配置文件中的tag。表1中可以看到,这5个模块之间的依赖关系是模块2,模块3,模块4,模块5依赖模块1;并且模块2,模块3,模块4,模块5之间互不依赖。在替换tag标签的时候就是,在模块1对应的配置文件中,如果有对应模块2的tag标签(tag2),则替换成模块2对应机器的地址,如果有tag3、tag4、tag5,则分别替换为模块3、模块4、模块5分配的机器地址。如果标签对应的PORT不为空,则将PORT(端口号信息)添加到ip后面,从而实现了上下游的自动连接。The topology shown in Figure 3 has five modules (module 1, module 2, module 3, module 4 and module 5). When each module is assigned a corresponding machine, the tag in the machine configuration file will be replaced. As can be seen in Table 1, the dependency relationship between the five modules is that module 2, module 3, module 4 and module 5 depend on module 1; and modules 2, module 3, module 4 and module 5 do not depend on each other. When replacing the tag label, in the configuration file corresponding to module 1, if there is a tag label (tag2) corresponding to module 2, it will be replaced with the address of the machine corresponding to module 2. If there are tag3, tag4 and tag5, they will be replaced with the machine addresses assigned to modules 3, module 4 and module 5 respectively. If the PORT corresponding to the tag is not empty, the PORT (port number information) will be added after the ip, thereby realizing the automatic connection between upstream and downstream.
下面以一具体实施例详细说明本方案的流程:The process of this solution is described in detail with a specific embodiment below:
图4是根据本发明实施例的一种环境搭建的方法的具体流程的示意图;如图4所示,包括:FIG4 is a schematic diagram of a specific process of a method for setting up an environment according to an embodiment of the present invention; as shown in FIG4 , the method includes:
步骤S401、创建一个任务,该任务中有多个模块;Step S401, creating a task, which has multiple modules;
步骤S402、对任务中的模块建立一个拓扑;Step S402: Establish a topology for the modules in the task;
步骤S403、判断拓扑中的模块是否存在指定git地址;若是,则执行S404;若否,则执行S4031,认定模块定义错误。Step S403, determine whether the module in the topology has a specified git address; if so, execute S404; if not, execute S4031 and determine that the module definition is wrong.
步骤S404、下载所述模块的代码;若失败,则执行S4041、重新下载代码;若成功,则执行S405;Step S404, download the code of the module; if failed, execute S4041, re-download the code; if successful, execute S405;
步骤S405、对模块进行分配机器;Step S405, assigning machines to modules;
步骤S406、判断拓扑中是否所有模块均已分配机器;若是,则执行S407;若否,则执行S4061;Step S406: determine whether all modules in the topology have been assigned machines; if so, execute S407; if not, execute S4061;
S4061、判断是否存在符合当前空闲模块的机器;若是、执行S4062;若否执行S4063;S4061, determine whether there is a machine that meets the current idle module; if so, execute S4062; if not, execute S4063;
步骤S4062、分配配置最低的机器给当前空闲模块;Step S4062: Allocate the machine with the lowest configuration to the current idle module;
步骤S4063、等待已经释放的机器;Step S4063, waiting for the released machine;
步骤S407、判断是否所有配置文件中的标签tag均被替换;若是,则执行S408;若否,则执行步骤S4071、根据数据表中的记录替换tag;Step S407, determine whether the tags in all configuration files are replaced; if so, execute S408; if not, execute step S4071, replace the tags according to the records in the data table;
步骤S408、调用环境部署工具,进行环境搭建。Step S408: call the environment deployment tool to build the environment.
图5是根据本发明实施例的一种环境搭建的装置500的主要模块的示意图,如图5所示,包括:FIG5 is a schematic diagram of main modules of an environment building device 500 according to an embodiment of the present invention, as shown in FIG5 , including:
模块501、拓扑建立模块,用于利用模块集合中的模块,建立拓扑;Module 501, a topology building module, is used to build a topology using modules in a module set;
模块502、机器分配模块,用于对所述拓扑中的模块分配机器;Module 502, a machine allocation module, configured to allocate machines to modules in the topology;
模块503、更新模块,用于根据所述拓扑,将所述模块对应的配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新;Module 503, an update module, is used to replace the label in the configuration file corresponding to the module with the address of the downstream machine it depends on according to the topology, so as to update the configuration file;
模块504、环境搭建模块,用于根据更新后的配置文件,调用环境部署工具对所述模块进行环境搭建。Module 504, an environment building module, is used to call an environment deployment tool to build the environment for the module according to the updated configuration file.
图6示出了可以应用本发明实施例的环境搭建方法或环境搭建装置的示例性系统架构600。FIG. 6 shows an exemplary system architecture 600 to which the environment building method or environment building device according to the embodiment of the present invention can be applied.
如图6所示,系统架构600可以包括终端设备601、602、603,网络604和服务器605。网络604用以在终端设备601、602、603和服务器605之间提供通信链路的介质。网络604可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in Fig. 6, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
用户可以使用终端设备601、602、603通过网络604与服务器605交互,以接收或发送消息等。终端设备601、602、603上可以安装有各种通讯客户端应用,例如购物类应用、网页浏览器应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等(仅为示例)。Users can use terminal devices 601, 602, and 603 to interact with server 605 through network 604 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 601, 602, and 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
终端设备601、602、603可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
服务器605可以是提供各种服务的服务器,例如对用户利用终端设备601、602、603所浏览的购物类网站提供支持的后台管理服务器(仅为示例)。后台管理服务器可以对接收到的产品信息查询请求等数据进行分析等处理,并将处理结果(例如目标推送信息、产品信息--仅为示例)反馈给终端设备。The server 605 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
需要说明的是,本发明实施例所提供的环境搭建方法一般由服务器605执行,相应地,环境搭建装置一般设置于服务器605中。It should be noted that the environment building method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the environment building device is generally arranged in the server 605 .
应该理解,图6中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the number of terminal devices, networks and servers in Figure 6 is only for illustration purposes and any number of terminal devices, networks and servers may be provided as required.
下面参考图7,其示出了适于用来实现本发明实施例的终端设备的计算机系统700的结构示意图。图7示出的终端设备仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。Referring to Figure 7, a schematic diagram of a computer system 700 suitable for implementing a terminal device of an embodiment of the present invention is shown. The terminal device shown in Figure 7 is only an example and should not limit the functions and scope of use of the embodiment of the present invention.
如图7所示,计算机系统700包括中央处理单元(CPU)701,其可以根据存储在只读存储器(ROM)702中的程序或者从存储部分708加载到随机访问存储器(RAM)703中的程序而执行各种适当的动作和处理。在RAM 703中,还存储有系统700操作所需的各种程序和数据。CPU 701、ROM 702以及RAM 703通过总线704彼此相连。输入/输出(I/O)接口705也连接至总线704。As shown in FIG7 , the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage portion 708 into a random access memory (RAM) 703. Various programs and data required for the operation of the system 700 are also stored in the RAM 703. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to the bus 704.
以下部件连接至I/O接口705:包括键盘、鼠标等的输入部分706;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分707;包括硬盘等的存储部分708;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分709。通信部分709经由诸如因特网的网络执行通信处理。驱动器710也根据需要连接至I/O接口705。可拆卸介质711,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器710上,以便于从其上读出的计算机程序根据需要被安装入存储部分708。The following components are connected to the I/O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
特别地,根据本发明公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本发明公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分709从网络上被下载和安装,和/或从可拆卸介质711被安装。在该计算机程序被中央处理单元(CPU)701执行时,执行本发明的系统中限定的上述功能。In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and/or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
需要说明的是,本发明所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本发明中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本发明中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
附图中的流程图和框图,图示了按照本发明各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
描述于本发明实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的单元也可以设置在处理器中,例如,可以描述为:一种处理器包括发送单元、获取单元、确定单元和第一处理单元。其中,这些单元的名称在某种情况下并不构成对该单元本身的限定,例如,发送单元还可以被描述为“向所连接的服务端发送图片获取请求的单元”。The units involved in the embodiments of the present invention may be implemented in software or hardware. The units described may also be provided in a processor. For example, they may be described as follows: a processor includes a sending unit, an acquiring unit, a determining unit, and a first processing unit. The names of these units do not, in some cases, limit the units themselves. For example, the sending unit may also be described as a "unit that sends a request for obtaining an image to a connected server."
作为另一方面,本发明还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该设备执行时,使得该设备包括:As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
利用模块集合中的模块,建立拓扑;利用模块集合中的模块,建立拓扑;Using modules in a module collection, a topology is established; Using modules in a module collection, a topology is established;
对所述拓扑中的模块分配机器;assigning machines to modules in the topology;
根据所述拓扑,将所述模块对应的配置文件中的标签替换为所依赖的下游机器的地址,实现配置文件的更新;According to the topology, replace the label in the configuration file corresponding to the module with the address of the downstream machine on which it depends, so as to update the configuration file;
根据更新后的配置文件,调用环境部署工具对所述模块进行环境搭建。According to the updated configuration file, the environment deployment tool is called to build the environment for the module.
根据本发明实施例的技术方案,可以达到如下有益效果:According to the technical solution of the embodiment of the present invention, the following beneficial effects can be achieved:
本申请通过对拓扑中模块对应的配置文件的更新,实现环境的自动搭建,避免了现有技术人工进行环境搭建时所需要的维护成本高、资源利用率低的技术缺陷,进而能够实现自动配制上下游关系,不需要维护固定的环境,不论选择哪一台机器进行搭建,都能自适应修改上下游端口文件,使得系统内的所有模块都能达到正常通信的技术效果。This application realizes automatic construction of the environment by updating the configuration files corresponding to the modules in the topology, avoiding the technical defects of high maintenance cost and low resource utilization required for manual environment construction in the prior art, and can realize automatic configuration of upstream and downstream relationships without maintaining a fixed environment. No matter which machine is selected for construction, the upstream and downstream port files can be adaptively modified, so that all modules in the system can achieve the technical effect of normal communication.
上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911202172.6A CN112988168B (en) | 2019-11-29 | 2019-11-29 | A method and device for building an environment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911202172.6A CN112988168B (en) | 2019-11-29 | 2019-11-29 | A method and device for building an environment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112988168A CN112988168A (en) | 2021-06-18 |
CN112988168B true CN112988168B (en) | 2024-10-18 |
Family
ID=76330900
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911202172.6A Active CN112988168B (en) | 2019-11-29 | 2019-11-29 | A method and device for building an environment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112988168B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102437938A (en) * | 2012-01-09 | 2012-05-02 | 北京邮电大学 | Large-scale network monitoring-oriented virtualization deployment system and method |
CN103309746A (en) * | 2013-05-13 | 2013-09-18 | 百度在线网络技术(北京)有限公司 | Method and device for building investigation environment |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7512942B2 (en) * | 2005-08-24 | 2009-03-31 | International Business Machines Corporation | Model-driven software deployment in an application server |
US8595693B2 (en) * | 2008-07-29 | 2013-11-26 | International Business Machines Corporation | Model driven deployment of composite applications |
US9104803B2 (en) * | 2011-01-03 | 2015-08-11 | Paypal, Inc. | On-demand software test environment generation |
CN104572372A (en) * | 2014-12-26 | 2015-04-29 | 浪潮电子信息产业股份有限公司 | System and method for building server performance testing environment |
CN108595222A (en) * | 2018-04-26 | 2018-09-28 | 努比亚技术有限公司 | Background service environmental structure method, server and computer readable storage medium |
-
2019
- 2019-11-29 CN CN201911202172.6A patent/CN112988168B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102437938A (en) * | 2012-01-09 | 2012-05-02 | 北京邮电大学 | Large-scale network monitoring-oriented virtualization deployment system and method |
CN103309746A (en) * | 2013-05-13 | 2013-09-18 | 百度在线网络技术(北京)有限公司 | Method and device for building investigation environment |
Also Published As
Publication number | Publication date |
---|---|
CN112988168A (en) | 2021-06-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021023149A1 (en) | Method and apparatus for dynamically returning message | |
CN110837409B (en) | A method and system for executing tasks at a scheduled time | |
CN113407194B (en) | Method and device for deploying software | |
CN112612467A (en) | Method and device for processing micro front-end architecture based on qiankun | |
CN111435329A (en) | Automatic testing method and device | |
CN112306984A (en) | A data source routing method and device | |
CN110019158A (en) | A kind of method and apparatus of monitoring data quality | |
CN114443294A (en) | Big data service component deployment method, system, terminal and storage medium | |
WO2024222194A1 (en) | Method for acquiring configuration information, electronic device, and medium | |
CN111382953A (en) | Dynamic process generation method and device | |
WO2022171190A1 (en) | Fixed execution sequence transaction method, and apparatus | |
CN112988168B (en) | A method and device for building an environment | |
CN111045928A (en) | Interface data testing method, device, terminal and storage medium | |
WO2024045646A9 (en) | Method, apparatus and system for managing cluster access permission | |
CN116737662A (en) | Method, device, electronic equipment and storage medium for processing business data | |
CN113556370B (en) | Service calling method and device | |
CN113110898A (en) | Transaction task execution method and device | |
CN113743630A (en) | Method and device for executing intelligent call reservation | |
CN114500485B (en) | Data processing method and device | |
CN113821430A (en) | Multi-service testing method and device | |
CN112099841A (en) | Method and system for generating configuration file | |
CN112559001A (en) | Method and device for updating application | |
CN113065920B (en) | Data processing method and system | |
CN110727739B (en) | Data storage method and device | |
CN113495747B (en) | Gray scale release method and device |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |