Spring Boot Starter Configuration

5.0.0-beta

Sharding

Configuration Item Explanation

  1. spring.shardingsphere.datasource.names= # Omit the data source configuration, please refer to the usage
  2. # Standard sharding table configuration
  3. spring.shardingsphere.rules.sharding.tables.<table-name>.actual-data-nodes= # Describe data source names and actual tables, delimiter as point, multiple data nodes separated with comma, support inline expression. Absent means sharding databases only.
  4. # Databases sharding strategy, use default databases sharding strategy if absent. sharding strategy below can choose only one.
  5. # For single sharding column scenario
  6. spring.shardingsphere.rules.sharding.tables.<table-name>.database-strategy.standard.<sharding-algorithm-name>.sharding-column= # Sharding column name
  7. spring.shardingsphere.rules.sharding.tables.<table-name>.database-strategy.standard.<sharding-algorithm-name>.sharding-algorithm-name= # Sharding algorithm name
  8. # For multiple sharding columns scenario
  9. spring.shardingsphere.rules.sharding.tables.<table-name>.database-strategy.complex.<sharding-algorithm-name>.sharding-columns= # Sharding column names, multiple columns separated with comma
  10. spring.shardingsphere.rules.sharding.tables.<table-name>.database-strategy.complex.<sharding-algorithm-name>.sharding-algorithm-name= # Sharding algorithm name
  11. # Sharding by hint
  12. spring.shardingsphere.rules.sharding.tables.<table-name>.database-strategy.hint.<sharding-algorithm-name>.sharding-algorithm-name= # Sharding algorithm name
  13. # Tables sharding strategy, same as database sharding strategy
  14. spring.shardingsphere.rules.sharding.tables.<table-name>.table-strategy.xxx= # Omitted
  15. # Auto sharding table configuraiton
  16. spring.shardingsphere.rules.sharding.auto-tables.<auto-table-name>.actual-data-sources= # data source names
  17. spring.shardingsphere.rules.sharding.auto-tables.<auto-table-name>.sharding-strategy.standard.sharding-column= # Sharding column name
  18. spring.shardingsphere.rules.sharding.auto-tables.<auto-table-name>.sharding-strategy.standard.sharding-algorithm= # Auto sharding algorithm name
  19. # Key generator strategy configuration
  20. spring.shardingsphere.rules.sharding.tables.<table-name>.key-generate-strategy.column= # Column name of key generator
  21. spring.shardingsphere.rules.sharding.tables.<table-name>.key-generate-strategy.key-generator-name= # Key generator name
  22. spring.shardingsphere.rules.sharding.binding-tables[0]= # Binding table name
  23. spring.shardingsphere.rules.sharding.binding-tables[1]= # Binding table name
  24. spring.shardingsphere.rules.sharding.binding-tables[x]= # Binding table name
  25. spring.shardingsphere.rules.sharding.broadcast-tables[0]= # Broadcast tables
  26. spring.shardingsphere.rules.sharding.broadcast-tables[1]= # Broadcast tables
  27. spring.shardingsphere.rules.sharding.broadcast-tables[x]= # Broadcast tables
  28. spring.shardingsphere.sharding.default-database-strategy.xxx= # Default strategy for database sharding
  29. spring.shardingsphere.sharding.default-table-strategy.xxx= # Default strategy for table sharding
  30. spring.shardingsphere.sharding.default-key-generate-strategy.xxx= # Default Key generator strategy
  31. # Sharding algorithm configuration
  32. spring.shardingsphere.rules.sharding.sharding-algorithms.<sharding-algorithm-name>.type= # Sharding algorithm type
  33. spring.shardingsphere.rules.sharding.sharding-algorithms.<sharding-algorithm-name>.props.xxx=# Sharding algorithm properties
  34. # Key generate algorithm configuration
  35. spring.shardingsphere.rules.sharding.key-generators.<key-generate-algorithm-name>.type= # Key generate algorithm type
  36. spring.shardingsphere.rules.sharding.key-generators.<key-generate-algorithm-name>.props.xxx= # Key generate algorithm properties

Please refer to Built-in sharding Algorithm List and Built-in keygen Algorithm List

Readwrite-splitting

