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 2019/09/04 07:10:26 UTC

[GitHub] [incubator-shardingsphere] betterjava commented on issue #2964: Can I configure multiple schemas?

betterjava commented on issue #2964:  Can I configure multiple schemas?
URL: https://github.com/apache/incubator-shardingsphere/issues/2964#issuecomment-527773470
 
 
   @M-make There is no 'shardingRule' in your config ymal.
   Here is my config and it works well.
   
   config-shard1.yaml:
   ```
   schemaName: z9
   
   dataSources:
     demo_ds_master_0:
       url: jdbc:mysql://127.0.0.1:3306/demo_ds_master_0?serverTimezone=UTC&useSSL=false
       username: root
       password:
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
     demo_ds_master_1:
       url: jdbc:mysql://127.0.0.1:3306/demo_ds_master_1?serverTimezone=UTC&useSSL=false
       username: root
       password:
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
   
   shardingRule:
     tables:
       user:
         actualDataNodes: demo_ds_master_0.user_$->{0..1}
         tableStrategy:
           inline:
             shardingColumn: ex_id
             algorithmExpression: user_$->{ex_id % 2}
         databaseStrategy:
           inline:
             shardingColumn: ex_id
             algorithmExpression: demo_ds_master_0
         keyGenerator:
           type: SNOWFLAKE
           column: id
     encryptRule:
       encryptors:
         user_name_encryptor:
           type: AES
           props:
             aes.key.value: 123456
       tables:
         user:
           columns:
             logic_name:
               cipherColumn: name
               plainColumn: pre_name
               assistedQueryColumn: name_assisted
               encryptor: user_name_encryptor
   ```
   
   config-shard2.ymal:
   
   ```
   schemaName: sharding_db
   
   dataSources:
     demo_ds_master_0:
       url: jdbc:mysql://127.0.0.1:3306/demo_ds_master_0?serverTimezone=UTC&useSSL=false
       username: root
       password:
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
     demo_ds_master_1:
       url: jdbc:mysql://127.0.0.1:3306/demo_ds_master_1?serverTimezone=UTC&useSSL=false
       username: root
       password:
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
   
   shardingRule:
     tables:
       user:
         actualDataNodes: demo_ds_master_0.user_$->{0..1}
         tableStrategy:
           inline:
             shardingColumn: ex_id
             algorithmExpression: user_$->{ex_id % 2}
         databaseStrategy:
           inline:
             shardingColumn: ex_id
             algorithmExpression: demo_ds_master_0
         keyGenerator:
           type: SNOWFLAKE
           column: id
   ```
   and the result picture:
   
   ![image](https://user-images.githubusercontent.com/4453100/64233176-120c1780-cf26-11e9-851d-d36a658bd724.png)
   
   

----------------------------------------------------------------
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