一、简介

Sharding-jdbc官网:http://shardingsphere.apache.org/
1.概述
a、Sharding-jdbc是一个开源的分布式的关系型数据库中间件
b、Sharding-jdbc是客户端代理模式
c、定位为轻量级的Java框架,以jar包提供服务;可以理解为增强版的jdbc驱动
d、完全兼容各种ORM框架,如Mybatis等
架构图:

2.与Mycat之间的差别
a、Mycat是服务端代理,sharding-jdbc是客户端代理
b、MyCat不支持同一库内的水平切分,Sharding-jdbc支持

二、使用

准备:使用前先准备两台Mysql数据库,作为分片节点
本项目使用的两台数据库节点分别为131和132
1.新建一个spring boot项目
a、通过idea创建一个springboot项目
b、通过Maven引入依赖

<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.0</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!--sharding-jdbc for spring --><!--<dependency>--><!--<groupId>org.apache.shardingsphere</groupId>--><!--<artifactId>sharding-jdbc-spring-namespace</artifactId>--><!--<version>4.0.0-RC2</version>--><!--</dependency>--><!--sharding-jdbc for springboot --><dependency><groupId>org.apache.shardingsphere</groupId><artifactId>sharding-jdbc-spring-boot-starter</artifactId><version>4.0.0-RC2</version></dependency></dependencies>

2.配置Sharding-jdbc
注意: a、Sharding-jdbc的配置在spring和springboot项目中是不同的
b、同时,在spring项目和spring-boot项目中,jar的引入方式也是不同的,请注意maven中sharding-jdbc的依赖包的引入方式
(1)第一种方式,使用spring名称空间的方式进行配置
a、创建sharding-jdbc.xml文件
文件位置:

