What is Nacos?

Official description: A dynamic service discovery, configuration management and service management platform that makes it easier to build cloud native applications.

Nacos is dedicated to helping you discover, configure, and manage microservices. Nacos provides an easy-to-use feature set that helps you quickly implement dynamic service discovery, service configuration, service metadata, and traffic management.

Nacos helps you build, deliver, and manage microservices platforms more agile and easily. Nacos is the service infrastructure for building modern “service” centric application architectures (e.g., microservices paradigm, cloud native paradigm).

Vision: Nacos by providing easy-to-use dynamic service discovery, service configuration, service sharing and management services such as infrastructure, to help users in the era of cloud native, the private cloud, a hybrid cloud or public clouds, etc all cloud environment, better build, delivery, management, service platform, multiplexing and composite business services faster, faster delivery of business innovation value, Thus win the market for users.

Two, what are the functions?

Dynamically configured service

Dynamic configuration services enable you to manage the configuration of all environments in a centralized, external, and dynamic manner. Dynamic configuration eliminates the need to redeploy applications and services when configuration changes. Centralized configuration management makes it easier to implement stateless services and to extend services flexibly on demand.

Service discovery and management

Dynamic service discovery is key to a service-oriented approach to application architecture, such as microservices and cloud native. Nacos supports dnS-BASED and RPC-based (Dubbo, gRPC) service discovery 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.

Dynamic DNS Service

By supporting weighted routing, the dynamic DNS service enables you to easily implement middle-layer load balancing, more flexible routing policies, traffic control, and simple DNS resolution services on the Intranet of simple data centers. Dynamic DNS services also make it easier to implement DNS protocol-based service discovery to eliminate the risk of coupling to vendor proprietary service discovery apis.

Three, what are the features?

Easy to use

Dynamic configuration management, service discovery, and dynamic one-stop solutions more than 20 out of the box service-oriented architecture features lightweight production requirements

Better suited to cloud architectures

Seamless support Kubernetes and Spring Cloud make it easier to deploy and run on mainstream public clouds (such as Ali Cloud and AWS) multi-tenant and multi-environment support

Production level

Based on alibaba’s 10 years of proven internal products support open source products with enterprise-level SLAs in large-scale scenarios with millions of services

Rich application scenarios

Support for traffic limiting, large promotion plan and remote live support directly or slightly extended to support a large number of useful Internet application scenarios traffic scheduling and service governance

4. Nacos map

Feature diagram: The feature demands of the problem domain to be solved will be comprehensively introduced from functional features and non-functional features

Architecture big picture: Quick access to the world of Nacos through clear architecture

Business Picture: The business scenarios that can be supported with the current features, and their best practices

Ecological picture: Systematically combs the relationship between Nacos and mainstream technology ecology

Advantages: Show the core competitiveness of Nacos

Strategic picture: The macro advantages of Nacos should be explained from strategic to tactical level

V. Ecological map of Nacos

As shown in the Nacos panorama, Nacos seamlessly supports some mainstream open source ecosystems, such as

Spring Cloud

Apache Dubbo and Dubbo Mesh

Kubernetes and CNCF.

Using Nacos simplifies service discovery, configuration management, service governance, and management solutions, making it easier to discover, manage, share, and compose microservices.

For information on how to use Nacos in these ecosystems, please refer to the official documentation: What is Nacos

6. Concept of Nacos

The concept of Nacos can be described in the official documentation below:

Nacos. IO/useful – cn/docs /…

PS: The above concepts are very important and need to be looked at carefully, otherwise there will be a lot of obstacles to understanding Nacos

Let me pick out a few of them for you:

Namespaces: Commonly used for production environment isolation, such as dev/test/beta/prod

An application service can be configured with multiple configuration files. The extension is required. The configuration ID is unique and the common format is = application name/application name +Profile(for example, mall-test.yml).

Configuration management: You can manage configuration files, edit, store, distribute, change management, historical version management, change audit, and other configuration-related activities

Configuration items: key/value form the configuration of the content, application application. Yml/bootstrap yml file content item, etc

Service: Service name = application name, service group = aggregation of a group of services, service cluster = aggregation of multiple instances in the same group with the same application name, service weight = weight. The greater the weight, the greater the traffic

Meta information: Describes Nacos data (such as configurations and services), such as service version, weight, DISASTER recovery policy, load balancing policy, authentication configuration, and customized labels. Meta information is classified into service-level meta information, cluster meta information, and instance meta information.

7. Nacos architecture

Nacos. IO/useful – cn/docs /…

The above is the official explanation of the Nacos architecture, students can take a look, the following I briefly describe some commonly used components and configuration.

Data is stored

Nacos data storage can be divided into two types, one is memory, the other is DB, which is commonly stored in MySQL to persist data and avoid data loss. The default initialization SQL is also provided, which can be downloaded from Github at: Initialize SQL.

The console

Nacos also provides a convenient for user to use the background page, can access through the link http://localhost:8848/naocs, a password is Nacos/Nacos, The console provides a number of out-of-the-box configuration management features, including configuration version tracking, Canary publishing, one-click rollback configuration, and client configuration update status tracking, to help you more securely manage configuration changes and reduce the risks associated with configuration changes in a production environment. Console Sample

Service management

Service management includes service CRUD, load forwarding policy, health check, and a whole set of service registration and discovery management.

Service configuration

