Microservice combat series (four)-registration center springcloud alibaba nacos

1. Scene description

Due to the use of microservices, regarding the registration center, I discussed with my colleagues on the technical prototype. The preliminary plan is to use: Alibaba's nacos+springcloud gateway. The following table is a comparison of the registration center compiled by my colleagues. Springcloud’s eureka is used as the registration center. Compared with eurka, the main reason for using Ali’s nacos this time is that nacos integrates dynamic loading without restarting the gateway and dynamically loading service configurations.

Registration center comparison:

Feature Zookeeper Eureka Consul Etcd Nacos
Service health check (Weak) long connection, keepalive Can be equipped with support Service status, memory, hard disk, etc. Connect heartbeat Heartbeat/Custom
Multiple data centers stand by stand by
kv storage service stand by stand by stand by stand by
consistency paxos raft raft raft
CAP theorem THAT AP THAT CP AP
Use interface (multi-language capability) Client http(sidecar) Support http and dns http/grpc dns/http/rpc
watch support stand by Support long polling/most incremental Full amount/support long polling Support long polling Full amount/support long polling
Self-monitoring metrics metrics metrics metrics
Safety acl acl /https https support (weak) acl /https
Spring Cloud integration Supported Supported Supported Supported Supported

Recommend Nacos>Consul>Etcd>Eureka>Zookeeper

Nacos is the springcloudalibaba family bucket component, suitable for using dubbo as the rpc service access of springcloud.

2. Brief introduction of nacos

Nacos is an open source project of Alibaba. The version released at the beginning of this year has reached the production level, with Chinese and English documents, and the community is very active.

Key features:

Interested children can check it out. Official website address: https://nacos.io/zh-cn/index.html

3. Deployment and description

In the past few days, I went through the official website documents and deployed a basic demo version. Let me introduce it.

3.1 Deployment instructions

Software Pharaoh used 6 virtual machines:

(1) 11 servers, deploy springcloud gateway to provide unified services to the outside world;

(2) The 12 and 13 servers are deployed with nacos, which are mutually registered, can be horizontally expanded, and provide external service registration, configuration registration, etc.;

(3) 14 servers, deployed producer (service provider), deployed two instances;

(4) 15 servers, a consumer (service caller) is deployed, and two instances are deployed;

(5) 16 servers, tested the dynamic configuration, can be ignored;

如果你觉得文章对你有些帮助,欢迎微信搜索「软件老王」第一时间阅读或交流!

3.2 Architecture diagram

3.3 Detailed description of the architecture diagram

3.3.1 nacos registration center and configuration center.

Nacos comes with its own console, access address: http://10.192.168.12:8848/nacos or http://10.192.168.13:8848/nacos

Username: nacos; Password: nacos;

After successful login, as shown below:

There are three main functions:

(1) The list of registration center nodes. The nacos registration center shown here can be expanded horizontally and multiple units can be deployed. Two units are deployed here, namely 12 and 13 servers.

(2) Service management. Three services are started, namely gateway, service provider (2 instances), and service consumer (2 instances).

(3) Configuration management. There are two configurations here. The first is for testing and dynamic acquisition is tested. The second is the configuration file of springcloud gate on the 11 server.

3.3.2 Visit instructions

(1) Gateway access address:

http://10.192.168.11:7000/producer/getpinfo

Note: 10.192.168.11:7000 is the gateway address, producer is the service name of the registration center, and getpinfo is the specific service.

(2) Service provider address:

http://10.192.168.14:7001/getpinfo,http:/10.192.1681.14:7001/getpinfo,
15的服务调用方,就是通过rest调用,跟直接从网关调用一样,软件老王就不啰嗦了。

(3) Nacos address:

http://10.192.168.12:8848/nacos,http:/10.192.1681.13:8848/nacos

3.4 Write at the end

At present, nacos is still in the rapid iteration stage. Both the version and the function are still a bit messy, and there are still some pits to step on. The software king thinks that a red heart is needed to prepare.


For more knowledge, please pay attention to the public account: "Software King" , share IT technology and related dry goods, reply to keywords to get the corresponding dry goods, java , send 10 must-see "Martial Arts Cheats"; pictures , send more than 1 million copies for commercial use High-definition pictures; interview , send java interview questions with a monthly salary of "20k" just after graduation, soft test , send official pdf books and customs clearance papers, follow-up will continue to update, such as " tools ", " videos ", etc., have been sorted out.
Insert picture description here

Guess you like

Origin blog.csdn.net/wjg8209/article/details/108777688