文件内容:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"xmlns:master-slave="http://shardingsphere.apache.org/schema/shardingsphere/masterslave"xmlns:bean="http://www.springframework.org/schema/util"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://shardingsphere.apache.org/schema/shardingsphere/shardinghttp://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsdhttp://shardingsphere.apache.org/schema/shardingsphere/masterslavehttp://shardingsphere.apache.org/schema/shardingsphere/masterslave/master-slave.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"><!--第一个数据源 主--><bean name="ds0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close" ><property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/><property name="username" value="root"/><property name="password" value="root" /><property name="jdbcUrl" value="jdbc:mysql://192.168.73.131/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false"/></bean><!--第一个数据源 从--><bean id="slave0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"><property name="driverClassName" value="com.mysql.cj.jdbc.Driver" /><property name="username" value="root" /><property name="password" value="root" /><property name="jdbcUrl" value="jdbc:mysql://192.168.73.130/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false"/></bean><!--第二个数据源--><bean id="ms1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"><property name="driverClassName" value="com.mysql.cj.jdbc.Driver" /><property name="username" value="root" /><property name="password" value="root" /><property name="jdbcUrl" value="jdbc:mysql://192.168.73.132/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false"/></bean><!--主从之间的负载均衡策略--><master-slave:load-balance-algorithm id="msStrategy" type="RANDOM"/><sharding:data-source id="sharding-data-source"><!--data-source-names: 该规则表示针对哪几个数据源;--><sharding:sharding-rule data-source-names="ds0,slave0,ms1" default-data-source-name="ms0"><!--主从关系,在这里主从共同构建成为一个一体的数据源--><sharding:master-slave-rules><sharding:master-slave-rule id="ms0" master-data-source-name="ds0" slave-data-source-names="slave0"strategy-ref="msStrategy" /></sharding:master-slave-rules><!--针对表的规则--><sharding:table-rules><!--logic-table: sharding-jdbc 中的逻辑表actual-data-nodes: 真实的数据节点,内容格式:库名.表名$->:占位符,相当于spring中的${}database-strategy-ref:数据库的分片策略table-strategy-ref: 表的分片策略--><sharding:table-rule logic-table="t_order" actual-data-nodes="ms$->{0..1}.t_order_$->{1..2}"database-strategy-ref="databaseStrategy" table-strategy-ref="tableStrategy"key-generator-ref="uuid" /><sharding:table-rule logic-table="t_order_item" actual-data-nodes="ms$->{0..1}.t_order_item_$->{1..2}"database-strategy-ref="databaseStrategy" table-strategy-ref="tableOrderItemStrategy"key-generator-ref="uuid" /></sharding:table-rules><!--全局表配置--><sharding:broadcast-table-rules><sharding:broadcast-table-rule table="area"/></sharding:broadcast-table-rules><!--子表(绑定表) 在4.0.0-RC2 这个版本中,存在bug,绑定表无法使用,若要使用请关注sharding-jdbc的更新--><sharding:binding-table-rules><!--父表:t_order      order_id(主键,且同一个库中,使用该字段进行分别); user_id,入库时,使用user_id进行分库子表:t_order_item 关联字段:order_id(t_order的主键),user_id,入库时使用该字段判断父表所在的库注意:sharding-jdbc不能指定绑定字段,因此,子表和父表必须要有相同的字段,并以该字段作为关联字段--><sharding:binding-table-rule logic-tables="t_order,t_order_item"/></sharding:binding-table-rules></sharding:sharding-rule></sharding:data-source><!--key 生成策略--><sharding:key-generator id="uuid" column="order_id" type="UUID"/><!--<sharding:key-generator id="snowflake" column="order_id" type="SNOWFLAKE" props-ref="snow"/>--><!--<bean:properties id="snow">--><!--<prop key="worker.id">678</prop>--><!--<prop key="max.tolerate.time.difference.milliseconds">10</prop>--><!--</bean:properties>--><!--sharding-column: 分片列algorithm-expression:表达式--><sharding:inline-strategy id="databaseStrategy" sharding-column="user_id"algorithm-expression="ms$->{user_id % 2}"/><!--分表策略--><!--<sharding:inline-strategy id="tableStrategy" sharding-column="order_id"--><!--algorithm-expression="t_order_$->{order_id % 2 + 1}"/>--><sharding:standard-strategy id="tableStrategy"sharding-column="order_id"precise-algorithm-ref="myShard"/><bean id="myShard" class="com.example.shardingjdbcdemo.sharding.MySharding"/><!--<sharding:inline-strategy id="tableOrderItemStrategy" sharding-column="order_id"--><!--algorithm-expression="t_order_item_$->{order_id % 2 + 1}"/>--><sharding:standard-strategy id="tableOrderItemStrategy"sharding-column="order_id"precise-algorithm-ref="myShard"/><!--接下来配置spring的SqlSessionFactory--><bean class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="sharding-data-source"/><property name="mapperLocations" value="classpath*:/mybatis/*.xml"/></bean><!--注意:以上配置完成后,请检查mapper中被分片的表的表名,不要使用实际表明,需要使用sharding:data-source配置的逻辑表名-->
</beans>

b、springBoot中引入该配置文件

c.整体项目结构


d、自定义的分片表达式处理类

package com.example.shardingjdbcdemo.sharding;import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;import java.util.Collection;/*** 自定义的处理分片表达式的类* 本次用例中,需要处理order_id 的分片规则* order_id 做为库内分片的字段,它既是t_order表的主键,同时也是子表t_order_item中的字段* order_id 使用了全局唯一主键 UUID*/
public class MySharding implements PreciseShardingAlgorithm<String> {@Overridepublic String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<String> shardingValue) {String id = shardingValue.getValue();int mode = id.hashCode() % availableTargetNames.size();String[] strings = availableTargetNames.toArray(new String[0]);//取绝对值mode = Math.abs(mode);System.out.println(strings[0]+"---------"+strings[1]);System.out.println("mode="+mode);return strings[mode];}
}

e.分布式id解决方案之雪花算法
概述:
snowFlake 时Twitter提出的分布式ID算法
一个64bit的long型数字
引入了时间戳,保持自增

基本概念

