Classification management of nacos

Please see gitee for the entire project: https://gitee.com/xwb1056481167/spring-cloud

For the construction of nacos, please see: https://blog.csdn.net/www1056481167/article/details/113612177

namespace (command space), group (grouping), dataid

Aid1 data  

The ID of a configuration set in Nacos. Configuration set ID is one of the dimensions of organization division configuration. Data ID is usually used to organize the configuration set of the partition system. A system or application can contain multiple configuration sets, and each configuration set can be identified by a meaningful name. Data ID usually adopts Java-like package (such as com.taobao.tc.refund.log.level) naming rules to ensure global uniqueness. This naming rule is not mandatory. This concept comes from the official document, the human word is the name of the configuration file, which is equivalent to the role of the primary key

2. Group (grouping)  

A set of configuration sets in Nacos is one of the dimensions of organization configuration. The configuration sets are grouped by a meaningful string (such as Buy or Trade) to distinguish the configuration sets with the same Data ID. When you create a configuration on Nacos, if the name of the configuration group is not filled in, the name of the configuration group defaults to DEFAULT_GROUP. Common scenarios for configuration grouping: different applications or components use the same configuration type, such as database_url configuration and MQ_topic configuration. Speaking of people, it means that you can group, and the configuration files of different systems or microservices can be placed in a group. For example, the configuration files of the user system and the order system can be placed in the same group.

3. Namespace (namespace)  

Used to perform tenant-granular configuration isolation. Under different namespaces, the same Group or Data ID configuration can exist. One of the common scenarios of Namespace is the separation and isolation of the configuration of different environments, such as the isolation of resources (such as configuration and service) between the development and test environment and the production environment

DataId scheme
1. Specify spring.profile.active and configure a robust DataID to read different configurations in different environments
2. Default space + default grouping + new dev and test two DataIDs (new dev configuration DataID, new test configuration DataID )
3. Read configuration files in multiple environments through the spring.profile.active property

group

1. Add two new groups TEST_GROUP and DEV_GROUP with the same file nacos-config-client-info.yaml in nacos

2. Modify the bootstrap of cloudalibaba-config-nacos-client3377 and add a new group: DEV_GROUP

server:
  port: 3377
spring:
  application:
    name: nacos-config-client
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848 #nacos服务注册中心地址
      config:
        server-addr: localhost:8848 #nacos作为配置中心地址
        file-extension: yaml #指定yaml格式的配置
        group: DEV_GROUP #nacos中配置的分组

3. Then specify the file to be accessed in application.yml

spring:
  profiles:
    active: info

Start cloudalibaba-config-nacos-client3377

namespace

Namespace is equivalent to a first-level directory, group is equivalent to a second-level directory, and dataId is equivalent to a third-level directory

1, yml placement namespace

1、bootstrap.yml
server:
  port: 3377
spring:
  application:
    name: nacos-config-client
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848 #nacos服务注册中心地址
      config:
        server-addr: localhost:8848 #nacos作为配置中心地址
        file-extension: yaml #指定yaml格式的配置
        group: DEV_GROUP #nacos中配置的分组
        namespace: 92f42772-0f13-435a-8b19-ee5ce2caeedd #nacos的dev的id
1、application.yml
spring:
  profiles:
    active: dev #namespace下group下dev的文件

2. Nacos creates a namespace and combines files

 

Guess you like

Origin blog.csdn.net/www1056481167/article/details/113615853