Shadow DB
- Configure shadow DB rules in the YAML file, including data sources, shadow library rules, global properties and other configuration items;
- Call the method of the
YamlShardingSphereDataSourceFactory
object to create a ShardingSphereDataSource based on the configuration information in the YAML file.
dataSources:
ds:
url: jdbc:mysql://127.0.0.1:3306/ds?serverTimezone=UTC&useSSL=false
username: root
password:
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
url: jdbc:mysql://127.0.0.1:3306/shadow_ds?serverTimezone=UTC&useSSL=false
username: root
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:
- !SHADOW
dataSources:
shadowDataSource:
productionDataSourceName: ds
shadowDataSourceName: shadow_ds
tables:
t_order:
- shadowDataSource
shadowAlgorithmNames:
- user_id_insert_match_algorithm
- simple_hint_algorithm
shadowAlgorithms:
user_id_insert_match_algorithm:
type: REGEX_MATCH
props:
operation: insert
column: user_id
regex: "[1]"
simple_hint_algorithm:
type: SIMPLE_HINT
props: