Readwrite-Splitting

Syntax

  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. [, loadBalancerDefinition])
  7. staticReadwriteSplittingRuleDefinition:
  8. WRITE_STORAGE_UNIT=storageUnitName, READ_STORAGE_UNITS(storageUnitName [, storageUnitName] ... )
  9. dynamicReadwriteSplittingRuleDefinition:
  10. AUTO_AWARE_RESOURCE=autoAwareResourceName [, WRITE_DATA_SOURCE_QUERY_ENABLED=writeDataSourceQueryEnabled]
  11. loadBalancerDefinition:
  12. TYPE(NAME=loadBalancerType [, PROPERTIES([algorithmProperties] )] )
  13. algorithmProperties:
  14. algorithmProperty [, algorithmProperty] ...
  15. algorithmProperty:
  16. key=value
  17. writeDataSourceQueryEnabled:
  18. TRUE | FALSE

Parameters Explained

nameDateTypeDescription
ruleNameIDENTIFIERRule name
storageUnitNameIDENTIFIERRegistered data source name
autoAwareResourceNameIDENTIFIERDatabase discovery logic data source name
writeDataSourceQueryEnabledBOOLEANAll read data source are offline, write data source whether the data source is responsible for read traffic
loadBalancerTypeSTRINGLoad balancing algorithm type

Notes

  • Support the creation of static readwrite-splitting rules and dynamic readwrite-splitting rules
  • Dynamic readwrite-splitting rules rely on database discovery rules
  • loadBalancerType specifies the load balancing algorithm type, please refer to Load Balance Algorithm
  • Duplicate ruleName will not be created

Example

  1. // Static
  2. CREATE READWRITE_SPLITTING RULE ms_group_0 (
  3. WRITE_STORAGE_UNIT=write_ds,
  4. READ_STORAGE_UNITS(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. WRITE_DATA_SOURCE_QUERY_ENABLED=false,
  11. TYPE(NAME="random")
  12. );
  13. ALTER READWRITE_SPLITTING RULE ms_group_1 (
  14. WRITE_STORAGE_UNIT=write_ds,
  15. READ_STORAGE_UNITS(read_ds_0,read_ds_1,read_ds_2),
  16. TYPE(NAME="random")
  17. );
  18. DROP READWRITE_SPLITTING RULE ms_group_1;