CREATE READWRITE_SPLITTING RULE

描述

CREATE READWRITE_SPLITTING RULE 语法用于创建读写分离规则。

语法定义

语法 铁路图

  1. CreateReadwriteSplittingRule ::=
  2. 'CREATE' 'READWRITE_SPLITTING' 'RULE' ifNotExists? readwriteSplittingDefinition (',' readwriteSplittingDefinition)*
  3. ifNotExists ::=
  4. 'IF' 'NOT' 'EXISTS'
  5. readwriteSplittingDefinition ::=
  6. ruleName '(' dataSourceDefinition (',' transactionalReadQueryStrategyDefinition)? (',' loadBalancerDefinition)? ')'
  7. dataSourceDefinition ::=
  8. 'WRITE_STORAGE_UNIT' '=' writeStorageUnitName ',' 'READ_STORAGE_UNITS' '(' storageUnitName (',' storageUnitName)* ')'
  9. transactionalReadQueryStrategyDefinition ::=
  10. 'TRANSACTIONAL_READ_QUERY_STRATEGY' '=' transactionalReadQueryStrategyType
  11. loadBalancerDefinition ::=
  12. 'TYPE' '(' 'NAME' '=' algorithmType (',' propertiesDefinition)? ')'
  13. ruleName ::=
  14. identifier
  15. writeStorageUnitName ::=
  16. identifier
  17. storageUnitName ::=
  18. identifier
  19. transactionalReadQueryStrategyType ::=
  20. string
  21. algorithmType ::=
  22. string
  23. propertiesDefinition ::=
  24. 'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
  25. key ::=
  26. string
  27. value ::=
  28. literal

补充说明

  • transactionalReadQueryStrategyType 指定事务内读请求路由策略,请参考YAML 配置
  • algorithmType 指定负载均衡算法类型,请参考负载均衡算法
  • 重复的 ruleName 将无法被创建;
  • ifNotExists 子句用于避免出现 Duplicate readwrite_splitting rule 错误。

示例

创建读写分离规则

  1. CREATE READWRITE_SPLITTING RULE ms_group_0 (
  2. WRITE_STORAGE_UNIT=write_ds,
  3. READ_STORAGE_UNITS(read_ds_0,read_ds_1),
  4. TYPE(NAME="random")
  5. );

使用 ifNotExists 子句创建读写分离规则

  • 读写分离规则
  1. CREATE READWRITE_SPLITTING RULE IF NOT EXISTS ms_group_0 (
  2. WRITE_STORAGE_UNIT=write_ds,
  3. READ_STORAGE_UNITS(read_ds_0,read_ds_1),
  4. TYPE(NAME="random")
  5. );

保留字

CREATEREADWRITE_SPLITTINGRULEWRITE_STORAGE_UNITREAD_STORAGE_UNITSTYPENAMEPROPERTIESTRUEFALSE

相关链接