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 ...
随机推荐
- 并发编程-concurrent指南-阻塞队列-同步队列SynchronousQueue
SynchronousQueue:同步Queue,属于线程安全的BlockingQueue的一种,此队列设计的理念类似于"单工模式",对于每个put/offer操作,必须等待一个t ...
- 56. Merge Interval
56. Merge Interval 0. 参考文献 序号 文献 1 花花酱 LeetCode 56. Merge Intervals 2 [LeetCode] Merge Intervals 合并区 ...
- Java实现异步调用
一.创建线程 @Test public void test0() throws Exception { System.out.println("main函数开始执行"); Thre ...
- mysql+mybatis存储超大json
1. 场景描述 因前端界面需存储元素较多,切割后再组装存储的话比较麻烦,就采用大对象直接存储到mysql字段中,根据mysql的介绍可以存放65535个字节,算了算差不多,后来存的时候发现: 一是基本 ...
- 盘一盘 System.out.println()
System.out.println("Hello World")是大部分程序员入门的第一行代码,也可以说是程序员们最熟悉的一行代码.大家真的深入研究过System.out.pri ...
- UVA816 Abbott的复仇 Abbott's Revenge
以此纪念一道用四天时间完结的题 敲了好几次代码的出错点:(以下均为正确做法) memset初始化 真正的出发位置必须找出. 转换东西南北的数组要从0开始. bfs没有初始化第一个d 是否到达要在刚刚取 ...
- 【原】docker部署单节点consul
docker下部署单节点的consul,最重要的是在run consul时,配置-bootstrap-expect=1 docker run --name consul1 -d -p : -p : - ...
- 面试题((A)null).fun()——java中null值的强转
面试题分享 public class A {public static void fun1() { System.out.println("fun1"); } public voi ...
- 安卓BindService笔记
1 前言 最近学习到了安卓的service,记录一下自己对BindService的理解,学习教程以及部分代码来自菜鸟教程的android教程:菜鸟教程安卓端BindService链接 2 正文 先贴一 ...
- 九、chart控件的使用(图表数据的展示)
chart属于老插件网上还有新的插件功能也更多) Chart控件是VS自带的控件,只是比较老了,功能肯定不如现在出来的某些插件强,不过对于简单的显示还是够用:那么现在来看看chart控件的使用方法: ...