Configuration Item Explanation

  1. spring.shardingsphere.datasource.names= # Omit the data source configuration, please refer to the usage
  2. spring.shardingsphere.rules.readwrite-splitting.data-sources.<readwrite-splitting-data-source-name>.primary-data-source-name= # Write data source name
  3. spring.shardingsphere.rules.readwrite-splitting.data-sources.<readwrite-splitting-data-source-name>.replica-data-source-names= # Read data source names, multiple data source names separated with comma
  4. spring.shardingsphere.rules.readwrite-splitting.data-sources.<readwrite-splitting-data-source-name>.load-balancer-name= # Load balance algorithm name
  5. # Load balance algorithm configuration
  6. spring.shardingsphere.rules.readwrite-splitting.load-balancers.<load-balance-algorithm-name>.type= # Load balance algorithm type
  7. spring.shardingsphere.rules.readwrite-splitting.load-balancers.<load-balance-algorithm-name>.props.xxx= # Load balance algorithm properties

Please refer to Built-in Load Balance Algorithm List for more details about type of algorithm.

Encryption

Configuration Item Explanation

  1. spring.shardingsphere.datasource.names= # Omit the data source configuration, please refer to the usage
  2. spring.shardingsphere.rules.encrypt.tables.<table-name>.columns.<column-name>.cipher-column= # Cipher column name
  3. spring.shardingsphere.rules.encrypt.tables.<table-name>.columns.<column-name>.assisted-query-column= # Assisted query column name
  4. spring.shardingsphere.rules.encrypt.tables.<table-name>.columns.<column-name>.plain-column= # Plain column name
  5. spring.shardingsphere.rules.encrypt.tables.<table-name>.columns.<column-name>.encryptor-name= # Encrypt algorithm name
  6. # Encrypt algorithm configuration
  7. spring.shardingsphere.rules.encrypt.encryptors.<encrypt-algorithm-name>.type= # Encrypt algorithm type
  8. spring.shardingsphere.rules.encrypt.encryptors.<encrypt-algorithm-name>.props.xxx= # Encrypt algorithm properties

Shadow DB

Configuration Item Explanation

  1. spring.shardingsphere.datasource.names= # Omit the data source configuration, please refer to the usage
  2. spring.shardingsphere.rules.shadow.column= # Shadow column name
  3. spring.shardingsphere.rules.shadow.shadow-mappings.<product-data-source-name>= # Shadow data source name

Governance

Configuration Item Explanation

Management
  1. spring.shardingsphere.governance.name= # Governance name
  2. spring.shardingsphere.governance.registry-center.type= # Governance instance type. Example:Zookeeper, etcd, Apollo, Nacos
  3. spring.shardingsphere.governance.registry-center.server-lists= # The list of servers that connect to governance instance, including IP and port number; use commas to separate
  4. spring.shardingsphere.governance.registry-center.props= # Other properties
  5. spring.shardingsphere.governance.overwrite= # Whether to overwrite local configurations with config center configurations; if it can, each initialization should refer to local configurations

Mixed Rules

