Skip to content

Commit

Permalink
Refactor and improve config doc of Dubbo 3 (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylixs committed Aug 2, 2021
1 parent 291484d commit 12893d4
Show file tree
Hide file tree
Showing 12 changed files with 846 additions and 360 deletions.
65 changes: 59 additions & 6 deletions content/zh/docs/concepts/configuration.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,60 @@
---
type: docs
title: "配置管理"
linkTitle: "配置"
weight: 4
description: "描述 Dubbo 支持的配置,Dubbo 的动态配置能力。"
---
type: docs
title: "配置管理"
linkTitle: "配置"
weight: 4
description: "描述 Dubbo 支持的配置,Dubbo 的动态配置能力。"
---

Dubbo配置主要分为几大类: 启动阶段配置项、服务治理规则、动态配置项。

## 启动阶段配置项
Dubbo启动时读取的配置项,用于初始化各个组件,不会监听这些配置项的变化。

Dubbo的配置来源有多种,配置项划分为多个配置组件,详细请参考 [配置概述](../../references/configuration/overview)

### 配置方式
按照编程方式可以分为四种方式:API配置、XML配置、Annotation配置、属性配置。

#### API配置
以Java编码的方式组织配置,包括Raw API和Bootstrap API,具体请参考[API配置](../../references/configuration/api)

#### XML配置
以XML方式配置各种组件,支持与Spring无缝集成,具体请参考[XML配置](../../references/configuration/xml)

#### Annotation配置
以注解方式暴露服务和引用服务接口,支持与Spring无缝集成,具体请参考[Annotation配置](../../references/configuration/annotation)

#### 属性配置
根据Key-value属性生成配置组件,类似SpringBoot的ConfigurationProperties,具体请参考[属性配置](../../references/configuration/properties)

属性配置的另外一个重要的功能特性是[属性覆盖](../../references/configuration/properties#属性覆盖),使用外部属性的值覆盖已创建的配置组件属性。

如果要将属性配置放到外部的配置中心,请参考[外部化配置](../../references/configuration/external-config)


## 服务治理规则
服务治理规则主要作用是改变运行时服务的行为和选址逻辑,达到限流,权重配置等目的,包括覆盖规则、标签路由、条件路由、条件路由。

Dubbo启动后监听服务治理相关的配置项,当配置发生变化时,会自动进行相应的处理。

服务治理规则的用法介绍请参考 [服务治理和配置管理](../../references/governance)

服务治理规则的存储方法请参考 [配置中心#服务治理](../../references/config-center#服务治理)

## 动态配置项
动态配置项一般用于控制动态开关。

Dubbo启动后监听动态配置项,当配置发生变化时,会自动进行相应的处理。

动态配置的存储方式请参考 [配置中心#动态配置](../../references/config-center#动态配置)

常用的动态配置项如下:

**[TODO 补充动态配置项说明]**

| 名称 | 描述 | 默认值|
| -----| ---- | ----|
| dubbo.application.migration.threshold | | |
| dubbo.application.service-discovery.migration | | |

80 changes: 80 additions & 0 deletions content/zh/docs/references/config-center.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
type: docs
title: "配置中心参考手册"
linkTitle: "配置中心"
weight: 2
description: "Dubbo 配置中心参考手册"
---

配置中心在 Dubbo 中承担3个职责:

1. 外部化配置:启动配置的集中式存储 (简单理解为 dubbo.properties 的外部化存储)。
2. 服务治理:服务治理规则的存储与通知。
3. 动态配置:控制动态开关或者动态变更属性值

启用动态配置,以 Zookeeper 为例,可查看 [配置中心属性详解](../../references/xml/dubbo-config-center)

```xml
<dubbo:config-center address="zookeeper://127.0.0.1:2181"/>
```

或者

```properties
dubbo.config-center.address=zookeeper://127.0.0.1:2181
```

或者

```java
ConfigCenterConfig configCenter = new ConfigCenterConfig();
configCenter.setAddress("zookeeper://127.0.0.1:2181");
```

> 为了兼容 2.6.x 版本配置,在使用 Zookeeper 作为注册中心,且没有显示配置配置中心的情况下,Dubbo 框架会默认将此 Zookeeper 用作配置中心,但将只作服务治理用途。
## 外部化配置
请参考文档 [外部化配置](../configuration/external-config)

## 动态配置
[TODO 待完善]

## 服务治理

#### Zookeeper

默认节点结构:

![zk-configcenter-governance](/imgs/user/zk-configcenter-governance.jpg)

- namespace,用于不同配置的环境隔离。
- config,Dubbo 约定的固定节点,不可更改,所有配置和服务治理规则都存储在此节点下。
- dubbo,所有服务治理规则都是全局性的,dubbo 为默认节点
- configurators/tag-router/condition-router/migration,不同的服务治理规则类型,node value 存储具体规则内容

#### Apollo

所有的服务治理规则都是全局性的,默认从公共命名空间 `dubbo` 读取和订阅:

![apollo-configcenter-governance.jpg](/imgs/user/apollo-configcenter-governance.jpg)

不同的规则以不同的 key 后缀区分:

- configurators,[覆盖规则](../../examples/config-rule)
- tag-router,[标签路由](../../examples/routing-rule)
- condition-router,[条件路由](../../examples/condition-router)
- migration, [迁移规则](../../examples/todo)

#### Nacos

所有的服务治理规则都是全局的,默认从 namespace: `public` 下进行读取, 通过 dataId: `interface name` 以及 group: `dubbo` 去读取和订阅:

![nacos-configcenter-governance.jpg](/imgs/user/nacos-configcenter-governance.png)

不同的规则以 dataId 的后缀区分:

- configurators,[覆盖规则](../../examples/config-rule)
- tag-router,[标签路由](../../examples/routing-rule)
- condition-router,[条件路由](../../examples/condition-router)
- migration, [迁移规则](../../examples/todo)

2 changes: 1 addition & 1 deletion content/zh/docs/references/configuration/annotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
type: docs
title: "注解配置"
linkTitle: "注解配置"
weight: 4
weight: 40
description: "以注解配置的方式来配置你的 Dubbo 应用"
---

Expand Down
Loading

0 comments on commit 12893d4

Please sign in to comment.