读写分离
mode:
type: Standalone
repository:
type: JDBC
dataSources:
write:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/yjgo?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root
read:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/yjgo?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root
rules:
- !SHARDING
autoTables:
sharding_test:
actualDataSources: write
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
shardingStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: auto_mod
shardingAlgorithms:
auto_mod:
type: MOD
props:
sharding-count: 3
keyGenerators:
snowflake:
type: SNOWFLAKE
- !READWRITE_SPLITTING
dataSources:
write:
writeDataSourceName: write
readDataSourceNames:
- read
loadBalancerName: round_robin
loadBalancers:
round_robin:
type: ROUND_ROBIN
props:
sql-show: true