Configuration Item Explanation

  1. # data source configuration
  2. spring.shardingsphere.datasource.names= write-ds0,write-ds1,write-ds0-read0,write-ds1-read0
  3. spring.shardingsphere.datasource.write-ds0.url= # Database URL connection
  4. spring.shardingsphere.datasource.write-ds0.type= # Database connection pool type name
  5. spring.shardingsphere.datasource.write-ds0.driver-class-name= # Database driver class name
  6. spring.shardingsphere.datasource.write-ds0.username= # Database username
  7. spring.shardingsphere.datasource.write-ds0.password= # Database password
  8. spring.shardingsphere.datasource.write-ds0.xxx= # Other properties of database connection pool
  9. spring.shardingsphere.datasource.write-ds1.url= # Database URL connection
  10. # ...Omit specific configuration.
  11. spring.shardingsphere.datasource.write-ds0-read0.url= # Database URL connection
  12. # ...Omit specific configuration.
  13. spring.shardingsphere.datasource.write-ds1-read0.url= # Database URL connection
  14. # ...Omit specific configuration.
  15. # Sharding rules configuration
  16. # Databases sharding strategy
  17. spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
  18. spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=default-database-strategy-inline
  19. # Binding table rules configuration ,and multiple groups of binding-tables configured with arrays
  20. spring.shardingsphere.rules.sharding.binding-tables[0]=t_user,t_user_detail
  21. spring.shardingsphere.rules.sharding.binding-tables[1]= # Binding table names,multiple table name are separated by commas
  22. spring.shardingsphere.rules.sharding.binding-tables[x]= # Binding table names,multiple table name are separated by commas
  23. # Broadcast table rules configuration
  24. spring.shardingsphere.rules.sharding.broadcast-tables= # Broadcast table names,multiple table name are separated by commas
  25. # Table sharding strategy
  26. # The enumeration value of `ds_$->{0..1}` is the name of the logical data source configured with readwrite-splitting
  27. spring.shardingsphere.rules.sharding.tables.t_user.actual-data-nodes=ds_$->{0..1}.t_user_$->{0..1}
  28. spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-column=user_id
  29. spring.shardingsphere.rules.sharding.tables.t_user.table-strategy.standard.sharding-algorithm-name=user-table-strategy-inline
  30. # Data encrypt configuration
  31. # Table `t_user` is the name of the logical table that uses for data sharding configuration.
  32. spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.cipher-column=user_name
  33. spring.shardingsphere.rules.encrypt.tables.t_user.columns.user_name.encryptor-name=name-encryptor
  34. spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.cipher-column=pwd
  35. spring.shardingsphere.rules.encrypt.tables.t_user.columns.pwd.encryptor-name=pwd-encryptor
  36. # Data encrypt algorithm configuration
  37. spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.type=AES
  38. spring.shardingsphere.rules.encrypt.encryptors.name-encryptor.props.aes-key-value=123456abc
  39. spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.type=AES
  40. spring.shardingsphere.rules.encrypt.encryptors.pwd-encryptor.props.aes-key-value=123456abc
  41. # Key generate strategy configuration
  42. spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.column=user_id
  43. spring.shardingsphere.rules.sharding.tables.t_user.key-generate-strategy.key-generator-name=snowflake
  44. # Sharding algorithm configuration
  45. spring.shardingsphere.rules.sharding.sharding-algorithms.default-database-strategy-inline.type=INLINE
  46. # The enumeration value of `ds_$->{user_id % 2}` is the name of the logical data source configured with readwrite-splitting
  47. spring.shardingsphere.rules.sharding.sharding-algorithms.default-database-strategy-inline.algorithm-expression=ds$->{user_id % 2}
  48. spring.shardingsphere.rules.sharding.sharding-algorithms.user-table-strategy-inline.type=INLINE
  49. spring.shardingsphere.rules.sharding.sharding-algorithms.user-table-strategy-inline.algorithm-expression=t_user_$->{user_id % 2}
  50. # Key generate algorithm configuration
  51. spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
  52. spring.shardingsphere.rules.sharding.key-generators.snowflake.props.worker-id=123
  53. # read query configuration
  54. # ds_0,ds_1 is the logical data source name of the readwrite-splitting
  55. spring.shardingsphere.rules.readwrite-splitting.data-sources.ds_0.write-data-source-name=write-ds0
  56. spring.shardingsphere.rules.readwrite-splitting.data-sources.ds_0.read-data-source-names=write-ds0-read0
  57. spring.shardingsphere.rules.readwrite-splitting.data-sources.ds_0.load-balancer-name=read-random
  58. spring.shardingsphere.rules.readwrite-splitting.data-sources.ds_1.write-data-source-name=write-ds1
  59. spring.shardingsphere.rules.readwrite-splitting.data-sources.ds_1.read-data-source-names=write-ds1-read0
  60. spring.shardingsphere.rules.readwrite-splitting.data-sources.ds_1.load-balancer-name=read-random
  61. # Load balance algorithm configuration
  62. spring.shardingsphere.rules.readwrite-splitting.load-balancers.read-random.type=RANDOM

Shardingsphere-4.x

Data Sharding

