古道长亭

Contact me with ixiaoqiang0011@gmail.com


  • 首页

  • 归档

  • 分类

  • 关于

  • Book

  • 搜索

强制路由实战

时间: 2023-01-01   |   分类: mysql高级   sharding-sphere   | 字数: 140 字 | 阅读约: 1分钟 | 阅读次数:

强制路由实战

实战代码示例: https://gitee.com/ixinglan/mysql-demo.git

sharding-jdbc-demo: 详见README.md 介绍

我们以city表示例

  • 新建 application-hint-database.yml, 并将主配置文件active改为hint-database
# datasource
spring:
  shardingsphere:
    datasource:
      names: ds0,ds1
      ds0:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class: com.mysql.jdbc.Driver
        jdbc-url: jdbc:mysql://localhost:3306/sharding-demo1
        username: root
        password: 123456
      ds1:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class: com.mysql.jdbc.Driver
        jdbc-url: jdbc:mysql://localhost:3306/sharding-demo2
        username: root
        password: 123456
    # sharding-database
    sharding:
      tables:
        city:
          databaseStrategy:
            hint:
              algorithmClassName: com.hint.MyHintShardingAlgorithm
  • 创建 MyHintShardingAlgorithm 类实现HintShardingAlgorithm
  • 测试方法 TestHintAlgorithm: test1
#mysql# #强制路由# #sharding-sphere#
QQ扫一扫交流

标题:强制路由实战

作者:古道长亭

声明: 欢迎加群交流!

如有帮助,欢迎多多交流 ^_^

微信打赏

支付宝打赏

数据脱敏剖析
强制路由剖析
  • 文章目录
  • 站点概览
古道长亭

古道长亭

Always remember that your present situation is not your final destination. The best is yet to come.

226 日志
57 分类
104 标签
GitHub Gitee
友情链接
  • 古道长亭的BOOK
  • JAVA学习
标签云
  • Mysql
  • 搜索引擎
  • Mybatis
  • 容器
  • 架构
  • 消息队列
  • Flink
  • Sharding sphere
  • 流处理
  • 缓存
© 2019 - 2024 京ICP备19012088号-1
0%