Mode

Configuration Item Explanation

Standalone mode

  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="shardingDatabasesTablesDataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" schema-name="sharding_db">
  18. <shardingsphere:mode type="Standalone" repository-ref="standaloneRepository" overwrite="true"/>
  19. </shardingsphere:data-source>
  20. </beans>

<standalone:repository />

NameTypeDescription
idAttributeStandalone mode instance name
typeAttributeStandalone Configuration persist type, such as: File
props (?)AttributeConfiguration persist properties, such as: path

<shardingsphere:data-source />

NameTypeDescription
schema-name (?)AttributeJDBC data source alias, this parameter can help the configuration shared between JDBC driver and Proxy

Cluster mode

  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="shardingDatabasesTablesDataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" schema-name="sharding_db">
  19. <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" overwrite="true"/>
  20. </shardingsphere:data-source>
  21. </beans>

<cluster:repository />

NameTypeDescription
idAttributeCluster mode instance name
typeAttributeCluster mode type. Example: ZooKeeper, etcd
namespaceAttributeCluster mode namespace
server-listsAttributeZookeeper or Etcd server list, including IP and port number; use commas to separate
props (?)AttributeProperties for center instance config, such as options of zookeeper

<shardingsphere:data-source />

NameTypeDescription
schema-name (?)AttributeJDBC data source alias, this parameter can help the configuration shared between JDBC driver and Proxy