5.0.0-beta

Data Source Configuration Item Explanation

  1. schemaName: # Logic schema name.
  2. dataSources: # Data sources configuration, multiple <data-source-name> available.
  3. <data-source-name>: # Different from ShardingSphere-JDBC configuration, it does not need to be configured with database connection pool.
  4. url: # Database URL.
  5. username: # Database username.
  6. password: # Database password.
  7. connectionTimeoutMilliseconds: # Connection timeout milliseconds.
  8. idleTimeoutMilliseconds: # Idle timeout milliseconds.
  9. maxLifetimeMilliseconds: # Maximum life milliseconds.
  10. maxPoolSize: 50 # Maximum connection count in the pool.
  11. minPoolSize: 1 # Minimum connection count in the pool.
  12. rules: # Keep consist with ShardingSphere-JDBC configuration.
  13. # ...

Authentication

It is used to verify the authentication to log in ShardingSphere-Proxy, which must use correct user name and password after the configuration of them.

  1. rules:
  2. - !AUTHORITY
  3. users:
  4. - root@localhost:root # <username>@<hostname>:<password>
  5. - sharding@:sharding
  6. provider:
  7. type: NATIVE # Must be explicitly specified.

If the hostname is % or empty, it means no restrict to the user’s host.

The type of the provider must be explicitly specified. Refer to 5.11 Proxy for more implementations.

Proxy Properties

  1. props:
  2. sql-show: # Whether show SQL or not in log. Print SQL details can help developers debug easier. The log details include: logic SQL, actual SQL and SQL parse result.Enable this property will log into log topic ShardingSphere-SQL, log level is INFO.
  3. sql-simple: # Whether show SQL details in simple style.
  4. executor-size: # The max thread size of worker group to execute SQL. One ShardingSphereDataSource will use a independent thread pool, it does not share thread pool even different data source in same JVM.
  5. max-connections-size-per-query: # Max opened connection size for each query.
  6. check-table-metadata-enabled: # Whether validate table meta data consistency when application startup or updated.
  7. proxy-frontend-flush-threshold: # Flush threshold for every records from databases for ShardingSphere-Proxy.
  8. proxy-transaction-type: # Default transaction type of ShardingSphere-Proxy. Include: LOCAL, XA and BASE.
  9. proxy-opentracing-enabled: # Whether enable opentracing for ShardingSphere-Proxy.
  10. proxy-hint-enabled: # Whether enable hint for ShardingSphere-Proxy. Using Hint will switch proxy thread mode from IO multiplexing to per connection per thread, which will reduce system throughput.
  11. xa-transaction-manager-type: # XA Transaction manager type. Include: Atomikos, Narayana and Bitronix.

5.0.0-alpha

Data Source Configuration Item Explanation

  1. schemaName: # Logic schema name.
  2. dataSourceCommon:
  3. username: # Database username.
  4. password: # Database password.
  5. connectionTimeoutMilliseconds: # Connection timeout milliseconds.
  6. idleTimeoutMilliseconds: # Idle timeout milliseconds.
  7. maxLifetimeMilliseconds: # Maximum life milliseconds.
  8. maxPoolSize: 50 # Maximum connection count in the pool.
  9. minPoolSize: 1 # Minimum connection count in the pool.
  10. dataSources: # Data sources configuration, multiple <data-source-name> available.
  11. <data-source-name>: # Different from ShardingSphere-JDBC configuration, it does not need to be configured with database connection pool.
  12. url: # Database URL.
  13. rules: # Keep consist with ShardingSphere-JDBC configuration.
  14. # ...

Override dataSourceCommon Configuration

If you want to override the ‘dataSourceCommon’ property, configure it separately for each data source.

  1. dataSources: # Data sources configuration, multiple <data-source-name> available.
  2. <data-source-name>: # Different from ShardingSphere-JDBC configuration, it does not need to be configured with database connection pool.
  3. url: # Database URL.
  4. username: # Database username, Override dataSourceCommon username property.
  5. password: # Database password, Override dataSourceCommon password property.
  6. connectionTimeoutMilliseconds: # Connection timeout milliseconds, Override dataSourceCommon connectionTimeoutMilliseconds property.
  7. idleTimeoutMilliseconds: # Idle timeout milliseconds, Override dataSourceCommon idleTimeoutMilliseconds property.
  8. maxLifetimeMilliseconds: # Maximum life milliseconds, Override dataSourceCommon maxLifetimeMilliseconds property.
  9. maxPoolSize: 50 # Maximum connection count in the pool, Override dataSourceCommon maxPoolSize property.
  10. minPoolSize: 1 # Minimum connection count in the pool, Override dataSourceCommon minPoolSize property.

Authentication

It is used to verify the authentication to log in ShardingSphere-Proxy, which must use correct user name and password after the configuration of them.

  1. authentication:
  2. users:
  3. root: # Self-defined username.
  4. password: root # Self-defined password.
  5. sharding: # Self-defined username.
  6. password: sharding # Self-defined password.
  7. authorizedSchemas: sharding_db, replica_query_db # Schemas authorized to this user, please use commas to connect multiple schemas. Default authorized schemas is all of the schemas.

