This is an automated email from the ASF dual-hosted git repository. min pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/dubbo-website.git
The following commit(s) were added to refs/heads/asf-site by this push: new 9416627 Add Nacos registry center page. (#380) 9416627 is described below commit 941662745221ace82e600e38b5983da6f27983f1 Author: Fury Zhu <fury....@nkorange.com> AuthorDate: Tue May 28 17:43:05 2019 +0800 Add Nacos registry center page. (#380) --- docs/en-us/user/references/registry/nacos.md | 122 +++++++++++++++++++++++++ docs/zh-cn/user/references/registry/nacos.md | 129 +++++++++++++++++++++++++++ site_config/docs.js | 8 ++ 3 files changed, 259 insertions(+) diff --git a/docs/en-us/user/references/registry/nacos.md b/docs/en-us/user/references/registry/nacos.md new file mode 100644 index 0000000..ef8707f --- /dev/null +++ b/docs/en-us/user/references/registry/nacos.md @@ -0,0 +1,122 @@ +# Nacos Registry Center + +Nacos is a very important registry center for Dubbo ecosystem, [`dubbo-registry-nacos`](https://github.com/apache/incubator-dubbo/tree/master/dubbo-registry/dubbo-registry-nacos) is the implementation of Nacos integration to Nacos. + + + +## Prepare Work + +When you integrate [`dubbo-registry-nacos`](https://github.com/apache/incubator-dubbo/tree/master/dubbo-registry/dubbo-registry-nacos) into your Dubbo project, please Make sure the Nacos service is started in the background. If you are not familiar with the basic use of Nacos, you can refer to [Nacos Quick Start](https://nacos.io/en-us/docs/quick-start.html). It is recommended to use the version equal or above Nacos `1.0.0`. + + +## Quick Start + +The steps for Dubbo to integrate Nacos as a registry center are very simple. The general steps can be divided into "add Maven dependencies" and "configure registry center". + + +### Add Maven Dependencies + +First, you need to add the `dubbo-registry-nacos` Maven dependency to your project's `pom.xml` file, and we strongly recommend that you use Dubbo `2.6.5`: + + +```xml +<dependencies> + + ... + + <!-- Dubbo Nacos registry dependency --> + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>dubbo-registry-nacos</artifactId> + <version>0.0.2</version> + </dependency> + + <!-- Keep latest Nacos client version --> + <dependency> + <groupId>com.alibaba.nacos</groupId> + <artifactId>nacos-client</artifactId> + <version>[0.6.1,)</version> + </dependency> + + <!-- Dubbo dependency --> + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>dubbo</artifactId> + <version>2.6.5</version> + </dependency> + + <!-- Alibaba Spring Context extension --> + <dependency> + <groupId>com.alibaba.spring</groupId> + <artifactId>spring-context-support</artifactId> + <version>1.0.2</version> + </dependency> + + ... + +</dependencies> +``` + +When you add `dubbo-registry-nacos` to your project, you don't need to explicitly program the service discovery and registration logic. The actual implementation is provided by the three-party package. + + +### Configure Registry Center + +Assuming your Dubbo app uses the Spring Framework assembly, there are two configuration options available: [Dubbo Spring Externalization Configuration](https://mercyblitz.github.io/2018/01/18/Dubbo-%E5% A4%96%E9%83%A8%E5%8C%96%E9%85%8D%E7%BD%AE/) and the Spring XML configuration file. + + +### [Dubbo Spring Externalization Configuration](https://mercyblitz.github.io/2018/01/18/Dubbo-%E5%A4%96%E9%83%A8%E5%8C%96%E9%85%8D%E7%BD%AE/) + + +The Dubbo Spring externalization configuration is a new feature introduced by Dubbo `2.5.8` that automatically generates and binds Dubbo configuration beans through the Spring `Environment` property, simplifying configuration and lowering the microservice development threshold. + +Assuming your Nacos Server is also running on server `10.20.153.10` and using the default Nacos service port `8848`, you only need to adjust the `dubbo.registry.address` property as follows: + + +```properties +## Other properties remain unchanged + +## Nacos registry address +dubbo.registry.address = nacos://10.20.153.10:8848 +... +``` + +Then, restart your Dubbo app, Dubbo's service provider and consumer information can be displayed on the Nacos console: + +![image-20181213103845976](../../../../../img/blog/dubbo-registry-nacos-1.png) + + +As shown in the figure, the information whose service name prefix is `providers:` is the meta information of the service provider, and the `consumers:` represents the meta information of the service consumer. Click on "**Details**" to view service status details: + +![image-20181213104145998](../../../../../img/blog/dubbo-registry-nacos-2.png) + + + +If you are using the Spring XML configuration file to assemble the Dubbo registry, please refer to the next section. + + + +### Spring XML Configuration File + +Similar to [Dubbo Spring Externalization Configuration](https://mercyblitz.github.io/2018/01/18/Dubbo-%E5%A4%96%E9%83%A8%E5%8C%96%E9%85%8D%E7%BD%AE/), just adjust the `address` attribute to configure: + +```xml +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:dubbo="http://dubbo.apache.org/schema/dubbo" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"> + + <!-- Provider application information for calculating dependencies --> + <dubbo:application name="dubbo-provider-xml-demo" /> + + <!-- Use Nacos as Registry Center --> + <dubbo:registry address="nacos://10.20.153.10:8848" /> + ... +</beans> +``` + + +After restarting the Dubbo app, you can also find that the registration meta-information of the service provider and consumer is presented on the Nacos console: + +![image-20181213113049185](../../../../../img/blog/dubbo-registry-nacos-3.png) diff --git a/docs/zh-cn/user/references/registry/nacos.md b/docs/zh-cn/user/references/registry/nacos.md new file mode 100644 index 0000000..f6142ee --- /dev/null +++ b/docs/zh-cn/user/references/registry/nacos.md @@ -0,0 +1,129 @@ +# Nacos 注册中心 + +Nacos 作为 Dubbo 生态系统中重要的注册中心实现,其中 [`dubbo-registry-nacos`](https://github.com/apache/incubator-dubbo/tree/master/dubbo-registry/dubbo-registry-nacos) 则是 Dubbo 融合 Nacos 注册中心的实现。 + + + +## 预备工作 + +当您将 [`dubbo-registry-nacos`](https://github.com/apache/incubator-dubbo/tree/master/dubbo-registry/dubbo-registry-nacos) 整合到您的 Dubbo 工程之前,请确保后台已经启动 Nacos 服务。如果您尚且不熟悉 Nacos 的基本使用的话,可先行参考 [Nacos 快速入门](https://nacos.io/en-us/docs/quick-start.html)。建议使用 Nacos `1.0.0` 及以上的版本。 + + + +## 快速上手 + +Dubbo 融合 Nacos 成为注册中心的操作步骤非常简单,大致步骤可分为“增加 Maven 依赖”以及“配置注册中心“。 + + +### 增加 Maven 依赖 + +首先,您需要 `dubbo-registry-nacos` 的 Maven 依赖添加到您的项目中 `pom.xml` 文件中,并且强烈地推荐您使用 Dubbo `2.6.5`: + +```xml +<dependencies> + + ... + + <!-- Dubbo Nacos registry dependency --> + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>dubbo-registry-nacos</artifactId> + <version>0.0.2</version> + </dependency> + + <!-- Keep latest Nacos client version --> + <dependency> + <groupId>com.alibaba.nacos</groupId> + <artifactId>nacos-client</artifactId> + <version>[0.6.1,)</version> + </dependency> + + <!-- Dubbo dependency --> + <dependency> + <groupId>com.alibaba</groupId> + <artifactId>dubbo</artifactId> + <version>2.6.5</version> + </dependency> + + <!-- Alibaba Spring Context extension --> + <dependency> + <groupId>com.alibaba.spring</groupId> + <artifactId>spring-context-support</artifactId> + <version>1.0.2</version> + </dependency> + + ... + +</dependencies> +``` + + + +当项目中添加 `dubbo-registry-nacos` 后,您无需显示地编程实现服务发现和注册逻辑,实际实现由该三方包提供,接下来配置 Naocs 注册中心。 + + + +### 配置注册中心 + +假设您 Dubbo 应用使用 Spring Framework 装配,将有两种配置方法可选,分别为:[Dubbo Spring 外部化配置](https://mercyblitz.github.io/2018/01/18/Dubbo-%E5%A4%96%E9%83%A8%E5%8C%96%E9%85%8D%E7%BD%AE/)以及 Spring XML 配置文件以及 ,推荐前者。 + + +### [Dubbo Spring 外部化配置](https://mercyblitz.github.io/2018/01/18/Dubbo-%E5%A4%96%E9%83%A8%E5%8C%96%E9%85%8D%E7%BD%AE/) + +Dubbo Spring 外部化配置是由 Dubbo `2.5.8` 引入的新特性,可通过 Spring `Environment` 属性自动地生成并绑定 Dubbo 配置 Bean,实现配置简化,并且降低微服务开发门槛。 + +假设您的 Nacos Server 同样运行在服务器 `10.20.153.10` 上,并使用默认 Nacos 服务端口 `8848`,您只需将 `dubbo.registry.address` 属性调整如下: + + + +```properties +## 其他属性保持不变 + +## Nacos registry address +dubbo.registry.address = nacos://10.20.153.10:8848 +... +``` + + + +随后,重启您的 Dubbo 应用,Dubbo 的服务提供和消费信息在 Nacos 控制台中可以显示: + +![image-20181213103845976](../../../../../img/blog/dubbo-registry-nacos-1.png) + + + +如图所示,服务名前缀为 `providers:` 的信息为服务提供者的元信息,`consumers:` 则代表服务消费者的元信息。点击“**详情**”可查看服务状态详情: + +![image-20181213104145998](../../../../../img/blog/dubbo-registry-nacos-2.png) + + + +如果您正在使用 Spring XML 配置文件装配 Dubbo 注册中心的话,请参考下一节。 + + + +### Spring XML 配置文件 + +与 [Dubbo Spring 外部化配置](https://mercyblitz.github.io/2018/01/18/Dubbo-%E5%A4%96%E9%83%A8%E5%8C%96%E9%85%8D%E7%BD%AE/) 配置类似,只需要调整 `address` 属性配置即可: + +```xml +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:dubbo="http://dubbo.apache.org/schema/dubbo" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd"> + + <!-- 提供方应用信息,用于计算依赖关系 --> + <dubbo:application name="dubbo-provider-xml-demo" /> + + <!-- 使用 Nacos 注册中心 --> + <dubbo:registry address="nacos://10.20.153.10:8848" /> + ... +</beans> +``` + + + +重启 Dubbo 应用后,您同样也能发现服务提供方和消费方的注册元信息呈现在 Nacos 控制台中: + +![image-20181213113049185](../../../../../img/blog/dubbo-registry-nacos-3.png) diff --git a/site_config/docs.js b/site_config/docs.js index ead9464..e2623e3 100644 --- a/site_config/docs.js +++ b/site_config/docs.js @@ -365,6 +365,10 @@ export default { link: '/en-us/docs/user/references/registry/zookeeper.html', }, { + title: 'Nacos registry', + link: '/en-us/docs/user/references/registry/nacos.html', + }, + { title: 'Redis registry', link: '/en-us/docs/user/references/registry/redis.html', }, @@ -969,6 +973,10 @@ export default { link: '/zh-cn/docs/user/references/registry/zookeeper.html', }, { + title: 'Nacos 注册中心', + link: '/zh-cn/docs/user/references/registry/nacos.html', + }, + { title: 'Redis 注册中心', link: '/zh-cn/docs/user/references/registry/redis.html', },