1. First acquaintance of nacos, comparison with eureka, install nacos on docker

Beginner

Start studying nacos today.

Why study this? Because now the mainstream of the company has begun to recommend nacos...Although, we haven't started using it...Be prepared in advance.

Nacos has two main functions. One is registration discovery, the other is configuration management

We register now and find that we are using eureka, and configuration management is using the configuration center of spring cloud. Nacos includes two aspects. From the perspective of server cost, it seems that we can save a little server cost. After all, the two are combined into one.

When studying, I will compare nacos and eureka, and the configuration center of spring cloud. Why do you recommend nacos?

We can’t just say yes because others say yes. We have to really know where it’s so good and why it’s so good? By understanding his strengths, we can better take its essence.

Know how to do than how to do more important

A preliminary research plan is drawn up:

  1. Understand what nacos is, its advantages and disadvantages, advantages

  2. Compare nacos and eureka, config

  3. Install and configure nacos. Now many of them are containerized using docker. You can try to install nacos using docker, and then other operations are performed on nacos

  4. According to the official website document, start learning.

  Official website address: https://nacos.io/en-us/docs/what-is-nacos.html

  github address: https://github.com/alibaba/nacos


1. What is nacos?

Break it down, what Nacos does in the box is explained below

nacos致力于注册发现, 配置和管理微服务

Two key points: service registration discovery, service configuration, service management three aspects

它提供了一组简单有用的功能,使您能够实现动态服务发现,服务配置,服务元数据和流量管理。

Dynamic service discovery: What is dynamic. I discussed with my colleagues before that one aspect of dynamic refers to the meaning of heat. For example, if the server is registered, it can be discovered without restarting. The service configuration is modified, and the service can be automatically identified without restarting the service Configuration modification.

Then service metadata and traffic management: This should be related to load balancing. How to distribute traffic, according to metadata settings, to manage

Nacos使构建,交付和管理微服务平台变得更容易,更快捷

How can it be easier and faster to build, deliver, and manage a microservice platform? I thought of the automated deployment. There is an interface, click a button, and you can start operation. No need for a server, a server to go deal with.

The above is the introduction given by the official website: After my understanding, it has become a vernacular. Hahaha

Official website explanation: What is nacos?

Service is a first-class citizen of Nacos

This is a bit of a sentence for a choice of words. Go says: Function is a first-class citizen. Channel is a first-class citizen. Here, nacos is a first-class citizen. What is a first-class citizen? Just like the customer is God, all around the customer . Nacos is all around service

Nacos支持发现,配置和管理几乎所有类型的服务

Kubernetes服务
gRPC和Dubbo RPC服务
Spring Cloud RESTful服务

Not much to say, we are now using spring cloud RESTful service

The main features of Nacos:

服务发现和服务运行状况检查

  Nacos支持基于DNS和基于RPC(Dubbo / gRPC)的服务发现。服务提供商向本机,OpenAPI或专用代理注册服务后,使用者可以使用DNS或HTTP查找服务。

  Nacos提供实时运行状况检查,以防止服务将请求发送到不正常的主机或服务实例。Nacos支持传输层(PING或TCP)健康检查和应用程序层(例如HTTP,Redis,MySQL和用户定义的协议)健康检查。
对于复杂的云和网络拓扑(例如VPC,边缘服务等)的运行状况检查,Nacos提供代理模式和服务器模式运行状况检查。Nacos还提供统一的服务运行状况仪表板,以帮助您管理服务的可用性和流量。
动态配置管理

  动态配置服务使您可以在所有环境中以集中,外部化和动态的方式管理所有应用程序和服务的配置。

  动态配置消除了在更新配置时重新部署应用程序和服务的需要。

  配置的集中管理使您更方便地实现无状态服务和按需弹性扩展服务实例。

  Nacos提供了易于使用的UI TODO,可帮助您管理所有应用程序或服务的配置。它提供了一些现成的功能,包括配置版本跟踪,canary / beta版本,
  配置回滚和客户端配置更新状态跟踪,以确保安全并控制配置更改的风险。
动态DNS服务

  支持加权路由的动态DNS服务使您可以更轻松地在数据中心内的生产环境中实施中间层负载平衡,灵活的路由策略,流量控制和简单的DNS解析服务。动态DNS服务使您更容易实现基于DNS的服务发现。

  Nacos提供了一些简单的DNS API TODO,供您管理DNS域名和IP。
服务治理和元数据管理

  Nacos允许您从微服务平台构建器的角度管理所有服务和元数据。这包括管理服务描述,生命周期,服务静态依赖关系分析,服务运行状况,服务流量管理,路由和安全规则,服务SLA和一线指标。

The following figure can understand the functions of nacos in detail. The
1. First acquaintance of nacos, comparison with eureka, install nacos on docker
above figure is given on the official website. Just look at it. It is a summary of the above content. What are the functions, functions, advantages, etc. of nacos.

