当前位置:网站首页>Relationship between Nacos namespace grouping and dataid
Relationship between Nacos namespace grouping and dataid
2022-04-22 07:12:00 【Add soldier】
Nacos Namespace grouping and DataID The relationship between the three
A term is used to explain
Namespace (Namespace)
Used for tenant granularity configuration isolation . Under different namespaces , There can be the same Group or Data ID Configuration of .Namespace One of the most common scenarios is the separation of configurations between different environments , For example, develop the resources of test environment and production environment ( Such as configuration 、 service ) Isolation etc. .
Configure grouping (Group)
Nacos A set of configuration sets in , It is one of the dimensions of organization configuration . Through a meaningful string ( Such as Buy or Trade ) Group configuration sets , To distinguish Data ID Same configuration set . When you are in Nacos When you create a configuration on , If the name of the configuration group is not filled in , Then the name of the configuration group is used by default DEFAULT_GROUP . Common scenarios for configuring grouping : Different applications or components use the same configuration type , Such as database_url Configuration and MQ_topic To configure .
config set ID(Data ID)
Nacos Of a configuration set in ID. config set ID It is one of the dimensions of organization division and configuration .Data ID Usually used to organize the configuration set of partition system . A system or application can contain multiple configuration sets , Each configuration set can be identified by a meaningful name .Data ID Class is usually used Java package ( Such as com.taobao.tc.refund.log.level) The naming rules guarantee global uniqueness . This naming rule is not mandatory .
config set : A set of related or unrelated configuration items is called a configuration set . In the system , A configuration file is usually a configuration set , Including all aspects of the system configuration . for example , A configuration set may contain data sources 、 Thread pool 、 Log level and other configuration items .
The relationship between the three
The relationship between the three is similar to Java Inside package And class name , The outermost Namespace Can be used to differentiate deployment environments ,Group and DataID Logically distinguish between two target objects .

By default
Namespace=public,Group=DEFAULT_GROUP, Default Cluster yes DEFAULT
Details
Nacos The default namespace is public, We can use it Namespace To achieve isolation , For example, we now have three environments : Development 、 test 、 Production environment , We can create three Namespace, Different N amespace It's isolated .
Group In itself, it means grouping , It can divide different micro services into the same group .
The rest is specific micro Services , One Service It can contain more than one Cluster,Nacos Default Cluster yes DEFAULT,Cluster Is a virtual partition of a specified microservice . for instance , Will a Service Deployed in computer rooms in Beijing and Hangzhou , Beijing computer room Service You can call it (BJ), In Hangzhou computer room Service You can call it (HZ), In this way, microservices in the same computer room can call each other as much as possible , Lifting performance .
Switch between different environments
DataID programme
-
Appoint spring.profile.active And configuration files DataID To read different configurations in different environments , Configuration rules : Default space + newly build dev and test Two DataId:
- newly build dev To configure DataID( Created )
- newly build test To configure DataID

-
adopt spring.profile.active Attribute can be used to read configuration files in multiple environments


spring: profiles: # active: dev # Represents the development environment active: test # Represents the test environment -
test
Finally, visit again :http://localhost:3377/localhost/config/info

Group programme
According to the previous explanation, we all know Group For grouping, the default is :DEFAULT_GROUP, So now we need to divide into two groups , One group is “Dev Development Group ”, One group is “test Test group ”
-
newly build Group
DEV_GROUP

TEST_GROUP

Configuration list , Two DataID Agreement , But grouping different profiles :

- After completing the above configuration , Then you need to pass bootstrap+application To complete , Specific way : stay config Add one more Group Can be configured , Can be configured as DEV_GROUP or TEST_GROUP
bootstrap:
# nacos To configure
server:
port: 3377
spring:
application:
name: nacos-config-client
cloud:
nacos:
discovery:
server-addr: localhost:8848 #Nacos Address of service registration center
config:
server-addr: localhost:8848 #Nacos As the configuration center address
file-extension: yaml # Appoint yaml Format configuration
group: TEST_GROUP # Add groups
application:
spring:
profiles:
# active: dev # Represents the development environment
# active: test # Represents the test environment
active: info
-
test ( Different groups can be tested ):
Finally, visit again :http://localhost:3377/localhost/config/info

