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/06/26 08:25:35 UTC

[GitHub] [shardingsphere] bankly opened a new issue #11023: @bankly Can you show more infomation?

bankly opened a new issue #11023:
URL: https://github.com/apache/shardingsphere/issues/11023


   @bankly Can you show more infomation?
   
   _Originally posted by @strongduanmu in https://github.com/apache/shardingsphere/issues/10883#issuecomment-864666079_
   
    Bug Report
   
   version:shardingsphere-jdbc 5.0.0-alph
   
   
   Configuration Spring boot starter broadcast-tables is invalid , but spring namespace is valid
   
   spring.shardingsphere.rules.sharding.broadcast-tables=area
   
   `# 配置真实数据源
   spring.shardingsphere.datasource.names=ds0,ds1
   
   # 配置第 1 个数据源
   spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.ds0.jdbc-url=jdbc:mysql://10.120.96.128:3306/sharding_order
   spring.shardingsphere.datasource.ds0.username=root
   spring.shardingsphere.datasource.ds0.password=123456
   
   # 配置第 2 个数据源
   spring.shardingsphere.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource
   spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver
   spring.shardingsphere.datasource.ds1.jdbc-url=jdbc:mysql://10.120.96.128:3306/sharding_order
   spring.shardingsphere.datasource.ds1.username=root
   spring.shardingsphere.datasource.ds1.password=123456
   
   # 配置 t_order 表规则
   spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds$->{0..1}.t_order_$->{1..2}
   
   # 配置 分片算法
   spring.shardingsphere.rules.sharding.sharding-algorithms.database_inline.type=INLINE
   spring.shardingsphere.rules.sharding.sharding-algorithms.database_inline.props.algorithm-expression=ds$->{user_id % 2}
   spring.shardingsphere.rules.sharding.sharding-algorithms.table_inline.type=INLINE
   spring.shardingsphere.rules.sharding.sharding-algorithms.table_inline.props.algorithm-expression=t_order_$->{id % 2+1}
   # # 广播表规则列表
   spring.shardingsphere.rules.sharding.broadcast-tables=area
   
   # 配置分库策略
   spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-column=user_id
   spring.shardingsphere.rules.sharding.tables.t_order.database-strategy.standard.sharding-algorithm-name=database_inline
   
   # 配置分表策略
   spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=id
   spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=table_inline
   
   
   # 省略配置 t_order_item 表规则...
   # ...
   #aaa
   mybatis.mapper-locations=/mybatis/*.xml
   logging.pattern.dateformat=HH:mm:ss
   
   `
   
   
   <?xml version="1.0" encoding="UTF-8"?>
   <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:context="http://www.springframework.org/schema/context"
          xmlns:tx="http://www.springframework.org/schema/tx"
          xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
          xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
          xsi:schemaLocation="http://www.springframework.org/schema/beans
                              http://www.springframework.org/schema/beans/spring-beans.xsd
                              http://www.springframework.org/schema/tx
                              http://www.springframework.org/schema/tx/spring-tx.xsd
                              http://www.springframework.org/schema/context
                              http://www.springframework.org/schema/context/spring-context.xsd
                              http://shardingsphere.apache.org/schema/shardingsphere/datasource
                              http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
                              http://shardingsphere.apache.org/schema/shardingsphere/sharding
                              http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
                              ">
   
   <!--    <context:component-scan base-package="com.example.demo" />-->
       <!-- 配置真实数据源 -->
       <!-- 配置第 1 个数据源 -->
       <bean id="ds0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
           <property name="driverClassName" value="com.mysql.jdbc.Driver" />
           <property name="jdbcUrl" value="jdbc:mysql://10.120.96.128:3306/sharding_order?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8" />
           <property name="username" value="root" />
           <property name="password" value="123456" />
       </bean>
       <!-- 配置第 2 个数据源 -->
       <bean id="ds1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
           <property name="driverClassName" value="com.mysql.jdbc.Driver" />
           <property name="jdbcUrl" value="jdbc:mysql://10.120.96.129:3306/sharding_order?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8" />
           <property name="username" value="root" />
           <property name="password" value="123456" />
       </bean>
   
   
   
       <!-- 配置分表策略 -->
       <sharding:sharding-algorithm id="tableStrategyAlgorithm" type="INLINE">
           <props>
               <prop key="algorithm-expression">t_order_$->{id % 2 + 1}</prop>
           </props>
       </sharding:sharding-algorithm>
       <sharding:standard-strategy id="tableStrategy" sharding-column="id" algorithm-ref="tableStrategyAlgorithm" />
   
       <!-- 配置分库策略 -->
       <sharding:sharding-algorithm id="databaseStrategyAlgorithm" type="INLINE">
           <props>
               <prop key="algorithm-expression">ds$->{user_id % 2}</prop>
           </props>
       </sharding:sharding-algorithm>
       <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseStrategyAlgorithm"/>
   
       <!-- 配置sharding策略 -->
       <sharding:rule id="shardingRule">
           <sharding:table-rules>
               <sharding:table-rule logic-table="t_order"
                                    actual-data-nodes="ds$->{0..1}.t_order_$->{1..2}"
                                    table-strategy-ref="tableStrategy"
                                    database-strategy-ref="databaseStrategy"
               />
           </sharding:table-rules>
           <sharding:broadcast-table-rules>
               <sharding:broadcast-table-rule table="area"/>
           </sharding:broadcast-table-rules>
       </sharding:rule>
   
   
       <!-- 配置ShardingSphereDataSource -->
       <shardingsphere:data-source id="shardingDataSource" data-source-names="ds0,ds1" rule-refs="shardingRule">
           <props>
               <prop key="sql-show">false</prop>
           </props>
       </shardingsphere:data-source>
   
   
   
       <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
           <property name="dataSource" ref="shardingDataSource"></property>
           <property name="mapperLocations" value="classpath*:mybatis/*.xml"></property>
       </bean>
   
   </beans>
   
   two configuration but only second must execute  broadcast-tables
   
   
   
   
   


-- 
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] avalon5666 commented on issue #11023: @bankly Can you show more infomation?

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


   Can you set sql.show=true, and provider the log?


-- 
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] terrymanu commented on issue #11023: @bankly Can you show more infomation?

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


   Closed because of no response


-- 
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] terrymanu closed issue #11023: @bankly Can you show more infomation?

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


   


-- 
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] avalon5666 commented on issue #11023: @bankly Can you show more infomation?

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


   Can you set sql.show=true, and provider the log?


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