Service configuration includes configuration CRUD, version control, listening management, push track, data aggregation and other functions.

User, role, and permission

Like normal systems, Nacos provides a user – role – permission infrastructure that solves the problem of registration – login – permission control.

Two boot modes

Nacos supports two modes of combining the Service Registry and Config Center in one process or separating them.

8. Nacos deployment

Nacos. IO/useful – cn/docs /…

Local mode

The basic configuration can be implemented according to the official documentation described in the link above. Several considerations will be explained in detail here.

Version: Current latest stable version V1.4.2, try to use the latest version, the official will continue to fix the problem, the new version will be better support, try not to use V2.0.1 version, this version is still to be verified, try to avoid stepping on the pit, stable later try again

Environment: you must pay attention to the official environment requirements, 64-bit jdk1.8+, 64-bit Linux/Windows, maven3.2+

Installation package: If there are no special circumstances, try to use the official compiled package to avoid the problem of packaging after downloading the official Git, except for secondary development or custom configuration

Configuration: launch configuration, the official launch by default using the embedded database form, here the author is recommended to use the MySQL database external way, if you use MySQL, you need to modify the conf/application. The properties configuration file, as follows:

If use MySQL as datasource:

spring.datasource.platform=mysql

Count of DB:

db.num=1

### Connect URL of DB: db.url.0=jdbc:mysql://localhost:3306/nacos_config? characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTime zone=Asia/Shanghai db.user.0=xxx db.password.0=xxx

If you do not know the Nacos MySQL initialization script, you can download the script by initializing SQL, or configure the script through conf/nacos-mysql.sql.

If the memory is insufficient, modify the bin/startup.sh startup configuration as follows:

` # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

JVM Configuration

#=========================================================================================== if [[ ” MODE”==”standalone”]]; thenJAVAOPT=”{MODE}” == “standalone” ]]; then JAVA_OPT=”MODE”==”standalone”]]; ThenJAVAOPT =”{JAVA_OPT} -xMS512m -Xmx512m-xmn256m “JAVA_OPT=” JAVAOPT− DNacos. standalone=true”elseif[[“{JAVA_OPT} – dnacos. standalone=true”elseif[[” JAVAOPT− DNacos. standalone=true”elseif[[“{EMBEDDED_STORAGE}” == “embedded”]]; then JAVA_OPT = “JAVAOPT – DembeddedStorage = true” fiJAVAOPT = “{JAVA_OPT} – DembeddedStorage = true” fi JAVA_OPT=”JAVAOPT−DembeddedStorage=true”fiJAVAOPT=”{JAVA_OPT} -server-xms2g -xmx2g-xmn1g-xx :MetaspaceSize=128m -XX:MaxMetaspaceSize=320m” JAVA_OPT=” XX: JAVAOPT – – OmitStackTraceInFastThrow – XX: + HeapDumpOnOutOfMemoryError – XX: HeapDumpPath = {JAVA_OPT} -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError – XX: HeapDumpPath = JAVAOPT – XX: – OmitStackTraceInFastThrow – XX: + HeapDumpOnOutOfMemoryError – XX: HeapDumpPath = {BASE_DIR} / logs/ja va_heapdump.hprof” JAVA_OPT=”${JAVA_OPT} -XX:-UseLargePages” fi`

PS: Startup command (-m standalone indicates standalone mode, if not, cluster mode)

Docker mode

Docker is similar to normal mode, but it also needs to set configuration files and startup parameters. I put the specific configuration and startup mode in Github instance project, students who need to have a look, as follows:

Github.com/YClimb/dock… The default standalone-mysql-5.7.yaml configuration is used to start Nacos, as described in the linked item above.

Management background

After the service is started, if you are a local or external server, you can access the console at http://IP:8848/nacos with the password nacos/nacos.

Ix. Authority, operation and maintenance

With the above examples, a basic Nacos configuration is complete. If you need permission configuration and operations related to Nacos, you can continue to read;

Access configuration

First, you need to check Nacos system parameters is introduced: Nacos system parameters is introduced, after you have read and understand the conf/application. The properties parameters of meaning;

Then you can start configuring permissions: authentication, through the description of the official document, you can change the configuration to complete authentication of open, it is important to note that for different versions, open service identification function is different, students need to see here, as far as possible with the latest stable version, otherwise the pit version problem may inadvertently will be met.

Operational problems

All of the deployments mentioned above are standalone versions. If you need a cluster version, you can check the following official documentation:

Nacos. IO/useful – cn/docs /… For cluster versions, this is done by default via [IP/domain name -> nginx -> instance]. There are a few issues to note:

Environment: 64-bit Linux, 64-bit JDK1.8+, Maven3.2+, 3 or more nodes (important, otherwise the election will not succeed)

Gz is recommended. Note that the cluster version is different from the standalone version. The recommended cluster version is 1.3.0

Cluster configuration: conf/cluster.conf to configure 3+ nodes

Data source: Use the MySQL database

Start: sh startup.sh External data sources are used by default

Domain name: When using domain names, do not set the compressed GZIP mode. Otherwise, garbled characters may occur when the application service obtains the configuration.

conclusion

I have compiled a Spring related information document, Spring series of family drum, Java systematic information (including Java core knowledge, interview topics and 21 years of the latest Internet real questions, e-books, etc.), friends who need to pay attention to the public number [procedures yuan Small wan] can obtain.