This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-docs.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f3adcd  Add usage documentation for consul's registry and 
configuration centers (#357)
5f3adcd is described below

commit 5f3adcde6b9e954efd0c44011df6fd86515f6ab6
Author: felixgis14 <[email protected]>
AuthorDate: Tue Jan 7 09:24:49 2025 +0800

    Add usage documentation for consul's registry and configuration centers 
(#357)
---
 java-chassis-reference/zh_CN/docs/config/consul.md | 88 ++++++++++++++++++++++
 .../zh_CN/docs/registry/consul.md                  | 47 ++++++++++++
 java-chassis-reference/zh_CN/mkdocs.yml            |  2 +
 3 files changed, 137 insertions(+)

diff --git a/java-chassis-reference/zh_CN/docs/config/consul.md 
b/java-chassis-reference/zh_CN/docs/config/consul.md
new file mode 100644
index 0000000..e6fa8dd
--- /dev/null
+++ b/java-chassis-reference/zh_CN/docs/config/consul.md
@@ -0,0 +1,88 @@
+# 使用 consul
+
+可以通过 
[Consul官网](https://developer.hashicorp.com/consul/install?product_intent=consul)
 下载和安装 Consul。
+
+
+## 开发使用
+使用Consul需要确保下面的软件包引入:
+
+```xml
+<dependency>
+  <groupId>org.apache.servicecomb</groupId>
+  <artifactId>config-consul</artifactId>
+  <version>x.x.x</version>
+</dependency>
+```
+
+然后在配置文件 applcation.yml 中增加如下配置项:
+```yaml
+servicecomb:
+  config:
+    consul:
+      enabled: true
+      host: localhost
+      port: 8500
+      acl-token: ''
+      watch-seconds: 8
+```
+* 配置项说明
+
+| 配置项                                             | 默认值         | 是否必选 | 含义    
                        |
+|:--------------------------------------------------|:---------------|:-----|:-----------------------------------|
+| servicecomb.config.consul.enabled                 | true           | 是   | 
是否启用consul。                   |
+| servicecomb.config.consul.host                    | localhost      | 是   | 
consul的ip                        |
+| servicecomb.config.consul.port                    | 8500           | 是   | 
consul的端口
+| servicecomb.config.consul.acl-token               | null           | 否   | 
当服务端启用ACL认证后,必须设置该值   |
+| servicecomb.config.consul.watch-seconds           | 8              | 是   | 
监听配置更新检查频率,在1-9之间,单位秒 |
+
+* 说明
+ACL的开启参考注册中心Consul的ACL开启步骤
+
+* 配置中心增加配置
+
+consul 
使用下面的配置结构和环境(Environment)、应用(Application)、服务(Service)、版本(Version)、Tag对应, 
配置级别优先级从低到高。
+
+```yaml
+servicecomb:
+  config:
+    environment:
+      ${environment}:
+        exampleText: exampleTextValue
+        exampleYaml.yaml: exampleYamlValue
+        exampleYaml.yml: exampleYamlValue
+        exampleProperties.properties: examplePropertiesValue
+    application:
+      ${environment}:
+        ${application}:
+          exampleText: exampleTextValue
+          exampleYaml.yaml: exampleYamlValue
+          exampleYaml.yml: exampleYamlValue
+          exampleProperties.properties: examplePropertiesValue
+    service:
+      ${environment}:
+        ${application}:
+          ${service}:
+            exampleText: exampleTextValue
+            exampleYaml.yaml: exampleYamlValue
+            exampleYaml.yml: exampleYamlValue
+            exampleProperties.properties: examplePropertiesValue
+    version:
+      ${environment}:
+        ${application}:
+          ${service}:
+            ${version}:
+              exampleText: exampleTextValue
+              exampleYaml.yaml: exampleYamlValue
+              exampleYaml.yml: exampleYamlValue
+              exampleProperties.properties: examplePropertiesValue
+    tag:
+      ${environment}:
+        ${application}:
+          ${service}:
+            ${version}:
+              ${tag}:
+                exampleText: exampleTextValue
+                exampleYaml.yaml: exampleYamlValue
+                exampleYaml.yml: exampleYamlValue
+                exampleProperties.properties: examplePropertiesValue
+```
\ No newline at end of file
diff --git a/java-chassis-reference/zh_CN/docs/registry/consul.md 
b/java-chassis-reference/zh_CN/docs/registry/consul.md
new file mode 100644
index 0000000..5585c77
--- /dev/null
+++ b/java-chassis-reference/zh_CN/docs/registry/consul.md
@@ -0,0 +1,47 @@
+# 使用 consul
+
+可以通过 
[Consul官网](https://developer.hashicorp.com/consul/install?product_intent=consul)
 下载和安装 Consul。
+
+使用Consul需要确保下面的软件包引入:
+
+```xml
+<dependency>
+  <groupId>org.apache.servicecomb</groupId>
+  <artifactId>registry-consul</artifactId>
+  <version>x.x.x</version>
+</dependency>
+```
+
+* 表1-1 访问consul常用的配置项
+
+| 配置项                                             | 默认值         | 是否必选 | 含义    
                        |
+|:--------------------------------------------------|:---------------|:-----|:-----------------------------------|
+| servicecomb.registry.consul.enabled               | true           | 是    | 
是否启用consul                    |
+| servicecomb.registry.consul.host                  | localhost      | 是    | 
consul的ip                        |
+| servicecomb.registry.consul.port                  | 8500           | 是    | 
是否注册契约
+| servicecomb.registry.consul.disdovery.enabled     | true           | 是    | 
是否启用服务发现                    |
+| servicecomb.registry.consul.disdovery.acl-token   | null           | 否    | 
当服务端启用ACL认证后,必须设置该值   |
+| servicecomb.registry.consul.disdovery.tags        | 空数组          | 否    | 
服务的标签                         |
+| servicecomb.registry.consul.disdovery.watch-seconds | 8            | 是    | 
监听服务变化的时间频率,在1-9之间,单位秒 |
+
+## Consul开启ACL
+开启Consul ACL的步骤如下:
+
+1. 在各个节点,新建目录,如:config
+1. 在config目录下新建 XXX.hcl
+1. 在XXX.hcl中添加acl的配置
+```
+acl = {
+  enabled = true
+  default_policy = "deny"
+  enable_token_persistence = true
+}
+```
+* 参数说明
+```
+enaled=true 代表开启ACL
+default_policy="deny" 默认为allow,如果需要自定义权限,需要将其设置为deny
+ebale_token_persistence=true 开启token持久化,将token持久化到磁盘上
+```
+1. 服务器端的启动命令添加 -config-data=config目录的绝对或相对路径 的启动参数
+1. 详细步骤可以参考:https://www.cnblogs.com/yucongblog/p/17833634.html
\ No newline at end of file
diff --git a/java-chassis-reference/zh_CN/mkdocs.yml 
b/java-chassis-reference/zh_CN/mkdocs.yml
index d39f9e3..617e286 100644
--- a/java-chassis-reference/zh_CN/mkdocs.yml
+++ b/java-chassis-reference/zh_CN/mkdocs.yml
@@ -72,6 +72,7 @@ nav:
     - 使用Etcd: registry/etcd.md
     - 本地注册发现: registry/local-registry.md
     - 去中心化注册发现: registry/distributed.md
+    - 使用Consul: registry/consul.md
 - 多样化的配置管理功能:
     - 服务配置介绍: config/general-config.md
     - 在程序中读取配置信息: config/read-config.md
@@ -81,6 +82,7 @@ nav:
     - 使用Etcd: config/etcd.md
     - 使用Apollo: config/apollo.md
     - 使用CSE1.0配置中心: config/cse1.md
+    - 使用Consul: config/consul.md
 - 服务治理功能参考:
     - 流量特征治理: references-handlers/rule-governance.md
     - 流量特征治理最佳实践: references-handlers/governance-best-practise.md

Reply via email to