You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/02/07 13:34:35 UTC

[GitHub] [shardingsphere] huanghao495430759 opened a new pull request #9378: Fix#9286

huanghao495430759 opened a new pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378


   add doc of mix rule for spring boot
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #9378: Fix#9286

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378#discussion_r571759699



##########
File path: docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/mix.cn.md
##########
@@ -3,4 +3,83 @@ title = "混合规则"
 weight = 6
 +++
 
-TODO
+混合配置的规则项之间的叠加使用是通过数据源名称和表名称关联的。
+
+如果前一个规则是面向数据源聚合的,下一个规则在配置数据源时,则需要使用前一个规则配置的聚合后的逻辑数据源名称;
+同理,如果前一个规则是面向表聚合的,下一个规则在配置表时,则需要使用前一个规则配置的聚合后的逻辑表名称。
+
+## 配置项说明
+```properties
+# 数据源配置
+# 数据源名称,多数据源以逗号分隔
+spring.shardingsphere.datasource.names= primary-ds0,primary-ds1,primary-ds0-replica0,primary-ds1-replica0
+
+spring.shardingsphere.datasource.primary-ds0.url= # 数据库 URL 连接
+spring.shardingsphere.datasource.primary-ds0.type=  # 数据库连接池类名称
+spring.shardingsphere.datasource.primary-ds0.driver-class-name= # 数据库驱动类名
+spring.shardingsphere.datasource.primary-ds0.username= # 数据库用户名
+spring.shardingsphere.datasource.primary-ds0.password= # 数据库密码
+spring.shardingsphere.datasource.primary-ds0.xxx=  # 数据库连接池的其它属性
+
+spring.shardingsphere.datasource.primary-ds1.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+spring.shardingsphere.datasource.primary-ds0-replica0.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+spring.shardingsphere.datasource.primary-ds1-replica0.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+# 分片规则配置
+# 分库策略
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=default-database-strategy-inline
+spring.shardingsphere.rules.sharding.binding-tables= # 绑定表名称,多个表之间以逗号分隔
+spring.shardingsphere.rules.sharding.broadcast-tables= # 广播表名称,多个表之间以逗号分隔
+
+# 分表策略
+# 数据源名称 `ds` 使用读写分离配置的逻辑数据源名称
+spring.shardingsphere.rules.sharding.tables.t_user.actual-data-nodes=ds.t_user_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-algorithm-name=user-table-strategy-inline
+
+# 数据加密配置
+# `t_user` 使用分片规则配置的逻辑表名称
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.cipher-column=user_name
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.encryptor-name=name-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.cipher-column=pwd
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.encryptor-name=pwd-encryptor
+
+# 数据加密算法配置
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.props.aes-key-value=123456abc
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.props.aes-key-value=123456abc
+
+# 分布式序列算法配置
+spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.column=user_id
+spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.key-generator-name=snowflake
+
+# 分片算法配置
+spring.shardingsphere.rules.sharding.sharding-algorithms.default-database-strategy-inline.type=INLINE
+# 数据源名称 `ds` 使用读写分离配置的逻辑数据源名称

Review comment:
       Hi what is this comment for?

##########
File path: docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/mix.cn.md
##########
@@ -3,4 +3,83 @@ title = "混合规则"
 weight = 6
 +++
 
-TODO
+混合配置的规则项之间的叠加使用是通过数据源名称和表名称关联的。
+
+如果前一个规则是面向数据源聚合的,下一个规则在配置数据源时,则需要使用前一个规则配置的聚合后的逻辑数据源名称;
+同理,如果前一个规则是面向表聚合的,下一个规则在配置表时,则需要使用前一个规则配置的聚合后的逻辑表名称。
+
+## 配置项说明
+```properties
+# 数据源配置
+# 数据源名称,多数据源以逗号分隔
+spring.shardingsphere.datasource.names= primary-ds0,primary-ds1,primary-ds0-replica0,primary-ds1-replica0
+
+spring.shardingsphere.datasource.primary-ds0.url= # 数据库 URL 连接
+spring.shardingsphere.datasource.primary-ds0.type=  # 数据库连接池类名称
+spring.shardingsphere.datasource.primary-ds0.driver-class-name= # 数据库驱动类名
+spring.shardingsphere.datasource.primary-ds0.username= # 数据库用户名
+spring.shardingsphere.datasource.primary-ds0.password= # 数据库密码
+spring.shardingsphere.datasource.primary-ds0.xxx=  # 数据库连接池的其它属性
+
+spring.shardingsphere.datasource.primary-ds1.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+spring.shardingsphere.datasource.primary-ds0-replica0.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+spring.shardingsphere.datasource.primary-ds1-replica0.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+# 分片规则配置
+# 分库策略
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=default-database-strategy-inline
+spring.shardingsphere.rules.sharding.binding-tables= # 绑定表名称,多个表之间以逗号分隔
+spring.shardingsphere.rules.sharding.broadcast-tables= # 广播表名称,多个表之间以逗号分隔
+
+# 分表策略
+# 数据源名称 `ds` 使用读写分离配置的逻辑数据源名称
+spring.shardingsphere.rules.sharding.tables.t_user.actual-data-nodes=ds.t_user_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-algorithm-name=user-table-strategy-inline
+
+# 数据加密配置
+# `t_user` 使用分片规则配置的逻辑表名称
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.cipher-column=user_name
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.encryptor-name=name-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.cipher-column=pwd
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.encryptor-name=pwd-encryptor
+
+# 数据加密算法配置
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.props.aes-key-value=123456abc
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.props.aes-key-value=123456abc
+
+# 分布式序列算法配置
+spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.column=user_id
+spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.key-generator-name=snowflake
+
+# 分片算法配置
+spring.shardingsphere.rules.sharding.sharding-algorithms.default-database-strategy-inline.type=INLINE
+# 数据源名称 `ds` 使用读写分离配置的逻辑数据源名称
+spring.shardingsphere.rules.sharding.sharding-algorithms.default-database-strategy-inline.algorithm-expression=ds$->{user_id % 2}
+spring.shardingsphere.rules.sharding.sharding-algorithms.user-table-strategy-inline.type=INLINE
+spring.shardingsphere.rules.sharding.sharding-algorithms.user-table-strategy-inline.algorithm-expression=t_user_$->{user_id % 2}
+
+# 分布式序列算法配置
+spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker-id=123
+
+# 读写分离策略配置
+# ds_0,ds_1为读写分离配置的逻辑数据源名称
+spring.shardingsphere.rules.replica-query.data-sources.ds_0.primary-data-source-name=primary-ds0

