Readwrite-Splitting
Syntax
CREATE READWRITE_SPLITTING RULE readwriteSplittingRuleDefinition [, readwriteSplittingRuleDefinition] ...
ALTER READWRITE_SPLITTING RULE readwriteSplittingRuleDefinition [, readwriteSplittingRuleDefinition] ...
DROP READWRITE_SPLITTING RULE ruleName [, ruleName] ...
readwriteSplittingRuleDefinition:
ruleName ([staticReadwriteSplittingRuleDefinition | dynamicReadwriteSplittingRuleDefinition]
[, loadBalancerDefinition])
staticReadwriteSplittingRuleDefinition:
WRITE_RESOURCE=writeResourceName, READ_RESOURCES(resourceName [, resourceName] ... )
dynamicReadwriteSplittingRuleDefinition:
AUTO_AWARE_RESOURCE=resourceName [, WRITE_DATA_SOURCE_QUERY_ENABLED=writeDataSourceQueryEnabled]
loadBalancerDefinition:
TYPE(NAME=loadBalancerType [, PROPERTIES([algorithmProperties] )] )
algorithmProperties:
algorithmProperty [, algorithmProperty] ...
algorithmProperty:
key=value
writeDataSourceQueryEnabled:
TRUE | FALSE
Parameters Explained
name | DateType | Description |
---|---|---|
ruleName | IDENTIFIER | Rule name |
writeResourceName | IDENTIFIER | Write data source name |
readResourceName | IDENTIFIER | Read data source name |
autoAwareResourceName | IDENTIFIER | Database discovery logic data source name |
writeDataSourceQueryEnabled | BOOLEAN | All read data source are offline, write data source whether the data source is responsible for read traffic |
loadBalancerType | STRING | Load 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
// Static
CREATE READWRITE_SPLITTING RULE ms_group_0 (
WRITE_RESOURCE=write_ds,
READ_RESOURCES(read_ds_0,read_ds_1),
TYPE(NAME="random")
);
// Dynamic
CREATE READWRITE_SPLITTING RULE ms_group_1 (
AUTO_AWARE_RESOURCE=group_0,
WRITE_DATA_SOURCE_QUERY_ENABLED=false,
TYPE(NAME="random",PROPERTIES(write_ds=2,read_ds_0=2,read_ds_1=2,read_ds_2=1))
);
ALTER READWRITE_SPLITTING RULE ms_group_1 (
WRITE_RESOURCE=write_ds,
READ_RESOURCES(read_ds_0,read_ds_1,read_ds_2),
TYPE(NAME="random",PROPERTIES(write_ds=2,read_ds_0=2,read_ds_1=2,read_ds_2=1))
);
DROP READWRITE_SPLITTING RULE ms_group_1;
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .