当前位置:网站首页>Nacos Foundation (6): Nacos configuration management model
Nacos Foundation (6): Nacos configuration management model
2022-04-23 11:26:00 【There is no retreat when sailing against the current】
List of articles
Preface
nacos Configuration management model for .
Section 1 Configuration management model
nacos Configuration management model , about nacos Configuration Management , adopt Namespace,group,Data Id Be able to locate a configuration set .

config set Data ID
In the system , A configuration file is usually a configuration set , A configuration set can contain various configuration information of the system . for example , A configuration set may contain data sources , Thread pool , Log level and other configuration items . Each configuration set can define a meaningful name , It's the configuration set ID(Data ID)
Configuration item
Configuration items are the configuration contents contained in the configuration set . It represents a specific configurable parameter and its domain value , Usually, the key=value There is a form of . For example, the commonly configured log output level (logLevel=INFO|WARN|ERROR) It's a configuration item . The following supported configuration information formats

Configure grouping group
Configuration grouping is the grouping of configuration sets , Denote by a meaningful string , Different configuration groups can have the same configuration set . When 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 for configuring groups : Can be used to distinguish between different projects or applications .
Namespace Namespace
The namespace can be used for configuration isolation of different environments . For example, you can isolate the development environment , Test environment and production environment , Because their configurations are different , Or isolate different users , Different developers use the same nacos Manage your own configuration , It can be done by namespace Isolation . Under different namespaces , There can be configuration groups or configuration sets with the same name .
practice
Namespace: Representing different environments , for example Development , test , production .
Group: On behalf of a project , For example, take out items , Taxi project
DataId: There are often several projects under each project , Each configuration set generation is the main configuration file of a project .
In the second quarter Namespace Management
namespace Isolation design
namespace The design of nacos Based on this, multi environment and multi tenant ( Multiple users share nacos) data ( Configuration and services ) Segregated .
- From the perspective of a tenant , If there are many different environments , At this time, you can create different namespaces according to the specified environment , In order to achieve multi environment isolation . for example : You may have development , Test and produce three different environments , Then use a set of nacos Clusters can be divided into three different namespace.

Namespace management and configuration data acquisition
How to create a namespace
-
Open the namespace on the left , Click new namespace


At this point, you can switch the newly created namespace by entering the configuration list .

-
At this time in dev Create a new dataset

-
Write code
Here we get dev Configuration under namespace , You need to pass namespace Of id( From the namespace, you can see namespace id),
If you don't pass namespace, The default is public, That is, the system's own namespace .
package com.it2;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import java.util.Properties;
public class NacosDemo01 {
public static void main(String[] args) throws NacosException {
String dataId="nacos-demo.yaml";
String group="DEFAULT_GROUP";
String serverAddr="127.0.0.1:8848";
Properties properties=new Properties();
properties.put("serverAddr",serverAddr);
// This is from wrong public Get configuration set from namespace of , You need a namespace id
properties.put("namespace","d0f32411-9568-4cd3-a595-a1d98989bbeb");
ConfigService configService= NacosFactory.createConfigService(properties);
String config=configService.getConfig(dataId,group,3000);
System.out.println(config);
}
}
- Run code

版权声明
本文为[There is no retreat when sailing against the current]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231117595161.html
边栏推荐
- 详解MySQL中timestamp和datetime时区问题导致做DTS遇到的坑
- Understanding of fileprovider path configuration strategy
- Interprocess communication -- message queue
- Laravel绑定钉钉群警报(php)
- 讯飞2021年营收183亿:同比增41% 净利为15.56亿
- 汇编语言 运行环境设置等教程链接整理
- When the activity is in progress! Click the link to join the live studio to participate in "can AI really save energy?" Let's have a discussion!
- Advanced file IO of system programming (13) -- IO multiplexing - Select
- Who said you should know PS? This open-source artifact can also be pulled in batch, and the effect is outstanding!
- Redis学习之五---高并发分布式锁实战
猜你喜欢
随机推荐
MQ在laravel中简单使用
MySQL分区表实现按月份归类
Write console script by laravel
赛微微电科创板上市破发:跌幅达26% 公司市值44亿
nacos基础(6):nacos配置管理模型
MySQL面试题讲解之如何设置Hash索引
汇编语言 运行环境设置等教程链接整理
laravel编写Console脚本
Summary of the relationship among GPU, CUDA and cudnn
VM set up static virtual machine
防止web项目中的SQL注入
Laravel always returns JSON response
qt5. 8. You want to use SQLite in the 64 bit static library, but the static library has no method to compile the supporting library
学习 Go 语言 0x08:《Go 语言之旅》中 练习使用 error
Implementation of inserting millions of data into MySQL database in 10 seconds
Solve the problem of "suncertpathbuilderexception: unable to find valid certification path to requested target"
Usage record of map < qstring, bool >
创客教育中的统筹方案管理模式
分享两个实用的shell脚本
Analyze the rules for the use of robots with good performance