基本保持全局唯一,毫秒内并发最大4096个ID
时间回调可能会引起ID重复
可设置最大容忍回调时间
应用
配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"xmlns:master-slave="http://shardingsphere.apache.org/schema/shardingsphere/masterslave"xmlns:bean="http://www.springframework.org/schema/util"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://shardingsphere.apache.org/schema/shardingsphere/shardinghttp://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsdhttp://shardingsphere.apache.org/schema/shardingsphere/masterslavehttp://shardingsphere.apache.org/schema/shardingsphere/masterslave/master-slave.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"><bean id="ds0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"><property name="driverClassName" value="com.mysql.cj.jdbc.Driver" /><property name="username" value="imooc" /><property name="password" value="Imooc@123456" /><property name="jdbcUrl" value="jdbc:mysql://192.168.73.131/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false"/></bean><bean id="slave0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"><property name="driverClassName" value="com.mysql.cj.jdbc.Driver" /><property name="username" value="imooc" /><property name="password" value="Imooc@123456" /><property name="jdbcUrl" value="jdbc:mysql://192.168.73.130/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false"/></bean><bean id="ms1" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"><property name="driverClassName" value="com.mysql.cj.jdbc.Driver" /><property name="username" value="imooc" /><property name="password" value="Imooc@123456" /><property name="jdbcUrl" value="jdbc:mysql://192.168.73.132/shard_order?serverTimezone=Asia/Shanghai&amp;useSSL=false"/></bean><master-slave:load-balance-algorithm id="msStrategy" type="RANDOM"/><sharding:data-source id="sharding-data-source"><sharding:sharding-rule data-source-names="ds0,slave0,ms1" ><sharding:master-slave-rules><sharding:master-slave-rule id="ms0" master-data-source-name="ds0" slave-data-source-names="slave0"strategy-ref="msStrategy"/></sharding:master-slave-rules><sharding:table-rules><sharding:table-rule logic-table="t_order" actual-data-nodes="ms$->{0..1}.t_order_$->{1..2}"database-strategy-ref="databaseStrategy" table-strategy-ref="standard"key-generator-ref="snowflake"/></sharding:table-rules><sharding:broadcast-table-rules><sharding:broadcast-table-rule table="area"/></sharding:broadcast-table-rules><!--<sharding:binding-table-rules>--><!--<sharding:binding-table-rule logic-tables="t_order,t_order_item" />--><!--</sharding:binding-table-rules>--></sharding:sharding-rule></sharding:data-source><sharding:key-generator id="snowflake" column="order_id" type="SNOWFLAKE" props-ref="snow"/><bean:properties id="snow"><prop key="worker.id">678</prop><prop key="max.tolerate.time.difference.milliseconds">10</prop></bean:properties><sharding:inline-strategy id="databaseStrategy" sharding-column="user_id"algorithm-expression="ms$->{user_id % 2}" /><bean id="myShard" class="com.example.shardingjdbcdemo.sharding.MySharding"/><sharding:standard-strategy id="standard" sharding-column="order_id" precise-algorithm-ref="myShard"/><sharding:inline-strategy id="tableStrategy" sharding-column="order_id"algorithm-expression="t_order_$->{order_id % 2 +1}" /><bean class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="sharding-data-source"/><property name="mapperLocations" value="classpath*:/mybatis/*.xml"/></bean></beans>

对应的自定义分片处理逻辑类

package com.example.shardingjdbcdemo.sharding;import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;import java.util.Collection;/*** 自定义的处理分片表达式的类* 本次用例中,需要处理order_id 的分片规则* order_id 做为库内分片的字段,它既是t_order表的主键,同时也是子表t_order_item中的字段* order_id 使用了全局唯一主键 雪花算法*/
public class MySharding implements PreciseShardingAlgorithm<Long> {@Overridepublic String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Long> shardingValue) {Long id = shardingValue.getValue();long mode = id % availableTargetNames.size();String[] strings = availableTargetNames.toArray(new String[0]);//取绝对值mode = Math.abs(mode);System.out.println(strings[0]+"---------"+strings[1]);System.out.println("mode="+mode);return strings[(int) mode];}
}

(2)第二种方式,使用springboot starter 的配置方式
a、注释关于spring名称空间的引用

b、修改maven依赖

c、修改application.properties文件如下

