This is an automated email from the ASF dual-hosted git repository.
panjuan 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 4d1ee7a292e Unified shadow DB spring boot start configuration style
(#20492)
4d1ee7a292e is described below
commit 4d1ee7a292e83d221e221753dd1ba8f145c845c9
Author: gin <[email protected]>
AuthorDate: Wed Aug 24 18:28:46 2022 +0800
Unified shadow DB spring boot start configuration style (#20492)
---
.../spring-boot-starter/rules/shadow.cn.md | 78 +++++++++++-----------
.../spring-boot-starter/rules/shadow.en.md | 78 +++++++++++-----------
2 files changed, 76 insertions(+), 80 deletions(-)
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/shadow.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/shadow.cn.md
index b9afc653e0f..2cac57c3385 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/shadow.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/shadow.cn.md
@@ -7,59 +7,57 @@ weight = 5
如果您想在 Spring Boot 环境中使用 ShardingSphere 影子库功能请参考以下配置。
## 参数解释
-### 配置入口
```properties
-spring.shardingsphere.rules.shadow
-```
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.production-data-source-name=
# 生产数据源名称
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=
# 影子数据源名称
+
+spring.shardingsphere.rules.shadow.tables.<table-name>.data-source-names= #
影子表关联影子数据源名称列表(多个值用","隔开)
+spring.shardingsphere.rules.shadow.tables.<table-name>.shadow-algorithm-names=
# 影子表关联影子算法名称列表(多个值用","隔开)
-### 可配置属性:
-| *名称* | *说明* | *默认值* |
-| ------- | ------ | ----- |
-| data-sources | 影子库逻辑数据源映射配置列表 | 无 |
-| tables | 影子表配置列表 | 无 |
-| shadowAlgorithms | 影子算法配置列表 | 无 |
-| default-shadow-algorithm-name | 默认影子算法名称 | 无,选配项 |
-
-### 影子数据源配置
-| *名称* | *说明* | *默认值* |
-| --------------------------- | ----------- | ------- |
-| production-data-source-name | 生产数据源名称 | 无 |
-| shadow-data-source-name | 影子数据源名称 | 无 |
-
-### 影子表配置
-| *名称* | *说明* | *默认值* |
-| ------- | ------ | ----- |
-| data-source-names | 影子表关联影子库逻辑数据源名称列表 | 无 |
-| shadow-algorithm-names | 影子表关联影子算法名称列表 | 无 |
-
-### 影子算法配置
-| *名称* | *说明* | *默认值* |
-| ------- | ------ | ----- |
-| type | 影子算法类型 | 无 |
-| props | 影子算法配置 | 无 |
+spring.shardingsphere.rules.shadow.defaultShadowAlgorithmName= # 默认影子算法名称,选配项
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.<shadow-algorithm-name>.type=
# 影子算法类型
+spring.shardingsphere.rules.shadow.shadow-algorithms.<shadow-algorithm-name>.props.xxx=
# 影子算法属性配置
+```
详情请参见[内置影子算法列表](/cn/user-manual/common-config/builtin-algorithm/shadow)
## 操作步骤
-1. 创建生产和影子数据源。
-2. 配置影子规则
- - 配置影子数据源
- - 配置影子表
- - 配置影子算法
+
+1. 在 SpringBoot 文件中配置影子库规则,包含数据源、影子规则、全局属性等配置项。
+2. 启动 SpringBoot 程序,会自动加载配置,并初始化 ShardingSphereDataSource。
## 配置示例
```properties
-spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.production-data-source-name=
# 生产数据源名称
-spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=
# 影子数据源名称
+spring.shardingsphere.datasource.names=ds,shadow-ds
-spring.shardingsphere.rules.shadow.tables.<table-name>.data-source-names= #
影子表关联影子数据源名称列表(多个值用","隔开)
-spring.shardingsphere.rules.shadow.tables.<table-name>.shadow-algorithm-names=
# 影子表关联影子算法名称列表(多个值用","隔开)
+spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds.username=root
+spring.shardingsphere.datasource.ds.password=
-spring.shardingsphere.rules.shadow.defaultShadowAlgorithmName= # 默认影子算法名称,选配项
+spring.shardingsphere.datasource.shadow-ds.jdbc-url=jdbc:mysql://localhost:3306/shadow_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.shadow-ds.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.shadow-ds.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.shadow-ds.username=root
+spring.shardingsphere.datasource.shadow-ds.password=
-spring.shardingsphere.rules.shadow.shadow-algorithms.<shadow-algorithm-name>.type=
# 影子算法类型
-spring.shardingsphere.rules.shadow.shadow-algorithms.<shadow-algorithm-name>.props.xxx=
# 影子算法属性配置
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.production-data-source-name=ds
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=shadow-ds
+
+spring.shardingsphere.rules.shadow.tables.t_user.data-source-names=shadow-data-source
+spring.shardingsphere.rules.shadow.tables.t_user.shadow-algorithm-names=user-id-insert-match-algorithm,simple-hint-algorithm
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.operation=insert
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.column=user_id
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.type=SIMPLE_HINT
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.shadow=true
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.foo=bar
```
## 相关参考
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/shadow.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/shadow.en.md
index d48cafbeb77..4ed1928e14a 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/shadow.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/spring-boot-starter/rules/shadow.en.md
@@ -7,47 +7,7 @@ weight = 5
If you want to use the ShardingSphere Shadow DB feature in the Spring Boot
environment, please refer to the following configuration.
## Parameters
-### Root Configuration
-```properties
-spring.shardingsphere.rules.shadow
-```
-
-### Configurable attributes
-| *Name* | *Description*
| *Default Value* |
-| ----------------------------- |
-------------------------------------------------------- | ---------------- |
-| data-sources | Shadow DB logical data source mapping
configuration list | none |
-| tables | Shadow table configuration list
| none |
-| shadowAlgorithms | Shadow algorithm configuration list
| none |
-| default-shadow-algorithm-name | Default shadow algorithm name
| none, options |
-
-### Shadow Data Source Configuration
-| *Name* | *Description* | *Default Value*
|
-| --------------------------- | --------------------------- | ----------------
|
-| production-data-source-name | Production data source name | none
|
-| shadow-data-source-name | Shadow data source name | none
|
-
-### Shadow Table Configuration
-| *Name* | *Description*
| *Default Value* |
-| ---------------------- |
--------------------------------------------------------------------- |
---------------- |
-| data-source-names | Shadow table associated shadow database logical
data source name list | none |
-| shadow-algorithm-names | Shadow table associated shadow algorithm name list
| none |
-
-### Shadow Algorithm Configuration
-| *Name* | *Description* | *Default Value* |
-| ------- | ------------------------------ | ---------------- |
-| type | Shadow algorithm type | none |
-| props | Shadow algorithm configuration | none |
-For details, see [list of built-in shadow
algorithms](/en/user-manual/common-config/builtin-algorithm/shadow/)
-
-## Procedure
-1. Create production and shadow data sources.
-2. Configure shadow rules:
- - Configure shadow data sources
- - Configure shadow tables
- - Configure shadow algorithm
-
-## Sample
```properties
spring.shardingsphere.datasource.names= # Omit the data source configuration,
please refer to the usage
@@ -63,6 +23,44 @@
spring.shardingsphere.rules.shadow.shadow-algorithms.<shadow-algorithm-name>.typ
spring.shardingsphere.rules.shadow.shadow-algorithms.<shadow-algorithm-name>.props.xxx=
# Shadow algorithm property configuration
```
+For details, see [list of built-in shadow
algorithms](/en/user-manual/common-config/builtin-algorithm/shadow/)
+
+## Procedure
+1. Configure the shadow library rules in the SpringBoot file, including
configuration items such as data sources, shadow rules, and global properties.
+2. Start the SpringBoot program, the configuration will be loaded
automatically, and the ShardingSphereDataSource will be initialized.
+
+## Sample
+```properties
+spring.shardingsphere.datasource.names=ds,shadow-ds
+
+spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds.username=root
+spring.shardingsphere.datasource.ds.password=
+
+spring.shardingsphere.datasource.shadow-ds.jdbc-url=jdbc:mysql://localhost:3306/shadow_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.shadow-ds.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.shadow-ds.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.shadow-ds.username=root
+spring.shardingsphere.datasource.shadow-ds.password=
+
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.production-data-source-name=ds
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=shadow-ds
+
+spring.shardingsphere.rules.shadow.tables.t_user.data-source-names=shadow-data-source
+spring.shardingsphere.rules.shadow.tables.t_user.shadow-algorithm-names=user-id-insert-match-algorithm,simple-hint-algorithm
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.operation=insert
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.column=user_id
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.type=SIMPLE_HINT
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.shadow=true
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.foo=bar
+```
+
## Related References
- [Feature Description of Shadow DB](/en/features/shadow/)
- [JAVA API: Shadow DB
](/en/user-manual/shardingsphere-jdbc/java-api/rules/shadow/)