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/22 15:00:19 UTC
[GitHub] [shardingsphere] zhang-j-x removed a comment on issue #9066: A question about datasource names
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