# 配置真实数据源
spring.shardingsphere.datasource.names=ds0,ms1,slave0# 配置第 1 个数据源 -主库(131与130构成主从关系)
spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds0.jdbcUrl=jdbc:mysql://192.168.73.131/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false
spring.shardingsphere.datasource.ds0.username=root
spring.shardingsphere.datasource.ds0.password=root#从库
spring.shardingsphere.datasource.slave0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.slave0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.slave0.jdbcUrl=jdbc:mysql://192.168.73.130/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false
spring.shardingsphere.datasource.slave0.username=root
spring.shardingsphere.datasource.slave0.password=root# 配置第 2 个数据源
spring.shardingsphere.datasource.ms1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ms1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ms1.jdbcUrl=jdbc:mysql://192.168.73.132/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false
spring.shardingsphere.datasource.ms1.username=root
spring.shardingsphere.datasource.ms1.password=root#读写分离配置
spring.shardingsphere.sharding.master-slave-rules.ms0.master-data-source-name=ds0
spring.shardingsphere.sharding.master-slave-rules.ms0.slave-data-source-names=slave0
spring.shardingsphere.sharding.master-slave-rules.ms0.load-balance-algorithm-type=RANDOM# 配置 t_order 表规则
spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=ms$->{0..1}.t_order_$->{0..1}# 配置分库策略
spring.shardingsphere.sharding.tables.t_order.database-strategy.inline.sharding-column=user_id
#相应的分片算法
spring.shardingsphere.sharding.tables.t_order.database-strategy.inline.algorithm-expression=ms$->{user_id % 2}# 配置分表策略
spring.shardingsphere.sharding.tables.t_order.table-strategy.standard.sharding-column=user_id
#自定义的分片算法
spring.shardingsphere.sharding.tables.t_order.table-strategy.standard.precise-algorithm-class-name=com.example.shardingjdbcdemo.sharding.MySharding
#配置t_order的主键生成策略
spring.shardingsphere.sharding.tables.t_order.key-generator.column=order_id
spring.shardingsphere.sharding.tables.t_order.key-generator.type=UUID#全局表
spring.shardingsphere.sharding.broadcast-tables=area#mybatis mapper 位置
mybatis.mapper-locations=/mybatis/*.xml

d、自定义的分片表达式处理类

package com.example.shardingjdbcdemo.sharding;import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;import java.util.Collection;/*** 自定义的处理分片表达式的类* 本次用例中,需要处理order_id 的分片规则* order_id 做为库内分片的字段,它既是t_order表的主键,同时也是子表t_order_item中的字段* order_id 使用了全局唯一主键 UUID*/
public class MySharding implements PreciseShardingAlgorithm<String> {@Overridepublic String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<String> shardingValue) {String id = shardingValue.getValue();int mode = id.hashCode() % availableTargetNames.size();String[] strings = availableTargetNames.toArray(new String[0]);//取绝对值mode = Math.abs(mode);System.out.println(strings[0]+"---------"+strings[1]);System.out.println("mode="+mode);return strings[mode];}
}

e.分布式id解决方案之雪花算法
概述:
snowFlake 时Twitter提出的分布式ID算法
一个64bit的long型数字
引入了时间戳,保持自增

基本概念

基本保持全局唯一,毫秒内并发最大4096个ID
时间回调可能会引起ID重复
可设置最大容忍回调时间
应用
配置:

