cunzhiwang commented on issue #28994:
URL:
https://github.com/apache/shardingsphere/issues/28994#issuecomment-2160370650
This is my config file
# 配置真实数据源
dataSources:
# 配置第 1 个数据源
ds0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url:
jdbc:mysql://127.0.0.1:3306/db_lab_orders_0?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true
username: root
password: root
# 配置第 2 个数据源
ds1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url:
jdbc:mysql://127.0.0.1:3306/db_lab_orders_1?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true
username: root
password: root
rules:
# 配置分片规则
- !SHARDING
tables:
cmp_contract:
actualDataNodes:
ds0.cmp_contract_$->{[0,2,4,6]},ds1.cmp_contract_$->{[1,3,5,7]}
# 配置分库策略
databaseStrategy:
standard:
shardingColumn: ID
shardingAlgorithmName: database_inline
# 配置分表策略
tableStrategy:
standard:
shardingColumn: ID
shardingAlgorithmName: table_inline
# 配置分片算法
shardingAlgorithms:
database_inline:
type: INLINE
props:
algorithm-expression: ds${ID % 2}
table_inline:
type: INLINE
props:
algorithm-expression: cmp_contract_${ID % 8}
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]