图文演示通过OneProxy实现MySQL分库分表

  

不知道大家之前对类似通过OneProxy实现MySQL分库分表的文章有无了解,今天我在这里给大家再简单的讲讲。感兴趣的话就一起来看看正文部分吧,相信看完通过OneProxy实现MySQL分库分表你一定会有所收获的。

OneProxy实现MySQL分库分表

简介

Part1:写在最前

,,,,随着网站的壮大,MySQL数据库架构一般会经历一个过程:

图文演示通过OneProxy实现MySQL分库分表

当我们数据量比较小的时候,一台单实例数据库足矣。等我们数据量增大的时候,我们会采用一主多从的数据库架构来降低我们的读写io。当我们某张业务表达到几百万上千万甚至上亿时,就应该去进行分表处理。本文演示OneProxy对数据库实现分表处理,对前端应用是透明的。


第二部分:环境简介

HE1:192.168.1.248 Master1

HE3:192.168.1.250 Master2

HE4:192.168.1.251 alt="图文演示通过OneProxy实现MySQL分库分表">


Part3:创建相关表

登录OneProxy管理库创建表

 [root@HE1  ~] #, mysql  -usys_admin  -pMANAGER  -h292.168.1.251  -P3307 测试
  mysql:[警告],Using  a  password 提醒,command  line  interface 还要be 没有安全感。
  Welcome 用,MySQL 监控只,Commands 最终获得with ,趁机\ g。
  Your  MySQL  connection  id  is  103年
  版本:Server  5.7.16  OneProxy-Community-5.8.5  (OneXSoft)
  Copyright  (c), 2000年,2016年,Oracle 和/或its 子公司只All  rights 保留。
  Oracle  is  a  registered  trademark  of  Oracle  Corporation 和/或它的
  子公司只Other  names  may  be  trademarks  of  their 各自
  的主人。
  Type  & # 39;帮助;& # 39;,趁机& # 39;\ h # 39;, for 帮助只Type  & # 39; \ c # 39;,用clear 从而current  input 语句。
  mysql>, create  table  helei (
  ,,,,,id  int (10), unsigned  NOT  NULL  AUTO_INCREMENT,
  ,,,,,c1  int (10), NOT  NULL  DEFAULT  & # 39; 0 & # 39;
  ,,,,,c2  int (10), unsigned  DEFAULT 空,
  ,,,,,c5  int (10), unsigned  NOT  NULL  DEFAULT  & # 39; 0 & # 39;
  ,,,,,c3  timestamp  NOT  NULL  DEFAULT  CURRENT_TIMESTAMP 提醒UPDATE  CURRENT_TIMESTAMP,
  ,,,,,c4  varchar (200), NOT  NULL  DEFAULT  & # 39; & # 39;
  ,,,,,PRIMARY 关键(id),
  ,,,,,KEY  idx_c1 (c1),
  ,,,,,KEY  idx_c2 (c2)
  ,,,,,)引擎=InnoDB ;
  Query 好吧,,0,rows  affected (0.27,秒)
  mysql>, \ q 


部件:插入数据

 [root@HE1  ~] #, mysql  -usys_admin  -pMANAGER  -h292.168.1.251  -P3307  test  -e" insert  into  helei (id、c1、c2、c5、c4),值(1,1,1,1 & # 39;1 & # 39;)“;
  mysql:[警告],Using  a  password 提醒,command  line  interface 还要be 没有安全感。
  (root@HE1  ~) #, mysql  -usys_admin  -pMANAGER  -h292.168.1.251  -P3307  test  -e" insert  into  helei (id、c1、c2、c5、c4),值(2 2 2 2 & # 39;2 & # 39;)“;
  mysql:[警告],Using  a  password 提醒,command  line  interface 还要be 没有安全感。
  (root@HE1  ~) #, mysql  -usys_admin  -pMANAGER  -h292.168.1.251  -P3307  test  -e" insert  into  helei (id、c1、c2、c5、c4),值(3,3,3,3,& # 39;3 & # 39;)“;
  mysql:[警告],Using  a  password 提醒,command  line  interface 还要be 没有安全感。
  (root@HE1  ~) #, mysql  -usys_admin  -pMANAGER  -h292.168.1.251  -P3307  test  -e" insert  into  helei (id、c1、c2、c5、c4),值(4、4、4、4 & # 39;4 & # 39;)“;
  mysql:[警告],Using  a  password 提醒,command  line  interface 还要be 没有安全感。

校验

Part1:校验oneproxy表内容

这里可以看到虚拟表helei中已经具有刚刚插入的内容;

 [root@HE1  ~] #, mysql  -usys_admin  -pMANAGER  -h292.168.1.251  -P3307  test  -e" select  *,得到helei";
  mysql:[警告],Using  a  password 提醒,command  line  interface 还要be 没有安全感。
  + - - - + - - - + - - - + - - - + - - - - - - - - - - - - - - - - - - - - - + - - - +
  | |,id  c1  |, c2 ,, |, c5  |, c3 ,,,,,,,,,,,,,,,,, |, c4  |
  + - - - + - - - + - - - + - - - + - - - - - - - - - - - - - - - - - - - - - + - - - +
  |,,4,|,,4,|,,,,4,|,,4,|,2016 - 12 - 23,00:07:21  |, 4, |
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null
  null

图文演示通过OneProxy实现MySQL分库分表