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. black box黑盒测试

    软件规格说明书 等价类划分,完备性,无冗余性(不能有交集).   健壮等价类:无效等价类 边界值分析,对于一个含有n个变量的程序,采用边界值分析法测试程序会产生4n+1个测试用例           ...

  2. strcpy strlen 实现

    1. strcpy:字符串拷贝函数,无边界,一直拷贝到字符串结束符 '\0' 为止. char* strcpy(char* strDest, const char* strSrc); 代码实现: #i ...

  3. HDU 2896:病毒侵袭(AC自动机)

    http://acm.hdu.edu.cn/showproblem.php?pid=2896 题意:中文题意. 思路:AC自动机模板题.主要在于字符有128种,输出还要排序和去重! 注意是“total ...

  4. 阿里云体验:安装jdk

    在阿里云的linux服务器上默认是没有安装java环境的,需要自己安装.查了许多资料,发现这篇文章简洁易用.http://www.cnblogs.com/cloudwind/archive/2012/ ...

  5. 【朝花夕拾】Android自定义View篇之(十)TouchSlop及VelocityTracker

    前言 在Android事件中,有几个比较基本的概念和知识点需要掌握.比如,表示最小移动阈值的TouchSlop,追踪事件速度的VelocityTracker,用于检测手势的GestureDetecto ...

  6. NOIP 2017 惊魂记

    考完了NOIP三周后才开始补……然后又补了一周…… DAY -1: 晚上吃了一顿送行宴散伙饭,然后默默地看了一遍之前所有考试后写的题解,再读了几遍板子,然后和QTY一起和达哥又一次在外面谈了一个小时, ...

  7. android_sdcard读写(二)

    接着上篇,继续研究sdcard的神秘之处.上篇代码不变,本篇新增代码都在下面~~~ 继续上代码~~ // 写文件 File path = new File("/mnt/sdcard/sxp/ ...

  8. binlog_format日志错误

    客户磁盘空间不够用,发现mysql的err日志文件已每天大概600M-800M的速度增长,开头考虑作日志切割,打开发现,整个7.8G的文件里面百分之99的文件全部是如下所示的warning警告信息 1 ...

  9. MLlib特征变换方法

    Spark1.6.2.2.3 PCA 算法介绍: 主成分分析是一种统计学方法,它使用正交转换从一系列可能相关的变量中提取线性无关变量集,提取出的变量集中的元素称为主成分.使用PCA方法可以对变量集合进 ...

  10. TCP、UDP和HTTP简述整理

    http:是用于www浏览的一个协议.tcp:是机器之间建立连接用的到的一个协议. 1.TCP/IP是个协议组,可分为三个层次:网络层.传输层和应用层.在网络层有IP协议.ICMP协议.ARP协议.R ...