首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏Hadoop数据仓库

    ShardingSphere实践(4)——读写分离

    4)读写数据         预览实际执行的SQL,确认路由符合预期。 , type(name=weight, properties(read_ds2=1,read_ds4=0)));         预览实际执行的SQL,因为read_ds4的权重指定为0,所以每次查询都路由到 ShardingSphere-Proxy会不会有同样的问题呢?先说结论,ShardingSphere-Proxy也无法透传客户端连接地址,但这并不是问题,相反如果透传了才会造成混淆。         : /root/apache-shardingsphere-5.1.1-shardingsphere-proxy-bin/bin/stop.sh /root/apache-shardingsphere- 5.1.1-shardingsphere-proxy-bin/bin/start.sh         从一个客户端连接ShardingSphere-Proxy执行查询: mysql -u root -

    1.6K31编辑于 2022-06-05
  • 来自专栏IT者

    ShardingSphere介绍

    概述 简介 ShardingSphere-JDBC ShardingSphere-Proxy ShardingSphere-Sidecar(TODO) 混合架构 解决方案 线路规划 ShardingSphere GitHub地址:https://github.com/apache/shardingsphere ShardingSphere 官网:https://shardingsphere.apache.org ShardingSphere 站在数据库的上层视角,关注他们之间的协作多于数据库自身。 连接、增量和可插拔是 Apache ShardingSphere 的核心概念。 ShardingSphere 已于2020年4月16日成为 Apache 软件基金会的顶级项目。 Apache ShardingSphere 是多接入端共同组成的生态圈。

    1.1K30编辑于 2022-10-31
  • 来自专栏晏霖

    ShardingSphere 数据分片

    我们今天用ShardingSphere 给大家演示数据分片,包括分库分表、只分表不分库进行说明。 下一节有时间的话在讲讲读写分离吧。 github地址:https://github.com/362460453/boot-sharding-JDBC 正文 目录 前言 正文 ShardingSphere介绍 为什么不用mycat 实践前的准备工作 代码案例 总结 ---- ShardingSphere介绍 ShardingSphere是一套开源的分布式数据库中间件解决方案组成的生态圈,它由Sharding-JDBC、Sharding-Proxy ShardingSphere的功能能帮助我们做什么 数据分片 读写分离 编排治理 分布式事务 2016年初Sharding-JDBC被开源,这个产品是当当的,加入了Apache 后改名为 ShardingSphere ,mycat和ShardingSphere是同类型的中间件,主要的功能,数据分片和读写分离两个都能去做,但是姿势却有很大的差别, 从字面意义上看Sharding 含义是分片、碎片的意思,所以不难理解ShardingSphere

    2.2K40发布于 2019-06-26
  • 来自专栏后端技术学习

    shardingSphere学习一

    shardingSphere1.0中,在看到mybatis的列子中,我们可以看到需要配置:mybatisContext.xml和shardingContext.xml。 ? 2.DatabaseShardingStrategy 数据源分片策略 SingleKeyModuloDatabaseShardingAlgorithm 单key模库分片算法 如图所示,图片来自shardingSphere

    29230发布于 2021-07-23
  • 来自专栏小四的技术文章

    ShardingSphere数据分片

    前言 上一篇我们说了ShardingSphere的读写分离,使用读写分离能够减轻单库的读写操作,从而提升数据库的吞吐量,但是当数据库中表的数据量到达一定数量时,我们可能就会需要进行分片了, 分片又分为垂直分片和水平分片 ShardingSphere数据分片实战 使用ShardingSphere数据分片,我们只需通过简单的配置就能实现,ShardingSphere帮我们屏蔽了底层逻辑,我们也可通过ShardingSphere spring: shardingsphere: mode: type: Standalone repository: type: File 分片算法 ShardingSphere的分片算法有多种,我们也可以自己实现一套分片算法,通过SPI,分片算法的顶层接口是ShardingAlgorithm,目前实现了多种算法。 关于ShardingSphere的数据分片,我们就说到这里,感谢你的观看,我们下期再见 ShardingSphere数据库读写分离

    1.4K21编辑于 2022-07-26
  • 来自专栏Hadoop数据仓库

    (一)ShardingSphere介绍

    比如把原始订单表分成4张分表,id列作为分片键。对于给定id行的存储表为hash(id)%4,即把数据分存储到t_order_0 - t_order_3四张表中。 如从4张表扩容到8张表,那之前id=5的数据存储在t_order_1表中(5%4=1),现在应该放到t_order_5(5%8=5),也就是说历史数据要做迁移。         4. 分库分表导致的复杂性         分库分表的确解决了很多问题,但是也给系统带来了复杂性。 4. 适用场景         三种产品的特性对比如下表所示。 ShardingSphere不仅提供了内置的分布式主键生成器,例如UUID、SNOWFLAKE,还抽离出分布式主键生成器的接口,方便用户实现自定义的自增主键生成器。 4.

    6.8K35编辑于 2022-05-26
  • 来自专栏读写分离

    ShardingSphere实现读写分离

    target=https%3A%2F%2Fgitee.com%2Fcreyanghang%2Fspring-example%2Ftree%2Fmaster%2Fspring-shardingsphere spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.apache.shardingsphere </groupId> <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId> <version name: sharging-jdbc-demo profiles: active: dev 复制 application-dev.yml: # 读写分离配置 spring: shardingsphere 8080/user/insert 图片 在这里插入图片描述 写入主数据源后,查询主数据库中数据是否写入,从数据库数据是否正常同步 2.2、事务测试 为了保证主从库间的事务一致性,避免跨服务的分布式事务,ShardingSphere-JDBC

    67541编辑于 2023-10-26
  • 来自专栏SpringBoot教程

    ShardingSphere实现读写分离

    spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.apache.shardingsphere </groupId> <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId> <version application: name: sharging-jdbc-demo profiles: active: dev application-dev.yml: # 读写分离配置 spring: shardingsphere /127.0.0.1:8080/user/insert 写入主数据源后,查询主数据库中数据是否写入,从数据库数据是否正常同步 2.2、事务测试 为了保证主从库间的事务一致性,避免跨服务的分布式事务,ShardingSphere-JDBC

    89710编辑于 2023-02-16
  • 来自专栏FoamValue

    ShardingSphere」SQL 路由引擎

    对源码有兴趣的同学可以阅读 shardingsphere-route.jar 包。

    84750发布于 2020-10-09
  • 来自专栏温安适的blog

    分库分表-ShardingSphere

    UUID,无序,写入性能差 snowflake·: ShardingSphere提供这个算法, 有序,写入性能好,生成性能无上限。 利用Redis作为发号器: String 类型 key:yyyyMMddHHmmssSSS value: 序号 防止时钟不准,key的有效时间为:30s,生产性能受到redis限制,一般业务够用 ShardingSphere 标准类图,ShardingSphere 改写部分的 略有不同。

    82621编辑于 2023-10-16
  • 来自专栏SpringBoot教程

    ShardingSphere-JDBC垂直分片

    server-user容器 1.2、创建server-order容器 2、程序实现 2.1、创建实体类 2.2、创建Mapper 2.3、配置垂直分片 3、测试垂直分片 常见错误 前言 垂直分片介绍 ShardingSphere PRIMARY KEY(id) ); 2、程序实现 2.1、创建实体类 @TableName("t_order")//逻辑表名 @Data public class Order { //当没有配置shardingsphere-jdbc Order> { } @Mapper public interface UserMapper extends BaseMapper<User> { } 2.3、配置垂直分片 # 垂直分片 spring: shardingsphere 常见错误 ShardingSphere-JDBC远程连接的方式默认的密码加密规则是:mysql_native_password 因此需要在服务器端修改服务器的密码加密规则,如下: ALTER USER

    33220编辑于 2023-02-16
  • 来自专栏Hadoop数据仓库

    ShardingSphere实践(8)——影子库

    建立影子库环境 (1)开启sqlCommentParseEnabled (2)创建逻辑库 (3)添加资源 (4)创建影子库规则 (4)创建缺省影子算法 3. ShardingSphere 关注于全链路压测场景下,数据库层面的解决方案。将压测数据自动路由至用户指定的数据库,是 ShardingSphere 影子库模块的主要设计目标。 2. -5.1.1-shardingsphere-proxy-bin/bin/stop.sh /root/apache-shardingsphere-5.1.1-shardingsphere-proxy-bin /shadow/ https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql /shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/ https://shardingsphere.apache.org/document

    2K51编辑于 2022-08-30
  • 来自专栏Hadoop数据仓库

    ShardingSphere实践(6)——弹性伸缩

    4)规则切换阶段         在此阶段,可能存在一定时间的业务只读窗口期,通过设置数据库只读或ShardingSphere的熔断机制,让旧数据节点中的数据短暂静态,确保增量同步已完全完成。         ShardingSphere-Scaling目前不是一个独立的产品,而是以ShardingSphere-Proxy中的一个配置项提供相应功能。 -5.1.1-shardingsphere-proxy-bin/lib/ # 重启Proxy /root/apache-shardingsphere-5.1.1-shardingsphere-proxy-bin ),(5,3,1,10),(6,3,2,20),(7,4,3,30),(8,4,4,40), (9,5,1,10),(10,5,2,20),(11,6,3,30),(12,6,4,40),(13,7,1,10 ),(14,7,2,20),(15,8,3,30),(16,8,4,40);         ShardingSphere-Proxy只支持对非分片表使用MySQL存储函数、存储过程操作,因此这里只能使用普通的

    4.6K21编辑于 2022-06-12
  • 来自专栏Hadoop数据仓库

    ShardingSphere实践(3)——数据分片

    改写引擎 (1)正确性改写 (2)优化改写 4. 执行引擎 (1)连接模式 (2)自动化执行引擎 5. 归并引擎 (1)遍历归并 (2)排序归并 (3)分组归并 (4)聚合归并 (5)分页归并 三、用例测试 1. 单表 2. 广播表 3. 只分库 4. 只分表 5. 在ShardingSphere的线路规划中,弹性伸缩将于4.x开启。 (1)分片路由         用于根据分片键进行路由的场景。 4. 执行引擎         ShardingSphere采用一套自动化的执行引擎,负责将路由和改写完成之后的真实SQL安全且高效发送到底层数据源执行。 分配规则是以后缀0-15再对资源数量4取模,结果为0-3的表分别分配到资源1-4。最终每个资源中创建了4个分表。

    4.9K21编辑于 2022-06-05
  • 来自专栏Hadoop数据仓库

    ShardingSphere实践(5)——性能测试

    读写分离 4. 数据分片 参考: ----         从业务角度考虑,分为直连、单路由、主从、分库分表四个基本应用场景,对 ShardingSphere-Proxy 和 MySQL 进行性能对比。 ShardingSphere官方文档中说明支持Sysbench和BenchmarkSQL 5.0,但是BenchmarkSQL 5.0本身不支持MySQL数据库(需要自行修改源码重新编译),因此别无选择只能使用 在以前做的tpcc-mysql对比测试中(“5.6.6 消费延迟监控”),Greenplum与MySQL的QPS相差2.75倍,虽然也有差距,但总不像ShardingSphere这般夸张。         参考: https://shardingsphere.apache.org/document/current/cn/reference/test/performance-test/performance-test

    1.6K21编辑于 2022-06-05
  • 来自专栏FoamValue

    ShardingSphere 介绍与简单入门

    于是,我将 Apache ShardingSphere 产品介绍与开发入门通篇阅读了一遍。 那么,本周将围绕 “Apache ShardingSphere” 进行展开。 1. Apache ShardingSphere 简介 它从2016年开源,到2020年4月16日成为 Apache 软件基金会的顶级项目。 Apache ShardingSphere 架构 ShardingSphere 由 JDBC、Proxy 和 Sidecar(规划中)这 3 款相互独立,却又能够混合部署配合使用的产品组成。 ShardingSphere-JDBC 采用无中心化架构,适用于 Java 开发的高性能的轻量级 OLTP 应用;ShardingSphere-Proxy 提供静态入口以及异构语言的支持,适用于 OLAP 4.

    85220发布于 2020-09-24
  • 来自专栏程序员云帆哥

    ShardingSphere实现分库分表

    文章目录 一、简介 二、项目使用 1、引入依赖 2、数据库 3、实体类 4、mapper 5、yml配置 6、测试类 7、数据 一、简介   Apache ShardingSphere 是一套开源的分布式数据库解决方案组成的生态圈 Apache ShardingSphere 5.x 版本开始致力于可插拔架构,项目的功能组件能够灵活的以可插拔的方式进行扩展。 Apache ShardingSphere 目前已提供数十个 SPI 作为系统的扩展点,仍在不断增加中。    ShardingSphere 已于2020年4月16日成为 Apache 软件基金会的顶级项目。 Data public class User { private Integer id; private String name; private Integer age; } 4

    1.5K30编辑于 2022-05-12
  • 来自专栏Hadoop数据仓库

    ShardingSphere实践(7)——数据加密

    加密规则 4. 加密处理过程 5. 解决方案详解 (1)新上线业务 (2)已上线业务改造 6. 中间件加密服务优势 7. 加密算法解析 三、用例测试 1. 准备测试用例环境 2. 执行数据加密 (1)创建逻辑库 (2)添加资源 (3)原表增加加密字段 (4)创建加密规则 3. 测试 4. 割接 参考: ---- 一、功能详解 1. 目前 ShardingSphere 内置了五种加解密算法:AES、MD5、RC4、SM3 和 SM4。用户还可以通过实现 ShardingSphere 提供的接口,自行实现一套加解密算法。 4. 当前,ShardingSphere 针对这种类型的加密解决方案提供了五种具体实现类,分别是 MD5(不可逆)、AES(可逆)、RC4(可逆)、SM3(不可逆)、SM4(可逆),用户只需配置即可使用这五种内置的方案

    2.4K11编辑于 2022-06-14
  • 来自专栏JAVA葵花宝典

    实战:Shardingsphere分库分表

    官方地址:http://shardingsphere.apache.org 本文目标 本文将以springboot进行集成演示,以订单表为例,演示shardingsphere分库分表的基本原理及配置。 spring.shardingsphere.datasource.names = db0,db1 spring.shardingsphere.datasource.db0.type = com.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.db0.driver-class-name = com.mysql.cj.jdbc.Driver spring.shardingsphere.datasource.db0 characterEncoding=utf8&useSSL=false spring.shardingsphere.datasource.db0.username = root spring.shardingsphere.datasource.db0 characterEncoding=utf8&useSSL=false spring.shardingsphere.datasource.db1.username = root spring.shardingsphere.datasource.db1

    3K11发布于 2020-06-17
  • 来自专栏晏霖

    ShardingSphere 读写分离-代码零入侵

    封面为好友拍摄的照片,想查看更多微信公众号搜索:JavaBoy王皓或csdn博客搜索:TenaciousD 前言 上文我们介绍Sharding-JDBC 分库分表(ShardingSphere 数据分片 mysql-connector-java</artifactId> </dependency> <dependency> <groupId>io.shardingsphere <version>3.1.0</version> </dependency> <dependency> <groupId>io.shardingsphere

    2.5K40发布于 2019-06-26
领券