CN117008957A - Method, device, equipment and storage medium for managing configuration file of micro service - Google Patents

Method, device, equipment and storage medium for managing configuration file of micro service Download PDF

Info

Publication number
CN117008957A
CN117008957A CN202311022236.0A CN202311022236A CN117008957A CN 117008957 A CN117008957 A CN 117008957A CN 202311022236 A CN202311022236 A CN 202311022236A CN 117008957 A CN117008957 A CN 117008957A
Authority
CN
China
Prior art keywords
configuration
middleware
micro
configuration file
service
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.)
Pending
Application number
CN202311022236.0A
Other languages
Chinese (zh)
Inventor
陈威威
郝昕悦
屠鲁俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai E Car Technology Co ltd
Original Assignee
Shanghai E Car Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shanghai E Car Technology Co ltd filed Critical Shanghai E Car Technology Co ltd
Priority to CN202311022236.0A priority Critical patent/CN117008957A/en
Publication of CN117008957A publication Critical patent/CN117008957A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/35Creation or generation of source code model driven

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method, a device, equipment and a storage medium for managing configuration files of micro services. The method comprises the following steps: defining a configuration file template, wherein the configuration file template comprises a general configuration file template and a middleware configuration file template, the middleware configuration file template is used for customizing a Software Development Kit (SDK), and the general configuration file template is used for configuring general parameters; generating a configuration file by carrying out unified configuration on the basis of the general configuration file template and the middleware configuration file template; and distributing the configuration files to each micro-service item, wherein in each micro-service item, the configuration files are uniformly managed by the micro-service item. The method provides the configuration file template of the micro service items, each item only needs to introduce the configuration file, repeated definition and configuration are not needed, and unified management of the configuration file of the micro service items is facilitated.

Description

