shardingsphere 5.0.0
pom
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.0</version>
</dependency>
yml
# 数据源
# 参考
# https://blog.csdn.net/if_icanfly/article/details/120063523?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link
spring:
# datasource:
# type: com.zaxxer.hikari.HikariDataSource
# driver-class-name: com.mysql.cj.jdbc.Driver
# username: root
# password: root
# url: jdbc:mysql://172.19.1.251:3306/yoyo?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
shardingsphere:
datasource:
names: master,slave
master:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: root
jdbc-url: jdbc:mysql://172.19.1.251:3306/database?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
slave:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: root
jdbc-url: jdbc:mysql://172.19.1.251:3306/database?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
props:
sql-show: true
enabled: true
rules:
# 读写分离
readwrite_splitting:
data-sources:
# database name
database:
auto-aware-data-source-name: master,slave
write-data-source-name: master
read-data-source-names: slave
load-balancers-name: round-robin
load-balancers:
# 轮训有多种,具体查看 shardingsphere 官网
round-robin:
type: ROUND_ROBIN
props:
workId: 1
sharding:
tables:
# table name
table_name:
actual-data-nodes: master.table_name_$->{0..0}
table-strategy:
standard:
sharding-column: table_column
sharding-algorithm-name: account-inline
table_name:
actual-data-nodes: master.table_name_$->{0..0}
table-strategy:
standard:
sharding-column: table_column
# algorithm-name 为自定义,与 sharding-algorithms 下 对应
sharding-algorithm-name: account-inline
table_name:
# master_$->{}.table_name_$->{} 具体查看 shardingsphere 官网的 行表达式
actual-data-nodes: master.table_name_$->{0..0}
table-strategy:
standard:
sharding-column: table_column
sharding-algorithm-name: short-inline
# INTERVAL 时间范围分片算法 按照月份分片
table_name:
actual-data-nodes: master.table_name_$->{2021..2023}_$->{['01','02','03','04','05','06','07','08','09','10','11','12']}
table-strategy:
standard:
sharding-column: create_time
sharding-algorithm-name: table-interval
sharding-algorithms:
account-inline:
type: MOD
props:
# mod 获取 properties 为 get() 后 toString 然后进行 parse int
sharding-count: 1
short-inline:
type: HASH_MOD
props:
# hash_mod 获取 properties 为 getPropertity() 后进行 parse int
sharding-count: '1'
# 时间范围分片
table-interval:
type: INTERVAL
props:
datetime-pattern: "yyyy-MM-dd HH:mm:ss"
datetime-lower: "2021-01-01 00:00:00"
datetime-upper: "2023-12-31 23:59:59"
sharding-suffix-pattern: "yyyy_MM"
datetime-interval-amount: "1"
datetime-interval-unit: "MONTHS"
** 注意 **
MOD 以及 HASH_MOD 理应为 auto_table 的分片方法,但是 在 table 中可以使用,sharding 官方认为这是一个bug ,后期可能会将其解决掉
shardingsphere 5.0.0的更多相关文章
- 重磅|Apache ShardingSphere 5.0.0 即将正式发布
Apache ShardingSphere 5.0.0 GA 版在经历 5.0.0-alpha 及 5.0.0-beta 接近两年时间的研发和打磨,终于将在 11 月份与大家正式见面! 11 月 10 ...
- Apache ShardingSphere 5.0.0 内核优化及升级指南
经过近两年时间的优化和打磨,Apache ShardingSphere 5.0.0 GA 版终于在本月正式发布,相比于 4.1.1 GA 版,5.0.0 GA 版在内核层面进行了大量的优化.首先,基于 ...
- ElasticJob 3.0.0:打造面向互联网生态和海量任务的分布式调度解决方案
ElasticJob 于 2020 年 5 月 28 日重启并成为 Apache ShardingSphere 子项目.新版本借鉴了 ShardingSphere 可拔插架构的设计理念,对内核进行了大 ...
- 官宣!ElasticJob 3.0.0 版本正式发布
ElasticJob 是面向互联网生态和海量任务的分布式调度解决方案,由两个相互独立的子项目 ElasticJob-Lite 和 ElasticJob-Cloud 组成.它通过弹性调度.资源管控.以及 ...
- sharding-jdbc5.0.0分表实践
本文基于shardingsphere-jdbc-core-spring-boot-starter 5.0.0,请注意不同版本的sharding-jdbc配置可能有不一样的地方,本文不一定适用于其它版本 ...
- ShardingSphere-proxy-5.0.0部署之分表实现(一)
一.说明 环境准备:JDK8+ mysql 5.x 官网:https://shardingsphere.apache.org/ 下载地址:https://archive.apache.org/ ...
- ShardingSphere-proxy-5.0.0分布式雪花ID生成(三)
一.目的 保证在分库分表中每条数据具有唯一性 二.修改配置文件config-sharding.yaml,并重启服务 # # Licensed to the Apache Software Founda ...
- ShardingSphere-proxy-5.0.0分布式哈希取模分片实现(四)
一.说明 主要是对字符串的字段进行hash取模 二.修改配置文件config-sharding.yaml,并重启服务 # # Licensed to the Apache Software Found ...
- ShardingSphere-proxy-5.0.0容量范围分片的实现(五)
一.修改配置文件config-sharding.yaml,并重启服务 # # Licensed to the Apache Software Foundation (ASF) under one or ...
- ShardingSphere-proxy-5.0.0建立mysql读写分离的连接(六)
一.修改配置文件config-sharding.yaml,并重启服务 # # Licensed to the Apache Software Foundation (ASF) under one or ...
随机推荐
- STM32F103和AIR32F103的FreeRTOS中断优先级
关于 Arm Cortex M 系列内核的中断优先级 https://community.arm.com/arm-community-blogs/b/embedded-blog/posts/cutti ...
- flutter 1.升级2.X在模型类中序列化JSON报错Non-nullable instance field 'title' must be initialized.
flutter 1.升级2.X在模型类中序列化JSON报错 Non-nullable instance field 'title' must be initialized. Try adding an ...
- mysql 简单查询
查询特定列SELECT ename,birthday FROM emp; 查询所有的select*from emp; 给列起别名select ename AS 姓名, salary AS 工资 FRO ...
- Windows静态库和动态库区别
个人建议:能使用静态库的就不要使用动态库,能使用隐式调用的就不要用显示调用. 注意: (1)动态库中的.lib文件叫做导入库,对于导入库而言,其实际的执行代码位于动态库中,导入库只包含了地址符 ...
- 【单片机】通过定时器实现模拟任意路PWM通道(带实例和计算方法)
前言说明 现在有很多单片机的硬件定时器都具备PWM输出功能,不过有时候会因为器件成本或硬件设计等原因,导致数量不够或者所使用的引脚不支持定时器输出.尴尬的是,笔者接手的项目两种情况都存在,项目需要支持 ...
- 12月22日内容总结——django中间件的三个了解要求的方法、基于django中间件的功能设计、cookie与session
目录 一.django中间件三个了解的方法 二.django中间件五个方法的执行流程详解 三.基于django中间件的功能设计 功能设计介绍 如何利用字符串导入模块 功能模拟 四.cookie与ses ...
- VeryCapture V1.8.9.5 中文版安装使用教程
VeryCapture简介 VeryCapture中文版是一款实用的屏幕捕捉工具.VeryCapture最新版持将图钉在桌面.这个功能可以方便图片对比,在写论文或者写文章时比较方便.VeryCaptu ...
- Windows / Mac 安装Typora
Typora Typora 是一款支持实时预览的 Markdown 文本编辑器. 附件下载:Typora 附件 Windows版本 1.解压Typora_1.3.8_windows.rar文件 2.双 ...
- P3_注册小程序账号&安装开发者工具
注册小程序账号 点击注册按钮 使用浏览器打开 https://mp.weixin.qq.com/ 网址,点击右上角的"立即注册"即可进入到小程序开发账号的注册流程,主要流程截图如下 ...
- ROS创建一个基本功能包
1.mkdir catkin_ws/src 2.cd catkin_ws/src 3.catkin_init_workspace 4.cd ~/catkin_ws/ 5.catkin_make 6.在 ...