Configuration Item Explanation

  1. spring.shardingsphere.datasource.names= #Data source name; multiple data sources are separated by commas
  2. spring.shardingsphere.datasource.<data-source-name>.type= #Database connection pool type name
  3. spring.shardingsphere.datasource.<data-source-name>.driver-class-name= #Database driver class name
  4. spring.shardingsphere.datasource.<data-source-name>.url= #Database url connection
  5. spring.shardingsphere.datasource.<data-source-name>.username= #Database username
  6. spring.shardingsphere.datasource.<data-source-name>.password= #Database password
  7. spring.shardingsphere.datasource.<data-source-name>.xxx= #Other properties of database connection pool
  8. spring.shardingsphere.sharding.tables.<logic-table-name>.actual-data-nodes= #It is consisted of data source name + table name, separated by decimal points; multiple tables are separated by commas and support inline expressions; default means using existing data sources and logic table names to generate data nodes; it can be applied in broadcast tables (each database needs a same table for relevance query, dictionary table mostly) or the situation with sharding database but without sharding table (table structures of all the databases are consistent)
  9. #Database sharding strategy; default means using default database sharding strategy; it can only choose one of the following sharding strategies
  10. #It is applied in standard sharding situation of single-sharding key
  11. spring.shardingsphere.sharding.tables.<logic-table-name>.database-strategy.standard.sharding-column= #Sharding column name
  12. spring.shardingsphere.sharding.tables.<logic-table-name>.database-strategy.standard.precise-algorithm-class-name= #Precise algorithm class name, applied in = and IN; the class needs to implement PreciseShardingAlgorithm interface and provide parameter-free constructor
  13. spring.shardingsphere.sharding.tables.<logic-table-name>.database-strategy.standard.range-algorithm-class-name= #Range sharding algorithm class name, applied in BETWEEN, optional; the class should implement RangeShardingAlgorithm interface and provide parameter-free constructor
  14. #It is applied in complex sharding situations with multiple sharding keys
  15. spring.shardingsphere.sharding.tables.<logic-table-name>.database-strategy.complex.sharding-columns= #Sharding column name, with multiple columns separated by commas
  16. spring.shardingsphere.sharding.tables.<logic-table-name>.database-strategy.complex.algorithm-class-name= #Complex sharding algorithm class name; the class needs to implement ComplexKeysShardingAlgorithm interface and provide parameter-free constructor
  17. #Inline expression sharding strategy
  18. spring.shardingsphere.sharding.tables.<logic-table-name>.database-strategy.inline.sharding-column= #Sharding column name
  19. spring.shardingsphere.sharding.tables.<logic-table-name>.database-strategy.inline.algorithm-expression= #Inline expression of sharding algorithm, which needs to conform to groovy statements
  20. #Hint Sharding Strategy
  21. spring.shardingsphere.sharding.tables.<logic-table-name>.database-strategy.hint.algorithm-class-name= #Hint algorithm class name; the class needs to implement HintShardingAlgorithm interface and provide parameter-free constructor
  22. #Table sharding strategy, same as database sharding strategy
  23. spring.shardingsphere.sharding.tables.<logic-table-name>.table-strategy.xxx= #Omitted
  24. spring.shardingsphere.sharding.tables.<logic-table-name>.key-generator.column= #Auto-increment column name; default means not using auto-increment key generator
  25. spring.shardingsphere.sharding.tables.<logic-table-name>.key-generator.type= #Auto-increament key generator type; default means using default auto-increament key generator; user defined generator or internal generator (SNOWFLAKE, UUID) can both be selected
  26. spring.shardingsphere.sharding.tables.<logic-table-name>.key-generator.props.<property-name>= #Properties, Notice: when use SNOWFLAKE, `worker.id` and `max.tolerate.time.difference.milliseconds` for `SNOWFLAKE` need to be set. To use the generated value of this algorithm as sharding value, it is recommended to configure `max.vibration.offset`
  27. spring.shardingsphere.sharding.binding-tables[0]= #Binding table rule list
  28. spring.shardingsphere.sharding.binding-tables[1]= #Binding table rule list
  29. spring.shardingsphere.sharding.binding-tables[x]= #Binding table rule list
  30. spring.shardingsphere.sharding.broadcast-tables[0]= #Broadcast table rule list
  31. spring.shardingsphere.sharding.broadcast-tables[1]= #Broadcast table rule list
  32. spring.shardingsphere.sharding.broadcast-tables[x]= #Broadcast table rule list
  33. spring.shardingsphere.sharding.default-data-source-name= #Tables without sharding rules will be located through default data source
  34. spring.shardingsphere.sharding.default-database-strategy.xxx= #Default database sharding strategy
  35. spring.shardingsphere.sharding.default-table-strategy.xxx= #Default table sharding strategy
  36. spring.shardingsphere.sharding.default-key-generator.type= #Default auto-increament key generator of type; it will use org.apache.shardingsphere.core.keygen.generator.impl.SnowflakeKeyGenerator in default; user defined generator or internal generator (SNOWFLAKE or UUID) can both be used
  37. spring.shardingsphere.sharding.default-key-generator.props.<property-name>= #Auto-increament key generator property configuration, such as worker.id and max.tolerate.time.difference.milliseconds of SNOWFLAKE algorithm
  38. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.master-data-source-name= #Refer to readwrite-splitting part for more details
  39. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[0]= #Refer to readwrite-splitting part for more details
  40. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[1]= #Refer to readwrite-splitting part for more details
  41. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[x]= #Refer to readwrite-splitting part for more details
  42. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.load-balance-algorithm-class-name= #Refer to readwrite-splitting part for more details
  43. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.load-balance-algorithm-type= #Refer to readwrite-splitting part for more details
  44. spring.shardingsphere.props.sql.show= #Show SQL or not; default value: false
  45. spring.shardingsphere.props.executor.size= #Executing thread number; default value: CPU core number