Namespace Space programme
We have DataID Scheme and Group The plan is complete , Then let's take a look at Namespace( Namespace ) programme , The default scheme is public, This scheme cannot be deleted , Now let's create two new namespace schemes

- newly build dev/test Of Namespace


-
Service management - View the service list page
At this point, we can switch the corresponding namespace , And then through Group and DataID To switch , If you want to switch namespaces , We need to pass the namespace ID To switch
-
Configure according to the domain name (Namespace+Group+DataId) To write
Through the first namespace Namespace ID To confirm the namespace used

# nacos To configure
server:
port: 3377
spring:
application:
name: nacos-config-client
cloud:
nacos:
discovery:
server-addr: localhost:8848 #Nacos Address of service registration center
config:
server-addr: localhost:8848 #Nacos As the configuration center address
file-extension: yaml # Appoint yaml Format configuration
group: TEST_GROUP # Assign groups
namespace: 4ba4bf0e-210c-41ce-954c-23538de1dcbc # Specify the namespace
spring:
profiles:
active: dev # Represents the development environment
# active: test # Represents the test environment
# active: info
And then back to Nacos Configuration list , add to Dev Configuration under namespace , add to 3 strip



- test : visit http://localhost:3377/localhost/config/info To test it
版权声明
本文为[Add soldier]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220608310741.html
边栏推荐
- IDEA debug调试教程
- ParseException Unparseable date 时间转换异常
- Covariance and covariance matrix
- leetcode打卡日记 day 01
- 什么是socket编程?
- Mcs-5 interrupt technology (Theory)
- What is the learning route of switching to digital IC Verification? Is there time to start turning now? 985 master's degree, second year of Graduate School of Electronics
- [review of Blue Bridge Cup] Naruto's shadow split
- Introduction to IC Analog Layout - learning notes on layout Basics (4)
- 芯片设计怎样准备即将面临的秋季补招和来年的春招?
猜你喜欢

Application of can optical transceiver in fire networking

Pl2586 design circuit | pl2586 replaces Fe1 1s circuit diagram | USB2 Scheme design of 0hub industrial hub

SeekBar 自定义 样式 详解

.NET学习笔记----关于.NET Core那些事(3)【配置文件的读取、json文件的通用解析、读取静态文件】

数字IC设计自学入门难吗?如何快速入门呢?

VScode 看这一篇就够了

什么是socket编程?

pyautocad 选择对象报错的解决方案

What knowledge and skills need to be added to IC design?

Application of can card in robot system
随机推荐
STM32学习记录——开发环境安装
STM32 timer synchronization trigger code experimental verification and sharing
Replace Fe1 1s hub card reading master chip-ma8601
Application of can card in robot system
Stm32wb55 RTT based ble sample making process
模拟ic设计和数字ic设计的区别,含薪资表
[review of Blue Bridge Cup] tree of life
First order digital low-pass filter - C language / Matlab implementation
Changes in the number of different types of calls in different months in 911 data
Leetcode268: missing number
FreeRTOS v10. 1.0 source code Chinese annotation version
再见了Postman,有一说一:Apifox才是YYDS
Fire fighting equipment optical fiber networking can to optical fiber converter
leetcode打卡日记 day 01
leetcode598:范围求和II
Leetcode598: range summation II
用大写的字段接受最终首字母却变小写
STM32学习记录0004——ISP串口下载
C#日常开发随手记----解决一个集合引用另一个集合导致一起改变
Replace rtd2171u | cs5266 design circuit | type C to HDMI scheme | cs5266an