Nacos - Open Source Configuration Ali Center

Configuration Center I believe we have heard, zookeeper, apollo and so are configured representative of the Center, but most of them are JAVA-based system, the author of the main development language used is Golang course, there are similar such components ETCD, but does not facilitate the management can not be visualized between Dad stumbled Ali open source nacos this configuration service discovery + central component, it has also been a period of time in here for everyone to share

attach:

Meow of a microphone blog: w-blog.cn

Nacos official Git address: https: //github.com/alibaba/nacos

Nacos official documents address: https: //nacos.io/zh-cn/docs/

Go Language SDK address: https: //github.com/sunmi-OS/gocore/tree/master/nacos

PS: The current latest official version V1.1.3, Ali cloud configuration center has provided services and use the same Nacos ACM, under the premise of using Ali cloud-free operation and maintenance is a good choice

A, Nacos Introduction

Nacos Ali cloud middleware team is a open source project, based on an independent internal ACM configuration management services provided by Ali cloud, up to now have github more than 8K star, although maturity and can not be compared Ctrip open source apollo, more component stability is also served on Ali cloud or worthy of belief, of course, be used to introduce Nacos must introduce such an idea introduced the distribution center.

Configuration Center is a common theme, from the beginning of configuration management for software programming projects are an important step, of course, with a single application mode requires only a single configuration file or environment variable to manage the configuration of this article is no longer like it within the scope of the discussion, the main distribution center address the following issues configuration management service or service of micro lower of:

  • Effective password management, development does not touch the password configuration, operation and maintenance personnel and unified management architecture teams to avoid the disclosure;
  • Configuring absolute unity in a multi-project, BUG caused by wrong configuration does not appear
  • For configuration editing, storage, distribution, change management, version history management, the ability to change a sound audit
  • Configuration packets and release the gray
  • Of course, there are disadvantages benefit, as opposed to using configuration files, we also need to address the following issues:
  • Configuration Center under abnormal conditions how to protect service available (SDK provides Cache function is not available when the service center will use the time to load cache configuration)
  • Configuration changes take effect after the program logic (SDK provides configuration changes Configuration changes can subscribe Subscribe logic write processing logic)
  • The development process of debugging the configuration file (required framework design)
  • Language, for some problems (PHP) arranged center performance (Nacos concurrent certain 8C16G 15K)
  • Contrast can be summed up or down more good than harm conclusions distribution center

Two, Nacos deployment

Nacos also support the deployment of more than supports binary support Docker and K8S deployment because Nacos is stored data state services need to rely on the way Mysql and clusters need to specify the IP slave so use K8S not a good choice (K8S use to run StatefulSet stateful service), the author here with Docker-Composer way to run Nacos

Nacos official Docker deployment Git address: HTTPS: //github.com/nacos-group/nacos-docker 
git clone https://github.com/nacos-group/nacos-docker.git
stand-alone deployment (Memory Mode):
Docker -compose -f example / standalone-derby.yaml up
a stand-alone deployment (Mysql mode):
Docker-Compose Example -f / standalone-mysql.yaml up
a clustered deployment:
Docker-Compose Example -f / cluster-up hostname.yaml

Visit: http: // localhost: 8848 / nacos / you can see the login screen

PS: The default user name and password are nacos

Nacos - Open Source Configuration Ali Center

 

Nacos - Open Source Configuration Ali Center

 

Ali cloud ACM service

Of course, to deploy their own Nacos will face many challenges, such as:

  • Cluster Setup
  • stability
  • Mysql database maintenance
  • Configuring Security (Nacos not say a password, but requires the use of ACM Ali cloud can improve the level of security keys)

PS: faith the principle of service can not build their own end-use is the author of Ali cloud services ACM (ACM service is currently free)

Nacos - Open Source Configuration Ali Center

 

Nacos - Open Source Configuration Ali Center

 

PS: Note that Ali cloud ACM and Nacos links manner in the SDK are different

Third, based on the use

Nacos There are a few basic concepts, we can only after first understand clearly better integration into business scenarios:

  • namespace Namespace
  • Group configuration packet
  • DataID specific configuration name

Generally, we use the namespace to distinguish between different projects or environmental differences distinguish the Department of Group A configuration such as the configuration of the business acquired and B teams there are some subtle differences can be distinguished by the Group, last used DataId to distinguish specific configuration items

Nacos - Open Source Configuration Ali Center

 

Add a namespace

Nacos - Open Source Configuration Ali Center

 

Add a configuration

Nacos - Open Source Configuration Ali Center

 

Supports a variety of configuration format, you can use a custom format even placed directly on the code line

Nacos - Open Source Configuration Ali Center

 

Nacos - Open Source Configuration Ali Center

 

Sample code has a corresponding JAVA-based

Nacos - Open Source Configuration Ali Center

 

Four, SDK and use the configuration OpenApi

Nacos SDK support what language (of course, the GIT, there are many unofficial SDK library):

  • Java
  • go
  • cpp
  • python
  • nodejs

You can see the specific use in official documents

The above configuration has been configured we can use it to access OpenApi

curl "http://172.16.0.13:8848/nacos/v1/cs/configs?dataId=test_config&group=DEFAULT_GROUP&tenant=b58ea912-e564-4958-b21f-3098ad15daf9"
{
"name":"sunmi"
}

Special attention tenant is required to enter the name of the namespace, but not the original name is the name of the following

Nacos - Open Source Configuration Ali Center

Guess you like

Origin www.cnblogs.com/cuiyubo/p/11756777.html