|
|
|
@ -2,19 +2,27 @@ spring.profiles.active=${SPRING_PROFILES_ACTIVE:dev} |
|
|
|
|
|
|
|
|
|
|
|
# sharding-jdbc 配置 |
|
|
|
# sharding-jdbc 配置 |
|
|
|
# 配置数据源 |
|
|
|
# 配置数据源 |
|
|
|
spring.shardingsphere.datasource.names=db1 |
|
|
|
spring.shardingsphere.datasource.names=ds1 |
|
|
|
|
|
|
|
spring.shardingsphere.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource |
|
|
|
spring.shardingsphere.datasource.db1.type=com.zaxxer.hikari.HikariDataSource |
|
|
|
spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver |
|
|
|
spring.shardingsphere.datasource.db1.driver-class-name=com.mysql.cj.jdbc.Driver |
|
|
|
spring.shardingsphere.datasource.ds1.jdbc-url=jdbc:mysql://cd-cdb-mrz9fw80.sql.tencentcdb.com:61843/soim_db?serverTimezone=GMT%2B8 |
|
|
|
spring.shardingsphere.datasource.db1.jdbc-url=jdbc:mysql://cd-cdb-mrz9fw80.sql.tencentcdb.com:61843/soim_db?serverTimezone=GMT%2B8 |
|
|
|
spring.shardingsphere.datasource.ds1.username=root |
|
|
|
spring.shardingsphere.datasource.db1.username=root |
|
|
|
spring.shardingsphere.datasource.ds1.password=sopod@2347# |
|
|
|
spring.shardingsphere.datasource.db1.password=sopod@2347# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 分表 |
|
|
|
# 分表 |
|
|
|
spring.shardingsphere.sharding.tables.im_user.actual-data-nodes=db1.im_user_$->{0..2} |
|
|
|
#spring.shardingsphere.sharding.tables.im_user.actual-data-nodes=db1.im_user_$->{0..2} |
|
|
|
# 指定t_user表的分片策略,分片策略包括分片键和分片算法 |
|
|
|
## 指定im_user表的分片策略,分片策略包括分片键和分片算法 |
|
|
|
spring.shardingsphere.sharding.tables.im_user.table-strategy.inline.sharding-column=id |
|
|
|
#spring.shardingsphere.sharding.tables.im_user.table-strategy.inline.sharding-column=id |
|
|
|
spring.shardingsphere.sharding.tables.im_user.table-strategy.inline.algorithm-expression=im_user_$->{id % 3} |
|
|
|
#spring.shardingsphere.sharding.tables.im_user.table-strategy.inline.algorithm-expression=im_user_$->{id % 3} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 5.1.0 分表 |
|
|
|
|
|
|
|
# https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-tables.yaml |
|
|
|
|
|
|
|
spring.shardingsphere.rules.sharding.tables.im_user.actual-data-nodes=ds1.im_user_$->{0..2} |
|
|
|
|
|
|
|
spring.shardingsphere.rules.sharding.tables.im_user.table-strategy.standard.sharding-column=id |
|
|
|
|
|
|
|
spring.shardingsphere.rules.sharding.tables.im_user.table-strategy.standard.sharding-algorithm-name=im-user-inline |
|
|
|
|
|
|
|
spring.shardingsphere.rules.sharding.binding-tables=im_user |
|
|
|
|
|
|
|
spring.shardingsphere.rules.sharding.sharding-algorithms.im-user-inline.type=INLINE |
|
|
|
|
|
|
|
spring.shardingsphere.rules.sharding.sharding-algorithms.im-user-inline.props.algorithm-expression=im_user_$->{id % 3} |
|
|
|
|
|
|
|
|
|
|
|
# 打开sharding-jdbc sql输出日志 |
|
|
|
# 打开sharding-jdbc sql输出日志 |
|
|
|
spring.shardingsphere.props.sql.show=true |
|
|
|
spring.shardingsphere.props.sql-show=true |
|
|
|
|