当前位置:网站首页>Nacos 的安装与服务的注册
Nacos 的安装与服务的注册
2022-07-06 08:47:00 【look-word】
Nacos 的安装与服务的注册
我们都知道naocs是一个注册中心,那么注册中心是什么呢?
- 什么是注册中心?
- 它类似与一个中介角色(不收费的良心中介), 在微服务中起纽带的作用,它提供了服务和服务地址的映射关系,生产者把服务名称和地址注册到这里,
消费者根据服务名称得到响应的访问地址.
- 它类似与一个中介角色(不收费的良心中介), 在微服务中起纽带的作用,它提供了服务和服务地址的映射关系,生产者把服务名称和地址注册到这里,
- 为什么使用注册中心
- 没有注册中心的时候, 调用者调用服务的时候需要知道
域名和端口, 当被调用者修改时,就需要修改代码,当调用的服务多时,那么我们需要修改的代码就会很多,无疑是在增加我们的工作量。
- 没有注册中心的时候, 调用者调用服务的时候需要知道
那么他究竟是如何工作的呢?
工作原理:
- 生产者(服务提供者)向注册中心登记自己的域名和端口
- 消费者向注册中心拉取服务列表,并进行远程调用
- 注册中心和服务提供者通过定时检查心跳确保可以正常提供服务

Nacos使用前准备
下载解压后 我们需要进入到 bin 目录启动 nacos 服务
一定不要双击启动naocs 也会 java 写的 在 target 目录下 可以看到 jar 文件

启动:
在上面搜索栏中 输入 cmd 进入黑窗口
命令:startup.cmd -m standalone

当最下面出现 程序启动时长 就说明
启动成功了

我们来到浏览器 输入localhost:8848 可以看到naocs的运行的界面 我们将在里面进行一系列的配置
- 用户名和密码都是
naocs

我们所注册的服务都会出现在
服务列表中 ,可以服务进行下线等操作!

服务注册
nacos 的注册流程有三步
- 添加依赖
- 配置nacos
- 启动服务
添加依赖
<!--服务注册 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
配置nacos
# Spring
spring:
application:
# 应用名称
name: project-xxxx
cloud:
nacos:
discovery:
# 服务注册地址 ip加端口号
server-addr: 127.0.0.1:8848
启动服务
可以看到,刚才启动的服务已经出现在了服务列表中

边栏推荐
猜你喜欢

Navicat Premium 创建MySql 创建存储过程

目标检测——Pytorch 利用mobilenet系列(v1,v2,v3)搭建yolov4目标检测平台

vb.net 随窗口改变,缩放控件大小以及保持相对位置

Detailed explanation of heap sorting

延迟初始化和密封类

Excellent software testers have these abilities

View computer devices in LAN

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

个人电脑好用必备软件(使用过)

FairGuard游戏加固:游戏出海热潮下,游戏安全面临新挑战
随机推荐
ROS compilation calls the third-party dynamic library (xxx.so)
Double pointeur en langage C - - modèle classique
C语言深度解剖——C语言关键字
【ROS】usb_cam相机标定
LeetCode:387. 字符串中的第一个唯一字符
Unified ordering background interface product description Chinese garbled
Promise 在uniapp的简单使用
R language uses the principal function of psych package to perform principal component analysis on the specified data set. PCA performs data dimensionality reduction (input as correlation matrix), cus
移位运算符
Sublime text in CONDA environment plt Show cannot pop up the problem of displaying pictures
项目连接数据库遇到的问题及解决
个人电脑好用必备软件(使用过)
LeetCode:剑指 Offer 03. 数组中重复的数字
[embedded] cortex m4f DSP Library
Guangzhou will promote the construction of a child friendly city, and will explore the establishment of a safe area 200 meters around the school
How to effectively conduct automated testing?
Report on Market Research and investment prospects of China's silver powder industry (2022 Edition)
Leetcode: Sword Finger offer 42. Somme maximale des sous - tableaux consécutifs
The harm of game unpacking and the importance of resource encryption
LeetCode:236. 二叉树的最近公共祖先