V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
littlecold
V2EX  ›  问与答

shardingsphere 读写分离之主从配置

  •  
  •   littlecold · 2022-09-23 18:29:51 +08:00 · 513 次点击
    这是一个创建于 582 天前的主题,其中的信息可能已经有所发展或是发生改变。

    版本是 5.1.1 ,主从数据库,分表不分库,表 sharding 没啥问题,主从的读写分离就一直不行,请求各位大佬支援。

    spring:
      shardingsphere:
        datasource:
          names: ds0,ds1
          # 主库 1,master 数据库
          ds0:
           xxxxxx
          # 从库 1,slave 数据库
          ds1:
            xxxxx
        props:
          sql-show: true
          sql-simple: false
          # 是否在启动时检查分表元数据一致性
          check-table-metadata-enabled: true
          check-duplicate-table-enabled: false
          sql-comment-parse-enabled: false
          sql-federation-enabled: false
        rules:
          # 分片
          sharding:
            tables:
              xxxxxx:
                actual-data-nodes: ds$->{0..1}.xxxxx$->{0..7}
                table-strategy:
                  standard:
                    sharding-column: uid
                    sharding-algorithm-name: xxxxAl
            default-sharding-column: uid
            binding-tables:
              - xxxxxx
            broadcast-tables:
            default-database-strategy:
              none:
            default-table-strategy:
              none:
    
    
            sharding-algorithms:
              xxxxAl:
                type: INLINE
                props:
                  algorithm-expression: xxxxxx_xxxx
          ### 读写分离
          readwrite-splitting:
            data-sources:
              readwrite_ds:
                type: Static
                load-balancer-name: round_robin
                props:
                  write-data-source-name: ds0
                  read-data-source-names: ds1
            load-balancers:
              round_robin:
                type: ROUND_ROBIN
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4539 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:06 · PVG 18:06 · LAX 03:06 · JFK 06:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.