Logo
Mode Configuration

Mode Configuration #

Configuration Item Explanation #

Namespace: http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource-5.1.0.xsd

<shardingsphere:mode />

NameTypeDescriptionDefault Value
typeAttributeType of mode configuration. Values could be: Cluster
repository-ref (?)AttributePersist repository configuration. Memory type does not need persist

Cluster Mode #

Configuration Item Explanation #

Namespace: http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster/repository-5.0.0.xsd

<cluster:repository />

NameTypeDescription
idAttributeName of persist repository bean
typeAttributeType of persist repository
namespaceAttributeNamespace of registry center
server-listsAttributeServer lists of registry center
props (?)TagProperties of persist repository

Example #

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
       xmlns:cluster="http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://shardingsphere.apache.org/schema/shardingsphere/datasource
                           http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
                           http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster
                           http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster/repository.xsd">
    <cluster:repository id="clusterRepository" type="Zookeeper" namespace="regCenter" server-lists="localhost:3182">
        <props>
            <prop key="max-retries">3</prop>
            <prop key="operation-timeout-milliseconds">1000</prop>
        </props>
    </cluster:repository>
    
    <shardingsphere:data-source id="ds" schema-name="foo_schema" data-source-names="..." rule-refs="...">
        <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" />
    </shardingsphere:data-source>
</beans>

Please refer to Builtin Persist Repository List for more details about type of repository.