linux-tutorial/docs/linux/soft/nacos-install.md
2019-05-10 18:35:33 +08:00

104 lines
2.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Nacos 安装配置
> [Nacos](https://nacos.io/zh-cn/) 是一款发现、配置和管理微服务的软件。
## 1.预备环境准备
Nacos 依赖 [Java](https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/) 环境来运行。如果您是从代码开始构建并运行Nacos还需要为此配置 [Maven](https://maven.apache.org/index.html)环境,请确保是在以下版本环境中安装使用:
1. 64 bit OS支持 Linux/Unix/Mac/Windows推荐选用 Linux/Unix/Mac。
2. 64 bit JDK 1.8+[下载](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) & [配置](https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/)。
3. Maven 3.2.x+[下载](https://maven.apache.org/download.cgi) & [配置](https://maven.apache.org/settings.html)。
## 2.下载源码或者安装包
你可以通过源码和发行包两种方式来获取 Nacos。
### 从 Github 上下载源码方式
```bash
git clone https://github.com/alibaba/nacos.git
cd nacos/
mvn -Prelease-nacos clean install -U
ls -al distribution/target/
// change the $version to your actual path
cd distribution/target/nacos-server-$version/nacos/bin
```
### 下载编译后压缩包方式
您可以从 [最新稳定版本](https://github.com/alibaba/nacos/releases) 下载 `nacos-server-$version.zip` 包。
```bash
unzip nacos-server-$version.zip 或者 tar -xvf nacos-server-$version.tar.gz
cd nacos/bin
```
## 3.启动服务器
### Linux/Unix/Mac
启动命令(standalone代表着单机模式运行非集群模式):
```
sh startup.sh -m standalone
```
### Windows
启动命令:
```
cmd startup.cmd
```
或者双击startup.cmd运行文件。
## 4.服务注册&发现和配置管理
### 服务注册
```
curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&ip=20.18.7.10&port=8080'
```
### 服务发现
```
curl -X GET 'http://127.0.0.1:8848/nacos/v1/ns/instances?serviceName=nacos.naming.serviceName'
```
### 发布配置
```
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test&content=HelloWorld"
```
### 获取配置
```
curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test"
```
## 5.关闭服务器
### Linux/Unix/Mac
```
sh shutdown.sh
```
### Windows
```
cmd shutdown.cmd
```
或者双击shutdown.cmd运行文件。
## 参考资料
- [Nacos Quick Start](https://nacos.io/zh-cn/docs/quick-start.html)