当前位置:网站首页>Nacos registry
Nacos registry
2022-06-10 17:32:00 【itmkyuan】
● Know and install Nacos
● Nacos Quick start
● Nacos Service hierarchical storage model
● Nacos Environmental isolation
know Nacos
Nacos It's Alibaba's product , Now it is SpringCloud A component of . comparison Eureka More features , It is highly popular in China .
nacos Service hierarchical storage model 
Cross cluster invocation of services
Select the local cluster service as much as possible for service invocation , Cross cluster call latency is high
When the local cluster is not accessible , Then visit other clusters 
Service cluster properties
1. modify application.yml attribute , Add the following
spring:
cloud:
nacos:
server-addr: localhost:8001 #nacos Service address of
discovery:
cluster-name: SH # Cluster name here SH Refers to Shanghai
2. stay nacos The console can see the cluster changes :
summary
1.Nacos Service hierarchical storage model
① The first level is service , for example userservice
② The second level is the cluster , For example, Hangzhou and Shanghai
③ The third level is the instance , For example, a certain computer room in Hangzhou has deployed userservice Service area of
2. How to set the cluster properties of an instance
① modify application.yml file , add to spring.cloud.nacos.discovery.cluster-name Attribute is enough
According to cluster load balancing
1. modify order-service Medium application.yml, Set the cluster to HZ:
spring:
cloud:
nacos:
server-addr: localhost:8001 #nacos Service address of
discovery:
cluster-name: HZ # Cluster name here HZ Hangzhou
2. And then in order-service Set load balancing in IRule by NacosRule, This rule gives priority to finding services in the same cluster as yourself :
userservice: # The name of the micro service to be configured
ribbon:
NFLoadBalancerRuleClassName: com.alibaba.cloud.nacos.ribbon.NacosRule # Load balancing rules
3. Pay attention to user-service The weight of is set to 1.
NacosRule Load balancing strategy
① The same cluster service list is preferred
② The local cluster cannot find the provider , Just go to other clusters to find , And will report a warning
③ After determining the list of available instances , Then random load balancing is used to select examples
Load balancing according to weight
This scenario will appear in the actual deployment :
- There are differences in the performance of server devices , The machine where some examples are located has good performance , Others are poor , We want better machines to take on more user requests
- nacos Weight configuration is provided to control access frequency , The greater the weight, the higher the access frequency
1. stay nacos The console can set the weight value of the instance , First, select the Edit button behind the instance
2. Set the weight value to 0.1, Tests can find 8082 The frequency of being visited is greatly reduced
Instance weight control
① nacos You can set the weight value of the instance ,0~1 Between
② The higher the weight of multiple instances in the same cluster, the higher the frequency of access
③ The weight is set to 0 Will not be accessed at all
Environmental isolation -namespace
Nacos The outermost layer of both service storage and data storage in is called namespace Things that are , Used for the outermost isolation 
1. stay Nacos The console can create namespace, Used to isolate different environments 
2. Then fill in a new namespace information 
3. After saving, you will see the name of this namespace in the console id:
4. modify oder-service Of application.yml, add to namespace:
spring:
cloud:
nacos:
server-addr: localhost:8001 #nacos Service address
discovery:
cluster-name: HZ # Cluster name
namespace: c072b17e-a5a6-4c23-aff3-aa83749eefa0 # Namespace fill id
5. restart order-service after , Check the console again 

6. Visit at this time order-service, because namespace Different , Will lead to the loss of userservice The console will report an error :
Nacos Environmental isolation
① namespace It's used for environmental isolation
② Every namespace There is only one id
③ Different namespace The service under is not visible
Nacos and Eureka contrast
nacos Registry detail analysis 
Temporary and non temporary instances
Service registered to nacos when , You can choose to register as a temporary instance or a temporary instance , Set... Through the following configuration :
spring:
cloud:
nacos:
server-addr: localhost:8001 #nacos Service address
discovery:
ephemeral: false # Whether it is a temporary instance
Nacos and eureka Common ground
① Both support service registration and service pull
② All support service providers' heartbeat for health detection
Nacos and eureka difference
① Nacos Support the server to actively monitor the status of service providers : The temporary instance adopts heartbeat mode , Active detection mode is adopted for non temporary instances
② The temporary instance will be kicked out if its heartbeat is abnormal , Non temporary instances will not be kicked out
③ Nacos Message push mode for hosting service list changes , The service list is updated more timely
④ Nacos The cluster adopts... By default AP The way , When there are non temporary instances in the cluster , use CP Pattern ;Eureka use AP Pattern
Thank you for your participation :
Video address :https://www.bilibili.com/video/BV1LQ4y127n4?p=17
边栏推荐
- What are the differences between domain name filing and ICP filing?
- Chongqing's first sci tech Innovation Board IPO is coming
- VBA divides strings, stores them in an array, writes them to a file, and saves them
- Fabric. Keep the original level when JS element is selected
- What should be done to improve the service level of the park and optimize the business environment
- 成立1年便成独角兽,腾讯滴滴做「靠山」,今年新晋的独角兽不简单
- 开源项目 PM 浅谈如何设计官网
- 提升园区服务水平,优化营商环境该从哪些方面入手
- 仅需三步学会使用低代码ThingJS与森数据DIX数据对接
- 运筹说 第64期丨动态规划奠基人——理查德·贝尔曼
猜你喜欢

Detailed steps for installing redis image in docker (easy to understand, suitable for novices to get started quickly)

Online communication skill network: a sparse model for solving multi task and multi-modal problems (Qingyuan talk, issue 19, tangduyu)

Thread interview related questions

Web3 is the most complete money making secret script. Just read this one

重庆第一个科创板IPO,来了

See how advanced technology changes human life

2022G1工业锅炉司炉考题及在线模拟考试

2022年G2电站锅炉司炉考试模拟100题及模拟考试

2022年茶艺师(中级)操作证考试题库及模拟考试

Full link tracking & performance monitoring tool skywalking practice
随机推荐
线上交流丨技能网络:解决多任务多模态问题的稀疏模型(青源Talk第19期 唐都钰)
KDD 2021 | MoCL:利用多层次领域知识的分子图对比学习
Fabric. Keep the original level when JS element is selected
Who is using my server? what are you doing? when?
Eliminate if Five ways of else
HTML+PHP+Mysql登录注册页面
Redis general instruction
Fabric. JS lock the background image, not affected by zooming and dragging
Solve the problem that idea is stuck in opening a project
Web3 is the most complete money making secret script. Just read this one
仅需三步学会使用低代码ThingJS与森数据DIX数据对接
Pytorch Foundation (I) -- anaconda and pytorch installation
2022年G2电站锅炉司炉考试模拟100题及模拟考试
When V-IF and V-for need to be used at the same time
ahk函数命令大全
This article introduces you to j.u.c's futuretask, fork/join framework and BlockingQueue
Fabric.js 锁定背景图,不受缩放和拖拽的影响
路由器实验之serial接口的静态路由配置(补充)
当v-if和v-for需要同时使用的时候
Brands are difficult to establish, IPO is difficult, and Chinese tea enterprises are trapped in "tradition"?