Review comment:
       Hi `ds_0` and `ds_1` are logic ds, aren't they? But I did not find where they are referred?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] huanghao495430759 commented on pull request #9378: Fix#9286

Posted by GitBox <gi...@apache.org>.
huanghao495430759 commented on pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378#issuecomment-783842058


   > Hi @huanghao495430759 ,
   > 
   > After another PR from you was merged, there are some conflicts. Could you give them a look?
   
   close this PR can resolve this conflict?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #9378: Fix#9286

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378#discussion_r579971646



##########
File path: docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/mix.en.md
##########
@@ -3,4 +3,82 @@ title = "Mixed Rules"
 weight = 6
 +++
 
-TODO
+The superposition between rules in mixed configuration is associated by data source name and table name.

Review comment:
       I am sorry, but actually these English statements are difficult to understand. Since you have some comments on the following configuration items, could you remove these instruction to avoid any confusion?

##########
File path: docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/mix.cn.md
##########
@@ -3,4 +3,83 @@ title = "混合规则"
 weight = 6
 +++
 
-TODO
+混合配置的规则项之间的叠加使用是通过数据源名称和表名称关联的。
+
+如果前一个规则是面向数据源聚合的,下一个规则在配置数据源时,则需要使用前一个规则配置的聚合后的逻辑数据源名称;
+同理,如果前一个规则是面向表聚合的,下一个规则在配置表时,则需要使用前一个规则配置的聚合后的逻辑表名称。
+
+## 配置项说明
+```properties
+# 数据源配置
+# 数据源名称,多数据源以逗号分隔
+spring.shardingsphere.datasource.names= primary-ds0,primary-ds1,primary-ds0-replica0,primary-ds1-replica0
+
+spring.shardingsphere.datasource.primary-ds0.url= # 数据库 URL 连接
+spring.shardingsphere.datasource.primary-ds0.type=  # 数据库连接池类名称
+spring.shardingsphere.datasource.primary-ds0.driver-class-name= # 数据库驱动类名
+spring.shardingsphere.datasource.primary-ds0.username= # 数据库用户名
+spring.shardingsphere.datasource.primary-ds0.password= # 数据库密码
+spring.shardingsphere.datasource.primary-ds0.xxx=  # 数据库连接池的其它属性
+
+spring.shardingsphere.datasource.primary-ds1.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+spring.shardingsphere.datasource.primary-ds0-replica0.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+spring.shardingsphere.datasource.primary-ds1-replica0.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+# 分片规则配置
+# 分库策略
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=default-database-strategy-inline
+spring.shardingsphere.rules.sharding.binding-tables= # 绑定表名称,多个表之间以逗号分隔

Review comment:
       Hi a little curiosity, how to configure multiple groups of binding-tables here? FYI., the style of yaml is about,
   ```yaml
   bindingTables:
       - t_order,t_order_item
       - t1, t2
     broadcastTables:
       - t_address
       - t_3
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] huanghao495430759 closed pull request #9378: Fix#9286

