sharding.yml
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# !!!数据源名称要和动态数据源中配置的名称一致
databaseName: master
# 具体参看官网文档说明
dataSources:
coupon_user_db_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl: jdbc:mysql://192.168.1.18:3306/ruoyi-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
username: root
password: root
rules:
- !SHARDING
tables: # 数据分片规则配置
coupon_user: # 逻辑表名称
actualDataNodes: coupon_user_db_0.coupon_user_$->{0..9} # 由数据源名 + 表名组成(参考 Inline 语法规则)
databaseStrategy: # 分库策略,缺省表示使用默认分库策略,以下的分片策略只能选其一
none:
tableStrategy: # 分表策略
standard: # 用于单分片键的标准分片场景
shardingColumn: user_id # 分片列名称
shardingAlgorithmName: user_inline
keyGenerateStrategy:
column: id
keyGeneratorName: snowflake
keyGenerators:
snowflake:
type: SNOWFLAKE
props:
worker-id: 123
# 分片算法配置
shardingAlgorithms:
user_inline:
type: INLINE
props:
algorithm-expression: coupon_user_$->{user_id % 10}
props:
sql-show: true