读写分离

定义

  1. CREATE READWRITE_SPLITTING RULE readwriteSplittingRuleDefinition [, readwriteSplittingRuleDefinition] ...
  2. ALTER READWRITE_SPLITTING RULE readwriteSplittingRuleDefinition [, readwriteSplittingRuleDefinition] ...
  3. DROP READWRITE_SPLITTING RULE ruleName [, ruleName] ...
  4. readwriteSplittingRuleDefinition:
  5. ruleName ([staticReadwriteSplittingRuleDefinition | dynamicReadwriteSplittingRuleDefinition]
  6. [, loadBanlancerDefinition])
  7. staticReadwriteSplittingRuleDefinition:
  8. WRITE_RESOURCE=writeResourceName, READ_RESOURCES(resourceName [, resourceName] ... )
  9. dynamicReadwriteSplittingRuleDefinition:
  10. AUTO_AWARE_RESOURCE=resourceName
  11. loadBanlancerDefinition:
  12. TYPE(NAME=loadBanlancerType [, PROPERTIES([algorithmProperties] )] )
  13. algorithmProperties:
  14. algorithmProperty [, algorithmProperty] ...
  15. algorithmProperty:
  16. key=value
  • 支持创建静态读写分离规则和动态读写分离规则
  • 动态读写分离规则依赖于数据库发现规则
  • loadBanlancerType 指定负载均衡算法类型,请参考 负载均衡算法
  • 重复的 ruleName 将无法被创建

示例

  1. // Static
  2. CREATE READWRITE_SPLITTING RULE ms_group_0 (
  3. WRITE_RESOURCE=write_ds,
  4. READ_RESOURCES(read_ds_0,read_ds_1),
  5. TYPE(NAME=random)
  6. );
  7. // Dynamic
  8. CREATE READWRITE_SPLITTING RULE ms_group_1 (
  9. AUTO_AWARE_RESOURCE=group_0,
  10. TYPE(NAME=random,PROPERTIES(read_weight='2:1'))
  11. );
  12. ALTER READWRITE_SPLITTING RULE ms_group_1 (
  13. WRITE_RESOURCE=write_ds,
  14. READ_RESOURCES(read_ds_0,read_ds_1,read_ds_2),
  15. TYPE(NAME=random,PROPERTIES(read_weight='2:0'))
  16. );
  17. DROP READWRITE_SPLITTING RULE ms_group_1;