Nacos概述及安装

Nacos是什么?
在Spring Cloud中咱们使用eureka、consul等作为服务注册中心,使用Spring Cloud Config作为配置中心。而Spring Cloud中,也可使用nacos组件便可完成服务注册发现与服务配置两大功能。
经过Nacos Server和spring-cloud-starter-alibaba-nacos-config实现配置的动态变动,实现Spring Cloud应用程序的外部化配置。
经过Nacos Server和spring-cloud-starter-alibaba-nacos-discovery实现服务的注册与发现。
 
Nacos致力于帮助您发现、配置和管理微服务。Nacos提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。Nacos Config Starter。
Nacos官网:https://nacos.io/zh-cn/index.html
Nacos 具备以下特性:
(1)服务发现和服务健康监测:支持基于DNS和基于RPC的服务发现,支持对服务的实时的健康检查,阻止向不健康的主机或服务实例发送请求;
(2)动态配置服务:动态配置服务可让您以中心化、外部化和动态化的方式管理全部环境的应用配置和服务配置;
(3)动态 DNS 服务:动态 DNS 服务支持权重路由,让您更容易地实现中间层负载均衡、更灵活的路由策略、流量控制以及数据中心内网的简单DNS解析服务;
(4)服务及其元数据管理:支持从微服务平台建设的视角管理数据中心的全部服务及元数据。
Spring Cloud Alibaba各组件版本关系
Spring Cloud Alibaba Version Sentinel Version Nacos Version RocketMQ Version Dubbo Version Seata Version
2.2.1.RELEASE 1.7.1 1.2.1 4.4.0 2.7.6 1.1.0
2.2.0.RELEASE 1.7.1 1.1.4 4.4.0 2.7.4.1 1.0.0
2.1.2.RELEASE or 2.0.2.RELEASE 1.7.1 1.2.1 4.4.0 2.7.6 1.1.0
2.1.1.RELEASE or 2.0.1.RELEASE or 1.5.1.RELEASE 1.7.0 1.1.4 4.4.0 2.7.3 0.9.0
2.1.0.RELEASE or 2.0.0.RELEASE or 1.5.0.RELEASE 1.6.3 1.1.1 4.4.0 2.7.3 0.7.1
毕业版本依赖关系
Spring Cloud Version Spring Cloud Alibaba Version Spring Boot Version
Spring Cloud Hoxton.SR3 2.2.1.RELEASE 2.2.5.RELEASE
Spring Cloud Hoxton.RELEASE 2.2.0.RELEASE 2.2.X.RELEASE
Spring Cloud Greenwich 2.1.2.RELEASE 2.1.X.RELEASE
Spring Cloud Finchley 2.0.2.RELEASE 2.0.X.RELEASE
Spring Cloud Edgware 1.5.1.RELEASE 1.5.X.RELEASE

此次项目中咱们用的alibaba版本是2.2.1.REALEASE,所以各组件的版本与之对应,在实际应用中请务必使用与Spring Cloud Alibaba版本相对应的Spring Cloud版本和Spring Boot版本。html

 

预备环境准备
Nacos依赖Java环境来运行。若是您是从源码开始构建并运行Nacos,还须要为此配置Maven环境。请确保是在如下版本环境中安装使用:
(1)64 bit OS,支持Linux/Unix/Mac/Windows,推荐选用Linux/Unix/Mac。
(2)64 bit JDK 1.8+。
(3)Maven 3.2.x+。
下载nacos源码或者nacos安装包
你能够经过源码和发行包两种方式来下载Nacos。
(1)从Github上下载源码方式:
git clone https://github.com/alibaba/nacos.git
cd nacos/
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U  
ls -al distribution/target/

// change the $version to your actual path
cd distribution/target/nacos-server-$version/nacos/bin

(2)下载编译后的压缩包方式git

您能够从最新稳定版本下载nacos-server-$version.zip包。下载地址:https://github.com/alibaba/nacos/releases
//解压安装包
unzip nacos-server-$version.zip
或者 tar -xvf nacos-server-$version.tar.gz cd nacos/bin

安装nacosgithub

nacos支持的三种模式:spring

单机模式 - 用于测试和单机试用。ubuntu

集群模式 - 用于生产环境,确保高可用。windows

多集群模式 - 用于多数据中心场景。bash

如下选择使用单机模式(standalone)进行安装。服务器

(1)安装nacos,启动nacos服务器markdown

先解压下载包,而后选择一下一种启动nacos服务器的方式。负载均衡

Linux/Unix/Mac下启动命令: 
sh startup.sh -m standalone
#若是您使用的是ubuntu系统,或者运行脚本报错提示[[符号找不到,可尝试以下运行:
bash startup.sh -m standalone

Windows下启动命令:

cmd startup.cmd -m standalone

Windows下点击启动文件启动:下载完成后解压,咱们发现bin目录下有两个启动文件,stratup.cmd 和 startup.sh。打开这两个文件咱们发现startup.cmd默认支持的是单机模式,startup.sh默认支持的是集群模式。咱们双击运行startup.cmd。

注意:
命令中的standalone表明着单机模式运行,非集群模式。
windows下运行启动命令要以超级管理员身份运行,不然将启动失败。双击运行startup.cmd也同样,当前登陆的用户要是超级管理员。因此最好仍是cmd中运行命令行靠谱。

 

 普通用户运行会出现以下错误,致使启动失败。

 

若是启动失败,能够从nacos按照目录/logs/nacos.log文件查看具体错误。

(2)访问http://127.0.0.1:8848/nacos/index.html,若是出现如下界面则安装正常。
nacos默认端口是:8848
默认用户名:nacos
默认密码:nacos

相关文章
相关标签/搜索