1234567891011121314151617181920212223242526272829 |
- # 数据源配置:支持多数据源(即支持分库)
- dataSources:
- ds_0:
- driverClassName: com.mysql.cj.jdbc.Driver
- dataSourceClassName: com.zaxxer.hikari.HikariDataSource
- jdbcUrl: jdbc:mysql://192.168.36.128:3306/webchat_ugc?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT%2b8&allowPublicKeyRetrieval=true
- username: root
- password: 12345678
- # 分库分表规则配置
- rules:
- - !SINGLE
- defaultDataSource: ds_0
- tables:
- - ds_0.* # 声明 ds_0 下所有表为单表
- - !SHARDING
- tables:
- web_chat_moment_timeline:
- actualDataNodes: ds_0.web_chat_moment_timeline_${0..2}
- tableStrategy:
- standard:
- shardingColumn: user_id
- shardingAlgorithmName: timeline_table_hash_mod
- shardingAlgorithms:
- timeline_table_hash_mod:
- type: CLASS_BASED
- props:
- strategy: STANDARD
- algorithmClassName: com.webchat.ugc.config.shardingJdbc.CustomHashModShardingAlgorithm
- sharding-count: 3
|