Readwrite Split

Configuration Item Explanation

  1. #Omit data source configurations; keep it consistent with data sharding
  2. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.master-data-source-name= #Data source name of master database
  3. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[0]= #Data source name list of slave database
  4. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[1]= #Data source name list of slave database
  5. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[x]= #Data source name list of slave database
  6. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.load-balance-algorithm-class-name= #Load balance algorithm class name; the class needs to implement MasterSlaveLoadBalanceAlgorithm interface and provide parameter-free constructor
  7. spring.shardingsphere.sharding.master-slave-rules.<master-slave-data-source-name>.load-balance-algorithm-type= #Load balance algorithm class of slave database; optional value: ROUND_ROBIN and RANDOM; if there is load-balance-algorithm-class-name, the configuration can be omitted
  8. spring.shardingsphere.props.sql.show= #Show SQL or not; default value: false
  9. spring.shardingsphere.props.executor.size= #Executing thread number; default value: CPU core number
  10. spring.shardingsphere.props.check.table.metadata.enabled= #Whether to check meta-data consistency of sharding table when it initializes; default value: false

Data Masking

Configuration Item Explanation

  1. #Omit data source configurations; keep it consistent with data sharding
  2. spring.shardingsphere.encrypt.encryptors.<encryptor-name>.type= #Type of encryptor,use user-defined ones or built-in ones, e.g. MD5/AES
  3. spring.shardingsphere.encrypt.encryptors.<encryptor-name>.props.<property-name>= #Properties, Notice: when use AES encryptor, `aes.key.value` for AES encryptor need to be set
  4. spring.shardingsphere.encrypt.tables.<table-name>.columns.<logic-column-name>.plainColumn= #Plain column name
  5. spring.shardingsphere.encrypt.tables.<table-name>.columns.<logic-column-name>.cipherColumn= #Cipher column name
  6. spring.shardingsphere.encrypt.tables.<table-name>.columns.<logic-column-name>.assistedQueryColumn= #AssistedColumns for query,when use ShardingQueryAssistedEncryptor, it can help query encrypted data
  7. spring.shardingsphere.encrypt.tables.<table-name>.columns.<logic-column-name>.encryptor= #Encryptor name

Orchestration

Configuration Item Explanation

  1. #Omit data source, data sharding, readwrite split and data masking configurations
  2. spring.shardingsphere.orchestration.name= #Orchestration instance name
  3. spring.shardingsphere.orchestration.overwrite= #Whether to overwrite local configurations with registry center configurations; if it can, each initialization should refer to local configurations
  4. spring.shardingsphere.orchestration.registry.type= #Registry center type. Example:zookeeper
  5. spring.shardingsphere.orchestration.registry.server-lists= #The list of servers that connect to registry center, including IP and port number; use commas to separate
  6. spring.shardingsphere.orchestration.registry.namespace= #Registry center namespace
  7. spring.shardingsphere.orchestration.registry.digest= #The token that connects to the registry center; default means there is no need for authentication
  8. spring.shardingsphere.orchestration.registry.operation-timeout-milliseconds= #The millisecond number for operation timeout; default value: 500 milliseconds
  9. spring.shardingsphere.orchestration.registry.max-retries= #Maximum retry time after failing; default value: 3 times
  10. spring.shardingsphere.orchestration.registry.retry-interval-milliseconds= #Interval time to retry; default value: 500 milliseconds
  11. spring.shardingsphere.orchestration.registry.time-to-live-seconds= #Living time of temporary nodes; default value: 60 seconds
  12. spring.shardingsphere.orchestration.registry.props= #Customize registry center props.