Posted by GitBox <gi...@apache.org>.
huanghao495430759 closed pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #9378: Fix#9286

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378#issuecomment-783840374


   Hi @huanghao495430759 ,
   
   After another PR from you was merged, there are some conflicts. Could you give them a look?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] huanghao495430759 commented on a change in pull request #9378: Fix#9286

Posted by GitBox <gi...@apache.org>.
huanghao495430759 commented on a change in pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378#discussion_r571767255



##########
File path: docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/mix.cn.md
##########
@@ -3,4 +3,83 @@ title = "混合规则"
 weight = 6
 +++
 
-TODO
+混合配置的规则项之间的叠加使用是通过数据源名称和表名称关联的。
+
+如果前一个规则是面向数据源聚合的,下一个规则在配置数据源时,则需要使用前一个规则配置的聚合后的逻辑数据源名称;
+同理,如果前一个规则是面向表聚合的,下一个规则在配置表时,则需要使用前一个规则配置的聚合后的逻辑表名称。
+
+## 配置项说明
+```properties
+# 数据源配置
+# 数据源名称,多数据源以逗号分隔
+spring.shardingsphere.datasource.names= primary-ds0,primary-ds1,primary-ds0-replica0,primary-ds1-replica0
+
+spring.shardingsphere.datasource.primary-ds0.url= # 数据库 URL 连接
+spring.shardingsphere.datasource.primary-ds0.type=  # 数据库连接池类名称
+spring.shardingsphere.datasource.primary-ds0.driver-class-name= # 数据库驱动类名
+spring.shardingsphere.datasource.primary-ds0.username= # 数据库用户名
+spring.shardingsphere.datasource.primary-ds0.password= # 数据库密码
+spring.shardingsphere.datasource.primary-ds0.xxx=  # 数据库连接池的其它属性
+
+spring.shardingsphere.datasource.primary-ds1.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+spring.shardingsphere.datasource.primary-ds0-replica0.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+spring.shardingsphere.datasource.primary-ds1-replica0.url= # 数据库 URL 连接
+... 忽略其他数据库配置项
+
+# 分片规则配置
+# 分库策略
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=default-database-strategy-inline
+spring.shardingsphere.rules.sharding.binding-tables= # 绑定表名称,多个表之间以逗号分隔
+spring.shardingsphere.rules.sharding.broadcast-tables= # 广播表名称,多个表之间以逗号分隔
+
+# 分表策略
+# 数据源名称 `ds` 使用读写分离配置的逻辑数据源名称
+spring.shardingsphere.rules.sharding.tables.t_user.actual-data-nodes=ds.t_user_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-algorithm-name=user-table-strategy-inline
+
+# 数据加密配置
+# `t_user` 使用分片规则配置的逻辑表名称
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.cipher-column=user_name
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.encryptor-name=name-encryptor
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.cipher-column=pwd
+spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.encryptor-name=pwd-encryptor
+
+# 数据加密算法配置
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.props.aes-key-value=123456abc
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.type=AES
+spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.props.aes-key-value=123456abc
+
+# 分布式序列算法配置
+spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.column=user_id
+spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.key-generator-name=snowflake
+
+# 分片算法配置
+spring.shardingsphere.rules.sharding.sharding-algorithms.default-database-strategy-inline.type=INLINE
+# 数据源名称 `ds` 使用读写分离配置的逻辑数据源名称

Review comment:
       Oh,it is my mistake,I should be comment what the inline expression means instead of `ds` means .




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] huanghao495430759 commented on pull request #9378: Fix#9286

Posted by GitBox <gi...@apache.org>.
huanghao495430759 commented on pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378#issuecomment-782815461


   > Hi @huanghao495430759
   > Kindly ping here.
   
   Hi @tristaZero  I've reviewed it a few days ago.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #9378: Fix#9286

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378#issuecomment-774839749


   Hi @huanghao495430759 ,
   
   Thanks for your PR. There are some comments to review.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #9378: Fix#9286

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #9378:
URL: https://github.com/apache/shardingsphere/pull/9378#issuecomment-782527463


   Hi @huanghao495430759 
   Kindly ping here.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org