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 2021/01/17 15:21:06 UTC

[GitHub] [shardingsphere] zhang-j-x opened a new issue #9066: A question about datasource names

zhang-j-x opened a new issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066


   
   when i try to config the demo of sharding databases tables,at first,i config like this 
   ![image](https://user-images.githubusercontent.com/48779230/104847042-ca1e4280-5918-11eb-8c8b-7259c6b77bd3.png)
   
   
   and then i found it run error
   ![image](https://user-images.githubusercontent.com/48779230/104847118-25e8cb80-5919-11eb-9c8d-2c38adfca536.png)
   
   ​​​​i realized the config of datasource.names must be as same as the name of physical database,but i found it strange that why not use the name of physical database as the key of datasourceMap,the configuration property name can not appear '-',when i used the database name like sharding_sphere,it will run error.
   
   ![image](https://user-images.githubusercontent.com/48779230/104847367-84fb1000-591a-11eb-8b07-b4e9379c17fe.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



[GitHub] [shardingsphere] zhang-j-x commented on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
zhang-j-x commented on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-765168476


   About the second point ,it's not what i want,but ShardingSphere needs to configure the datasource.names with the actual database names.I just want to configure like this
   ![image](https://user-images.githubusercontent.com/48779230/105454950-b75f9100-5cbd-11eb-815c-cc04e5a47118.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



[GitHub] [shardingsphere] JiekerTime commented on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
JiekerTime commented on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-774615969


   Hi ~ @zhang-j-x  ! Thanks for your feedback!
   In fact, datasource.names is a logical database name, which can be inconsistent with the actual database name.
   Do you also report an error in the url when you use "_"?


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



[GitHub] [shardingsphere] tristaZero commented on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-765296209


   Got it. Please show me the table rules.


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



[GitHub] [shardingsphere] zhang-j-x removed a comment on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
zhang-j-x removed a comment on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-765462953


   `#=================分库分表======================
   spring:
     shardingsphere:
       props:
         sql-show: true
       #数据库信息
       datasource:
         names: ds1,ds2
         common:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
           username: root
           password: 123456
         ds1:
           #和 druid整合必须为url
           url: jdbc:mysql://127.0.0.1:3306/sharding-sphere1?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
         ds2:
           url: jdbc:mysql://127.0.0.1:3306/sharding-sphere2?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
       #分库分表信息
       rules:
         sharding:
           #分库分表说明 分库字段 分表字段 自增主键
           tables:
             t_order:
               actual-data-nodes: sharding-sphere$->{1..2}.t_order$->{1..2}
               database-strategy:
                 standard:
                   sharding-column: user_id
                   sharding-algorithm-name: database-inline
               table-strategy:
                 standard:
                   sharding-column: order_id
                   sharding-algorithm-name: table-inline
               key-generate-strategy:
                 column: order_id
                 key-generator-name: snowflake
           #分库分表算法
           sharding-algorithms:
             database-inline:
               type: INLINE
               props:
                 algorithm-expression: sharding-sphere$->{user_id % 2 + 1}
             table-inline:
               type: INLINE
               props:
                 algorithm-expression: t_order$->{order_id % 2 + 1}
           #自增主键生成策略
           key-generators:
             snowflake:
               type: SNOWFLAKE
               props:
                 worker-id: 123
   `


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



[GitHub] [shardingsphere] tristaZero commented on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-764217924


   Hi @zhang-j-x ,
   
   You use Sharding-JDBC Datasource with SpringBoot, don't you?
   
   
   Let me iterate your case. Please correct me if something is misunderstood,
   
   - The databases in your MySQL instance are named with `-`
   - You want to configure the `datasource.names`  with the actual database names
   - But there is an exception
   
   Actually, ShardingSphere has no such limitation. Could you give SpringBoot Configuration a check? I remember some version of `SpringBoot` has terrible support for keys with `-`.


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



[GitHub] [shardingsphere] tristaZero commented on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-764217924


   Hi @zhang-j-x ,
   
   You use Sharding-JDBC Datasource with SpringBoot, don't you?
   
   
   Let me iterate your case. Please correct me if something is misunderstood,
   
   - The databases in your MySQL instance are named with `-`
   - You want to configure the `datasource.names`  with the actual database names
   - But there is an exception
   
   Actually, ShardingSphere has no such limitation. Could you give SpringBoot Configuration a check? I remember some version of `SpringBoot` has terrible support for keys with `-`.


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



[GitHub] [shardingsphere] zhang-j-x commented on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
zhang-j-x commented on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-763638577


   yes,rename can solve this problem,but it means that it not supports the database which name contains '_',   sometimes we can not rename the physical database's name.The version i use is 5.0.0-alpha.


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



[GitHub] [shardingsphere] terrymanu closed issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066


   


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

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] zhang-j-x commented on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
zhang-j-x commented on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-765467022


   ![image](https://user-images.githubusercontent.com/48779230/105507434-25c84180-5d06-11eb-8345-ea0e620f7587.png)
   
   `
   #=================分库分表======================
   spring:
     shardingsphere:
       props:
         sql-show: true
       #数据库信息
       datasource:
         names: ds1,ds2
         common:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
           username: root
           password: 123456
         ds1:
           #和 druid整合必须为url
           url: jdbc:mysql://127.0.0.1:3306/sharding-sphere1?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
         ds2:
           url: jdbc:mysql://127.0.0.1:3306/sharding-sphere2?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
       #分库分表信息
       rules:
         sharding:
           #分库分表说明 分库字段 分表字段 自增主键
           tables:
             t_order:
               actual-data-nodes: sharding-sphere$->{1..2}.t_order$->{1..2}
               database-strategy:
                 standard:
                   sharding-column: user_id
                   sharding-algorithm-name: database-inline
               table-strategy:
                 standard:
                   sharding-column: order_id
                   sharding-algorithm-name: table-inline
               key-generate-strategy:
                 column: order_id
                 key-generator-name: snowflake
           #分库分表算法
           sharding-algorithms:
             database-inline:
               type: INLINE
               props:
                 algorithm-expression: sharding-sphere$->{user_id % 2 + 1}
             table-inline:
               type: INLINE
               props:
                 algorithm-expression: t_order$->{order_id % 2 + 1}
           #自增主键生成策略
           key-generators:
             snowflake:
               type: SNOWFLAKE
               props:
                 worker-id: 123
   
   
   `
   


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



[GitHub] [shardingsphere] tristaZero commented on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-763335738


   How about rename `sharding_sphere` without `_` ?  BTW, which version is in your case?


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



[GitHub] [shardingsphere] zhang-j-x commented on issue #9066: A question about datasource names

Posted by GitBox <gi...@apache.org>.
zhang-j-x commented on issue #9066:
URL: https://github.com/apache/shardingsphere/issues/9066#issuecomment-765462953


   `#=================分库分表======================
   spring:
     shardingsphere:
       props:
         sql-show: true
       #数据库信息
       datasource:
         names: ds1,ds2
         common:
           type: com.alibaba.druid.pool.DruidDataSource
           driver-class-name: com.mysql.cj.jdbc.Driver
           username: root
           password: 123456
         ds1:
           #和 druid整合必须为url
           url: jdbc:mysql://127.0.0.1:3306/sharding-sphere1?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
         ds2:
           url: jdbc:mysql://127.0.0.1:3306/sharding-sphere2?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
       #分库分表信息
       rules:
         sharding:
           #分库分表说明 分库字段 分表字段 自增主键
           tables:
             t_order:
               actual-data-nodes: sharding-sphere$->{1..2}.t_order$->{1..2}
               database-strategy:
                 standard:
                   sharding-column: user_id
                   sharding-algorithm-name: database-inline
               table-strategy:
                 standard:
                   sharding-column: order_id
                   sharding-algorithm-name: table-inline
               key-generate-strategy:
                 column: order_id
                 key-generator-name: snowflake
           #分库分表算法
           sharding-algorithms:
             database-inline:
               type: INLINE
               props:
                 algorithm-expression: sharding-sphere$->{user_id % 2 + 1}
             table-inline:
               type: INLINE
               props:
                 algorithm-expression: t_order$->{order_id % 2 + 1}
           #自增主键生成策略
           key-generators:
             snowflake:
               type: SNOWFLAKE
               props:
                 worker-id: 123
   `


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