shardingsphere-3.x

Sharding

Configuration Item Explanation

  1. sharding.jdbc.datasource.names= #Names of data sources. Multiple data sources separated with comma
  2. sharding.jdbc.datasource.<data-source-name>.type= #Class name of data source pool
  3. sharding.jdbc.datasource.<data-source-name>.driver-class-name= #Class name of database driver
  4. sharding.jdbc.datasource.<data-source-name>.url= #Database URL
  5. sharding.jdbc.datasource.<data-source-name>.username= #Database username
  6. sharding.jdbc.datasource.<data-source-name>.password= #Database password
  7. sharding.jdbc.datasource.<data-source-name>.xxx= #Other properties for data source pool
  8. sharding.jdbc.config.sharding.tables.<logic-table-name>.actual-data-nodes= #Describe data source names and actual tables, delimiter as point, multiple data nodes separated with comma, support inline expression. Absent means sharding databases only. Example: ds${0..7}.tbl${0..7}
  9. #Databases sharding strategy, use default databases sharding strategy if absent. sharding strategy below can choose only one.
  10. #Standard sharding scenario for single sharding column
  11. sharding.jdbc.config.sharding.tables.<logic-table-name>.database-strategy.standard.sharding-column= #Name of sharding column
  12. sharding.jdbc.config.sharding.tables.<logic-table-name>.database-strategy.standard.precise-algorithm-class-name= #Precise algorithm class name used for `=` and `IN`. This class need to implements PreciseShardingAlgorithm, and require a no argument constructor
  13. sharding.jdbc.config.sharding.tables.<logic-table-name>.database-strategy.standard.range-algorithm-class-name= #Range algorithm class name used for `BETWEEN`. This class need to implements RangeShardingAlgorithm, and require a no argument constructor
  14. #Complex sharding scenario for multiple sharding columns
  15. sharding.jdbc.config.sharding.tables.<logic-table-name>.database-strategy.complex.sharding-columns= #Names of sharding columns. Multiple columns separated with comma
  16. sharding.jdbc.config.sharding.tables.<logic-table-name>.database-strategy.complex.algorithm-class-name= #Complex sharding algorithm class name. This class need to implements ComplexKeysShardingAlgorithm, and require a no argument constructor
  17. #Inline expression sharding scenario for si-gle s-arding column
  18. sharding.jdbc.config.sharding.tables.<logic-table-name>.database-strategy.inline.sharding-column= #Name of sharding column
  19. sharding.jdbc.config.sharding.tables.<logic-table-name>.database-strategy.inline.algorithm-expression= #Inline expression for sharding algorithm
  20. #Hint sharding strategy
  21. sharding.jdbc.config.sharding.tables.<logic-table-name>.database-strategy.hint.algorithm-class-name= #Hint sharding algorithm class name. This class need to implements HintShardingAlgorithm, and require a no argument constructor
  22. #Tables sharding strategy, Same as database- shar-ing strategy
  23. sharding.jdbc.config.sharding.tables.<logic-table-name>.table-strategy.xxx= #Ignore
  24. sharding.jdbc.config.sharding.tables.<logic-table-name>.key-generator-column-name= #Column name of key generator, do not use Key generator if absent
  25. sharding.jdbc.config.sharding.tables.<logic-table-name>.key-generator-class-name= #Key generator, use default key generator if absent. This class need to implements KeyGenerator, and require a no argument constructor
  26. sharding.jdbc.config.sharding.tables.<logic-table-name>.logic-index= #Name if logic index. If use `DROP INDEX XXX` SQL in Oracle/PostgreSQL, This property needs to be set for finding the actual tables
  27. sharding.jdbc.config.sharding.binding-tables[0]= #Binding table rule configurations
  28. sharding.jdbc.config.sharding.binding-tables[1]= #Binding table rule configurations
  29. sharding.jdbc.config.sharding.binding-tables[x]= #Binding table rule configurations
  30. sharding.jdbc.config.sharding.broadcast-tables[0]= #Broadcast table rule configurations
  31. sharding.jdbc.config.sharding.broadcast-tables[1]= #Broadcast table rule configurations
  32. sharding.jdbc.config.sharding.broadcast-tables[x]= #Broadcast table rule configurations
  33. sharding.jdbc.config.sharding.default-data-source-name= #If table not configure at table rule, will route to defaultDataSourceName
  34. sharding.jdbc.config.sharding.default-database-strategy.xxx= #Default strategy for sharding databases, same as databases sharding strategy
  35. sharding.jdbc.config.sharding.default-table-strategy.xxx= #Default strategy for sharding tables, same as tables sharding strategy
  36. sharding.jdbc.config.sharding.default-key-generator-class-name= #Default key generator class name, default value is `io.shardingsphere.core.keygen.DefaultKeyGenerator`. This class need to implements KeyGenerator, and require a no argument constructor
  37. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.master-data-source-name= #more details can reference readwrite-splitting part
  38. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[0]= #more details can reference readwrite-splitting part
  39. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[1]= #more details can reference readwrite-splitting part
  40. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[x]= #more details can reference readwrite-splitting part
  41. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.load-balance-algorithm-class-name= #more details can reference readwrite-splitting part
  42. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.load-balance-algorithm-type= #more details can reference readwrite-splitting part
  43. sharding.jdbc.config.config.map.key1= #more details can reference Readwrite-splitting part
  44. sharding.jdbc.config.config.map.key2= #more details can reference Readwrite-splitting part
  45. sharding.jdbc.config.config.map.keyx= #more details can reference Readwrite-splitting part
  46. sharding.jdbc.config.props.sql.show= #To show SQLS or not, default value: false
  47. sharding.jdbc.config.props.executor.size= #The number of working threads, default value: CPU count
  48. sharding.jdbc.config.config.map.key1= #User-defined arguments
  49. sharding.jdbc.config.config.map.key2= #User-defined arguments
  50. sharding.jdbc.config.config.map.keyx= #User-defined arguments

