spring: shardingsphere: enabled: true props: sql-show: true mode: type: Memory schema: name: multit-tenant datasource: # 配置真实数据源 names: ds0,ds1 ds0: # 配置第 1 个数据源 type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver jdbc-url: jdbc:mysql://xxx username: password: ds1: # 配置第 2 个数据源 type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver jdbc-url: jdbc:mysql://xxx username: password: rules: sharding: # 配置 分片算法 sharding-algorithms: my: # 分片类型 type: CLASS_BASED props: strategy: STANDARD algorithmClassName: com.sunjee.portal.config.sharding.YearMonthShardingAlgorithm #引用分表类 tables: tableName: # 分表,表名 # 分表年月 ds指向下面读写分离数据的名称 actual-data-nodes: ds.zwwx_login_${2022..2099}0${1..9},ds.zwwx_login_${2022..2099}1${0..2} #数据节点,均匀分布 table-strategy: # 配置分表策略 standard: sharding-column: create_date sharding-algorithm-name: my #读写分离配置 readwriteSplitting: data-sources: ds: type: Static loadBalancerName: my props: write-data-source-name: ds0 read-data-source-names: ds1 loadBalancers: my: # 负载均衡算法名称 type: ROUND_ROBIN # 负载均衡算法类型 props: default: 0
shardingsphere-jdbc 5.1.0 yml读写分离,分表配置记录
最新推荐文章于 2024-08-12 17:29:36 发布