Blame view

jeecg-boot-master/jeecg-boot/jeecg-cloud-module/jeecg-cloud-test/jeecg-cloud-test-shardingsphere/src/main/resources/application-sharding2.yml 2.39 KB
1
2
3
4
5
6
7
8
# 双库分表配置
spring:
  shardingsphere:
    props:
      sql-show: true
    datasource:
      ds0:
        driverClassName: com.mysql.cj.jdbc.Driver
肖超群 authored
9
        url: jdbc:mysql://localhost:3306/jeecg-boot?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
10
11
12
13
14
        type: com.alibaba.druid.pool.DruidDataSource
        username: root
        password: root
      ds1:
        driverClassName: com.mysql.cj.jdbc.Driver
肖超群 authored
15
        url: jdbc:mysql://localhost:3306/jeecg-boot2?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
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
62
63
64
65
66
67
68
69
70
71
72
        type: com.alibaba.druid.pool.DruidDataSource
        username: root
        password: root
      names: ds0,ds1
    # 规则配置
    rules:
      replica-query:
        # 负载均衡算法
        load-balancers:
          round-robin:
            type: ROUND_ROBIN
            props:
              default: 0
        data-sources:
          prds:
            primary-data-source-name: ds0
            replica-data-source-names: ds1
            load-balancer-name: round_robin
      sharding:
        # 配置绑定表,每一行为一组,绑定表会提高查询效率
        binding-tables:
          - sys_log
        # 分布式序列算法配置
        key-generators:
          snowflake:
            type: SNOWFLAKE
            props:
              worker-id: 123
        # 分片算法配置
        sharding-algorithms:
          table-classbased:
            props:
              strategy: standard
              algorithmClassName: org.jeecg.modules.test.sharding.algorithm.StandardModTableShardAlgorithm
            type: CLASS_BASED
          # 通过operate_type取模的方式确定数据落在哪个库
          database-inline:
            type: INLINE
            props:
              algorithm-expression: ds$->{operate_type % 2}
        tables:
          # 逻辑表名称
          sys_log:
            #配置具体表的数据节点
            actual-data-nodes: ds$->{0..1}.sys_log$->{0..1}
            # 分库策略
            database-strategy:
              standard:
                sharding-column: operate_type
                sharding-algorithm-name: database-inline
            # 分表策略
            table-strategy:
              standard:
                # 分片算法名称
                sharding-algorithm-name: table-classbased
                # 分片列名称
                sharding-column: log_type