Readwrite-splitting

Configuration Item Explanation

  1. #Ignore data sources configuration, same as sharding
  2. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.master-data-source-name= #Name of master data source
  3. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[0]= #Name of master data source
  4. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[1]= #Names of Slave data sources
  5. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.slave-data-source-names[x]= #Names of Slave data sources
  6. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.load-balance-algorithm-class-name= #Load balance algorithm class name. This class need to implements MasterSlaveLoadBalanceAlgorithm, and require a no argument constructor
  7. sharding.jdbc.config.sharding.master-slave-rules.<master-slave-data-source-name>.load-balance-algorithm-type= #Load balance algorithm type, values should be: `ROUND_ROBIN` or `RANDOM`. Ignore if `load-balance-algorithm-class-name` is present
  8. sharding.jdbc.config.config.map.key1= #User-defined arguments
  9. sharding.jdbc.config.config.map.key2= #User-defined arguments
  10. sharding.jdbc.config.config.map.keyx= #User-defined arguments
  11. sharding.jdbc.config.props.sql.show= #To show SQLS or not, default value: false
  12. sharding.jdbc.config.props.executor.size= #The number of working threads, default value: CPU count
  13. sharding.jdbc.config.props.check.table.metadata.enabled= #Check the metadata consistency of all the tables, default value: false

Orchestration

Configuration Item Explanation

  1. #Ignore data sources, sharding and readwrite splitting configuration
  2. sharding.jdbc.config.sharding.orchestration.name= #Name of orchestration instance
  3. sharding.jdbc.config.sharding.orchestration.overwrite= #Use local configuration to overwrite registry center or not
  4. sharding.jdbc.config.sharding.orchestration.registry.server-lists= #Rgistry servers list, multiple split as comma. Example: host1:2181,host2:2181
  5. sharding.jdbc.config.sharding.orchestration.registry.namespace= #Namespace of registry
  6. sharding.jdbc.config.sharding.orchestration.registry.digest= #Digest for registry. Default is not need digest.
  7. sharding.jdbc.config.sharding.orchestration.registry.operation-timeout-milliseconds= #Operation timeout time in milliseconds, default value is 500 milliseconds
  8. sharding.jdbc.config.sharding.orchestration.registry.max-retries= #Max number of times to retry, default value is 3
  9. sharding.jdbc.config.sharding.orchestration.registry.retry-interval-milliseconds= #Time interval in milliseconds on each retry, default value is 500 milliseconds
  10. sharding.jdbc.config.sharding.orchestration.registry.time-to-live-seconds= #Time to live in seconds of ephemeral keys, default value is 60 seconds

