|
@@ -15,12 +15,19 @@ mybatis:
|
|
|
|
|
|
mydbinfo:
|
|
mydbinfo:
|
|
list:
|
|
list:
|
|
- - shardingDbName: sharding-user
|
|
|
|
|
|
+ - shardingDbName: sharding0
|
|
ip: 47.108.115.128
|
|
ip: 47.108.115.128
|
|
port: 3306
|
|
port: 3306
|
|
- dbname: sharding
|
|
|
|
- username: sharding
|
|
|
|
- password: TpTX2s47fNHF5EpG
|
|
|
|
|
|
+ dbname: sharding0
|
|
|
|
+ username: root
|
|
|
|
+ password: zdd755
|
|
|
|
+ tables: t_user_,t_order_
|
|
|
|
+ - shardingDbName: sharding1
|
|
|
|
+ ip: 47.108.115.128
|
|
|
|
+ port: 3306
|
|
|
|
+ dbname: sharding1
|
|
|
|
+ username: root
|
|
|
|
+ password: zdd755
|
|
tables: t_user_,t_order_
|
|
tables: t_user_,t_order_
|
|
|
|
|
|
spring:
|
|
spring:
|
|
@@ -32,24 +39,44 @@ spring:
|
|
shardingsphere:
|
|
shardingsphere:
|
|
datasource:
|
|
datasource:
|
|
#数据库别名
|
|
#数据库别名
|
|
- names: sharding-user
|
|
|
|
- sharding-user:
|
|
|
|
|
|
+ names: sharding0,sharding1
|
|
|
|
+ sharding0:
|
|
|
|
+ type: com.alibaba.druid.pool.DruidDataSource
|
|
|
|
+ driver-class-name: com.mysql.cj.jdbc.Driver
|
|
|
|
+ url: jdbc:mysql://47.108.115.128:3306/sharding0?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
|
|
|
+ username: root
|
|
|
|
+ password: zdd755
|
|
|
|
+ sharding1:
|
|
type: com.alibaba.druid.pool.DruidDataSource
|
|
type: com.alibaba.druid.pool.DruidDataSource
|
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
|
- url: jdbc:mysql://47.108.115.128:3306/sharding?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
|
|
|
- username: sharding
|
|
|
|
- password: TpTX2s47fNHF5EpG
|
|
|
|
|
|
+ url: jdbc:mysql://47.108.115.128:3306/sharding1?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
|
|
|
+ username: root
|
|
|
|
+ password: zdd755
|
|
sharding:
|
|
sharding:
|
|
tables:
|
|
tables:
|
|
#逻辑表名
|
|
#逻辑表名
|
|
t_user_:
|
|
t_user_:
|
|
- actual-data-nodes: sharding-user.t_user_$->{2022}
|
|
|
|
|
|
+ actual-data-nodes: sharding$->{0..1}.t_user_$->{2022..2023}
|
|
|
|
+# key-generator:
|
|
|
|
+# column: id
|
|
|
|
+# type: SNOWFLAKE
|
|
|
|
+ databaseStrategy:
|
|
|
|
+ inline:
|
|
|
|
+ shardingColumn: id
|
|
|
|
+ algorithmExpression: sharding${id % 2}
|
|
table-strategy:
|
|
table-strategy:
|
|
standard:
|
|
standard:
|
|
sharding-column: year
|
|
sharding-column: year
|
|
precise-algorithm-class-name: com.xin.shardingspherejdbcdemo.config.sharding.TableShardingAlgorithm
|
|
precise-algorithm-class-name: com.xin.shardingspherejdbcdemo.config.sharding.TableShardingAlgorithm
|
|
t_order_:
|
|
t_order_:
|
|
- actual-data-nodes: sharding-user.t_order_$->{2022}
|
|
|
|
|
|
+ actual-data-nodes: sharding$->{0..1}.t_order_$->{2022..2023}
|
|
|
|
+# key-generator:
|
|
|
|
+# column: id
|
|
|
|
+# type: SNOWFLAKE
|
|
|
|
+ databaseStrategy:
|
|
|
|
+ inline:
|
|
|
|
+ shardingColumn: id
|
|
|
|
+ algorithmExpression: sharding${id % 2}
|
|
table-strategy:
|
|
table-strategy:
|
|
standard:
|
|
standard:
|
|
sharding-column: year
|
|
sharding-column: year
|