如果您想在 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
- sql_hint_algorithm
shadowAlgorithms:
user_id_insert_match_algorithm:
type: REGEX_MATCH
props:
operation: insert
column: user_id
regex: "[1]"
sql_hint_algorithm:
type: SQL_HINT