# 配置真实数据源
spring.shardingsphere.datasource.names=ds0,ms1,slave0# 配置第 1 个数据源 -主库(131与130构成主从关系)
spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ds0.jdbcUrl=jdbc:mysql://192.168.73.131/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false
spring.shardingsphere.datasource.ds0.username=root
spring.shardingsphere.datasource.ds0.password=root#从库
spring.shardingsphere.datasource.slave0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.slave0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.slave0.jdbcUrl=jdbc:mysql://192.168.73.130/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false
spring.shardingsphere.datasource.slave0.username=root
spring.shardingsphere.datasource.slave0.password=root# 配置第 2 个数据源
spring.shardingsphere.datasource.ms1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ms1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.ms1.jdbcUrl=jdbc:mysql://192.168.73.132/sharding_order?serverTimezone=Asia/Shanghai&amp;useSSL=false
spring.shardingsphere.datasource.ms1.username=root
spring.shardingsphere.datasource.ms1.password=root#读写分离配置
spring.shardingsphere.sharding.master-slave-rules.ms0.master-data-source-name=ds0
spring.shardingsphere.sharding.master-slave-rules.ms0.slave-data-source-names=slave0
spring.shardingsphere.sharding.master-slave-rules.ms0.load-balance-algorithm-type=RANDOM# 配置 t_order 表规则
spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=ms$->{0..1}.t_order_$->{0..1}# 配置分库策略
spring.shardingsphere.sharding.tables.t_order.database-strategy.inline.sharding-column=user_id
#相应的分片算法
spring.shardingsphere.sharding.tables.t_order.database-strategy.inline.algorithm-expression=ms$->{user_id % 2}# 配置分表策略
spring.shardingsphere.sharding.tables.t_order.table-strategy.standard.sharding-column=user_id
#自定义的分片算法
spring.shardingsphere.sharding.tables.t_order.table-strategy.standard.precise-algorithm-class-name=com.example.shardingjdbcdemo.sharding.MySharding
#配置t_order的主键生成策略
spring.shardingsphere.sharding.tables.t_order.key-generator.column=order_id#spring.shardingsphere.sharding.tables.t_order.key-generator.type=UUID  全局id生成策略 UUID#全局ID生成策略之雪花算法相关配置
spring.shardingsphere.sharding.tables.t_order.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.t_order.key-generator.props.worker.id=345
spring.shardingsphere.sharding.tables.t_order.key-generator.props.max.tolerate.time.difference.milliseconds=10#全局表
spring.shardingsphere.sharding.broadcast-tables=area#mybatis mapper 位置
mybatis.mapper-locations=/mybatis/*.xml

对应的自定义分片处理逻辑类:

package com.example.shardingjdbcdemo.sharding;import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;import java.util.Collection;/*** 自定义的处理分片表达式的类* 本次用例中,需要处理order_id 的分片规则* order_id 做为库内分片的字段,它既是t_order表的主键,同时也是子表t_order_item中的字段* order_id 使用了全局唯一主键 雪花算法*/
public class MySharding implements PreciseShardingAlgorithm<Long> {@Overridepublic String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Long> shardingValue) {Long id = shardingValue.getValue();long mode = id % availableTargetNames.size();String[] strings = availableTargetNames.toArray(new String[0]);//取绝对值mode = Math.abs(mode);System.out.println(strings[0]+"---------"+strings[1]);System.out.println("mode="+mode);return strings[(int) mode];}
}

