使用痛点:
1、现系统存在60个库 100张表 配置hint 分片策略,配置起来非常繁琐,是否有简化的配置
2、如何再此分片基础继续配置读写分离
配置如下:
spring.shardingsphere.datasource.names=ds1,ds2,ds3,ds4,ds5,ds6,ds7,ds8,ds9,ds10,ds11,ds12,ds13,ds14,ds15,ds16,ds17,ds18,ds19,ds20,ds21,ds22,ds23,ds24,ds25,ds26,ds27,ds28,ds29,ds30,ds31,ds32,ds33,ds34,ds35,ds36,ds37,ds38,ds39,ds40,ds41,ds42,ds43,ds44,ds45,ds46,ds47,ds48,ds49,ds50,ds51,ds52,ds53,ds54,ds55,ds56,ds57,ds58,ds59,ds60
spring.shardingsphere.datasource.common.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.common.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds1.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.ds1.driver‐class‐name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds1.url=jdbc:mysql://xxx.db.com:3306/MY_DB1?serverTimezone=Asia/Shanghai
spring.shardingsphere.datasource.ds1.username=admin
spring.shardingsphere.datasource.ds1.password=123456
spring.shardingsphere.datasource.ds2.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.ds2.driver‐class‐name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds2.url=jdbc:mysql://xxx.db.com:3306/MY_DB2?serverTimezone=Asia/Shanghai
spring.shardingsphere.datasource.ds2.username=admin
spring.shardingsphere.datasource.ds2.password=123456
#等等 60个数据源配置
标准分片表配置
spring.shardingsphere.rules.sharding.tables.my_table1.actual-data-nodes=ds$->{1…60}.my_table1
spring.shardingsphere.rules.sharding.tables.my_table2.actual-data-nodes=ds$->{1…60}.my_table2
spring.shardingsphere.rules.sharding.tables.my_table3.actual-data-nodes=ds$->{1…60}.my_table3
#等等 100个配置
spring.shardingsphere.rules.sharding.tables.my_table100.database-strategy.hint.sharding-algorithm-name=my-hint
#默认库分片策略
spring.shardingsphere.sharding.default-database-strategy.hint.sharding-algorithm-name=my-hint
分片算法配置
spring.shardingsphere.rules.sharding.sharding-algorithms.my-hint.type=CLASS_BASED
spring.shardingsphere.rules.sharding.sharding-algorithms.my-hint.props.strategy=HINT
spring.shardingsphere.rules.sharding.sharding-algorithms.my-hint.props.algorithmClassName=com.sharding.shardingjdbc.DatabaseHintShardingKeyAlgorithm
spring.shardingsphere.props.sql-show=true
#注:DatabaseHintShardingKeyAlgorithm 实现按分片建取模hint 指定具体的 ds 如:3456%60+1=50 则数据源指向 ds50
问题:配置读写分离后 hint 该如何指向ds ?