Shardingsphere-2.x

Sharding

Configuration Item Explanation

  1. # Ignore data sources configuration
  2. sharding.jdbc.config.sharding.default-data-source-name= #Tables without sharding rules will be located through default data source
  3. sharding.jdbc.config.sharding.default-database-strategy.inline.sharding-column= #Name of database sharding column
  4. sharding.jdbc.config.sharding.default-database-strategy.inline.algorithm-expression= #Inline expression for database sharding algorithm
  5. sharding.jdbc.config.sharding.tables.t_order.actualDataNodes= #Describe data source names and actual tables, delimiter as point, multiple data nodes separated with comma, support inline expression. Absent means sharding databases only. Example: ds${0..7}.tbl${0..7}
  6. sharding.jdbc.config.sharding.tables.t_order.tableStrategy.inline.shardingColumn= #Name of table sharding column
  7. sharding.jdbc.config.sharding.tables.t_order.tableStrategy.inline.algorithmInlineExpression= #Inline expression for table sharding algorithm
  8. sharding.jdbc.config.sharding.tables.t_order.keyGeneratorColumnName= #Column name of key generator, do not use Key generator if absent
  9. sharding.jdbc.config.sharding.tables.<logic-table-name>.key-generator-column-name= #Column name of key generator, do not use Key generator if absent
  10. sharding.jdbc.config.sharding.tables.<logic-table-name>.key-generator-class-name= #Key generator, use default key generator if absent. This class need to implements KeyGenerator, and require a no argument constructor

Readwrite-splitting

Configuration Item Explanation

  1. # Ignore data sources configuration
  2. sharding.jdbc.config.masterslave.load-balance-algorithm-type= #Load balance algorithm class of slave database; optional value: ROUND_ROBIN and RANDOM; if there is load-balance-algorithm-class-name, the configuration can be omitted
  3. sharding.jdbc.config.masterslave.name= # master name
  4. sharding.jdbc.config.masterslave.master-data-source-name= #Name of master data source
  5. sharding.jdbc.config.masterslave.slave-data-source-names= #Name of master data source

Orchestration

Configuration Item Explanation

  1. # Ignore data sources configuration
  2. sharding.jdbc.config.orchestration.name= #Name of orchestration instance
  3. sharding.jdbc.config.orchestration.overwrite= #Use local configuration to overwrite registry center or not
  4. sharding.jdbc.config.sharding.orchestration.name= #Name of orchestration instance
  5. sharding.jdbc.config.sharding.orchestration.overwrite= #Use local configuration to overwrite registry center or not
  6. sharding.jdbc.config.sharding.orchestration.registry.server-lists= #Rgistry servers list, multiple split as comma. Example: host1:2181,host2:2181
  7. sharding.jdbc.config.sharding.orchestration.registry.namespace= #Namespace of registry
  8. sharding.jdbc.config.sharding.orchestration.registry.digest= #Digest for registry. Default is not need digest.
  9. sharding.jdbc.config.sharding.orchestration.registry.operation-timeout-milliseconds= #Operation timeout time in milliseconds, default value is 500 milliseconds
  10. sharding.jdbc.config.sharding.orchestration.registry.max-retries= #Max number of times to retry, default value is 3
  11. sharding.jdbc.config.sharding.orchestration.registry.retry-interval-milliseconds= #Time interval in milliseconds on each retry, default value is 500 milliseconds
  12. sharding.jdbc.config.sharding.orchestration.registry.time-to-live-seconds= #Time to live in seconds of ephemeral keys, default value is 60 seconds
  13. # The configuration in Zookeeper
  14. sharding.jdbc.config.orchestration.zookeeper.namespace= #Namespace of zookeeper registry
  15. sharding.jdbc.config.orchestration.zookeeper.server-lists= #Zookeeper Rgistry servers list, multiple split as comma. Example: host1:2181,host2:2181
  16. # The configuration in Etcd
  17. sharding.jdbc.config.orchestration.etcd.server-lists= #Etcd Rgistry servers list, multiple split as comma. Example: host1:2181,host2:2181