Method, device, equipment and storage medium for managing configuration file of micro service
Technical Field
The embodiment of the invention relates to the technical field of digital information, in particular to a method, a device, equipment and a storage medium for managing a configuration file of a micro service.
Background
In the use of programs, configuration files are indispensable. The syntax to be followed by the configuration files of different micro-service items is also different, which generates too many configuration files in the micro-service architecture to be uniformly managed.
When the Spring Boot and Spring Cloud are used for micro-service design, for the configuration related to the micro-service items, different micro-service items need to repeatedly define the configuration, so that the management efficiency of the configuration file of the micro-service items is greatly affected.
When the Spring Boot and Spring Cloud are used for micro-service design, other middleware is often required to be used, some middleware is of general configuration, and some middleware is required to be configured in a self-defined mode according to each item. If each project is configured by itself, when a developer configures related middleware, the developer needs to spend time to debug whether the related configuration is correct and effective, so that the cost of collaborative development of project members is greatly increased.
Disclosure of Invention
The invention provides a method, a device, equipment and a storage medium for managing configuration files of micro-services, which are used for solving the problems that for configuration related to the micro-service items, different micro-service items need to repeatedly define the configuration, the management efficiency of the configuration files of the micro-service items is greatly affected, and developers need to configure related middleware for each micro-service item, so that the collaborative development cost of item members is increased.
According to an aspect of the present invention, there is provided a profile management method for a micro service, including:
defining a configuration file template, wherein the configuration file template comprises a general configuration file template and a middleware configuration file template, the middleware configuration file template is used for customizing a Software Development Kit (SDK), and the general configuration file template is used for configuring general parameters;
uniformly configuring based on the general configuration file template and the middleware configuration file template to generate a configuration file;
and distributing the configuration file to each micro-service item, wherein in each micro-service item, the configuration file is uniformly managed by the micro-service item.
According to another aspect of the present invention, there is provided a profile management apparatus for a micro service, comprising:
the definition module is used for defining a configuration file template, wherein the configuration file template comprises a general configuration file template and a middleware configuration file template, the middleware configuration file template is used for customizing a Software Development Kit (SDK), and the general configuration file template is used for configuring general parameters;
the configuration module is used for carrying out unified configuration based on the general configuration file template and the middleware configuration file template to generate a configuration file;
And the management module is used for distributing the configuration file to each micro-service item, and in each micro-service item, the configuration file is uniformly managed by the micro-service item.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor;
and a memory communicatively coupled to the at least one processor;
wherein the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method for profile management of a micro service according to any one of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement a profile management method for a micro service according to any one of the embodiments of the present invention when executed.
According to the technical scheme, the configuration file template comprises a general configuration file template and a middleware configuration file template, wherein the middleware configuration file template is used for customizing a Software Development Kit (SDK); uniformly configuring based on the configuration file template to generate a configuration file; and distributing the configuration files to each micro-service project, wherein in each micro-service project, the configuration files are uniformly managed by the micro-service project, so that the beneficial effects of facilitating uniform management of the micro-service project and improving the writing office efficiency of developers are achieved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a method for managing configuration files of a micro service according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a configuration flow of a micro service according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a configuration file management device for micro services according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device of a method for managing a configuration file of a micro service according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention. It should be understood that the various steps recited in the method embodiments of the present invention may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the invention is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those skilled in the art will appreciate that "one or more" is intended to be construed as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the devices in the embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of such messages or information.
Example 1
Fig. 1 is a flow chart of a method for managing configuration files of a micro service according to a first embodiment of the present invention, where the method is applicable to a case of unified configuration management of different micro service items, and the method may be performed by a configuration file management device of the micro service, where the device may be implemented by software and/or hardware and is generally integrated on an electronic device, and in this embodiment, the electronic device includes but is not limited to: a computer device.
As shown in fig. 1, a method for managing a configuration file of a micro service according to an embodiment of the present invention includes the following steps:
s110, defining a configuration file template, wherein the configuration file template comprises a general configuration file template and a middleware configuration file template, the middleware configuration file template is used for customizing a Software Development Kit (SDK), and the general configuration file template is used for configuring general parameters.
In this embodiment, a plurality of configuration items are defined in a configuration file template, and the configuration file template may include a general configuration file template and a unified middleware configuration file template.
The general configuration file template is a general configuration file template based on Spring Boot and Spring Cloud micro-service items, and related general configuration of different micro-service items is defined in the general configuration file template, so that the general configuration file template can be used for the general purpose of a plurality of micro-service items only by one definition; the middleware configuration file template is a unified middleware configuration file template based on Spring Boot and Spring Cloud micro-service items, when Spring Boot and Spring Cloud are used for micro-service design, other middleware such as Redis, mysql, rocker MQ, mongoDB, MQTT and the like is often required to be used, some middleware is in general configuration, some middleware is required to be configured according to the customization of each item, the middleware configuration required by different micro-service items is defined in the middleware configuration file template, and the middleware configuration file template supports the customization of each micro-service item.
It is to be appreciated that the middleware profile template can be utilized to customize the relevant SDKs and can include both uniformly formulated SDKs and custom SDKs.
Wherein, the tool package for realizing a function of a software product provided by a relevant service provider for assisting in developing a certain type of software generally appears in the form of a collection kpi and documents, examples and tools, namely, a collection of documents, examples and tools of many types of files can be called an SDK, and can be understood as a third party.
And S120, carrying out unified configuration based on the general configuration file template and the middleware configuration file template to generate a configuration file.
In this embodiment, after the developer fills in the configuration information according to the general configuration file template and the middleware configuration file template, the computer correspondingly fills the configuration information into the general configuration file template and the middleware configuration file template to automatically generate the configuration file.
Wherein, the unified configuration based on the universal configuration file template and the middleware configuration file template may include: performing basic configuration, remote configuration of micro service items registered on the nano according to the general configuration template, and public configuration of the micro service items; and carrying out public configuration, middleware custom configuration and uniform middleware configuration of the micro-service items on all the middleware according to the middleware configuration template.
Specifically, a developer can fill in configuration information required by basic configuration, configuration information required by remote configuration of micro service items registered on the nacos and configuration information required by public configuration of the micro service items according to a general configuration template; the developer can fill in the configuration information required by the public configuration of all middleware, the configuration information required by the custom configuration of the middleware and the configuration information required by the uniform middleware configuration of the micro-service project according to the middleware configuration template.
Wherein, nacos is the first acronym of Dynamic Naming and Configuration Service, a dynamic service discovery, configuration management and service management platform for cloud native applications is easier to build. Nacos is a service infrastructure that builds modern application frameworks (e.g., micro-service paradigm, yun Yuansheng paradigm) centered on "services".
And S130, distributing the configuration file to each micro-service item, wherein in each micro-service item, the configuration file is uniformly managed by the micro-service item.
After the configuration file is generated, the corresponding configuration file can be distributed to the corresponding micro service items according to the requirements of the micro service items, the configuration file is uniformly managed by the micro service items, and relevant parameters in the configuration file are supported to be modified by the items.
The first embodiment of the invention provides a configuration file management method of a micro service, which comprises the steps of firstly defining a configuration file template, wherein the configuration file template comprises a general configuration file template and a middleware configuration file template, the middleware configuration file template is used for customizing a Software Development Kit (SDK), and the general configuration file template is used for configuring general parameters; then, uniformly configuring the universal configuration file template and the middleware configuration file template to generate a configuration file; and finally distributing the configuration file to each micro-service project, wherein in each micro-service project, the configuration file is uniformly managed by the micro-service project. On the one hand, the method provides the configuration file template of the micro service items, and each item can be defined and configured repeatedly without introducing the configuration file, so that the micro service items can be managed uniformly; on the other hand, the method provides the middleware configuration file template, and each micro service item only needs to introduce the required middleware configuration file, so that the bottom configuration is not required to be concerned, and unified management of the configuration files of the micro service items is facilitated.
On the basis of the above embodiments, modified embodiments of the above embodiments are proposed, and it is to be noted here that only the differences from the above embodiments are described in the modified embodiments for the sake of brevity of description.
In one embodiment, the general configuration file template comprises basic configuration, remote configuration of micro service items registered on the nacos and public configuration of the micro service items, and the middleware configuration file template comprises public configuration of middleware, middleware custom configuration and middleware configuration of micro service items unification;
the middleware self-defining configuration and the SDK middleware configuration of the micro service item self-defining are mutually independent.
Firstly, performing basic configuration on each Spring Cloud micro service item based on a configuration file template to generate a corresponding configuration file; secondly, remote configuration of registering the micro service items on the nano is carried out to generate a corresponding configuration file; then executing public configuration of the micro service items to generate corresponding configuration files; then, public configuration of all middleware is carried out to generate a corresponding configuration file which is suitable for unifying all SDKs of the micro service items; then, the middleware custom configuration is carried out to generate a corresponding configuration file, and the generated configuration file is applicable to the micro service item custom SDK; and finally, carrying out uniform middleware configuration of the micro service items.
The middleware configuration is uniformly managed by the micro service project, and the middleware custom configuration and the SDK middleware configuration of the micro service project are separated and independent from each other, so that the micro service project can be uniformly managed and flexibly strained during operation.
Further, the method comprises the steps of, the base configuration includes an environment configuration, a prefix that configures micro-service controller interface access, a name space configuration for the nacos, a group configuration for the nacos, a username configuration for the nacos, and a password configuration for the nacos.
The configuration files of the development environment, the test environment and the production environment can be provided at the same time through the active: test, and different environments can be switched through the configuration.
Wherein, different namespaces are isolated when the Nacos namespaces are configured, and the same environment is under the same space when the namespaces are uniformly configured.
When the micro services are deployed in the same service cluster, groups can be divided, and different groups are configured under the same naming space and are isolated.
Further, the remote configuration of the micro service item registered to the nacos includes defining a middleware port and introducing a unified middleware configuration of the micro service item, wherein the middleware includes but is not limited to: any one or combination of Redis, mysql, rocker MQ, mongoDB, MQTT.
After the middleware configuration is cited, the middleware SDK, such as a rock MQ, an MQTT and the like, can be uniformly manufactured; if the operation and maintenance are in the deployment or the environment switching, the unified configuration is used, so that the maintenance of the micro-service items is more convenient.
The method for introducing the middleware configuration unified with the micro service items can comprise introducing MongoDB, and a database required by configuration operation is required; introducing MQTT, and configuring ClientID; introducing Mysql, and configuring a database required by operation; introducing rediss requires configuring databases required for redis operations.
In the remote configuration, the remote configuration may further include a common configuration of all middleware, such as ip, port, name, password, etc., if the middleware port is changed, only the configuration needs to be updated; and the method can also comprise defining the public configuration of the middleware, such as ip, port, name, password and the like, if the address of the middleware is required to be customized, the ip and the port can be directly introduced, and if the corresponding configuration change only needs to modify the configuration, all items can be automatically updated.
Further, the public configuration of the micro service item at least comprises one or more of micro service discovery and registration, micro service interface request global context prefix configuration, swagger general configuration and service health detection.
The public configuration of the micro service items mainly defines some general configurations in each Spring Cloud micro service item, such as micro service discovery and registration, micro service interface request global context prefix configuration, swagger general configuration, service health detection and the like.
Further, the public configuration of the middleware and the custom configuration of the middleware are used for micro service project unified SDK, and the public configuration of all the middleware and the custom configuration of the middleware are combined for use; the common configuration of all middleware and the custom configuration of the middleware comprise: the ip of all middleware, the ports of all middleware, the user names of all middleware and the passwords of all middleware are configured.
Wherein, the public configuration of middleware is suitable for micro service item unified SDK, such as ip, port, name, password, etc., and the specification unified management is defined herein, and the ip, port, user name, password, etc. in each middleware depend on the configuration. And if the middleware port is changed later, only the configuration is required to be updated, and the information of each middleware is uniformly managed, so that the operation and maintenance efficiency can be greatly improved. Meanwhile, the SDK of the related middleware can also be dependent on the configuration, so that project collaborative development is more agile and efficient.
The middleware custom configuration also provides all middleware ips and ports, but is applicable to custom SDKs of various projects, for example, some projects need to develop related middleware SDKs by themselves, and the unified middleware SDKs in the projects are not hoped to be used, and the configuration in the configuration is only needed. Configuration modification of other unified middleware caused by modification of custom SDK is avoided, and middleware custom configuration and middleware public configuration can be combined for use, so that micro-service items are more flexible.
Further, the middleware configuration unified for the micro service items includes, but is not limited to: the method comprises the steps of micro-service item unified Redis middleware configuration, micro-service item unified Mysql middleware configuration, micro-service item unified Mongodb middleware configuration, micro-service item unified Roccket mq middleware configuration and micro-service item unified mqtt middleware configuration.
Among them, mysql, mongodb, rock mq and mqtt act the same as Redis.
Example two
The embodiment of the invention provides a specific implementation mode based on the technical scheme of each embodiment.
As a specific implementation manner of the present embodiment, fig. 2 is a schematic diagram of a configuration flow of a micro service item provided in the second embodiment of the present invention, and is illustrated by a new micro service item spring-naocs-config-test, including the following flows:
bootmap. Yml is generated, which is the basic configuration of each Spring Cloud micro-service item, and the specific codes are as follows:
spring:
application: name: spring-naocs-config-test# micro service name
profiles:
active test# effective configuration, which can develop environment, test environment and production environment configuration files simultaneously, and switch different environments by the configuration, taking test environment as an example
The ecar-nacos-server-addr 127.0.0.1:8848#nacos address configuration
Prefix of context-path-/spring-naocs-config-test# micro-service controller interface access
The configuration of the name space of the name-space is isolated, the configuration is unified, and the same environment is under the same space
When the same service cluster is deployed by the NAcos-GROUP DEFAULT_GROUP# micro-service, GROUPs can be divided, and different GROUPs are configured under the same naming space and are isolated
Nacos-usernames: nacos #Nacos username
NAcos-password, NAcos#NAcos password
---
spring:
config:
activate:
on-Profile test# test Environment test Profile
cloud:
nacos:
config:
Server-addr # - { ecar-nanocos-server-addr } # configures the address registered to the nanocos
Namespace $ { nacos-nacespace } # configuration registers to the nacess namespace
username: $ { nicos-username } # configuration registers to the nicos username
The password $ { nicos-password } # configuration is registered to the nicos password
group $ { nicos-group } # configuration is registered to the group of nacos
file-extension yaml# profile suffix: default is properties
Prefix $ { spring. Application. Name } #Nacos effective Profile prefix (divided by micro-service name)
enabled: whether the configuration file on true#nacos is valid
Boottap.yml is registered with the nacos, and the remote configuration file d.spring-naocs-config-test on the nacos is obtained by remote config of the nacos. The specific codes are as follows:
mongodb-database-name spring-nano-MongoDB-test# introduces MongoDB, database requiring configuration operations
MQT is introduced into MQTT in $ { spring. Application. Name } #, and the required ClientIDmysql-database-name is configured in such a way that spring-nano-mysql-test# introduces mysql middleware, and the required database is configured
Redis-database-name # 0 introduces redis, a required database server that needs to configure redis operations:
port:8061
spring:
cloud:
nacos:
config:
extension-configs:
data-id Spring-common. Yaml # Spring Cloud project public configuration
group $ { nacos-group } # group corresponding to the group of nacos
Refresh, true# micro-service configuration hot update
Data-id global-config. Yaml# common configuration of all middleware such as ip, port, name, password, etc., if the middleware port changes, only the configuration needs to be updated.
group:${nacaos-group}
refresh:true
Data-id common-config. Yaml# custom middleware common configuration such as ip, port, name, password, etc., if custom configuration middleware address is needed, ip and port can be directly introduced here, if corresponding configuration change only needs to modify the configuration, all items can be automatically updated
group:DEFAULT_GROUP
refresh:true
Data-id mysql-config. Yaml# import item unified mysql configuration
group:${nacaos-group}
Data-id, locktq-config. Yaml# import item unified locktq configuration group: $ { nacos-group }
refresh:true
Data-id dis-config. Yaml# import item unified dis configuration
group:${nacaos-group}
refresh:true
Data-id mondab-config. Yaml# import item unified mondab configuration group: $ { nacos-group }
refresh:true
Data-id mqtt-config. Yaml# import item unified mqtt configuration
group:${nacaos-group}
refresh:true
Spring-common.yaml, global-config.yaml, global-common-config.yaml, redis-config.yaml, mysql-config.yaml, mongpb-config.yaml, docktq-config.yaml, and mqtt-config.yaml were generated.
The Spring-common. Yaml is a configuration common to Spring Cloud micro service items, and mainly defines some general configurations in each item, such as micro service discovery and registration (convenient for a Fegin call), a global context prefix configuration requested by a micro service interface, a Swagger general configuration, service health detection and the like, and specific codes are as follows:
spring:
mvc:
static-path-pattern:/**
pathmatch:
matching-strategy: ant_path_match #Swagger2.9 and version configuration above
server:
servlet:
context-path # - { context-path } # configures the prefix of the micro-service controller interface access
cloud:
nacos:
discovery:
Server-addr # - { ecar-Nacos-server-addr } # configure micro-service registration and discover Nacos address
group $ { Nacos-group } # configures micro-service registration and discovery of Nacos groups
Namespace $ { spring.profiles.active } # configure micro-service registration and discover Nacos namespaces
usernames $ { Nacos-usernames } # configure microservice registration and discover Nacos usernames
pass word $ { nicos-pass word } # configure micro-service registration and discover Nacos password
management- # health detection configuration
health:
probes:
enabled:true
security:
enabled:false
endpoints:
web:
exposure:
include:"*"
#exclude:info
endpoint:
shutdown:
enabled:true
health:
show-details:always
The global-config. Yaml is a common configuration of all middleware, and is suitable for project unified SDKs, such as ip, port, name, password, etc., where a specification unified management is defined, and ip, ports, user names, passwords, etc. in each middleware depend on the configuration. The specific codes are as follows:
global:
mongodb:
host:127.0.0.1#mongodb ip
port 27017#mong odb Port
username admin #mongfodb username
password # -mongasdb password
mysql:
url:127.0.0.1#mysql ip
Port 3306#mysql Port
username root#mysql username
password # mysql password
redis:
host:127.0.0.1#redis ip
Port 6379# rediss Port
username root#rediss user name
password, root#redis password
rocketmq:
NAmeserver 127.0.0.1:9876#rocket mq connects ip and port
mqtt:
url:tcp:// 127.0.1:1883#mqtt connects ip and port
username root#mqtt connection authentication user name
password, root#mqtt connection authentication password
The global-common-config.yaml is a middleware custom configuration, which also provides all middleware ips and ports, but is applicable to custom SDKs of various projects, for example, some projects need to develop related middleware SDKs by themselves, and the unified middleware SDKs in the projects are not required to be used, so that the configuration in the configuration is used, and specific codes are as follows:
global:
mysql:
url:127.0.0.1#mysql ip
Port 3306#mysql Port
username root#mysql username
password # mysql password
redis:
host:127.0.0.1#redis ip
Port 6379# rediss Port
username root#rediss user name
password, root#redis password
rocketmq:
NAmeServer 127.0.0.1:9876#rocket mq connects ip and port
mqtt:
url:tcp:// 127.0.1:1883#mqtt connects ip and port
username root#mqtt connection authentication user name
password, root#mqtt connection authentication password
Wherein, redis-config. Yaml is the uniform Redis middleware configuration of micro service items, and the specific codes are as follows:
spring:
redis:
database:${redis-database-name}
host:${global.redis.host}
lettuce:
pool:
max-active 8# maximum connection database connection number, 0 is set to be no limit
max-idle 8# number in maximum waiting connection, 0 is set to be no limit
max-wait-1ms# maximum setup connection latency. If this time is exceeded, an exception is received. Setting to-1 represents no limitation.
min-idle 0# number in minimum wait connection, 0 is set to be no limit
Automatic connection closing after 100ms # timeout
usernames $ { global.rediss. Usernames } # username
password $ { global.redis. Password } # password
Port $ { global. Redis. Port } # Port
timeout of 30000# timeout time
Wherein Mysql-config. Yaml is a unified Mysql middleware configuration for micro-service items, and the specific codes are as follows:
spring:
datasource:
type com. Alibaba. Current data source operation type
driver-class-name com.mysql.cj.jdbc.driver #mysql driver class
url:
jdbc:// $ { global.mysql.url }: $ { global.mysql.port }/$ { mysql-database-name? ch aracterEncoding =utf-8 & useunicode=true & usessl=false & tinyInt1 isbit=false & all owPublicKeyRetrieval =true & servertimezone=asia/Shanghai & allowances=true# configuration database connection
username $ { global.mysql. Username } # username }
password $ { global.mysql.password } # password
initial size 5# initial number of connections
minIdle:5
maxActive:10
maxWait:60000
druid:
stat-view-servlet:
enabled:true
loginUsername:admin
loginPassword:123456
allow:
web-stat-filter:
enabled:true
Configuration information of # connection pool
# initialization size, minimum, maximum
initial-size:5
min-idle:5
maxActive:20
Configuration # acquisition connection latency time
maxWait:60000
How often a configuration interval is # detected, the idle connection that needs to be closed is detected, and the unit is milliseconds
timeBetweenEvictionRunsMillis:60000
Configuration # a minimum lifetime of a connection in a pool is in milliseconds
minEvictableIdleTimeMillis:300000
validationQuery:SELECT 1FROM DUAL
testWhileIdle:true
testOnBorrow:false
testOnReturn:false
# open PSCache and specify the size of PSCache on each connection
poolPreparedStatements:true
maxPoolPreparedStatementPerConnectionSize:20
Filters for monitoring statistics interception are configured # and the monitoring interface sql can not be counted after removal, and 'wall' is used for a firewall
filters:stat,slf4j
# turn on the mergeSql function by connectiproperties attribute; slow SQL recording
connectionProperties:
druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
Wherein mondab-config. Yaml is a unified mondab middleware configuration for micro-service items, and the configuration codes are as follows:
spring:
data:
mongodb:
username $ { global. Mongodb. Username } # username
password $ { global. Monglodb. Password } # password
authentication-database admin# sets up authentication database, if any
database $ { mongab-database-name } # operated library
port:${global.mongodb.port}
host:${global.mongodb.host}
auto-index-creation index is automatically created by true #
Wherein, the rock tmq-config. Yaml is a uniform rock mq middleware configuration of micro service items, and the specific codes are as follows:
rocketmq:
name-server $ { global. Rocketmq. Nameserver } # rock mq connects ip and port
producer:
group $ { spring. Application. Name } # rock mq connection group
send-message-timeout:30000
client:
logUseSlf4j:true
logLevel:error
Wherein, the mqtt-config. Yaml is the unified mqtt middleware configuration of the micro-service items, and the specific codes are as follows:
mqtt:
url:${global.mqtt.url}
client Id $ { MQTT-client-id } #MQTT client connection id (unique)
userName $ { global.mqtt.username } #mqtt client connection authentication userName
passWord $ { global.mqtt.password } # MQTT client-side connection authentication passWord
timeout 5000# MQTT client connection timeout time
keepAlive:3
Example III
Fig. 3 is a schematic structural diagram of a configuration file management device for micro services according to a third embodiment of the present invention, where the device may be applied to a case of unified configuration management for different micro service items, and the device may be implemented by software and/or hardware and is generally integrated on an electronic device.
As shown in fig. 3, the apparatus includes: definition module 110, configuration module 120, and management module 130.
A definition module 110, configured to define a configuration file template, where the configuration file template includes a general configuration file template and a middleware configuration file template, where the middleware configuration file template is used to customize a software development kit SDK, and the general configuration file template is used to configure general parameters;
the configuration module 120 is configured to perform unified configuration based on the general configuration file template and the middleware configuration file template, and generate a configuration file;
and the management module 130 is used for distributing the configuration file to each micro-service item, and in each micro-service item, the configuration file is uniformly managed by the micro-service item.
In this embodiment, the device first defines a configuration file template through the definition module 110, where the configuration file template includes a general configuration file template and a middleware configuration file template, where the middleware configuration file template is used to customize a software development kit SDK, and the general configuration file template is used to configure general parameters; then, the configuration module 120 performs unified configuration based on the general configuration file template and the middleware configuration file template to generate a configuration file; finally, the configuration file is distributed to each micro-service item through the management module 130, and in each micro-service item, the configuration file is uniformly managed by the micro-service item.
The embodiment provides a configuration file management device for micro services, which can improve the management efficiency of micro service project configuration files.
Further, the general configuration file template comprises basic configuration, remote configuration of micro service items registered on the nacos and public configuration of the micro service items, and the middleware configuration file template comprises public configuration of middleware, middleware custom configuration and middleware configuration of uniform micro service items;
the middleware self-defining configuration and the SDK middleware configuration of the micro service item self-defining are mutually independent.
Based on the optimization, the basic configuration comprises an environment configuration, a prefix configuration accessed by the micro-service controller interface, a configuration of a name space of the nacos, a configuration of a group of the nacos, a configuration of a user name of the nacos and a configuration of a password of the nacos.
The remote configuration of the micro-service item registered to the nano includes defining a middleware port and introducing a unified middleware configuration of the micro-service item, the middleware including but not limited to: redis, mysql, rocketMQ, mongoDB, MQTT, any one or combination thereof.
The common configuration of the micro service items at least comprises one or more of micro service discovery and registration, micro service interface request global context prefix configuration, swagger general configuration and service health detection.
The public configuration of all middleware and the middleware custom configuration are used for micro service project unified SDK, and the public configuration of all middleware and the middleware custom configuration are combined for use; the public configuration of the middleware and the custom configuration of the middleware comprise: the ip of all middleware, the ports of all middleware, the user names of all middleware and the passwords of all middleware are configured.
The micro-service project unified middleware configuration includes, but is not limited to: the method comprises the steps of micro-service item unified Redis middleware configuration, micro-service item unified Mysql middleware configuration, micro-service item unified Mongodb middleware configuration, micro-service item unified Roccket mq middleware configuration and micro-service item unified mqtt middleware configuration.
The configuration file management device of the micro service can execute the configuration file management method of the micro service provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example IV
Fig. 4 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 4, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the profile management method of the microservice.
In some embodiments, the profile management method of the microservice may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the above-described method of profile management of micro-services may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the profile management method of the micro-service in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method for managing configuration files of a micro service, the method comprising:
defining a configuration file template, wherein the configuration file template comprises a general configuration file template and a middleware configuration file template, the middleware configuration file template is used for customizing a Software Development Kit (SDK), and the general configuration file template is used for configuring general parameters;
uniformly configuring based on the general configuration file template and the middleware configuration file template to generate a configuration file;
And distributing the configuration file to each micro-service item, wherein in each micro-service item, the configuration file is uniformly managed by the micro-service item.
2. The method of claim 1, wherein the generic profile template comprises a base configuration, a remote configuration in which micro-service items are registered on the nano, and a common configuration in which micro-service items are registered, the middleware profile template comprising a common configuration in middleware, a middleware custom configuration, and a middleware configuration in which micro-service items are unified;
the middleware self-defining configuration and the SDK middleware configuration of the micro service item self-defining are mutually independent.
3. The method of claim 2, wherein the base configuration comprises an environment configuration, a prefix configuration accessed by a micro-service controller interface, a nicos namespace configuration, a nicos group configuration, a nicos username configuration, and a nicos password configuration.
4. The method of claim 2, wherein the remote configuration of the micro-service items registered to the nacos includes defining middleware ports and introducing a unified middleware configuration of micro-service items, the middleware including, but not limited to: any one or combination of Redis, mysql, rocker MQ, mongoDB, MQTT.
5. The method of claim 2, wherein the common configuration of the micro-service items comprises at least one or more of micro-service discovery and registration, micro-service interface request global context prefix configuration, swagger generic configuration, and service health detection.
6. The method of claim 2, wherein the common configuration of all middleware and the middleware custom configuration are used for micro service project unified SDKs, the common configuration of all middleware and the middleware custom configuration are used in combination;
the public configuration of the middleware and the custom configuration of the middleware comprise: the ip of all middleware, the ports of all middleware, the user names of all middleware and the passwords of all middleware are configured.
7. The method of claim 2, wherein the micro-service project unified middleware configuration includes, but is not limited to: the method comprises the steps of micro-service item unified Redis middleware configuration, micro-service item unified Mysql middleware configuration, micro-service item unified Mongodb middleware configuration, micro-service item unified Roccket mq middleware configuration and micro-service item unified mqtt middleware configuration.
8. A profile management apparatus for a micro service, the apparatus comprising:
the definition module is used for defining a configuration file template, wherein the configuration file template comprises a general configuration file template and a middleware configuration file template, the middleware configuration file template is used for customizing a Software Development Kit (SDK), and the general configuration file template is used for configuring general parameters;
the configuration module is used for carrying out unified configuration based on the general configuration file template and the middleware configuration file template to generate a configuration file;
and the management module is used for distributing the configuration file to each micro-service item, and in each micro-service item, the configuration file is uniformly managed by the micro-service item.
9. An electronic device, the electronic device comprising:
at least one processor;
and a memory communicatively coupled to the at least one processor;
wherein the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method of profile management of a micro service of any one of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to implement the method of profile management of a microservice of any one of claims 1-7 when executed.
CN202311022236.0A 2023-08-14 2023-08-14 Method, device, equipment and storage medium for managing configuration file of micro service Pending CN117008957A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311022236.0A CN117008957A (en) 2023-08-14 2023-08-14 Method, device, equipment and storage medium for managing configuration file of micro service

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311022236.0A CN117008957A (en) 2023-08-14 2023-08-14 Method, device, equipment and storage medium for managing configuration file of micro service

Publications (1)

Publication Number Publication Date
CN117008957A true CN117008957A (en) 2023-11-07

Family

ID=88574170

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311022236.0A Pending CN117008957A (en) 2023-08-14 2023-08-14 Method, device, equipment and storage medium for managing configuration file of micro service

Country Status (1)

Country Link
CN (1) CN117008957A (en)

Similar Documents

Publication Publication Date Title
US11010191B1 (en) Platform-independent interface for generating virtualized multi-service hardware systems and infrastructure
US11308129B2 (en) Container clustering in a container-based architecture
US10452372B2 (en) Method and deployment module for managing a container to be deployed on a software platform
CN110324169B (en) Interface management method and device
CN107800565B (en) Inspection method, inspection device, inspection system, computer equipment and storage medium
US11126688B2 (en) Resource management for objects within a web application
US9513978B2 (en) Integrated support for application porting transparency and streamlined system migration in heterogeneous platform environments
US11042473B2 (en) Intelligent test case management for system integration testing
CN111580869A (en) Data communication method and system based on OPC UA
KR20190077992A (en) Apparatus and method for network function virtualization in wireless communication system
US11461288B2 (en) Systems and methods for database management system (DBMS) discovery
US9201938B2 (en) Parameter driven data format conversion in client/server architectures
CN111339055B (en) Big data cluster capacity expansion method and device
CN117008957A (en) Method, device, equipment and storage medium for managing configuration file of micro service
EP4106293A2 (en) Network configuring method and apparatus for cloud mobile phone, device and storage medium
US20200218432A1 (en) Intelligent overflow menu
CN114721686A (en) Configuration data updating method and device, electronic equipment and storage medium
US10713041B1 (en) Application configuration manager
US11381448B2 (en) Systems and methods for cloud resource synchronization
CN113179332A (en) Method, electronic device and storage medium for acquiring configuration information
Sill When to use standards-based apis (part 2)
JP2022525568A (en) How to implement application interfaces on the upper platform layer, equipment, equipment and media
US10516767B2 (en) Unifying realtime and static data for presenting over a web service
US20230246916A1 (en) Service map conversion with preserved historical information
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