sharding demo 读写分离 U (分库分表 & 不分库只分表)
application-sharding.yml sharding:
jdbc:
datasource:
names: ds0,ds1,dsx,dsy
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/db0?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
ds1:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/db1?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
dsx:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/db2?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
dsy:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/db3?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
config:
sharding:
default-database-strategy:
inline:
sharding-column: order_id
algorithm-expression: ds$->{order_id % 2}
tables:
t_order:
actual-data-nodes: ds$->{5..6}.t_order_$->{0..1}
table-strategy:
inline:
sharding-column: user_id
algorithm-expression: t_order_$->{user_id % 2}
key-generator-column-name: id props:
sql:
show: true
master-slave-rules:
ds5:
master-data-source-name: ds0
slave-data-source-names: dsx
load-balance-algorithm-type: round_robin
ds6:
master-data-source-name: ds1
slave-data-source-names: dsy
load-balance-algorithm-class-name: shardingsphere.demo.balance.NewBananceAlgorithm application.yml
logging:
level:
ROOT: INFO
shardingsphere.demo: DEBUG
shardingsphere.demo.mapper: debug
server:
port: 8100 mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: shardingsphere.demo.entity
config-location: classpath:mybatis-config.xml spring:
profiles:
active: sharding 不分库 只分表
sharding:
jdbc:
datasource:
names: ds0,ds1
ds0:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/db0?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
ds1:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/db1?useUnicode=true&characterEncoding=utf8&useSSL=false
username: hsq
password: root
config:
sharding:
default-database-strategy:
none:
sharding-column: none
tables:
t_order:
actual-data-nodes: dsx.t_order_$->{0..1}
table-strategy:
inline:
sharding-column: user_id
algorithm-expression: t_order_$->{user_id % 2}
key-generator-column-name: id
user:
actual-data-nodes: dsx.user
props:
sql:
show: true
master-slave-rules:
dsx:
master-data-source-name: ds0
slave-data-source-names: ds1
load-balance-algorithm-type: round_robin
sharding demo 读写分离 U (分库分表 & 不分库只分表)的更多相关文章
- ShardingJdbc-分表;分库;分库分表;读写分离;一主多从+分表;一主多从+分库分表;公共表;数据脱敏;分布式事务
目录 创建项目 分表 导包 表结构 Yml 分库 Yml Java 分库分表 数据库 Yml 读写分离 数据库 Yml 其他 只请求主库 读写分离判断逻辑代码 一主多从+分表 Yml 一主多从+分库分 ...
- mycat+mysql集群:实现读写分离,分库分表
1.mycat文档:https://github.com/MyCATApache/Mycat-doc 官方网站:http://www.mycat.org.cn/ 2.mycat的优点: 配 ...
- 高可用Mysql架构_Mysql主从复制、Mysql双主热备、Mysql双主双从、Mysql读写分离(Mycat中间件)、Mysql分库分表架构(Mycat中间件)的演变
[Mysql主从复制]解决的问题数据分布:比如一共150台机器,分别往电信.网通.移动各放50台,这样无论在哪个网络访问都很快.其次按照地域,比如国内国外,北方南方,这样地域性访问解决了.负载均衡:M ...
- SpringBoot使用Sharding-JDBC读写分离
本文介绍SpringBoot使用当当Sharding-JDBC进行读写分离. 1.有关Sharding-JDBC 本文还是基于当当网Sharding-Jdbc的依赖,与上一篇使用Sharding-Jd ...
- Mycat读写分离、主从切换学习(转)
http://blog.csdn.net/zhanglei_16/article/details/50707487 Mycat读写分离.主从切换学习问题一:分表.分库的优缺点,以及分表无法成为主流分表 ...
- 030:Cetus中间件和MHA读写分离
030:Cetus中间件和MHA读写分离 line:V1.1 mail: gczheng@139.com date: 2018-08-30 一.主机环境 虚拟机配置 CPU 内存 硬盘 OS版本 My ...
- ProxySQL简介原理及读写分离应用
MySQL-ProxySQL中间件简介 同类型产品 MySQL Route:是现在MySQL官方Oracle公司发布出来的一个中间件. Atlas:是由奇虎360公发的基于MySQL协议的数据库中间件 ...
- centos 7 Atlas keepalived 实现高可用 MySQL 5.7 MHA环境读写分离
目录 简介 相关链接 环境准备 Atlas 环境 MySQL 集群环境 Atlas 安装 和 配置 为数据库的密码加密 修改配置文件 启动 Keepalived 安装配置 安装 master 配置 K ...
- Atlas 读写分离 & Atlas + MHA 故障自动恢复
目录 Atals 介绍 Atlas 主要功能 Atlas 相对于官方 MySQL-Proxy 的优势 Atlas 使用 Atlas 安装 Atlas 目录 Atlas 配置 Atlas 启动 Atla ...
随机推荐
- IO解惑:cephfs、libaio与io瓶颈
最近笔者在对kernel cephfs客户端进行fio direct随机大io读测试时发现,在numjobs不变的情况下,使用libaio作为ioengine,无论怎么调节iodepth,测试结果都变 ...
- 02-三种Bean装配机制(三)
在前两篇中分别介绍了自动化装配机制和通过JavaConfig类进行装配,接下来介绍下通过XML装配bean,其实就目前趋势来看,这种方式用的越来越少(不是我说的,是作者说的,喜欢这种方式的别喷我
- BZOJ 3990 排序
[题目描述]: 小A有一个1~2N的排列A[1..2N],他希望将数组A从小到大排序.小A可以执行的操作有N种,每种操作最多可以执行一次.对于所有的i(1<=i<=N),第i种操作为:将序 ...
- 阿里系手淘weex学习第一天
官网原文:https://weex.apache.org/zh/tools/extension.html#功能 功能 创建Weex项目. 支持在VSCode对Weex的语法支持. 检查iOS和Andr ...
- vue.js打包部署线上
你完成了工程开发,需要部署到外网环境,要进行下面的步骤: 一.首先你要购买一个服务器或者有自己的服务器.我介绍给大家的一个免费的服务器:http://free.3v.do/index.html可以免费 ...
- Python的函数, 返回值, 参数
1. 函数 函数是对功能的封装 语法: def 函数名(形参): 函数体(代码块,return) 调用: 函数名(实参) 2. 返回值 return:在函数执行的时候, 遇到return 就直接返回, ...
- scrapy基础知识之 parse()方法的工作机制思考:
1.因为使用的yield,而不是return.parse函数将会被当做一个生成器使用.scrapy会逐一获取parse方法中生成的结果,并判断该结果是一个什么样的类型: 2.如果是request则加入 ...
- AWS S3 上传文件
一.获取签名的URL 通过后端给的接口拿到已经签名好的文件上传的URL地址 二.读取文件(注:AWS 接受的二进制,不能使用form-data) // 获取文件二进制 getFileMd5 = (ke ...
- 拓扑排序 (Topological Sorting)
拓扑排序(Topological Sorting) 一.拓扑排序 含义 构造AOV网络全部顶点的拓扑有序序列的运算称为拓扑排序(Topological Sorting). 在图论中,拓扑排序(Topo ...
- JAVA面试题 手写ArrayList的实现,在笔试中过关斩将?
面试官Q1:可以手写一个ArrayList的简单实现吗? 我们都知道ArrayList是基于数组实现,如果让你实现JDK源码ArrayList中add().remove().get()方法,你知道如何 ...