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: Memory, Standalone, Cluster
repository-ref (?)AttributePersist repository configuration. Memory type does not need persist
overwrite (?)AttributeWhether overwrite persistent configuration with local configurationfalse

Memory Mode

It is the default value.

Example

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans.xsd
  7. http://shardingsphere.apache.org/schema/shardingsphere/datasource
  8. http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd">
  9. <shardingsphere:data-source id="ds" schema-name="foo_schema" data-source-names="..." rule-refs="..." />
  10. </beans>

Standalone Mode

Configuration Item Explanation

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

<standalone:repository />

NameTypeDescription
idAttributeName of persist repository bean
typeAttributeType of persist repository
props (?)TagProperties of persist repository

Example

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
  5. xmlns:standalone="http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/standalone"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans.xsd
  8. http://shardingsphere.apache.org/schema/shardingsphere/datasource
  9. http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
  10. http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/standalone
  11. http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/standalone/repository.xsd">
  12. <standalone:repository id="standaloneRepository" type="File">
  13. <props>
  14. <prop key="path">target</prop>
  15. </props>
  16. </standalone:repository>
  17. <shardingsphere:data-source id="ds" schema-name="foo_schema" data-source-names="..." rule-refs="..." >
  18. <shardingsphere:mode type="Standalone" repository-ref="standaloneRepository" overwrite="true" />
  19. </shardingsphere:data-source>
  20. </beans>

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

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
  5. xmlns:cluster="http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans.xsd
  8. http://shardingsphere.apache.org/schema/shardingsphere/datasource
  9. http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
  10. http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster
  11. http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster/repository.xsd">
  12. <cluster:repository id="clusterRepository" type="Zookeeper" namespace="regCenter" server-lists="localhost:3182">
  13. <props>
  14. <prop key="max-retries">3</prop>
  15. <prop key="operation-timeout-milliseconds">1000</prop>
  16. </props>
  17. </cluster:repository>
  18. <shardingsphere:data-source id="ds" schema-name="foo_schema" data-source-names="..." rule-refs="...">
  19. <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" overwrite="true" />
  20. </shardingsphere:data-source>
  21. </beans>

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