如果您想在 ShardingSphere-Proxy 中使用 ShardingSphere 影子库功能请参考以下配置。
rules:
- !SHADOW
dataSources:
shadowDataSource:
productionDataSourceName: # 生产数据源名称
shadowDataSourceName: # 影子数据源名称
tables:
<table-name>:
dataSourceNames: # 影子表关联影子数据源名称列表
- <shadow-data-source>
shadowAlgorithmNames: # 影子表关联影子算法名称列表
- <shadow-algorithm-name>
defaultShadowAlgorithmName: # 默认影子算法名称(选配项)
shadowAlgorithms:
<shadow-algorithm-name> (+): # 影子算法名称
type: # 影子算法类型
props: # 影子算法属性配置
详情请参见内置影子算法列表
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
shadow_ds:
url: jdbc:mysql://127.0.0.1:3306/shadow_ds?serverTimezone=UTC&useSSL=false
username: root
password:
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:
- !SHADOW
dataSources:
shadowDataSource:
productionDataSourceName: ds
shadowDataSourceName: shadow_ds
tables:
t_order:
dataSourceNames:
- 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:
foo: bar