The following figure shows the structure and components of nacos:
1. First acquaintance of nacos, comparison with eureka, install nacos on docker

  • Service management : realize service CRUD, domain name CRUD, service health status check, service weight management and other functions
  • Configuration management : realize configuration management CRUD, version management, gray management, monitoring management, push track, aggregate data and other functions
  • Metadata management : Provide metadata CURD and marking capabilities
  • Plug-in mechanism : realize the separable and combinable capabilities of the three modules, and realize the extension point SPI mechanism
  • Event mechanism : implement asynchronous event notification, sdk data change asynchronous notification and other logic
  • Log module : manage log classification, log level, log portability (especially to avoid conflicts), log format, exception code + help document
  • Callback mechanism : SDK notification data, callback user processing through a unified mode. Interface and data structure need to be extensible
  • Addressing mode : to solve multiple addressing modes such as ip, domain name, nameserver, broadcast, etc., it needs to be expandable
  • Push channel : solve the push performance problem between server and storage, server, server and SDK
  • Capacity management : Manage the capacity of each tenant and group to prevent storage from being overwritten and affecting service availability
  • Traffic management : Control request frequency, number of long links, message size, and request flow control according to multiple dimensions such as tenants and groups
  • Cache mechanism : disaster tolerance directory, local cache, server cache mechanism. Tools required for disaster recovery catalog use
  • Start mode : According to stand-alone mode, configuration mode, service mode, dns mode, or all mode, start different programs + UI
  • Consistency protocol : Different consistency mechanisms for different data and different consistency requirements
  • Storage module : solve data persistence, non-persistent storage, and solve the problem of data fragmentation
  • Nameserver : Solve the routing problem from namespace to clusterid, and solve the problem of mapping between user environment and nacos physical environment
  • CMDB : Solve metadata storage, docking with third-party cmdb systems, and solve the relationship between applications, people, and resources
  • Metrics : Expose standard metrics data to facilitate connection with third-party monitoring systems
  • Trace : Expose standard trace, which is convenient to get through with SLA system, log whitening, push trace and other capabilities, and can get through with metering and billing system
  • Access management : It is equivalent to the process of Alibaba Cloud opening services, assigning identity, capacity, and permissions
  • User management : solve user management, login, sso and other issues
  • Authority management : Solve problems of identity recognition, access control, role management, etc.
  • Audit system : extended interface to facilitate connection with audit systems of different companies
  • Notification system : core data changes, or operations, convenient to get through the SMS system, and notify the counterparty of data changes
  • OpenAPI : Exposes standard Rest style HTTP interface, easy to use, convenient for multi-language integration
  • Console : Easy-to-use console for service management, configuration management and other operations
  • SDK : Multilingual SDK
  • Agent : dns-f similar mode, or integrated with mesh and other solutions
  • CLI : The command line performs lightweight management of the product, as easy to use as git.
    This is the function of nacos. When studying later, you can study it according to this diagram.

Build, deploy and start mode:

  • Two delivery methods
    Nacos supports standard Docker images (TODO: supported from version 0.2) and zip (tar.gz) compressed package construction.

  • Startup mode
    Nacos supports two modes in which the Service Registry and the Config Center are deployed together in one process or the two are deployed separately.

  • The free public cloud service model
    In addition to deploying and starting Nacos services yourself, in the cloud computing era, Nacos also supports the public cloud model. Alibaba Cloud’s public cloud commercial products (such as ACM, EDAS) will provide free Nacos services. Public cloud services. You can also use Alibaba Cloud public cloud provider to provide Nacos public cloud services.

2. Comparison of the advantages and disadvantages of nacos and eureka

Spring Cloud Nacos

advantage:

1) Out of the box, suitable for dubbo, spring cloud, etc.

2) AP model, data consistency

3) Two-in-one registration center and configuration center (two-in-one is not necessarily an advantage), providing console management

4) Purely made in China, with various Chinese documents, which have been tested on Double Eleven

Disadvantages:

1) Not long after the open source, the community is not hot enough, and there are still bugs

Spring Cloud Eureka:

advantage:

1) Spring Cloud official recommendation

2) AP model, data consistency

3) Out of the box, with console management

Disadvantages:

1) The client registration service reports all the information. In the case of many nodes, the network and the server are under too much pressure and memory is wasted

2) The client updates the service information through a simple polling mechanism. When the number of services is huge, the server is under pressure.

3) The scalability of the cluster is not strong, and the server cluster uses broadcast replication to increase the server pressure

4) Eureka2.0 closed source (the latest version of Spring Cloud still uses the 1.X version of Eureka)

Personally, I feel that the reason why I have to abandon eureka is this last one, eureka2.0 is closed source, that is to say, if you want to continue to use, sorry, please pay... Then, nacos It is also good enough in the country...so...nacos has been vigorously developed

So: if you want to get a chance at a certain moment...then, please always be ready, good enough

3. Nacos is installed on docer

I have installed docker locally.

Step 1: download the image

docker pull nacos/nacos-server
This is to download the latest version of nacos mirror

Step 2: View the downloaded image: docker images

1. First acquaintance of nacos, comparison with eureka, install nacos on docker

Step 3: Start nacos

docker run --env MODE=standalone --name nacos -d -p 8848:8848 nacos/nacos-server

Parameter analysis:

  • run start running container
  • --env configuration environment MODE=standalong single node
  • --name nacos mirror name is nacos
  • -d guardian container
  • -p 8848: 8848 port mapping
    1. First acquaintance of nacos, comparison with eureka, install nacos on docker

    Step 4: Visit ip:8848/nacos in the browser, the login password defaults to nacos/nacos

    See the following interface, success!!
    1. First acquaintance of nacos, comparison with eureka, install nacos on docker

Step 5: Check whether nacos can work normally

1. Publish the configuration to the configuration center

Nacos is a service, it also provides a lot of external interfaces, one of which is to add configuration interface. We simulate this interface for configuration:

curl -X POST " http://localhost:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test&content=HelloWorld "
See that the return result is true. Then refresh the console, you can see the following
1. First acquaintance of nacos, comparison with eureka, install nacos on docker

2. Get the configuration from the configuration center

curl -X GET "http://localhost:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test"

This command is to get the configuration
1. First acquaintance of nacos, comparison with eureka, install nacos on docker

Get helloworld content


Reference materials:

  1. nacos official website: https://nacos.io/en-us/docs/what-is-nacos.html

  2. github: https://github.com/alibaba/nacos

  3. The difference between nacos and Eureka: https://www.pianshen.com/article/8646198661/

Guess you like

Origin blog.51cto.com/15091061/2606809