What is Nacos?

Nacos, an open source project of Alibaba, is a dynamic service discovery, configuration management and service management platform that makes it easier to help build cloud native applications. Na is the Naming /nameServer of the registry,co is the Configuration registry, and Service is the service-centered registry and Configuration center.

Nacos function description

Dynamic configuration services: Dynamic configuration services enable you to manage the configuration of all environments in a centralized, externalized, and dynamic manner. Dynamic configuration eliminates the need to redeploy applications and services when configuration changes occur. Centralized configuration management makes it easier to implement stateless services and to scale services flexibly on demand. 2. Service Discovery and Management: Dynamic service discovery is critical to a service-centric approach to application architecture such as microservices and cloud native. Nacos supports service discovery in BOTH DNS-BASED and RPC-based (Dubbo, gRPC) modes. Nacos also provides real-time health checks to prevent requests from being sent to unhealthy hosts or service instances. With Nacos, you can more easily implement circuit breakers for your services. 3. Dynamic DNS service: By supporting weighted routing, dynamic DNS service enables you to easily implement load balancing at the middle layer, more flexible routing policies, traffic control, and simple DNS resolution services on simple data center Intranet. Dynamic DNS services also make it easier for you to implement DNS protocol-based service discovery, eliminating the risk of coupling to vendor-private service discovery apis.

Why Nacos?

1, easy to use: dynamic configuration management, service discovery and dynamic one-stop solution; More than 20 out-of-the-box service-oriented architecture features; A lightweight and easy-to-use console that basically meets production requirements. 2. Better fit for Cloud architecture: seamless support for Kubernetes and Spring Cloud; Easier to deploy and run on mainstream public clouds (such as Aliyun and AWS); Multi-tenant and multi-environment support. 3. Production level: based on the internal products that have been verified by Alibaba for 10 years; Support for large-scale scenarios with millions of services; Open source products with enterprise level SLAs.

4, rich application scenarios: support limited flow, big promotion plan and remote multi-live; Support directly or with minor extensions for a wide range of useful Internet application scenarios; Traffic scheduling and service governance.

Prepare the environment

Before starting, please install the following components (officially recommended) :

64-bit operating system: Supports Linux/Unix/Mac/Windows. Linux/Unix/Mac is recommended (this demonstration is on Windows). 64-bit JDK 1.8 or later. Maven 3.2.x or later.

Download the source code or installation package

Nacos can be downloaded in either source code or distribution.

1) Download the source code from Github

git clone https:``//github.com/alibaba/nacos.git``cd nacos/``mvn -Prelease-nacos -Dmaven.test.skip=``true clean install -U ``ls -al distribution/target/`` // change the $version to your actual path``cd distribution/target/nacos-server-$version/nacos/bin
Copy the code

2) Download the compiled compression package

Github.com/alibaba/nac…

It is recommended to select a stable version (replace $version with the version number) :

unzip nacos-server-$version.zip OR tar -xvf nacos-server-$version.tar.gz``cd nacos/bin
Copy the code

For Windows, use the decompression tool.

Start the Nacos Server service

On Linux/Unix/Mac, run the following command:

sh startup.sh -m standalone
Copy the code

If you are using an Ubuntu system, or you are encountering this error message (symbol not found), please try running the following:

bash startup.sh -m standalone
Copy the code

If the OS is Windows, run the following command:

cmd startup.cmd
Copy the code

Service and configuration management nacos server access address: http://127.0.0.1:8848/nacos/nacos default account password: nacos/nacos

1. Service registration Manually add the following configuration information to the console:

The curl -x POST "http://127.0.0.1:8848/nacos/v1/ns/instance? ServiceName=blog.yoodb.com & IP = 123.57.47.154 & port = 443"Copy the code

Refer to the figure below:

Parameter meaning

Service name :blog.yoodb.com Protection threshold :0 Group (default) :DEFAULT_GROUP

2. Service Discovery Reference Service registration Skip this step

The curl -x GET http://127.0.0.1:8848/nacos/v1/ns/instance/list?. serviceName=blog.yoodb.com"Copy the code

3. Publish configuration

To add a configuration to Nacos Server, run the following command on the command line, or manually on the console.

The curl -x POST "http://127.0.0.1:8848/nacos/v1/cs/configs? dataId=blog.yoodb.com&group=TEXT_GROUP&content=helloWorld"Copy the code

Refer to the figure below:

Parameter meaning

DataId:blog.yoodb.com group:TEXT_GROUP configuration content :helloWorld

4. Obtain the configuration Reference. Publish the configuration skip this step.

The curl -x GET http://127.0.0.1:8848/nacos/v1/cs/configs?. dataId=blog.yoodb.com&group=TEXT_GROUP"Copy the code