当前位置:网站首页>Nacos注册中心
Nacos注册中心
2022-06-25 22:36:00 【自由梦想程序员】
Nacos注册中心

springcloud的alibab版本的注册中心
nacso官网
nacos.io


端口8848,复制console的网址访问nacos页面
默认账号密码就是nacos
快速入门

去父工程添加依赖
<!--nacos的管理依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.5.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
在user-service模块中添加nacos依赖,注释掉eureka依赖(只需要添加客户端依赖)
<!--nacos客户端依赖包 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
修改配置环境
order-service进行一样的操作
返回到nacos页面,刷新下,点击服务管理

服务分级存储模型



我复制了几个user-service模块,便于理解集群
修改user-service模块的环境配置

然后运行8083和8081端口的user-service模块(先把所有运行的模块停止运行)
在修改user-service模块的环境配置
运行8082端口的user-service模块(如果集群数显示的是三个,就重启下nacos)
点击详情

NacosRule负载均衡
把order-service模块按照上述进行配置(集群改为HZ)
这时候调用order-service模块,多调用几次就发现所有集群都有调用的情况
修改order-service模块的环境配置
userserive: #要做配置的微服务的名称
ribbon:
NFLoadBalancerRuleClassName: com.alibaba.cloud.nacos.ribbon.NacosRule #负载均衡原理
这下就可以走本机集群
服务实例的权重配置


权重越高,服务请求越频繁
环境隔离







Nacos和Eureka对比


在order-service修改配置环境
重启order-service模块

Nacos配置管理
已经创建的配置前忘截图了,也就是本来就没有配置




微服务配置的拉取
之前是这样的
现在

去user-service添加客户端管理依赖
在resources包下创建新的配置文件bootstarp.yml
spring:
application:
name: userservice
profiles:
active: dev # 环境
cloud:
nacos:
server-addr: nacos:8848 # nacos地址
config:
file-extension: yaml # 文件后缀名


配置刷新

改配置环境格式,直接刷新打开页面



多环境配置共享





边栏推荐
- 从进程的角度来解释 输入URL后浏览器会发生什么?
- 2021-04-28
- 鼠标拖拽围绕某个物体旋转展示
- js数组中修改元素的方法
- 基于OpenVINOTM开发套件“无缝”部署PaddleNLP模型
- Redux workflow explanation + small examples
- 【图像检测】基于高斯过程和Radon变换实现血管跟踪和直径估计附matlab代码
- Methods to realize asynchrony
- Use js to obtain the last quarter based on the current quarter
- Solution to SMT grape ball phenomenon
猜你喜欢

渲云携手英特尔,共创云渲染“芯”时代

Atlas200dk刷机

渗透工具-Burpsuite

Mysql5.7.31 user defined installation details

leetcode.14 --- 最长公共前缀

mtb13_Perform extract_blend_Super{Candidate(PrimaryAlternate)_Unique(可NULL过滤_Foreign_index_granulari

QT excellent open source project 9: qtox

Why is it best to use equals for integer comparisons

元宇宙中的法律与自我监管

Is camkiia the same as gcamp6f?
随机推荐
Permission design = function permission + Data permission
Mysql5.7.31 user defined installation details
Explain from a process perspective what happens to the browser after entering a URL?
Login interceptor
Camkiia et gcamp6f sont - ils les mêmes?
Penetration tool -burpsuite
Maintenance and key points of SMT Mounter
1-10vmware builds customized network architecture
C IO stream (I) basic concept_ Basic definition
Idea kotlin version upgrade
Learn to identify follow-up questions in dialogue Q & A
Function and principle of SPI solder paste inspection machine
Redisson 3.17.4 发布
11.1.2 overview of Flink_ Wordcount case
Performance leads the cloud native database market! Intel and Tencent jointly build cloud technology ecology
【TSP问题】基于Hopfield神经网络求解旅行商问题附Matlab代码
Tensorrt PB to UF problem
Summary of common terms and knowledge in SMT chip processing industry
Deploy Ogg on the same machine and test
Balanced binary tree AVL