Sharding-jdbc实现读写分离、分库分表相关推荐

  1. 视频教程-ShardingSphere:SpringBoot2+MybatisPlus+读写分离+分库分表-Java

    ShardingSphere:SpringBoot2+MybatisPlus+读写分离+分库分表 10多年互联网一线实战经验,现就职于大型知名互联网企业,架构师, 有丰富实战经验和企业面试经验:曾就职 ...

  2. MySql高可用搭建 + 读写分离 + 分库分表

    Mysql读写分离与分库分表 一.Mysql读写分离解决的问题 二.mysql处理请求运行流程 三.读写分离结构 四.读写分离产生场景 五.读写分离工具 5.1 MyCat 5.2 HAProxy 5 ...

  3. @mysql读写分离分库分表

    文章目录 MySQL中间件Atlas 一 atlas简介 二 主要功能 三 使用场景 四 企业读写分离及分库分表其他方案了解 五 安装Atlas 六 配置 七 启动服务 1) mysql库创建账号 八 ...

  4. Sharding-Jdbc 实现读写分离 + 分库分表,写得太好了!

    欢迎关注方志朋的博客,回复"666"获面试宝典 来自:CSDN,作者:邋遢的流浪剑客 链接:https://blog.csdn.net/qq_40378034/article/de ...

  5. SpringCloud微服务实战——搭建企业级开发框架(二十七):集成多数据源+Seata分布式事务+读写分离+分库分表

      读写分离:为了确保数据库产品的稳定性,很多数据库拥有双机热备功能.也就是,第一台数据库服务器,是对外提供增删改业务的生产服务器:第二台数据库服务器,主要进行读的操作.   目前有多种方式实现读写分 ...

  6. MyCAT读写分离分库分表

    MyCAT读写分离及分库分表 第1章 MyCAT分布式系统解决方案 1.1 分布式系统介绍: 分布式系统特性: 1. 透明性: a) 分布式系统对用户来说是透明的,一个分布式系统在用户面前的表现就像一 ...

  7. MySQL搭建主从复制 读写分离 分库分表 MyCat高可用

    主从演示 读写演示 分表演示 主从复制 环境的介绍 系统环境:centos7.0 客户端连接工具:xshell 远程文件传输工具:xftp 服务器: 192.168.126.138(主) 192.16 ...

  8. Mycat 读写分离+分库分表

    上次进过GTID复制的学习记录,已经搭建好了主从复制的服务器,现在利用现有的主从复制环境,加上正在研究的Mycat,实现了主流分布式数据库的测试 Mycat就不用多介绍了,可以实现很多分布式数据库的功 ...

  9. 数据库主从复制,读写分离,分库分表理解 (数据库架构演变)

    主从复制 主从复制, 主要是针对MySQL数据库的高可用性, 容灾性上面.      是叫做高可用性? 高可用性可以简单的理解为容灾性, 稳定性, 针对故障,风险情况下的处理, 备案, 策略.  指系 ...

  10. 商城订单模块实战 - 数据库设计、ABA问题处理、读写分离分库分表

    引言 订单系统可以说是整个电商系统中最重要的一个子系统,因此订单数据可以算作电商企业最重要的数据资产.这篇文章我们来看看在我们的商城系统中订单服务是如何实现的,特别是在设计和实现一个订单系统的过程中有 ...

最新文章

  1. 服务器信号为970101,cDIN_EN_ISO_306.970101精选.pdf
  2. python实现Anderson-Darling正态分布检验
  3. 《zw版·Halcon-delphi系列原创教程》 Halcon分类函数011,ocr,字符识别
  4. boost::hana::keys用法的测试程序
  5. 细谈Web框架设计与实现
  6. java项目启动后运行方法_spring boot在启动项目之后执行的实现方法
  7. 专科计算机组成原理大一试题及答案,计算机组成原理专科试题答案.doc
  8. python初心记录一
  9. webpack+vue解决前端跨域问题
  10. js判断当前页面是否有父页面,页面部分跳转解决办法,子页面跳转父页面不跳转解决 (原)...
  11. Ubuntu软件安装新选择—星火应用商店(QQ、微信等一网打尽)
  12. html简单网页源代码表格,HTML 表格
  13. 试简述smtp通信的三个阶段的过程_对通信技术来说,物联网起了什么样的作用?...
  14. DM9601 USB网卡驱动
  15. 【转载】CSDI2018广州关于《Nginx》的分享(附文字速录与PPT)
  16. 灯塔 (数据结构)
  17. 82. 采用 OPA5 开发支持页面跳转的 SAP UI5 集成测试用例
  18. win10修改系统时间(2038,2050)重启后桌面一直刷新
  19. 可擦玻璃平顶的机器人_擦玻璃机器人的优点和缺点各是什么?智能擦窗机真的好用吗?有人工擦的干净吗...
  20. qq号码凶吉 php,QQ号码测吉凶

热门文章

  1. android浏览器内核检测,一段非常简单的js判断浏览器的内核
  2. jmeter最大请求数_jmeter支持的最大线程数
  3. 最实用的必备电脑软件
  4. 控制工程笔记2|拉普拉斯变换
  5. Silverlight/Windows8/WPF/WP7/HTML5周学习导读(7月23日-7月29日)
  6. 聚类分析法-层次聚类
  7. 爬取京东上商品的所有详细信息
  8. Python:星期一
  9. 企业应如何正确应对负面报道?
  10. 使用点九图在Android Studio中实现与Axure设计图一致的阴影效果