Logo
读写分离

读写分离 #

配置入口 #

类名称:org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration

可配置属性:

名称数据类型说明
dataSources (+)Collection<ReadwriteSplittingDataSourceRuleConfiguration>读写数据源配置
loadBalancers (*)Map<String, ShardingSphereAlgorithmConfiguration>从库负载均衡算法配置

主从数据源配置 #

类名称:org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration

可配置属性:

名称数据类型说明默认值
nameString读写分离数据源名称-
staticStrategyStaticReadwriteSplittingStrategyConfiguration静态读写分离配置-
dynamicStrategyDynamicReadwriteSplittingStrategyConfiguration动态读写分离配置-
loadBalancerName (?)String读库负载均衡算法名称轮询负载均衡算法

类名称:org.apache.shardingsphere.readwritesplitting.api.strategy.StaticReadwriteSplittingStrategyConfiguration

可配置属性:

名称数据类型说明
writeDataSourceNameString写库数据源名称
readDataSourceNamesList<String>读库数据源列表

类名称:org.apache.shardingsphere.readwritesplitting.api.strategy.DynamicReadwriteSplittingStrategyConfiguration

可配置属性:

名称数据类型说明默认值
autoAwareDataSourceNameString数据库发现的逻辑数据源名称-
writeDataSourceQueryEnabled (?)String读库全部下线,主库是否承担读流量true

算法类型的详情,请参见内置负载均衡算法列表