Proxy Properties

  1. props:
  2. sql-show: # Whether show SQL or not in log. Print SQL details can help developers debug easier. The log details include: logic SQL, actual SQL and SQL parse result.Enable this property will log into log topic ShardingSphere-SQL, log level is INFO.
  3. sql-simple: # Whether show SQL details in simple style.
  4. acceptor-size: # The max thread size of accepter group to accept TCP connections.
  5. executor-size: # The max thread size of worker group to execute SQL. One ShardingSphereDataSource will use a independent thread pool, it does not share thread pool even different data source in same JVM.
  6. max-connections-size-per-query: # Max opened connection size for each query.
  7. check-table-metadata-enabled: # Whether validate table meta data consistency when application startup or updated.
  8. query-with-cipher-column: # Whether query with cipher column for data encrypt. User you can use plaintext to query if have.
  9. proxy-frontend-flush-threshold: # Flush threshold for every records from databases for ShardingSphere-Proxy.
  10. proxy-transaction-type: # Default transaction type of ShardingSphere-Proxy. Include: LOCAL, XA and BASE.
  11. proxy-opentracing-enabled: # Whether enable opentracing for ShardingSphere-Proxy.
  12. proxy-hint-enabled: # Whether enable hint for ShardingSphere-Proxy. Using Hint will switch proxy thread mode from IO multiplexing to per connection per thread, which will reduce system throughput.

ShardingSphere-4.x

Data Source and Sharding Configuration Item Explanation

Data Sharding

  1. schemaName: # Logic data schema name.
  2. dataSources: # Data source configuration, which can be multiple data_source_name.
  3. <data_source_name>: # Different from Sharding-JDBC configuration, it does not need to be configured with database connection pool.
  4. url: # Database url connection.
  5. username: # Database username.
  6. password: # Database password.
  7. connectionTimeoutMilliseconds: 30000 # Connection timeout.
  8. idleTimeoutMilliseconds: 60000 # Idle timeout setting.
  9. maxLifetimeMilliseconds: 1800000 # Maximum lifetime.
  10. maxPoolSize: 65 # Maximum connection number in the pool.
  11. shardingRule: #Omit data sharding configuration and be consistent with Sharding-JDBC configuration.

Read-write splitting

  1. schemaName: # Logic data schema name.
  2. dataSources: # Omit data source configurations; keep it consistent with data sharding.
  3. masterSlaveRule: # Omit data source configurations; keep it consistent with Sharding-JDBC.

Data Masking

  1. dataSource: # Ignore data sources configuration.
  2. encryptRule:
  3. encryptors:
  4. <encryptor-name>:
  5. type: # encryptor type.
  6. props: # Properties, e.g. `aes.key.value` for AES encryptor.
  7. aes.key.value:
  8. tables:
  9. <table-name>:
  10. columns:
  11. <logic-column-name>:
  12. plainColumn: # plaintext column name.
  13. cipherColumn: # ciphertext column name.
  14. assistedQueryColumn: # AssistedColumns for query,when use ShardingQueryAssistedEncryptor, it can help query encrypted data.
  15. encryptor: # encrypt name.
  16. props:
  17. query.with.cipher.column: true #Whether use cipherColumn to query or not

Overall Configuration Explanation

Orchestration

It is the same with Sharding-JDBC configuration.

Proxy Properties

  1. # Omit configurations that are the same with Sharding-JDBC.
  2. props:
  3. acceptor.size: # The thread number of accept connection; default to be 2 times of cpu core.
  4. proxy.transaction.type: # Support LOCAL, XA, BASE; Default is LOCAL transaction, for BASE type you should copy ShardingTransactionManager associated jar to lib directory.
  5. proxy.opentracing.enabled: # Whether to enable opentracing, default not to enable; refer to [APM](/en/features/orchestration/apm/) for more details.
  6. check.table.metadata.enabled: # Whether to check metadata consistency of sharding table when it initializes; default value: false.

Authentication

It is used to verify the authentication to log in Sharding-Proxy, which must use correct user name and password after the configuration of them.

  1. authentication:
  2. users:
  3. root: # self-defined username.
  4. password: root # self-defined password.
  5. sharding: # self-defined username.
  6. password: sharding # self-defined password.
  7. authorizedSchemas: sharding_db, masterslave_db # schemas authorized to this user, please use commas to connect multiple schemas. Default authorizedSchemas is all of the schemas.

ShardingSphere-3.x

Data sources and sharding rule configuration reference

Data Sharding

  1. schemaName: # Logic database schema name.
  2. dataSources: # Data sources configuration, multiple `data_source_name` available.
  3. <data_source_name>: # Different with Sharding-JDBC, do not need configure data source pool here.
  4. url: # Database URL.
  5. username: # Database username.
  6. password: # Database password.
  7. autoCommit: true # The default config of hikari connection pool.
  8. connectionTimeout: 30000 # The default config of hikari connection pool.
  9. idleTimeout: 60000 # The default config of hikari connection pool.
  10. maxLifetime: 1800000 # The default config of hikari connection pool.
  11. maximumPoolSize: 65 # The default config of hikari connection pool.
  12. shardingRule: # Ignore sharding rule configuration, same as Sharding-JDBC.

Read-write splitting

  1. schemaName: # Logic database schema name.
  2. dataSources: # Ignore data source configuration, same as sharding.
  3. masterSlaveRule: # Ignore read-write splitting rule configuration, same as Sharding-JDBC.

Global configuration reference

Orchestration

Same as configuration of Sharding-JDBC.

Proxy Properties

  1. # Ignore configuration which same as Sharding-JDBC.
  2. props:
  3. acceptor.size: # Max thread count to handle client's requests, default value is CPU*2.
  4. proxy.transaction.enabled: # Enable transaction, only support XA now, default value is false.
  5. proxy.opentracing.enabled: # Enable open tracing, default value is false. More details please reference[APM](/en/features/orchestration/apm/).
  6. check.table.metadata.enabled: # To check the metadata consistency of all the tables or not, default value : false.

Authorization

To perform Authorization for Sharding Proxy when login in. After configuring the username and password, you must use the correct username and password to login into the Proxy.

  1. authentication:
  2. username: root
  3. password: