未验证 提交 5d530344 编写于 作者: L Liang Zhang 提交者: GitHub

Update feature/governance document (#5846)

* update index

* update config-center

* update registry-center

* update metadata-center

* update supported-center-repo

* add management url

* update management

* add observability url

* add metrics
上级 51bb74ca
......@@ -5,6 +5,14 @@ weight = 4
chapter = true
+++
## 导览
## 背景
编排治理模块提供配置中心/注册中心/元数据中心、配置动态化、数据库熔断禁用、调用链路等治理能力。
TODO
## 挑战
TODO
## 目标
TODO
......@@ -5,6 +5,14 @@ weight = 4
chapter = true
+++
## Navigation
## Background
Provide governance of config/registry/metadata center, dynamic configuration, database & application disabling, and APM.
TODO
## Challenges
TODO
## Goal
TODO
\ No newline at end of file
+++
pre = "<b>3.4.5. </b>"
title = "应用性能监控集成"
weight = 5
+++
## 背景
`APM`是应用性能监控的缩写。目前`APM`的主要功能着眼于分布式系统的性能诊断,其主要功能包括调用链展示,应用拓扑分析等。
ShardingSphere并不负责如何采集、存储以及展示应用性能监控的相关数据,而是将SQL解析与SQL执行这两块数据分片的最核心的相关信息发送至应用性能监控系统,并交由其处理。
换句话说,ShardingSphere仅负责产生具有价值的数据,并通过标准协议递交至相关系统。ShardingSphere可以通过两种方式对接应用性能监控系统。
第一种方式是使用OpenTracing API发送性能追踪数据。面向OpenTracing协议的APM产品都可以和ShardingSphere自动对接,比如SkyWalking,Zipkin和Jaeger。使用这种方式只需要在启动时配置OpenTracing协议的实现者即可。
它的优点是可以兼容所有的与OpenTracing协议兼容的产品作为APM的展现系统,如果采用公司愿意实现自己的APM系统,也只需要实现OpenTracing协议,即可自动展示ShardingSphere的链路追踪信息。
缺点是OpenTracing协议发展并不稳定,较新的版本实现者较少,且协议本身过于中立,对于个性化的相关产品的实现不如原生支持强大。
第二种方式是使用SkyWalking的自动探针。
[ShardingSphere](https://shardingsphere.apache.org)团队与[SkyWalking](https://skywalking.apache.org)团队共同合作,在`SkyWalking`中实现了`ShardingSphere`自动探针,可以将相关的应用性能数据自动发送到`SkyWalking`中。
## 使用方法
### 使用OpenTracing协议
* 方法1:通过读取系统参数注入APM系统提供的Tracer实现类
启动时添加参数
```
-Dorg.apache.shardingsphere.opentracing.tracer.class=org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer
```
调用初始化方法
```java
ShardingTracer.init();
```
* 方法2:通过参数注入APM系统提供的Tracer实现类
```java
ShardingTracer.init(new SkywalkingTracer());
```
*注意:使用SkyWalking的OpenTracing探针时,应将原ShardingSphere探针插件禁用,以防止两种插件互相冲突*
### 使用SkyWalking自动探针
请参考[SkyWalking部署手册](https://github.com/apache/skywalking/blob/5.x/docs/cn/Quick-start-CN.md)
## 效果展示
无论使用哪种方式,都可以方便的将APM信息展示在对接的系统中,以下以SkyWalking为例。
### 应用架构
使用`ShardingSphere-Proxy`访问两个数据库`192.168.0.1:3306``192.168.0.2:3306`,且每个数据库中有两个分表。
### 拓扑图展示
![拓扑图](https://shardingsphere.apache.org/document/current/img/apm/5x_topology.png)
从图中看,用户访问18次ShardingSphere-Proxy应用,每次每个数据库访问了两次。这是由于每次访问涉及到每个库中的两个分表,所以每次访问了四张表。
### 跟踪数据展示
![跟踪图](https://shardingsphere.apache.org/document/current/img/apm/5x_trace.png)
从跟踪图中可以能够看到SQL解析和执行的情况。
`/Sharding-Sphere/parseSQL/` : 表示本次SQL的解析性能。
![解析节点](https://shardingsphere.apache.org/document/current/img/apm/5x_parse.png)
`/Sharding-Sphere/executeSQL/` : 表示具体执行的实际SQL的性能。
![实际访问节点](https://shardingsphere.apache.org/document/current/img/apm/5x_executeSQL.png)
### 异常情况展示
![异常跟踪图](https://shardingsphere.apache.org/document/current/img/apm/5x_trace_err.png)
从跟踪图中可以能够看到发生异常的节点。
`/Sharding-Sphere/executeSQL/` : 表示执行SQL异常的结果。
![异常节点](https://shardingsphere.apache.org/document/current/img/apm/5x_executeSQL_Tags_err.png)
`/Sharding-Sphere/executeSQL/` : 表示执行SQL异常的日志。
![异常节点日志](https://shardingsphere.apache.org/document/current/img/apm/5x_executeSQL_Logs_err.png)
+++
pre = "<b>3.4.1 </b>"
title = "治理"
weight = 1
chapter = true
+++
## 导览
本小节主要介绍 Apache ShardingSphere 分布式治理的相关功能
* 配置中心
* 注册中心
* 元数据中心
* 第三方组件依赖
+++
pre = "<b>3.4.1 </b>"
title = "Management"
weight = 1
chapter = true
+++
## Navigation
This chapter mainly introduces the features of the distributed governance:
* Config center
* Registry center
* Metadata center
* Third-party components dependency
+++
pre = "<b>3.4.1. </b>"
title = "配置中心"
weight = 1
+++
......@@ -8,35 +7,37 @@ weight = 1
- 配置集中化:越来越多的运行时实例,使得散落的配置难于管理,配置不同步导致的问题十分严重。将配置集中于配置中心,可以更加有效进行管理。
- 配置动态化:配置修改后的分发,是配置中心可以提供的另一个重要能力。它可支持数据源、表与分片及读写分离策略的动态切换。
- 配置动态化:配置修改后的分发,是配置中心可以提供的另一个重要能力。它可支持数据源和规则的动态切换。
## 配置中心数据结构
配置中心在定义的命名空间的config下,以YAML格式存储,包括数据源,数据分片,读写分离、Properties配置,可通过修改节点来实现对于配置的动态管理。
配置中心在定义的命名空间的 `config` 节点下,以 YAML 格式存储,包括数据源信息,规则信息、权限配置和属性配置,可通过修改节点来实现对于配置的动态管理。
```
config
├──authentication # ShardingSphere-Proxy权限配置
├──authentication # 权限配置
├──props # 属性配置
├──schema # Schema配置
├ ├──sharding_db # SchemaName配置
├ ├──schema_1 # Schema名称1
├ ├ ├──datasource # 数据源配置
├ ├ ├──rule # 数据分片规则配置
├ ├──masterslave_db # SchemaName配置
├ ├ ├──rule # 规则配置
├ ├──schema_2 # Schema名称2
├ ├ ├──datasource # 数据源配置
├ ├ ├──rule # 读写分离规则
├ ├ ├──rule # 规则配置
```
### config/authentication
权限配置,可配置访问ShardingSphere-Proxy的用户名和密码。
```yaml
password: root
username: root
password: root
```
### config/sharding/props
### config/props
相对于shardingsphere配置里面的Sharding Properties
属性配置,详情请参见[配置手册](/cn/manual/shardingsphere-jdbc/configuration/)
```yaml
executor.size: 20
......@@ -76,58 +77,20 @@ ds_1: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourc
### config/schema/sharding_db/rule
数据分片配置,包括数据分片 + 读写分离配置。
规则配置,可包括数据分片、读写分离、数据加密、影子库压测、多副本等配置。
```yaml
tables:
t_order:
actualDataNodes: ds_$->{0..1}.t_order_$->{0..1}
databaseStrategy:
inline:
shardingColumn: user_id
algorithmExpression: ds_$->{user_id % 2}
keyGenerator:
column: order_id
logicTable: t_order
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_order_$->{order_id % 2}
t_order_item:
actualDataNodes: ds_$->{0..1}.t_order_item_$->{0..1}
databaseStrategy:
inline:
shardingColumn: user_id
algorithmExpression: ds_$->{user_id % 2}
keyGenerator:
column: order_item_id
logicTable: t_order_item
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_order_item_$->{order_id % 2}
bindingTables:
- t_order,t_order_item
broadcastTables:
- t_config
rules:
- !SHARDING
xxx
defaultDataSourceName: ds_0
masterSlaveRules: {}
```
### config/schema/masterslave/rule
读写分离独立使用时使用该配置。
```yaml
name: ds_ms
masterDataSourceName: ds_master
slaveDataSourceNames:
- ds_slave0
- ds_slave1
loadBalanceAlgorithmType: ROUND_ROBIN
- !MASTERSLAVE
xxx
- !ENCRYPT
xxx
```
## 动态生效
在注册中心上修改、删除、新增相关配置,会动态推送到生产环境并立即生效。
\ No newline at end of file
+++
pre = "<b>3.4.1. </b>"
title = "Config Center"
weight = 1
+++
......@@ -8,35 +7,37 @@ weight = 1
- Centralized configuration: more and more running examples have made it hard to manage separate configurations and asynchronized configurations can cause serious problems. Concentrating them in the configuration center can make the management more effective.
- Dynamic configuration: distribution after configuration modification is another important capability of configuration center. It can support dynamic switch between data sources, tables, shards and the read-write split strategy.
- Dynamic configuration: distribution after configuration modification is another important capability of configuration center. It can support dynamic switch between data sources and rule configurations.
## Data Structure in Configuration Center
## Structure in Configuration Center
Under defined name space config, configuration center stores data sources, sharding databases, sharding tables, read-write split, and properties in YAML. Modifying nodes can dynamically manage configuration.
Under defined namespace `config` node, configuration center stores data sources, rule configurations, authentication configuration, and properties in YAML. Modifying nodes can dynamically refresh configurations.
```
config
├──authentication # ShardingSphere-Proxy authentication configuration
├──authentication # Authentication configuration
├──props # Properties configuration
├──schema # Schema configuration
├ ├──sharding_db # SchemaName configuration
├ ├──schema_1 # Schema name 1
├ ├ ├──datasource # Datasource configuration
├ ├ ├──rule # Sharding rule configuration
├ ├──masterslave_db # SchemaName configuration
├ ├ ├──rule # Rule configuration
├ ├──schema_2 # Schema name 2
├ ├ ├──datasource # Datasource configuration
├ ├ ├──rule # Master-slave rule configuration
├ ├ ├──rule # Rule configuration
```
### config/authentication
Authentication configuration. Can configure username and password for ShardingSphere-Proxy.
```yaml
password: root
username: root
password: root
```
### config/sharding/props
### config/props
It corresponds to Sharding Properties in ShardingSphere configuration.
Properties configuration. Please refer to [Configuration Manual](/en/manual/shardingsphere-jdbc/configuration/) for more details.
```yaml
executor.size: 20
......@@ -76,59 +77,20 @@ ds_1: !!org.apache.shardingsphere.orchestration.core.configuration.YamlDataSourc
### config/schema/sharding_db/rule
It refers to sharding configuration, including sharding + read-write split configuration.
```yaml
tables:
t_order:
actualDataNodes: ds_$->{0..1}.t_order_$->{0..1}
databaseStrategy:
inline:
shardingColumn: user_id
algorithmExpression: ds_$->{user_id % 2}
keyGenerator:
column: order_id
logicTable: t_order
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_order_$->{order_id % 2}
t_order_item:
actualDataNodes: ds_$->{0..1}.t_order_item_$->{0..1}
databaseStrategy:
inline:
shardingColumn: user_id
algorithmExpression: ds_$->{user_id % 2}
keyGenerator:
column: order_item_id
logicTable: t_order_item
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_order_item_$->{order_id % 2}
bindingTables:
- t_order,t_order_item
broadcastTables:
- t_config
defaultDataSourceName: ds_0
masterSlaveRules: {}
```
### config/schema/masterslave/rule
This configuration is used when read-write split is used alone.
Rule configurations, including sharding, read-write split, data encryption, shadow DB, multi replica configurations.
```yaml
name: ds_ms
masterDataSourceName: ds_master
slaveDataSourceNames:
- ds_slave0
- ds_slave1
loadBalanceAlgorithmType: ROUND_ROBIN
rules:
- !SHARDING
xxx
- !MASTERSLAVE
xxx
- !ENCRYPT
xxx
```
## Dynamic Effectiveness
Modification, deletion and insertion of relevant configurations in the registry center will immediately take effect in the producing environment.
Modification, deletion and insertion of relevant configurations in the registry center will immediately take effect in the producing environment.
+++
title = "第三方组件依赖"
weight = 4
+++
Apache ShardingSphere 在数据库治理模块使用 SPI 方式载入数据到配置中心/注册/元数据中心,进行实例熔断和数据库禁用。
目前,Apache ShardingSphere 内部支持 ZooKeeper,Etcd,Apollo 和 Nacos 等常用的配置中心/注册中心。
此外,开发者可以使用其他第三方组件,并通过 SPI 的方式注入到 Apache ShardingSphere,从而使用该配置中心/注册/元数据中心,实现数据库治理功能。
| | *实现驱动* | *版本* | *配置中心* | *注册中心* | *元数据中心* |
| --------------------------------------------- | ---------------------------------------------------- | ------ | ---------- | --------- | ----------- |
| [Zookeeper](https://zookeeper.apache.org/) | [Apache Curator](http://curator.apache.org/) | 3.4.6 | 支持 | 支持 | 支持 |
| [Etcd](https://etcd.io/) | [jetcd](https://github.com/etcd-io/jetcd) | v3 | 支持 | 支持 | 支持 |
| [Apollo](https://github.com/ctripcorp/apollo) | [Apollo Client](https://github.com/ctripcorp/apollo) | 1.5.0 | 支持 | 不支持 | 不支持 |
| [Nacos](https://nacos.io/zh-cn/docs/sdk.html) | [Nacos Client](https://nacos.io/zh-cn/docs/sdk.html) | 1.0.0 | 支持 | 不支持 | 不支持 |
+++
title = "Third-party Components"
weight = 4
+++
Apache ShardingSphere uses SPI to load data to the config center/registry/metadata center and disable instances and databases.
Currently, Apache ShardingSphere supports frequently used registry centers, Zookeeper, Etcd, Apollo and Nacos.
In addition, by injecting them to ShardingSphere with SPI, users can use other third-party config/registry/metadata centers to enable databases orchestration.
| | *Driver* | *Version* | *Config Center* | *Registry Center* | *Metadata Center* |
| --------------------------------------------- | ---------------------------------------------------- | --------- | --------------- | ----------------- | ----------------- |
| [Zookeeper](https://zookeeper.apache.org/) | [Apache Curator](http://curator.apache.org/) | 3.4.6 | Support | Support | Support |
| [Etcd](https://etcd.io/) | [jetcd](https://github.com/etcd-io/jetcd) | v3 | Support | Support | Support |
| [Apollo](https://github.com/ctripcorp/apollo) | [Apollo Client](https://github.com/ctripcorp/apollo) | 1.5.0 | Support | Not Support | Not Support |
| [Nacos](https://nacos.io/zh-cn/docs/sdk.html) | [Nacos Client](https://nacos.io/zh-cn/docs/sdk.html) | 1.0.0 | Support | Not Support | Not Support |
+++
pre = "<b>3.4.3. </b>"
title = "元数据中心"
weight = 3
+++
## 实现动机
- 元数据是ShardingSphere-JDBC/ShardingSphere-Proxy所使用的数据源的表、列和索引等核心数据,元数据保障ShardingSphere各个组件能够正确运行。
- 元数据是 ShardingSphere 所使用的数据源的表、列和索引等核心数据,元数据保障 ShardingSphere 各个组件能够正确运行。
- 元数据中心对元数据进行统一组织和管理,实现元数据的统一加载、变更通知和数据同步。
## 元数据中心数据结构
元数据中心在定义的命名空间和治理节点的metadata节点下,以YAML格式存储,每个逻辑数据源独立存储。
元数据中心在定义的命名空间和治理节点的 `metadata` 节点下,以 YAML 格式存储,每个逻辑数据源独立存储。
```
├─orchestration-namespace
│ ├─orchestration-name
│ │ ├──metadata
│ │ │ ├──schema1
│ │ │ │ ├── [YAML text contents]
│ │ │ ├──schema2
│ │ │ │ ├── [YAML text contents]
│ │ │ ├──schema_1
│ │ │ │ ├── [YAML text contents]
│ │ │ ├──schema_2
│ │ │ │ ├── [YAML text contents]
│ │ │ ├──....
```
......@@ -101,4 +100,5 @@ unconfiguredSchemaMetaDataMap:
## 变更通知
通过某一个Proxy实例执行DDL以后,ShardingSphere先将新的元数据存储到元数据中心,然后通过事件广播机制,通知其它Proxy实例从元数据中心同步元数据,保证元数据一致。
通过某一个 ShardingSphere 实例执行 DDL 之后,
ShardingSphere 先将新的元数据存储到元数据中心,然后通过事件广播机制,通知其它 ShardingSphere 实例从元数据中心同步元数据,保证元数据一致。
+++
pre = "<b>3.4.3. </b>"
title = "Metadata Center"
weight = 3
+++
## Motivation
- Metadata is the core data of the data source used by ShardingSphere-JDBC/ShardingSphere-Proxy, which contains tables, columns, and indexes, etc. Metadata ensures that each component of ShardingSphere can run correctly.
- Metadata is the core data of the data source used by ShardingSphere, which contains tables, columns, and indexes, etc. Metadata ensures that each component of ShardingSphere can run correctly.
- The metadata center organizes and manages the metadata in a unified manner to realize the unified loading of metadata, change notifications and data synchronization.
......
+++
pre = "<b>3.4.2. </b>"
title = "注册中心"
weight = 2
+++
## 实现动机
- 相对于配置中心管理配置数据,注册中心存放运行时的动态/临时状态数据,比如可用的proxy的实例,需要禁用或熔断的datasource实例
- 相对于配置中心管理配置数据,注册中心存放运行时的动态/临时状态数据,比如可用的 ShardingSphere 的实例,需要禁用或熔断的数据源等
- 通过注册中心,可以提供熔断数据库访问程序对数据库的访问和禁用从库的访问的编排治理能力。治理仍然有大量未完成的功能(比如流控等)。
- 通过注册中心,可以提供熔断数据库访问程序对数据库的访问和禁用从库的访问的编排治理能力。治理模块仍然有大量未完成的功能(比如流控等)。
## 注册中心数据结构
注册中心在定义的命名空间的state下,创建数据库访问对象运行节点,用于区分不同数据库访问实例。包括instances和datasources节点。
注册中心在定义的命名空间的 `state` 节点下,创建数据库访问对象运行节点,用于区分不同数据库访问实例。包括 `instances``datasources` 节点。
```
instances
......@@ -24,7 +23,9 @@ datasources
├──ds1
├──....
```
ShardingSphere-Proxy支持多逻辑数据源,因此datasources子节点的名称采用schema_name.data_source_name的形式。
ShardingSphere-Proxy 支持多逻辑数据源,因此 `datasources` 子节点的名称采用 `schema_name.data_source_name` 的形式。
```
instances
├──your_instance_ip_a@-@your_instance_pid_x
......@@ -35,6 +36,7 @@ datasources
├──sharding_db.ds1
├──....
```
### state/instances
数据库访问对象运行实例信息,子节点是当前运行实例的标识。
......@@ -49,9 +51,9 @@ datasources
### 熔断实例
可在IP地址@-@PID节点写入`DISABLED`(忽略大小写)表示禁用该实例,删除DISABLED表示启用。
可在 `IP地址@-@PID` 节点写入 `DISABLED`(忽略大小写)表示禁用该实例,删除 `DISABLED` 表示启用。
Zookeeper命令如下:
Zookeeper 命令如下:
```
[zk: localhost:2181(CONNECTED) 0] set /your_zk_namespace/your_app_name/state/instances/your_instance_ip_a@-@your_instance_pid_x DISABLED
......@@ -59,9 +61,9 @@ Zookeeper命令如下:
### 禁用从库
在读写分离(或数据分片+读写分离)场景下,可在数据源名称子节点中写入`DISABLED`(忽略大小写)表示禁用从库数据源,删除DISABLED或节点表示启用。
在读写分离场景下,可在数据源名称子节点中写入`DISABLED`(忽略大小写)表示禁用从库数据源,删除 `DISABLED` 或节点表示启用。
Zookeeper命令如下:
Zookeeper 命令如下:
```
[zk: localhost:2181(CONNECTED) 0] set /your_zk_namespace/your_app_name/state/datasources/your_slave_datasource_name DISABLED
......
+++
pre = "<b>3.4.2. </b>"
title = "Registry Center"
weight = 2
+++
......@@ -12,7 +11,7 @@ weight = 2
## Data Structure in Registry Center
The registry center can create running node of database access object under `state` in defined name space, to distinguish different database access instances, including `instances` and `datasources` nodes.
The registry center can create running node of database access object under `state` in defined namespace, to distinguish different database access instances, including `instances` and `datasources` nodes.
```
instances
......@@ -50,7 +49,7 @@ It is able to orchestrate read-write split slave database, delete or disable dat
### Circuit Breaker
Write `DISABLED` (case insensitive) to @-@PID in IP to disable that instance; delete `DISABLED` to enable the instance.
Write `DISABLED` (case insensitive) to `IP@-@PID` to disable that instance; delete `DISABLED` to enable the instance.
Zookeeper command is as follow:
......@@ -60,7 +59,7 @@ Zookeeper command is as follow:
### Disable Slave Database
Under read-write split (or shardinng + read-write split) scenarios, users can write `DISABLED` (case insensitive) to sub-nodes of data source name to disable slave database sources. Delete `DISABLED` or the node to enable it.
Under read-write split scenarios, users can write `DISABLED` (case insensitive) to sub-nodes of data source name to disable slave database sources. Delete `DISABLED` or the node to enable it.
Zookeeper command is as follow:
......
+++
pre = "<b>3.4.2 </b>"
title = "可观察性"
weight = 2
chapter = true
+++
## 导览
本小节主要介绍 Apache ShardingSphere 可观察性的相关功能
* 应用性能监控集成
* 度量指标监控
+++
pre = "<b>3.4.2 </b>"
title = "Observability"
weight = 2
chapter = true
+++
## Navigation
This chapter mainly introduces the features of the observability:
* APM Integration
* Metrics
+++
title = "应用性能监控集成"
weight = 1
+++
## 背景
APM 是应用性能监控的缩写。目前 APM 的主要功能着眼于分布式系统的性能诊断,其主要功能包括调用链展示,应用拓扑分析等。
Apache ShardingSphere 并不负责如何采集、存储以及展示应用性能监控的相关数据,而是将 SQL 解析与 SQL 执行这两块数据分片的最核心的相关信息发送至应用性能监控系统,并交由其处理。
换句话说,Apache ShardingSphere 仅负责产生具有价值的数据,并通过标准协议递交至相关系统。Apache ShardingSphere 可以通过两种方式对接应用性能监控系统。
第一种方式是使用 OpenTracing API 发送性能追踪数据。面向 OpenTracing 协议的 APM 产品都可以与 Apache ShardingSphere 自动对接,比如 SkyWalking,Zipkin 和 Jaeger。
使用这种方式只需要在启动时配置 OpenTracing 协议的实现者即可。
它的优点是可以兼容所有的与 OpenTracing 协议兼容的产品作为 APM 的展现系统,如果采用公司愿意实现自己的 APM 系统,也只需要实现 OpenTracing 协议,即可自动展示 Apache ShardingSphere 的链路追踪信息。
缺点是 OpenTracing 协议发展并不稳定,较新的版本实现者较少,且协议本身过于中立,对于个性化的相关产品的实现不如原生支持强大。
第二种方式是使用 SkyWalking 的自动探针。
[Apache ShardingSphere](https://shardingsphere.apache.org) 团队与[Apache SkyWalking](https://skywalking.apache.org) 团队共同合作,在 SkyWalking 中实现了 Apache ShardingSphere 自动探针,可以将相关的应用性能数据自动发送到 SkyWalking 中。
## 使用方法
### 使用 OpenTracing 协议
* 方法1:通过读取系统参数注入APM系统提供的 Tracer 实现类
启动时添加参数
```
-Dorg.apache.shardingsphere.opentracing.tracer.class=org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer
```
调用初始化方法
```java
ShardingTracer.init();
```
* 方法2:通过参数注入APM系统提供的 Tracer 实现类
```java
ShardingTracer.init(new SkywalkingTracer());
```
*注意:使用 SkyWalking 的 OpenTracing 探针时,应将原 Apache ShardingSphere 探针插件禁用,以防止两种插件互相冲突*
### 使用 SkyWalking 自动探针
请参考 [SkyWalking 部署手册](https://github.com/apache/skywalking/blob/5.x/docs/cn/Quick-start-CN.md)
## 效果展示
无论使用哪种方式,都可以方便的将APM信息展示在对接的系统中,以下以 SkyWalking 为例。
### 应用架构
使用 ShardingSphere-Proxy 访问两个数据库`192.168.0.1:3306``192.168.0.2:3306`,且每个数据库中有两个分表。
### 拓扑图展示
![拓扑图](https://shardingsphere.apache.org/document/current/img/apm/5x_topology.png)
从图中看,用户访问 18 次 ShardingSphere-Proxy 应用,每次每个数据库访问了两次。这是由于每次访问涉及到每个库中的两个分表,所以每次访问了四张表。
### 跟踪数据展示
![跟踪图](https://shardingsphere.apache.org/document/current/img/apm/5x_trace.png)
从跟踪图中可以能够看到 SQL 解析和执行的情况。
`/Sharding-Sphere/parseSQL/` : 表示本次 SQL 的解析性能。
![解析节点](https://shardingsphere.apache.org/document/current/img/apm/5x_parse.png)
`/Sharding-Sphere/executeSQL/` : 表示具体执行的实际 SQL 的性能。
![实际访问节点](https://shardingsphere.apache.org/document/current/img/apm/5x_executeSQL.png)
### 异常情况展示
![异常跟踪图](https://shardingsphere.apache.org/document/current/img/apm/5x_trace_err.png)
从跟踪图中可以能够看到发生异常的节点。
`/Sharding-Sphere/executeSQL/` : 表示执行 SQL 异常的结果。
![异常节点](https://shardingsphere.apache.org/document/current/img/apm/5x_executeSQL_Tags_err.png)
`/Sharding-Sphere/executeSQL/` : 表示执行 SQL 异常的日志。
![异常节点日志](https://shardingsphere.apache.org/document/current/img/apm/5x_executeSQL_Logs_err.png)
+++
pre = "<b>3.4.5. </b>"
title = "APM Integration"
weight = 5
weight = 1
+++
## Background
`APM` is the abbreviation for application performance monitoring. Currently, main `APM` functions lie in the performance diagnosis of distributed systems, including chain demonstration, application topology analysis and so on.
APM is the abbreviation for application performance monitoring.
Currently, main APM functions lie in the performance diagnosis of distributed systems, including chain demonstration, application topology analysis and so on.
ShardingSphere is not responsible for gathering, storing and demonstrating APM data, but sends the core information of SQL parsing and enforcement to APM to process. In other words, ShardingSphere is only responsible for generating valuable data and submitting it to relevant systems through standard protocol.
Apache ShardingSphere is not responsible for gathering, storing and demonstrating APM data, but sends the core information of SQL parsing and enforcement to APM to process.
In other words, Apache ShardingSphere is only responsible for generating valuable data and submitting it to relevant systems through standard protocol.
It can connect to APM systems in two ways.
The first way is to send performance tracing data by OpenTracing API. APM products facing OpenTracing protocol can all automatically connect to ShardingSphere, like SkyWalking, Zipkin and Jaeger. In this way, users only need to configure the implementation of OpenTracing protocol at the start. Its advantage is the compatibility of all the products compatible of OpenTracing protocol, such as the APM demonstration system. If companies intend to implement their own APM systems, they only need to implement the OpenTracing protocol, and they can automatically show the chain tracing information of ShardingSphere. Its disadvantage is that OpenTracing protocol is not stable in its development, has only a few new versions, and is too neutral to support customized products as native ones do.
The first way is to send performance tracing data by OpenTracing API.
APM products facing OpenTracing protocol can all automatically connect to Apache ShardingSphere, like SkyWalking, Zipkin and Jaeger.
In this way, users only need to configure the implementation of OpenTracing protocol at the start.
Its advantage is the compatibility of all the products compatible of OpenTracing protocol, such as the APM demonstration system.
If companies intend to implement their own APM systems, they only need to implement the OpenTracing protocol, and they can automatically show the chain tracing information of Apache ShardingSphere.
Its disadvantage is that OpenTracing protocol is not stable in its development, has only a few new versions, and is too neutral to support customized products as native ones do.
The second way is to use SkyWalking's automatic monitor agent. Cooperating with [SkyWalking](https://skywalking.apache.org/) team, ShardingSphere team has realized `ShardingSphere` automatic monitor agent to automatically send application performance data to `SkyWalking`.
The second way is to use SkyWalking's automatic monitor agent.
Cooperating with [Apache SkyWalking](https://skywalking.apache.org/) team,
Apache ShardingSphere team has realized `ShardingSphere` automatic monitor agent to automatically send application performance data to `SkyWalking`.
## Usage
......@@ -24,23 +32,19 @@ The second way is to use SkyWalking's automatic monitor agent. Cooperating with
Add startup arguments
```
-Dorg.apache.shardingsphere.opentracing.tracer.class=org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer
-Dorg.apache.shardingsphere.opentracing.tracer.class=org.apache.skywalking.apm.toolkit.opentracing.SkywalkingTracer
```
Call initialization method
```java
ShardingTracer.init();
```
```
ShardingTracer.init();
ShardingTracer.init();
```
* Method 2: inject Tracer provided by APM through parameter
```java
ShardingTracer.init(new SkywalkingTracer());
ShardingTracer.init(new SkywalkingTracer());
```
*Notice: when using SkyWalking OpenTracing agent, you should disable the former ShardingSphere agent plug-in to avoid the conflict between them.*
......@@ -51,7 +55,7 @@ Please refer to [SkyWalking Manual](https://github.com/apache/skywalking/blob/5.
## Result Demonstration
No matter in which way, it is convenient to demonstrate APM information in the connected system. Take SkyWalking for example:
No matter in which way, it is convenient to demonstrate APM information in the connected system. Take SkyWalking for example:
### Application Architecture
......
+++
title = "度量指标监控"
weight = 2
+++
TODO
+++
pre = "<b>3.4.4. </b>"
title = "支持的配置/注册/元数据中心"
weight = 4
+++
## SPI
[Service Provider Interface (SPI)](https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html)是一种为了被第三方实现或扩展的API。它可以用于实现框架扩展或组件替换。
ShardingSphere在数据库治理模块使用SPI方式载入数据到配置中心/注册/元数据中心,进行实例熔断和数据库禁用。
目前,ShardingSphere内部支持Zookeeper和etcd这种常用的配置中心/注册中心。
此外,您可以使用其他第三方配置中心/注册/元数据中心,并通过SPI的方式注入到ShardingSphere,从而使用该配置中心/注册/元数据中心,实现数据库治理功能。
## Zookeeper
ShardingSphere官方使用[Apache Curator](http://curator.apache.org/)作为Zookeeper的实现方案(支持配置中心、注册中心和元数据中心)。
请使用Zookeeper 3.4.6及其以上版本,详情请参见[官方网站](https://zookeeper.apache.org/)
## Etcd
ShardingSphere官方使用[io.etcd/jetcd](https://github.com/etcd-io/jetcd)作为Etcd的实现方案(支持配置中心、注册中心和元数据中心)。
请使用Etcd v3以上版本,详情请参见[官方网站](https://etcd.io/)
## Apollo
ShardingSphere官方使用[Apollo Client](https://github.com/ctripcorp/apollo)作为Apollo的实现方案(支持配置中心)。
请使用Apollo Client 1.5.0及其以上版本,详情请参见[官方网站](https://github.com/ctripcorp/apollo)
## Nacos
ShardingSphere官方使用[Nacos Client](https://nacos.io/zh-cn/docs/sdk.html)作为Nacos的实现方案(支持配置中心)。
请使用Nacos Client 1.0.0及其以上版本,详情请参见[官方网站](https://nacos.io/zh-cn/docs/sdk.html)
## 其他
使用SPI方式自行实现相关逻辑编码。
+++
pre = "<b>3.4.4. </b>"
title = "Available Config/Registry/Metadata Center"
weight = 4
+++
## SPI
[Service Provider Interface (SPI)](https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html) is a kind of API that aims to be implemented or extended by the third party.
It can be used to realize framework extension or component replacement.
ShardingSphere uses SPI to load data to the config center/registry/metadata center and disable instances and databases. Currently, ShardingSphere supports frequently used registry centers, Zookeeper and Etcd. In addition, by injecting them to ShardingSphere with SPI, users can use other third-party config/registry/metadata centers to enable databases orchestration.
## Zookeeper
ShardingSphere adopts [Apache Curator](http://curator.apache.org/) to enable Zookeeper(support config center&registry center&metadata center). Please use Zookeeper 3.4.6 and above, see the [official website](https://zookeeper.apache.org/) for details.
## Etcd
ShardingSphere adopts [io.etcd/jetcd](https://github.com/etcd-io/jetcd) to enable Etcd(support config center&registry center&metadata center). Please use Etcd v3 and above, see the [official website](https://etcd.io/) for details.
## Apollo
ShardingSphere adopts [Apollo Client](https://github.com/ctripcorp/apollo) to enable Apollo(support config center). Please use Apollo Client 1.5.0 and above, see the [official website](https://github.com/ctripcorp/apollo) for details.
## Nacos
ShardingSphere adopts [Nacos Client](https://nacos.io/en-us/docs/sdk.html) to enable Nacos(support config center). Please use Nacos Client 1.0.0 and above, see the [official website](https://nacos.io/en-us/docs/sdk.html) for details.
## Others
Use SPI to realize relevant logic coding.
+++
pre = "<b>3.2.1.1 </b>"
title = "XA两阶段事务"
weight = 1
+++
......
+++
pre = "<b>3.2.1.1 </b>"
title = "XA Transaction"
weight = 1
+++
......
+++
pre = "<b>3.2.1.2 </b>"
title = "Seata 柔性事务"
weight = 3
+++
......
+++
pre = "<b>3.2.1.2 </b>"
title = "Seata BASE transaction"
weight = 3
+++
......
+++
pre = "<b>3.2.2.1 </b>"
title = "XA两阶段事务"
weight = 2
+++
......
+++
pre = "<b>3.2.2.1 </b>"
title = "XA Transaction"
weight = 2
+++
......
+++
pre = "<b>3.2.2.2 </b>"
title = "Seata 柔性事务"
weight = 3
+++
......
+++
pre = "<b>3.2.2.2 </b>"
title = "Seata BASE transaction"
weight = 3
+++
......
+++
pre = "<b>3.2.3.2 </b>"
title = "XA两阶段事务"
weight = 2
+++
......
+++
pre = "<b>3.2.3.2 </b>"
title = "XA transaction"
weight = 2
+++
......
+++
pre = "<b>3.2.3.3 </b>"
title = "Seata 柔性事务"
weight = 3
+++
......
+++
pre = "<b>3.2.3.3 </b>"
title = "Seata BASE transaction"
weight = 3
+++
......
+++
pre = "<b>3.2.3.1 </b>"
title = "本地事务"
weight = 1
+++
......
+++
pre = "<b>3.2.3.1 </b>"
title = "Local Transaction"
weight = 1
+++
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册