Flyiyu commented on issue #20764:
URL:
https://github.com/apache/shardingsphere/issues/20764#issuecomment-1236294528
config yml
```yml
shardingsphere:
# 是否开启
enabled: true
mode:
type: Cluster
repository:
type: ZooKeeper
props:
namespace: governance_ds
server-lists: 127.0.0.1:2181
retryIntervalMilliseconds: 500
timeToLiveSeconds: 60
maxRetries: 3
operationTimeoutMilliseconds: 500
overwrite: false
datasource:
# 自定义的名称不能使用下划线,除了逻辑表名称
names: master0,master1
master0:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://127.0.0.1:3307/rootss
username: root
password: root
master1:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://127.0.0.1:3305/rootss
username: root
password: root
rules:
# 分片配置
sharding:
tables:
# 逻辑表名称
sys_experience_task:
# 由数据源名 + 表名组成(参考 Inline
语法规则https://shardingsphere.apache.org/document/5.1.1/cn/features/sharding/concept/inline-expression/)
actual-data-nodes:
master0.sys_experience_task_0,master1.sys_experience_task_1
# 分库策略
database-strategy:
standard:
sharding-column: id
sharding-algorithm-name: db-inline
# 分表策略
table-strategy:
standard:
sharding-column: id
sharding-algorithm-name: sys-experience-task-inline
# 分片算法配置
sharding-algorithms:
db-inline:
type: INLINE
props:
algorithm-expression: master$->{id % 2}
sys-experience-task-inline:
# 也可以自定义分片规则
type: INLINE
props:
algorithm-expression: sys_experience_task_$->{id % 2}
props:
# 打印sql
sql-show: true
```
--
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]