当前位置:网站首页>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 # 文件后缀名


配置刷新

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



多环境配置共享





边栏推荐
- SMT Mounter workflow
- Is camkiia the same as gcamp6f?
- Middle order clue binary tree
- [TSP problem] solving traveling salesman problem based on Hopfield neural network with matlab code
- Redux workflow explanation + small examples
- Apache基金会正式宣布Apache InLong成为顶级项目
- The development context of Ba Kong Yuan universe industry
- 统一网关Gateway
- DPVS fullnat mode deployment
- Send mail tool class
猜你喜欢

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

mtb13_ Perform extract_ blend_ Super{candidate (primaryalternate) \u unique (nullable filtering \foreign\index\granulati

C IO stream (II) extension class_ Packer

Redisson 3.17.4 release

Web学习之TypeScript

Camkiia et gcamp6f sont - ils les mêmes?

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

Compiler Telegram Desktop end (tdesktop) en utilisant vs2022

Idea view unit test coverage

Flink报错:Error: A JNI error has occurred, please check your installation and try again
随机推荐
Deploy Ogg on the same machine and test
Resolve thread concurrency security issues
QT excellent open source project 9: qtox
C IO stream (I) basic concept_ Basic definition
Summary of common terms and knowledge in SMT chip processing industry
Explain from a process perspective what happens to the browser after entering a URL?
C IO stream (II) extension class_ Packer
mtb13_Perform extract_blend_Super{Candidate(PrimaryAlternate)_Unique(可NULL过滤_Foreign_index_granulari
信号处理函数内必须使用可重入函数
Example: use C # Net to teach you how to develop wechat official account (21) -- using wechat to pay online collection: H5 method
每日刷题记录 (四)
Penetration tool -burpsuite
CaMKIIa和GCaMP6f是一样的嘛?
Ad20 (Altium designer) PCB highlight network
渗透工具-Burpsuite
Machine vision: illuminating "intelligence" and creating a new "vision" world
Causes and solutions to the phenomenon of PCBA monument in SMT patch processing
毕业季 | 在不断探索中拟合最好的自己
Qt优秀开源项目之九:qTox
Logstash discards log data that does not match the file name exactly