吴学文
2019-07-09 2ce35cb8d146582b32fd8867ef27ac2930da6ae3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
spring:
  shardingsphere:
    datasource:
#      names: ds_master_0,ds_master_1,ds_master_0_slave_0,ds_master_0_slave_1,ds_master_1_slave_0,ds_master_1_slave_1
      names: ds_master_0,ds_master_1
#      ds_master_0_slave_0:
#        jdbc-url: jdbc:mysql://localhost:3306/demo_ds_master_0_slave_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
#        password:
#        type: com.zaxxer.hikari.HikariDataSource
#        driver-class-name: com.mysql.jdbc.Driver
#        username: root
      ds_master_0:
        driver-class-name: com.mysql.jdbc.Driver
        type: com.alibaba.druid.pool.DruidDataSource
        jdbc-url: jdbc:mysql://dev.db.java110.com:3306/hc_community?useUnicode=true&characterEncoding=utf-8
        username: hc_community
        password: hc_community@12345678
        minIdle: 5
        validationQuery: SELECT 1 FROM DUAL
        initialSize: 5
        maxWait: 60000
        filters: stat,wall,log4j
        poolPreparedStatements: true
      ds_master_1:
        driver-class-name: com.mysql.jdbc.Driver
        type: com.alibaba.druid.pool.DruidDataSource
        jdbc-url: jdbc:mysql://dev.db.java110.com:3306/TT?useUnicode=true&characterEncoding=utf-8
        username: TT
        password: TT@12345678
        minIdle: 5
        validationQuery: SELECT 1 FROM DUAL
        initialSize: 5
        maxWait: 60000
        filters: stat,wall,log4j
        poolPreparedStatements: true
    sharding:
      tables:
        business_community:
          actual-data-nodes: ds_master_$->{0..1}.business_community
          database-strategy:
            inline:
              sharding-column: community_id
              algorithm-expression: ds_master_$->{Long.parseLong(community_id) % 2}
        community:
          actual-data-nodes: ds_master_$->{0..1}.community
          database-strategy:
            inline:
              sharding-column: community_id
              algorithm-expression: ds_master_$->{Long.parseLong(community_id) % 2}
      default-database-strategy:
        none:
      default-table-strategy:
        none:
      default-datasource-name: ds_master_0
#      master-slave-rules:
#        ds_1:
#          slave-data-source-names: ds_master_1_slave_0, ds_master_1_slave_1
#          master-data-source-name: ds_master_1
#        ds_0:
#          slave-data-source-names: ds_master_0_slave_0, ds_master_0_slave_1
#          master-data-source-name: ds_master_0