You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/06/18 04:55:52 UTC
[shardingsphere] branch master updated: Update
user-manual/yaml/sharding (#6111)
This is an automated email from the ASF dual-hosted git repository.
zhangyonglun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new f5156a8 Update user-manual/yaml/sharding (#6111)
f5156a8 is described below
commit f5156a8624cbcccbae4d0c085d4149d3f9cdd8ea
Author: Liang Zhang <te...@163.com>
AuthorDate: Thu Jun 18 12:55:42 2020 +0800
Update user-manual/yaml/sharding (#6111)
---
.../configuration/yaml/config-yaml.cn.md | 431 --------------------
.../configuration/yaml/config-yaml.en.md | 436 ---------------------
.../configuration/yaml/sharding.cn.md | 95 ++++-
.../configuration/yaml/sharding.en.md | 95 ++++-
4 files changed, 186 insertions(+), 871 deletions(-)
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.cn.md
deleted file mode 100644
index 9dbd337..0000000
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.cn.md
+++ /dev/null
@@ -1,431 +0,0 @@
-+++
-title = "Yaml配置"
-weight = 20
-+++
-
-## 配置示例
-
-### 数据分片
-
-```yaml
-dataSources:
- ds0: !!org.apache.commons.dbcp2.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds0
- username: root
- password:
- ds1: !!org.apache.commons.dbcp2.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds1
- username: root
- password:
-
-shardingRule:
- tables:
- t_order:
- actualDataNodes: ds${0..1}.t_order${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ds${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order${order_id % 2}
- keyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
- t_order_item:
- actualDataNodes: ds${0..1}.t_order_item${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ds${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order_item${order_id % 2}
- bindingTables:
- - t_order,t_order_item
- broadcastTables:
- - t_config
-
- defaultDataSourceName: ds0
- defaultTableStrategy:
- none:
- defaultKeyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
-
-props:
- sql.show: true
-```
-
-### 读写分离
-
-```yaml
-dataSources:
- ds_master: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_master
- username: root
- password:
- ds_slave0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_slave0
- username: root
- password:
- ds_slave1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_slave1
- username: root
- password:
-
-masterSlaveRule:
- name: ds_ms
- masterDataSourceName: ds_master
- slaveDataSourceNames:
- - ds_slave0
- - ds_slave1
-
-props:
- sql.show: true
-```
-
-### 数据加密
-```yaml
-dataSource: !!org.apache.commons.dbcp2.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://127.0.0.1:3306/encrypt?serverTimezone=UTC&useSSL=false
- username: root
- password:
-
-encryptRule:
- encryptors:
- aes_encryptor:
- type: AES
- props:
- aes.key.value: 123456abc
- md5_encryptor:
- type: MD5
- tables:
- t_encrypt:
- columns:
- user_id:
- plainColumn: user_plain
- cipherColumn: user_cipher
- encryptorName: aes_encryptor
- order_id:
- cipherColumn: order_cipher
- encryptorName: md5_encryptor
-props:
- query.with.cipher.column: true #是否使用密文列查询
-```
-
-### 数据分片 + 读写分离
-
-```yaml
-dataSources:
- ds0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds0
- username: root
- password:
- ds0_slave0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds0_slave0
- username: root
- password:
- ds0_slave1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds0_slave1
- username: root
- password:
- ds1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds1
- username: root
- password:
- ds1_slave0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds1_slave0
- username: root
- password:
- ds1_slave1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds1_slave1
- username: root
- password:
-
-shardingRule:
- tables:
- t_order:
- actualDataNodes: ms_ds${0..1}.t_order${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ms_ds${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order${order_id % 2}
- keyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
- t_order_item:
- actualDataNodes: ms_ds${0..1}.t_order_item${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ms_ds${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order_item${order_id % 2}
- bindingTables:
- - t_order,t_order_item
- broadcastTables:
- - t_config
-
- defaultDataSourceName: ds_0
- defaultTableStrategy:
- none:
- defaultKeyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
-
- masterSlaveRules:
- ms_ds0:
- masterDataSourceName: ds0
- slaveDataSourceNames:
- - ds0_slave0
- - ds0_slave1
- loadBalanceAlgorithmType: ROUND_ROBIN
- ms_ds1:
- masterDataSourceName: ds1
- slaveDataSourceNames:
- - ds1_slave0
- - ds1_slave1
- loadBalanceAlgorithmType: ROUND_ROBIN
-props:
- sql.show: true
-```
-
-### 数据分片 + 数据加密
-
-```yaml
-dataSources:
- ds_0: !!com.zaxxer.hikari.HikariDataSource
- driverClassName: com.mysql.jdbc.Driver
- jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0
- username: root
- password:
- ds_1: !!com.zaxxer.hikari.HikariDataSource
- driverClassName: com.mysql.jdbc.Driver
- jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1
- username: root
- password:
-
-shardingRule:
- tables:
- t_order:
- actualDataNodes: ds_${0..1}.t_order_${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ds_${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order_${order_id % 2}
- keyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
- t_order_item:
- actualDataNodes: ds_${0..1}.t_order_item_${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ds_${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order_item_${order_id % 2}
- bindingTables:
- - t_order,t_order_item
-
- defaultTableStrategy:
- none:
-
- encryptRule:
- encryptors:
- aes_encryptor:
- type: AES
- props:
- aes.key.value: 123456abc
- tables:
- t_order:
- columns:
- order_id:
- plainColumn: order_plain
- cipherColumn: order_cipher
- encryptorName: aes_encryptor
-
-props:
- sql.show: true
-```
-
-### 治理
-
-```yaml
-#省略数据分片、读写分离和数据加密配置
-
-orchestration:
- orchestration_ds:
- orchestrationType: config_center,registry_center,metadata_center
- instanceType: zookeeper
- serverLists: localhost:2181
- namespace: orchestration
- props:
- overwrite: true
-```
-
-## 配置项说明
-
-### 数据分片
-
-```yaml
-dataSources: #数据源配置,可配置多个data_source_name
- <data_source_name>: #<!!数据库连接池实现类> `!!`表示实例化该类
- driverClassName: #数据库驱动类名
- url: #数据库url连接
- username: #数据库用户名
- password: #数据库密码
- # ... 数据库连接池的其它属性
-
-shardingRule:
- tables: #数据分片规则配置,可配置多个logic_table_name
- <logic_table_name>: #逻辑表名称
- actualDataNodes: #由数据源名 + 表名组成,以小数点分隔。多个表以逗号分隔,支持inline表达式。缺省表示使用已知数据源与逻辑表名称生成数据节点,用于广播表(即每个库中都需要一个同样的表用于关联查询,多为字典表)或只分库不分表且所有库的表结构完全一致的情况
-
- databaseStrategy: #分库策略,缺省表示使用默认分库策略,以下的分片策略只能选其一
- standard: #用于单分片键的标准分片场景
- shardingColumn: #分片列名称
- preciseAlgorithmClassName: #精确分片算法类名称,用于=和IN。。该类需实现PreciseShardingAlgorithm接口并提供无参数的构造器
- rangeAlgorithmClassName: #范围分片算法类名称,用于BETWEEN,可选。。该类需实现RangeShardingAlgorithm接口并提供无参数的构造器
- complex: #用于多分片键的复合分片场景
- shardingColumns: #分片列名称,多个列以逗号分隔
- algorithmClassName: #复合分片算法类名称。该类需实现ComplexKeysShardingAlgorithm接口并提供无参数的构造器
- inline: #行表达式分片策略
- shardingColumn: #分片列名称
- algorithmInlineExpression: #分片算法行表达式,需符合groovy语法
- hint: #Hint分片策略
- algorithmClassName: #Hint分片算法类名称。该类需实现HintShardingAlgorithm接口并提供无参数的构造器
- none: #不分片
- tableStrategy: #分表策略,同分库策略
- keyGenerateStrategy:
- column: #自增列名称,缺省表示不使用自增主键生成器
- type: #自增列值生成器类型,缺省表示使用默认自增列值生成器。可使用用户自定义的列值生成器或选择内置类型:SNOWFLAKE/UUID
- props: #属性配置, 注意:使用SNOWFLAKE算法,需要配置worker.id与max.tolerate.time.difference.milliseconds属性。若使用此算法生成值作分片值,建议配置max.vibration.offset属性
- <property-name>: 属性名称
-
- bindingTables: #绑定表规则列表
- - <logic_table_name1, logic_table_name2, ...>
- - <logic_table_name3, logic_table_name4, ...>
- - <logic_table_name_x, logic_table_name_y, ...>
- broadcastTables: #广播表规则列表
- - table_name1
- - table_name2
- - table_name_x
-
- defaultDataSourceName: #未配置分片规则的表将通过默认数据源定位
- defaultDatabaseStrategy: #默认数据库分片策略,同分库策略
- defaultTableStrategy: #默认表分片策略,同分库策略
- defaultKeyGenerateStrategy: #默认的主键生成算法 如果没有设置,默认为SNOWFLAKE算法
- type: #默认自增列值生成器类型,缺省将使用org.apache.shardingsphere.core.keygen.generator.impl.SnowflakeKeyGenerator。可使用用户自定义的列值生成器或选择内置类型:SNOWFLAKE/UUID
- props:
- <property-name>: #自增列值生成器属性配置, 比如SNOWFLAKE算法的worker.id与max.tolerate.time.difference.milliseconds
-
- masterSlaveRules: #读写分离规则,详见读写分离部分
- <data_source_name>: #数据源名称,需要与真实数据源匹配,可配置多个data_source_name
- masterDataSourceName: #详见读写分离部分
- slaveDataSourceNames: #详见读写分离部分
- loadBalanceAlgorithmType: #详见读写分离部分
- props: #读写分离负载算法的属性配置
- <property-name>: #属性值
-
-props: #属性配置
- sql.show: #是否开启SQL显示,默认值: false
- executor.size: #工作线程数量,默认值: CPU核数
- max.connections.size.per.query: # 每个查询可以打开的最大连接数量,默认为1
- check.table.metadata.enabled: #是否在启动时检查分表元数据一致性,默认值: false
-```
-
-### 读写分离
-
-```yaml
-dataSources: #省略数据源配置,与数据分片一致
-
-masterSlaveRule:
- name: #读写分离数据源名称
- masterDataSourceName: #主库数据源名称
- slaveDataSourceNames: #从库数据源名称列表
- - <data_source_name1>
- - <data_source_name2>
- - <data_source_name_x>
- loadBalanceAlgorithmType: #从库负载均衡算法类型,可选值:ROUND_ROBIN,RANDOM。若`loadBalanceAlgorithmClassName`存在则忽略该配置
- props: #读写分离负载算法的属性配置
- <property-name>: #属性值
-```
-
-### 数据加密
-
-```yaml
-dataSource: #省略数据源配置
-
-encryptRule:
- encryptors:
- <encrypt-algorithm-name>:
- type: #加解密算法类型,可自定义或选择内置类型:MD5/AES
- props: #属性配置, 注意:使用AES加密算法,需要配置AES加密算法的KEY属性:aes.key.value
- aes.key.value:
- tables:
- <table-name>:
- columns:
- <logic-column-name>:
- plainColumn: #存储明文的字段
- cipherColumn: #存储密文的字段
- assistedQueryColumn: #辅助查询字段,针对 QueryAssistedEncryptAlgorithm 类型的加解密算法进行辅助查询
- encryptorName: #加密算法名字
-```
-
-### 治理
-
-```yaml
-dataSources: #省略数据源配置
-shardingRule: #省略分片规则配置
-masterSlaveRule: #省略读写分离规则配置
-encryptRule: #省略数据加密规则配置
-
-orchestration:
- orchestration_ds: #治理实例名称
- orchestrationType: #治理类型,例如config_center/registry_center/metadata_center
- instanceType: #配置/注册/元数据中心类型。如:zookeeper
- serverLists: #连接配置/注册/元数据中心服务器的列表。包括IP地址和端口号。多个地址用逗号分隔。如: host1:2181,host2:2181
- namespace: #配置/注册/元数据中心的命名空间
- props: #其它配置
- overwrite: #本地配置是否覆盖配置中心配置。如果可覆盖,每次启动都以本地配置为准
- digest: #连接注册中心的权限令牌。缺省为不需要权限验证
- operationTimeoutMilliseconds: #操作超时的毫秒数,默认500毫秒
- maxRetries: #连接失败后的最大重试次数,默认3次
- retryIntervalMilliseconds: #重试间隔毫秒数,默认500毫秒
- timeToLiveSeconds: #临时节点存活秒数,默认60秒
-```
-
-## Yaml语法说明
-
-`!!` 表示实例化该类
-
-`-` 表示可以包含一个或多个
-
-`[]` 表示数组,可以与减号相互替换使用
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.en.md
deleted file mode 100644
index 79f0b2b..0000000
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.en.md
+++ /dev/null
@@ -1,436 +0,0 @@
-+++
-title = "Yaml Configuration"
-weight = 20
-+++
-
-## Configuration Instance
-
-### Data Sharding
-
-```yaml
-dataSources:
- ds0: !!org.apache.commons.dbcp2.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds0
- username: root
- password:
- ds1: !!org.apache.commons.dbcp2.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds1
- username: root
- password:
-
-shardingRule:
- tables:
- t_order:
- actualDataNodes: ds${0..1}.t_order${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ds${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order${order_id % 2}
- keyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
- t_order_item:
- actualDataNodes: ds${0..1}.t_order_item${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ds${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order_item${order_id % 2}
- bindingTables:
- - t_order,t_order_item
- broadcastTables:
- - t_config
-
- defaultDataSourceName: ds0
- defaultTableStrategy:
- none:
- defaultKeyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
-
-props:
- sql.show: true
-```
-
-### Read-Write Split
-
-```yaml
-dataSources:
- ds_master: !!org.apache.commons.dbcp2.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_master
- username: root
- password:
- ds_slave0: !!org.apache.commons.dbcp2.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_slave0
- username: root
- password:
- ds_slave1: !!org.apache.commons.dbcp2.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_slave1
- username: root
- password:
-
-masterSlaveRule:
- name: ds_ms
- masterDataSourceName: ds_master
- slaveDataSourceNames:
- - ds_slave0
- - ds_slave1
-
-props:
- sql.show: true
-```
-
-### data encryption
-
-```yaml
-dataSource: !!org.apache.commons.dbcp2.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://127.0.0.1:3306/encrypt?serverTimezone=UTC&useSSL=false
- username: root
- password:
-
-encryptRule:
- encryptors:
- aes_encryptor:
- type: AES
- props:
- aes.key.value: 123456abc
- md5_encryptor:
- type: MD5
- tables:
- t_encrypt:
- columns:
- user_id:
- plainColumn: user_plain
- cipherColumn: user_cipher
- encryptorName: aes_encryptor
- order_id:
- cipherColumn: order_cipher
- encryptorName: md5_encryptor
-props:
- query.with.cipher.column: true
-```
-
-### Data Sharding + Read-Write Split
-
-```yaml
-dataSources:
- ds0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds0
- username: root
- password:
- ds0_slave0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds0_slave0
- username: root
- password:
- ds0_slave1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds0_slave1
- username: root
- password:
- ds1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds1
- username: root
- password:
- ds1_slave0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds1_slave0
- username: root
- password:
- ds1_slave1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds1_slave1
- username: root
- password:
-
-shardingRule:
- tables:
- t_order:
- actualDataNodes: ms_ds${0..1}.t_order${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ms_ds${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order${order_id % 2}
- keyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
- t_order_item:
- actualDataNodes: ms_ds${0..1}.t_order_item${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ms_ds${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order_item${order_id % 2}
- bindingTables:
- - t_order,t_order_item
- broadcastTables:
- - t_config
-
- defaultDataSourceName: ds0
- defaultTableStrategy:
- none:
- defaultKeyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
-
- masterSlaveRules:
- ms_ds0:
- masterDataSourceName: ds0
- slaveDataSourceNames:
- - ds0_slave0
- - ds0_slave1
- loadBalanceAlgorithmType: ROUND_ROBIN
- ms_ds1:
- masterDataSourceName: ds1
- slaveDataSourceNames:
- - ds1_slave0
- - ds1_slave1
- loadBalanceAlgorithmType: ROUND_ROBIN
-props:
- sql.show: true
-```
-
-### Data Sharding + data encryption
-
-```yaml
-dataSources:
- ds_0: !!com.zaxxer.hikari.HikariDataSource
- driverClassName: com.mysql.jdbc.Driver
- jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0
- username: root
- password:
- ds_1: !!com.zaxxer.hikari.HikariDataSource
- driverClassName: com.mysql.jdbc.Driver
- jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1
- username: root
- password:
-
-shardingRule:
- tables:
- t_order:
- actualDataNodes: ds_${0..1}.t_order_${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ds_${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order_${order_id % 2}
- keyGenerateStrategy:
- type: SNOWFLAKE
- column: order_id
- t_order_item:
- actualDataNodes: ds_${0..1}.t_order_item_${0..1}
- databaseStrategy:
- inline:
- shardingColumn: user_id
- algorithmExpression: ds_${user_id % 2}
- tableStrategy:
- inline:
- shardingColumn: order_id
- algorithmExpression: t_order_item_${order_id % 2}
- bindingTables:
- - t_order,t_order_item
-
- defaultTableStrategy:
- none:
-
- encryptRule:
- encryptors:
- aes_encryptor:
- type: AES
- props:
- aes.key.value: 123456abc
- tables:
- t_order:
- columns:
- order_id:
- plainColumn: order_plain
- cipherColumn: order_cipher
- encryptorName: aes_encryptor
-
-props:
- sql.show: true
-```
-
-### Orchestration
-
-```yaml
-#Omit data sharding, read-write split and encrypt configurations
-
-orchestration:
- orchestration_ds:
- orchestrationType: config_center,registry_center,metadata_center
- instanceType: zookeeper
- serverLists: localhost:2181
- namespace: orchestration
- props:
- overwrite: true
-```
-
-## Configuration Item Explanation
-
-### Sharding
-
-```yaml
-dataSources: #Data sources configuration, multiple `data_source_name` available
- <data_source_name>: #<!!Data source pool implementation class> `!!` means class instantiation
- driverClassName: #Class name of database driver
- url: #Database URL
- username: #Database username
- password: #Database password
- # ... Other properties for data source pool
-
-shardingRule:
- tables: #Sharding rule configuration, multiple `logic_table_name` available
- <logic_table_name>: #Name of logic table
- actualDataNodes: #Describe data source names and actual tables, delimiter as point, multiple data nodes separated with comma, support inline expression. Absent means sharding databases only. Example: ds${0..7}.tbl${0..7}
-
- databaseStrategy: #Databases sharding strategy, use default databases sharding strategy if absent. sharding strategy below can choose only one.
- standard: #Standard sharding scenario for single sharding column
- shardingColumn: #Name of sharding column
- preciseAlgorithmClassName: #Precise algorithm class name used for `=` and `IN`. This class need to implements PreciseShardingAlgorithm, and require a no argument constructor
- rangeAlgorithmClassName: #Range algorithm class name used for `BETWEEN`. This class need to implements RangeShardingAlgorithm, and require a no argument constructor
- complex: #Complex sharding scenario for multiple sharding columns
- shardingColumns: #Names of sharding columns. Multiple columns separated with comma
- algorithmClassName: #Complex sharding algorithm class name. This class need to implements ComplexKeysShardingAlgorithm, and require a no argument constructor
- inline: #Inline expression sharding scenario for single sharding column
- shardingColumn: #Name of sharding column
- algorithmInlineExpression: #Inline expression for sharding algorithm
- hint: #Hint sharding strategy
- algorithmClassName: #Hint sharding algorithm class name. This class need to implements HintShardingAlgorithm, and require a no argument constructor
- none: #Do not sharding
- tableStrategy: #Tables sharding strategy, Same as databases sharding strategy
- keyGenerateStrategy:
- column: #Column name of key generator
- type: #Type of key generator, use default key generator if absent, and there are three types to choose, that is, SNOWFLAKE/UUID
- props: #Properties, Notice: when use SNOWFLAKE, `worker.id` and `max.tolerate.time.difference.milliseconds` for `SNOWFLAKE` need to be set. To use the generated value of this algorithm as sharding value, it is recommended to configure `max.vibration.offset`
-
- bindingTables: #Binding table rule configurations
- - <logic_table_name1, logic_table_name2, ...>
- - <logic_table_name3, logic_table_name4, ...>
- - <logic_table_name_x, logic_table_name_y, ...>
- broadcastTables: #Broadcast table rule configurations
- - table_name1
- - table_name2
- - table_name_x
-
- defaultDataSourceName: #If table not configure at table rule, will route to defaultDataSourceName
- defaultDatabaseStrategy: #Default strategy for sharding databases, same as databases sharding strategy
- defaultTableStrategy: #Default strategy for sharding tables, same as tables sharding strategy
- defaultKeyGenerateStrategy:
- type: #Type of default key generator, use user-defined ones or built-in ones, e.g. SNOWFLAKE, UUID. Default key generator is `org.apache.shardingsphere.core.keygen.generator.impl.SnowflakeKeyGenerator`
- column: #Column name of default key generator
- props: #Properties of default key generator, e.g. `worker.id` and `max.tolerate.time.difference.milliseconds` for `SNOWFLAKE`
-
- masterSlaveRules: #Read-write splitting rule configuration, more details can reference Read-write splitting part
- <data_source_name>: #Data sources configuration, need consist with data source map, multiple `data_source_name` available
- masterDataSourceName: #more details can reference Read-write splitting part
- slaveDataSourceNames: #more details can reference Read-write splitting part
- loadBalanceAlgorithmType: #more details can reference Read-write splitting part
- props: #Properties configuration of load balance algorithm
- <property-name>: #property key value pair
-
-props: #Properties
- sql.show: #To show SQLS or not, default value: false
- executor.size: #The number of working threads, default value: CPU count
- check.table.metadata.enabled: #To check the metadata consistency of all the tables or not, default value : false
- max.connections.size.per.query: #The maximum connection number allocated by each query of each physical database. default value: 1
-```
-
-### Read-Write Split
-
-```yaml
-dataSources: #Omit data source configurations; keep it consistent with data sharding
-
-masterSlaveRule:
- name: #Read-write split data source name
- masterDataSourceName: #Master data source name
- slaveDataSourceNames: #Slave data source name
- - <data_source_name1>
- - <data_source_name2>
- - <data_source_name_x>
- loadBalanceAlgorithmType: #Slave database load balance algorithm type; optional value, ROUND_ROBIN and RANDOM, can be omitted if `loadBalanceAlgorithmClassName` exists
- props: #Properties configuration of load balance algorithm
- <property-name>: #property key value pair
-
-props: #Property configuration
- sql.show: #Show SQL or not; default value: false
- executor.size: #Executing thread number; default value: CPU core number
- check.table.metadata.enabled: # Whether to check table metadata consistency when it initializes; default value: false
- max.connections.size.per.query: #The maximum connection number allocated by each query of each physical database. default value: 1
-```
-
-### data encryption
-```yaml
-dataSource: #Ignore data sources configuration
-
-encryptRule:
- encryptors:
- <encrypt-algorithm-name>:
- type: #encrypt algorithm type
- props: #Properties, e.g. `aes.key.value` for AES encrypt algorithm
- aes.key.value:
- tables:
- <table-name>:
- columns:
- <logic-column-name>:
- plainColumn: #plaintext column name
- cipherColumn: #ciphertext column name
- assistedQueryColumn: #AssistedColumns for query,when use QueryAssistedEncryptAlgorithm, it can help query encrypted data
- encryptorName: #encrypt name
-```
-
-### Orchestration
-
-```yaml
-dataSources: #Omit data source configurations
-shardingRule: #Omit sharding rule configurations
-masterSlaveRule: #Omit read-write split rule configurations
-encryptRule: #Omit encrypt rule configurations
-
-orchestration:
- orchestration_ds: #Orchestration instance name
- orchestrationType: #The type of orchestration center: config_center or registry_center or metadata_center
- instanceType: #Center instance type. Example:zookeeper
- serverLists: #The list of servers that connect to registry center, including IP and port number; use commas to seperate addresses, such as: host1:2181,host2:2181
- namespace: #Center namespace
- props: #Other properties
- overwrite: #Whether to overwrite local configurations with config center configurations; if it can, each initialization should refer to local configurations
- digest: #The token that connects to the center; default means there is no need for authentication
- operationTimeoutMilliseconds: #Default value: 500 milliseconds
- maxRetries: #Maximum retry time after failing; default value: 3 times
- retryIntervalMilliseconds: #Interval time to retry; default value: 500 milliseconds
- timeToLiveSeconds: #Living time of temporary nodes; default value: 60 seconds
-```
-
-## Yaml Syntax Explanation
-
-`!!` means instantiation of that class
-
-`-` means one or multiple can be included
-
-`[]` means array, substitutable with `-`
\ No newline at end of file
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/sharding.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/sharding.cn.md
index 75d00ce..b19bedc 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/sharding.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/sharding.cn.md
@@ -5,8 +5,99 @@ weight = 1
## 配置示例
-TODO
+```yaml
+dataSources:
+ ds0: !!org.apache.commons.dbcp2.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://127.0.0.1:3306/ds0
+ username: root
+ password: root
+ ds1: !!org.apache.commons.dbcp2.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://127.0.0.1:3306/ds1
+ username: root
+ password: root
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds${0..1}.t_order_${0..7}
+ databaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: db_inline
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ t_order_item:
+ actualDataNodes: ds${0..1}.t_order_item_${0..7}
+ databaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: db_inline
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+
+ shardingAlgorithms:
+ db_inline:
+ type: INLINE
+ props:
+ algorithm.expression: ds_${user_id % 2}
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm.expression: t_order_${order_id % 8}
+ t_order_item_inline:
+ type: INLINE
+ props:
+ algorithm.expression: t_order_item_${order_id % 8}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+```
## 配置项说明
-TODO
\ No newline at end of file
+```yaml
+dataSources: # 省略数据源配置
+
+rules:
+- !SHARDING
+ tables: # 数据分片规则配置
+ <logic_table_name> (+): # 逻辑表名称
+ actualDataNodes (?): #由数据源名 + 表名组成,以小数点分隔。多个表以逗号分隔,支持行表达式。缺省表示使用已知数据源与逻辑表名称生成数据节点,用于广播表(即每个库中都需要一个同样的表用于关联查询,多为字典表)或只分库不分表且所有库的表结构完全一致的情况
+ databaseStrategy (?): # 分库策略,缺省表示使用默认分库策略,以下的分片策略只能选其一
+ standard: # 用于单分片键的标准分片场景
+ shardingColumn: # 分片列名称
+ shardingAlgorithmName: # 分片算法名称
+ complex: # 用于多分片键的复合分片场景
+ shardingColumns: #分片列名称,多个列以逗号分隔
+ shardingAlgorithmName: # 分片算法名称
+ hint: # Hint 分片策略
+ shardingAlgorithmName: # 分片算法名称
+ none: # 不分片
+ tableStrategy: # 分表策略,同分库策略
+ keyGenerateStrategy: # 分布式序列策略
+ column: # 自增列名称,缺省表示不使用自增主键生成器
+ keyGeneratorName: # 分布式序列算法名称
+ bindingTables (+): # 绑定表规则列表
+ - <logic_table_name_1, logic_table_name_2, ...>
+ broadcastTables (+): # 广播表规则列表
+ - <table_name>
+ defaultDatabaseStrategy: # 默认数据库分片策略
+ defaultTableStrategy: # 默认表分片策略
+ defaultKeyGenerateStrategy: # 默认的分布式序列策略
+
+props:
+ # ...
+```
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/sharding.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/sharding.en.md
index 621a9a7..e116a34 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/sharding.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/sharding.en.md
@@ -5,8 +5,99 @@ weight = 1
## Configuration Example
-TODO
+```yaml
+dataSources:
+ ds0: !!org.apache.commons.dbcp2.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://127.0.0.1:3306/ds0
+ username: root
+ password: root
+ ds1: !!org.apache.commons.dbcp2.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://127.0.0.1:3306/ds1
+ username: root
+ password: root
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds${0..1}.t_order_${0..7}
+ databaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: db_inline
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ t_order_item:
+ actualDataNodes: ds${0..1}.t_order_item_${0..7}
+ databaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: db_inline
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+
+ shardingAlgorithms:
+ db_inline:
+ type: INLINE
+ props:
+ algorithm.expression: ds_${user_id % 2}
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm.expression: t_order_${order_id % 8}
+ t_order_item_inline:
+ type: INLINE
+ props:
+ algorithm.expression: t_order_item_${order_id % 8}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+```
## Configuration Item Explanation
-TODO
\ No newline at end of file
+```yaml
+dataSources: # Ignore data source configuration
+
+rules:
+- !SHARDING
+ tables: # Sharding rule configuration
+ <logic_table_name> (+): # Logic table name
+ actualDataNodes (?): # Describe data source names and actual tables, delimiter as point, multiple data nodes separated with comma, support inline expression. Absent means sharding databases only. Example: ds${0..7}.tbl${0..7}
+ databaseStrategy (?): # Databases sharding strategy, use default databases sharding strategy if absent. sharding strategy below can choose only one.
+ standard: # For single sharding column scenario
+ shardingColumn: # Sharding column name
+ shardingAlgorithmName: # Sharding algorithm name
+ complex: # For multiple sharding columns scenario
+ shardingColumns: # Sharding column names
+ shardingAlgorithmName: # Sharding algorithm name
+ hint: # Sharding by hint
+ shardingAlgorithmName: # Sharding algorithm name
+ none: # Do not sharding
+ tableStrategy: # Tables sharding strategy, same as database sharding strategy
+ keyGenerateStrategy: # Key generator strategy
+ column: # Column name of key generator
+ keyGeneratorName: # Key generator name
+ bindingTables (+): # Binding table rule configurations
+ - <logic_table_name_1, logic_table_name_2, ...>
+ broadcastTables (+): # Broadcast table rule configurations
+ - <table_name>
+ defaultDatabaseStrategy: # Default strategy for database sharding
+ defaultTableStrategy: # Default strategy for table sharding
+ defaultKeyGenerateStrategy: # Key generator strategy
+
+props:
+ # ...
+```
\ No newline at end of file