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 (分库分表 & 不分库只分表)的更多相关文章

  1. ShardingJdbc-分表;分库;分库分表;读写分离;一主多从+分表;一主多从+分库分表;公共表;数据脱敏;分布式事务

    目录 创建项目 分表 导包 表结构 Yml 分库 Yml Java 分库分表 数据库 Yml 读写分离 数据库 Yml 其他 只请求主库 读写分离判断逻辑代码 一主多从+分表 Yml 一主多从+分库分 ...

  2. mycat+mysql集群:实现读写分离,分库分表

    1.mycat文档:https://github.com/MyCATApache/Mycat-doc       官方网站:http://www.mycat.org.cn/ 2.mycat的优点: 配 ...

  3. 高可用Mysql架构_Mysql主从复制、Mysql双主热备、Mysql双主双从、Mysql读写分离(Mycat中间件)、Mysql分库分表架构(Mycat中间件)的演变

    [Mysql主从复制]解决的问题数据分布:比如一共150台机器,分别往电信.网通.移动各放50台,这样无论在哪个网络访问都很快.其次按照地域,比如国内国外,北方南方,这样地域性访问解决了.负载均衡:M ...

  4. SpringBoot使用Sharding-JDBC读写分离

    本文介绍SpringBoot使用当当Sharding-JDBC进行读写分离. 1.有关Sharding-JDBC 本文还是基于当当网Sharding-Jdbc的依赖,与上一篇使用Sharding-Jd ...

  5. Mycat读写分离、主从切换学习(转)

    http://blog.csdn.net/zhanglei_16/article/details/50707487 Mycat读写分离.主从切换学习问题一:分表.分库的优缺点,以及分表无法成为主流分表 ...

  6. 030:Cetus中间件和MHA读写分离

    030:Cetus中间件和MHA读写分离 line:V1.1 mail: gczheng@139.com date: 2018-08-30 一.主机环境 虚拟机配置 CPU 内存 硬盘 OS版本 My ...

  7. ProxySQL简介原理及读写分离应用

    MySQL-ProxySQL中间件简介 同类型产品 MySQL Route:是现在MySQL官方Oracle公司发布出来的一个中间件. Atlas:是由奇虎360公发的基于MySQL协议的数据库中间件 ...

  8. centos 7 Atlas keepalived 实现高可用 MySQL 5.7 MHA环境读写分离

    目录 简介 相关链接 环境准备 Atlas 环境 MySQL 集群环境 Atlas 安装 和 配置 为数据库的密码加密 修改配置文件 启动 Keepalived 安装配置 安装 master 配置 K ...

  9. Atlas 读写分离 & Atlas + MHA 故障自动恢复

    目录 Atals 介绍 Atlas 主要功能 Atlas 相对于官方 MySQL-Proxy 的优势 Atlas 使用 Atlas 安装 Atlas 目录 Atlas 配置 Atlas 启动 Atla ...

随机推荐

  1. code forces 1173 B. Nauuo and Chess

    本文链接:https://www.cnblogs.com/blowhail/p/10991237.html B. Nauuo and Chess  原题链接:http://codeforces.com ...

  2. vs 编译说明

    静态编译/MT,/MTD 是指使用libc和msvc相关的静态库(lib).   动态编译,/MD,/MDd是指用相应的DLL版本编译.   其中字母含义  d:debug    m:multi-th ...

  3. JWT的入门案例

    1.什么是JWT? JWT全称JSON Web Token.是为了在网络应用环境键传递声明而执行的一种基于JSON的开放标准. 2.JWT的使用场景? 授权:一旦用户登录,每个后续请求将包括JWT,允 ...

  4. 面试中常见的算法之Java中的递归

    1.方法定义中调用方法本身的现象2.递归注意实现 1) 要有出口,否则就是死递归 2) 次数不能太多,否则就内存溢出 3) 构造方法不能递归使用3.递归解决问题的思想和图解: 分解和合并[先分解后合并 ...

  5. python初识(3)

    bool 字符串 for循环 bool 数字非零全都是True 字符串非空全都是True 字符串 索引 从0开始 0 切片选取 [x:y] 左闭右开区间 [x:y:z] 选取x到y之间 每隔z选取一次 ...

  6. 获取一个整数所有的质因数(C语言实现)

    一.题目要求 1. 用户输入任意一个整数,要求程序输出此整数所有的质因数: 2. 用户可以反复输入,直至输入字符'q'退出程序. 二.分析 质因数的概念大家可以问度娘. 题目关键有几个要点,分析透了这 ...

  7. VC win32 static library静态链接库简单示例

    中午在宿舍闲来没事,看到网上一篇帖子,关于静态链接库的英文示例.它在.Net上开发,我将其移到VC上开发,因此对其代码做了相应修改.帖子内容如下:(代码我已修改).原帖见:http://msdn.mi ...

  8. [01] HEVD 双机调试环境搭建

    [01] HEVD 双机调试环境搭建 span::selection, .CodeMirror-line > span > span::selection { background: #d ...

  9. MTSC2019第五届移动互联网测试开发大会PPT下载

    关注公众号「软件测试大本营」后台回复「MTSC」或「测试开发大会」即可获取云盘下载地址及提取码. 注:PPT文件版权归相关撰写人所有,仅供学习交流,请勿用于任何商业用途,谢谢 前不久在北京举办了第五届 ...

  10. David与Vincent的博弈游戏[树型DP]

    \(\mathcal{Description}\) \(\mathcal{Solution}\) 根据题意,我们知道 根节点深度为1,深度为 奇数 的节点由\(David\)移动,我们称为\(D\)点 ...