1
- rules :
2
- - !SHARDING
3
- tables : # Sharding table configuration
4
- apijson_user :
5
- actualDataNodes : ds-$->{0..1}.apijson_user # 分库 shading databases/schemas
6
- Moment : # Logic table name
7
- actualDataNodes : ds-0.Moment_$->{0..1} # 分表 shading tables
8
- Comment : # Logic table name
9
- actualDataNodes : ds-$->{0..1}.Comment_$->{0..1} # 分库*分表 shading both databases/schemas and tables
10
1
dataSources :
11
2
ds-0 :
12
3
dataSourceClassName : com.zaxxer.hikari.HikariDataSource
@@ -19,4 +10,48 @@ dataSources:
19
10
driverClassName : com.mysql.jdbc.Driver
20
11
jdbcUrl : jdbc:mysql://localhost:3306/ds_2?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8
21
12
username : root
22
- password : apijson
13
+ password : apijson
14
+
15
+ rules :
16
+ - !SHARDING
17
+ tables : # Sharding table configuration
18
+ apijson_user :
19
+ actualDataNodes : ds-$->{0..1}.apijson_user # 分库 shading databases/schemas
20
+ databaseStrategy :
21
+ standard :
22
+ shardingColumn : id
23
+ shardingAlgorithmName : user-sharding-ds
24
+ Moment : # Logic table name
25
+ actualDataNodes : ds-0.Moment_$->{0..1} # 分表 shading tables
26
+ tableStrategy :
27
+ standard :
28
+ shardingColumn : userId
29
+ shardingAlgorithmName : moment-sharding-table
30
+ Comment : # Logic table name
31
+ actualDataNodes : ds-$->{0..1}.Comment_$->{0..1} # 分库*分表 shading both databases/schemas and tables
32
+ databaseStrategy :
33
+ standard :
34
+ shardingColumn : userId
35
+ shardingAlgorithmName : comment-sharding-ds
36
+ tableStrategy :
37
+ standard :
38
+ shardingColumn : momentId
39
+ shardingAlgorithmName : comment-sharding-table
40
+
41
+ shardingAlgorithms :
42
+ user-sharding-ds :
43
+ type : INLINE
44
+ props :
45
+ algorithm-expression : ds-${id % 2}
46
+ moment-sharding-table :
47
+ type : INLINE
48
+ props :
49
+ algorithm-expression : Moment_${userId % 2}
50
+ comment-sharding-ds :
51
+ type : INLINE
52
+ props :
53
+ algorithm-expression : ds-${userId % 2}
54
+ comment-sharding-table :
55
+ type : INLINE
56
+ props :
57
+ algorithm-expression : Comment_${momentId % 2}
0 commit comments