Appearance
下面这段配置的含义是,如果操作t_user
表则去ds_0
数据源操作,,如果操作t_order
表则去ds_1
数据源操作,t_user
与t_order
表是ShardingSphere中的虚拟表,和实际表名不相同也没关系,配置好了就行。
修改配置config-sharding.yaml
yaml
schemaName: sharding_db
dataSources:
ds_0:
url: jdbc:mysql://192.168.100.201:3301/db_user?serverTimezone=UTC&useSSL=false
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
ds_1:
url: jdbc:mysql://192.168.100.201:3302/db_order?serverTimezone=UTC&useSSL=false
username: root
password: 123456
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:
- !SHARDING
tables:
t_user:
actualDataNodes: ds_0.t_user
t_order:
actualDataNodes: ds_1.t_order