影子库压测

语法说明

  1. CREATE SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
  2. ALTER SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
  3. CREATE SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
  4. ALTER SHADOW ALGORITHM shadowAlgorithm [, shadowAlgorithm] ...
  5. DROP SHADOW RULE ruleName [, ruleName] ...
  6. DROP SHADOW ALGORITHM algorithmName [, algorithmName] ...
  7. CREATE DEFAULT SHADOW ALGORITHM NAME = algorithmName
  8. shadowRuleDefinition: ruleName(resourceMapping, shadowTableRule [, shadowTableRule] ...)
  9. resourceMapping: SOURCE=resourceName, SHADOW=resourceName
  10. shadowTableRule: tableName(shadowAlgorithm [, shadowAlgorithm] ...)
  11. shadowAlgorithm: ([algorithmName, ] TYPE(NAME=shadowAlgorithmType, PROPERTIES([algorithmProperties] ...)))
  12. algorithmProperties: algorithmProperty [, algorithmProperty] ...
  13. algorithmProperty: key=value
  • 重复的ruleName无法被创建
  • resourceMapping 指定源数据库和影子库的映射关系,需使用 RDL 管理的 resource ,请参考 数据源资源
  • shadowAlgorithm 可同时作用于多个 shadowTableRule
  • algorithmName 未指定时会根据 ruleNametableNameshadowAlgorithmType 自动生成
  • shadowAlgorithmType 目前支持 VALUE_MATCHREGEX_MATCHSIMPLE_HINT
  • shadowTableRule 能够被不同的 shadowRuleDefinition 复用,因此在执行 DROP SHADOW RULE 时,对应的 shadowTableRule 不会被移除
  • shadowAlgorithm 能够被不同的 shadowTableRule 复用,因此在执行 ALTER SHADOW RULE 时,对应的 shadowAlgorithm 不会被移除

示例

  1. CREATE SHADOW RULE shadow_rule(
  2. SOURCE=demo_ds,
  3. SHADOW=demo_ds_shadow,
  4. 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]')))),
  5. t_order_item((TYPE(NAME=VALUE_MATCH, PROPERTIES("operation"="insert","column"="user_id", "value"='1')))));
  6. ALTER SHADOW RULE shadow_rule(
  7. SOURCE=demo_ds,
  8. SHADOW=demo_ds_shadow,
  9. 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]')))),
  10. t_order_item((TYPE(NAME=VALUE_MATCH, PROPERTIES("operation"="insert","column"="user_id", "value"='1')))));
  11. CREATE SHADOW ALGORITHM
  12. (simple_hint_algorithm, TYPE(NAME=SIMPLE_HINT, PROPERTIES("shadow"="true", "foo"="bar"))),
  13. (user_id_match_algorithm, TYPE(NAME=REGEX_MATCH,PROPERTIES("operation"="insert", "column"="user_id", "regex"='[1]')));
  14. ALTER SHADOW ALGORITHM
  15. (simple_hint_algorithm, TYPE(NAME=SIMPLE_HINT, PROPERTIES("shadow"="false", "foo"="bar"))),
  16. (user_id_match_algorithm, TYPE(NAME=VALUE_MATCH,PROPERTIES("operation"="insert", "column"="user_id", "value"='1')));
  17. DROP SHADOW RULE shadow_rule;
  18. DROP SHADOW ALGORITHM simple_note_algorithm;
  19. CREATE DEFAULT SHADOW ALGORITHM NAME = simple_hint_algorithm;