影子库压测
语法说明
CREATE SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
ALTER SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
CREATE SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
ALTER SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
DROP SHADOW RULE ruleName [, ruleName] ...
DROP SHADOW ALGORITHM algorithmName [, algorithmName] ...
CREATE DEFAULT SHADOW ALGORITHM NAME = algorithmName
shadowRuleDefinition: ruleName(resourceMapping, shadowTableRule [, shadowTableRule] ...)
resourceMapping: SOURCE=resourceName, SHADOW=resourceName
shadowTableRule: tableName(shadowAlgorithm [, shadowAlgorithm] ...)
shadowAlgorithm: ([algorithmName, ] TYPE(NAME=shadowAlgorithmType, PROPERTIES([algorithmProperties] ...)))
algorithmProperties: algorithmProperty [, algorithmProperty] ...
algorithmProperty: key=value
- 重复的
ruleName
无法被创建 resourceMapping
指定源数据库和影子库的映射关系,需使用 RDL 管理的resource
,请参考 数据源资源shadowAlgorithm
可同时作用于多个shadowTableRule
algorithmName
未指定时会根据ruleName
、tableName
和shadowAlgorithmType
自动生成shadowAlgorithmType
目前支持VALUE_MATCH
、REGEX_MATCH
和SIMPLE_HINT
shadowTableRule
能够被不同的shadowRuleDefinition
复用,因此在执行DROP SHADOW RULE
时,对应的shadowTableRule
不会被移除shadowAlgorithm
能够被不同的shadowTableRule
复用,因此在执行ALTER SHADOW RULE
时,对应的shadowAlgorithm
不会被移除
示例
CREATE SHADOW RULE shadow_rule(
SOURCE=demo_ds,
SHADOW=demo_ds_shadow,
t_order((simple_hint_algorithm, TYPE(NAME=SIMPLE_HINT, PROPERTIES("shadow"="true", foo="bar"))),(TYPE(NAME=REGEX_MATCH, PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]')))),
t_order_item((TYPE(NAME=VALUE_MATCH, PROPERTIES("operation"="insert","column"="user_id", "value"='1')))));
ALTER SHADOW RULE shadow_rule(
SOURCE=demo_ds,
SHADOW=demo_ds_shadow,
t_order((simple_hint_algorithm, TYPE(NAME=SIMPLE_HINT, PROPERTIES("shadow"="true", foo="bar"))),(TYPE(NAME=REGEX_MATCH, PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]')))),
t_order_item((TYPE(NAME=VALUE_MATCH, PROPERTIES("operation"="insert","column"="user_id", "value"='1')))));
CREATE SHADOW ALGORITHM
(simple_hint_algorithm, TYPE(NAME=SIMPLE_HINT, PROPERTIES("shadow"="true", "foo"="bar"))),
(user_id_match_algorithm, TYPE(NAME=REGEX_MATCH,PROPERTIES("operation"="insert", "column"="user_id", "regex"='[1]')));
ALTER SHADOW ALGORITHM
(simple_hint_algorithm, TYPE(NAME=SIMPLE_HINT, PROPERTIES("shadow"="false", "foo"="bar"))),
(user_id_match_algorithm, TYPE(NAME=VALUE_MATCH,PROPERTIES("operation"="insert", "column"="user_id", "value"='1')));
DROP SHADOW RULE shadow_rule;
DROP SHADOW ALGORITHM simple_note_algorithm;
CREATE DEFAULT SHADOW ALGORITHM NAME = simple_hint_algorithm;
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .