tianhao960 commented on issue #20506:
URL:
https://github.com/apache/shardingsphere/issues/20506#issuecomment-1239353744
@strongduanmu try the sharding scenario with following config:
`spring:
shardingsphere:
# 是否开启
datasource:
# 数据源(逻辑名字)
names: m1
# 配置数据源
m1:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: org.postgresql.Driver
jdbc-url: jdbc:postgresql://192.168.64.2:5432/test
username: root
password: 123456
# 分片的配置
rules:
sharding:
# 表的分片策略
tables:
# 逻辑表的名称
tb_user:
# 数据节点配置,采用Groovy表达式
actual-data-nodes: m1.tb_user${0..1}
# 配置策略
table-strategy:
# 用于单分片键的标准分片场景
standard:
sharding-column: id
# 分片算法名字
sharding-algorithm-name: user_inline
key-generate-strategy: # 主键生成策略
column: id # 主键列
key-generator-name: snowflake # 策略算法名称(推荐使用雪花算法)
key-generators:
snowflake:
type: SNOWFLAKE
sharding-algorithms:
user_inline:
type: inline
props:
algorithm-expression: tb_user$->{id % 2}
props:
# 日志显示具体的SQL
sql-show: true`
and insert success.
--
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]