微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

sharding demo

application-sharding.yml

sharding:
jdbc:
datasource:
names: ds0,ds1,dsx,dsy
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.MysqL.jdbc.Driver
jdbc-url: jdbc:MysqL://localhost:3306/db0?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
ds1:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.MysqL.jdbc.Driver
jdbc-url: jdbc:MysqL://localhost:3306/db1?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
dsx:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.MysqL.jdbc.Driver
jdbc-url: jdbc:MysqL://localhost:3306/db2?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
dsy:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.MysqL.jdbc.Driver
jdbc-url: jdbc:MysqL://localhost:3306/db3?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
config:
sharding:
default-database-strategy:
inline:
sharding-column: order_id
algorithm-expression: ds$->{order_id % 2}
tables:
t_order:
actual-data-nodes: ds$->{5..6}.t_order_$->{0..1}
table-strategy:
inline:
sharding-column: user_id
algorithm-expression: t_order_$->{user_id % 2}
key-generator-column-name: id

props:
sql:
show: true
master-slave-rules:
ds5:
master-data-source-name: ds0
slave-data-source-names: dsx
load-balance-algorithm-type: round_robin
ds6:
master-data-source-name: ds1
slave-data-source-names: dsy
load-balance-algorithm-class-name: shardingsphere.demo.balance.NewBananceAlgorithm


application.yml
logging:
level:
ROOT: INFO
shardingsphere.demo: DEBUG
shardingsphere.demo.mapper: debug
server:
port: 8100

mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: shardingsphere.demo.entity
config-location: classpath:mybatis-config.xml

spring:
profiles:
active: sharding

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