You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/02/24 05:50:59 UTC

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #4431: sharding-jdbc4,How to configure only tables that need to be fragmented through default config and customized code

KomachiSion commented on issue #4431: sharding-jdbc4,How to configure only tables that need to be fragmented through default config and customized code
URL: https://github.com/apache/incubator-shardingsphere/issues/4431#issuecomment-590175902
 
 
   Hi, @fantacy2001 ,
   
   ShardingSphere need you configured actual data nodes if you want to shard both datasources and tables. If there are no `actualDataNodes` configured, ShardingSphere can't know what's the Possible shardingNodes which should be input into your sharding algorithms.
   
   For your situation, I think you can have a try like follow:
   
   ```yaml
   dataSources:
     ds_0: !!com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.jdbc.Driver
       jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
       username: root
       password:
     ds_1: !!com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.jdbc.Driver
       jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
       username: root
       password:
   
   
   shardingRule:
     tables:
       tableA: 
         actualDataNodes: ds_0.tenantId&->{1..2},ds_1.tenantId{3..4}   
       tableB:
         actualDataNodes: ds_0.tenantId&->{1..2},ds_1.tenantId{3..4} 
     defaultDatabaseStrategy:
       stardard:
         shardingColumn: xxx
         preciseShardingAlgorithm: ${your.algorithm}
     defaultTableStrategy:
       stardard:
         shardingColumn: yyy
         preciseShardingAlgorithm: ${your.algorithm}
   ```
   
   and map the actual tableName in your algorithms.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services