nacos 简述 安装&运行

一、下载

官网:Redirecting to: https://nacos.io/

文档:Nacos 快速开始

github地址:GitHub - alibaba/nacos: an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.

下载nacos server(tips:也可以选择其他下载方式)

版本映射关系:版本说明 · alibaba/spring-cloud-alibaba Wiki · GitHub

https://github.com/alibaba/spring-cloud-alibaba/wiki/版本说明

Spring Cloud Alibaba Version

Sentinel Version

Nacos Version

RocketMQ Version

Dubbo Version

Seata Version

2022.0.0.0-RC2

1.8.6

2.2.1

4.9.4

~

1.7.0-native-rc2

2021.0.5.0

1.8.6

2.2.0

4.9.4

~

1.6.1

2.2.10-RC1

1.8.6

2.2.0

4.9.4

~

1.6.1

2022.0.0.0-RC1

1.8.6

2.2.1-RC

4.9.4

~

1.6.1

2.2.9.RELEASE

1.8.5

2.1.0

4.9.4

~

1.5.2

2021.0.4.0

1.8.5

2.0.4

4.9.4

~

1.5.2

2.2.8.RELEASE

1.8.4

2.1.0

4.9.3

~

1.5.1

2021.0.1.0

1.8.3

1.4.2

4.9.2

~

1.4.2

2.2.7.RELEASE

1.8.1

2.0.3

4.6.1

2.7.13

1.3.0

2.2.6.RELEASE

1.8.1

1.4.2

4.4.0

2.7.8

1.3.0

2021.1 or 2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE

1.8.0

1.4.1

4.4.0

2.7.8

1.3.0

2.2.3.RELEASE or 2.1.3.RELEASE or 2.0.3.RELEASE

1.8.0

1.3.3

4.4.0

2.7.8

1.3.0

2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE

1.7.1

1.2.1

4.4.0

2.7.6

1.2.0

2.2.0.RELEASE

1.7.1

1.1.4

4.4.0

2.7.4.1

1.0.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

window环境:startup.cmd、shutdown.cmd

Linux环境:startup.sh、shutdown.sh

二、安装

Linux

解压压缩包

## 解压安装包,这里下载的是2.2.2版本的包 tar -zxvf nacos-server-2.2.2.tar.gz

解压时可以指定名字

window

window环境下nacos需要安装jdk环境并设置JAVA_HOME环境变量供cmd文件使用

window下单击启动可以对startup.cmd文件做修改

@echo off
rem Copyright 1999-2018 Alibaba Group Holding Ltd.
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem      http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! & EXIT /B 1
set "JAVA=%JAVA_HOME%\bin\java.exe"

setlocal enabledelayedexpansion

set BASE_DIR=%~dp0
rem added double quotation marks to avoid the issue caused by the folder names containing spaces.
rem removed the last 5 chars(which means \bin\) to get the base DIR.
set BASE_DIR="%BASE_DIR:~0,-5%"

set CUSTOM_SEARCH_LOCATIONS=file:%BASE_DIR%/conf/

rem danji or jiqun >> standalone or cluster
rem set MODE="cluster"
set MODE="standalone"
set FUNCTION_MODE="all"
set SERVER=nacos-server
set MODE_INDEX=-1
set FUNCTION_MODE_INDEX=-1
set SERVER_INDEX=-1
set EMBEDDED_STORAGE_INDEX=-1
set EMBEDDED_STORAGE=""


set i=0
for %%a in (%*) do (
    if "%%a" == "-m" ( set /a MODE_INDEX=!i!+1 )
    if "%%a" == "-f" ( set /a FUNCTION_MODE_INDEX=!i!+1 )
    if "%%a" == "-s" ( set /a SERVER_INDEX=!i!+1 )
    if "%%a" == "-p" ( set /a EMBEDDED_STORAGE_INDEX=!i!+1 )
    set /a i+=1
)

set i=0
for %%a in (%*) do (
    if %MODE_INDEX% == !i! ( set MODE="%%a" )
    if %FUNCTION_MODE_INDEX% == !i! ( set FUNCTION_MODE="%%a" )
    if %SERVER_INDEX% == !i! (set SERVER="%%a")
    if %EMBEDDED_STORAGE_INDEX% == !i! (set EMBEDDED_STORAGE="%%a")
    set /a i+=1
)

rem if nacos startup mode is standalone
if %MODE% == "standalone" (
    echo "nacos is starting with standalone"
      set "NACOS_OPTS=-Dnacos.standalone=true"
    set "NACOS_JVM_OPTS=-Xms512m -Xmx512m -Xmn256m"
)

rem if nacos startup mode is cluster
if %MODE% == "cluster" (
    echo "nacos is starting with cluster"
      if %EMBEDDED_STORAGE% == "embedded" (
          set "NACOS_OPTS=-DembeddedStorage=true"
      )

    set "NACOS_JVM_OPTS=-server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%BASE_DIR%\logs\java_heapdump.hprof -XX:-UseLargePages"
)

rem set nacos's functionMode
if %FUNCTION_MODE% == "config" (
    set "NACOS_OPTS=%NACOS_OPTS% -Dnacos.functionMode=config"
)

if %FUNCTION_MODE% == "naming" (
    set "NACOS_OPTS=%NACOS_OPTS% -Dnacos.functionMode=naming"
)

rem set nacos options
set "NACOS_OPTS=%NACOS_OPTS% -Dloader.path=%BASE_DIR%/plugins,%BASE_DIR%/plugins/health,%BASE_DIR%/plugins/cmdb,%BASE_DIR%/plugins/selector"
set "NACOS_OPTS=%NACOS_OPTS% -Dnacos.home=%BASE_DIR%"
set "NACOS_OPTS=%NACOS_OPTS% -jar %BASE_DIR%\target\%SERVER%.jar"

rem set nacos spring config location
set "NACOS_CONFIG_OPTS=--spring.config.additional-location=%CUSTOM_SEARCH_LOCATIONS%"

rem set nacos log4j file location
set "NACOS_LOG4J_OPTS=--logging.config=%BASE_DIR%/conf/nacos-logback.xml"


set COMMAND="%JAVA%" %NACOS_JVM_OPTS% %NACOS_OPTS% %NACOS_CONFIG_OPTS% %NACOS_LOG4J_OPTS% nacos.nacos %*

rem start nacos command
%COMMAND%

rem not exit cmd window after start
cmd /k

三、运行nacos

nacos可以单机模式运行也可集群模式

在0.7版本前单机模式使用的是内嵌数据库,0.7版本后增加了mysql数据源的支持能力

安装mysql数据库

初始化数据库,执行config/mysql-schema.sql创建响应的表

修改config/application.properties文件,配置mysql数据源

一、单机模式使用:
## 指定单机模式 
sh startup.sh -m standalone
二、集群模式

准备不同的nacos服务

可以使用多个机器,没有条件就使用单个机器不同端口模拟,但可能出现服务端之间通信端口的问题,最好用多个机器模拟


同样集群模式下修改config/application.properties文件增加数据源配置

修改cluster.conf配置文件中机器的ip:port用来对应不同的nacos服务器

## 默认集群模式启动 
sh startup.sh

登录浏览器访问对应的nacos服务器

http://ip:port/context >>>> http://ip地址:服务端口(默认是8848)/服务名(默认是nacos)

地址中的端口服务名都可以在application.properties中修改

三、登录查看

http://ip:port/nacos

http://ip:8848/nacos

nacos在Linux环境下安装icon-default.png?t=N7T8http://t.csdnimg.cn/TiT6N 

  • 7
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Raphael-laq

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值