【原创】MySQL Proxy - 架构篇

架构篇(architecture)

       MySQL Proxy 的定位是存在于 mysql client 和 mysql server 之间的一个简单的程序,能够对从其上通过的数据进行检查、转换和直接进行相应操作。

应用范围包括:
  1. 负载均衡(load balancing)
  2. 故障处理(fail over)
  3. 查询追踪(query tracking)
  4. 查询分析(query analysis)
  5. (...)
       内部实现上讲,MySQL Proxy 是这样的一个协议栈:

(应该有个图,但是,额,太监了)

基于这个 core 能够将 protocol 的各个 phase 暴露给 plugin 。
  • connect -> auth;
  • auth -> command;
  • command -> disconnect;
  • command -> command;
  • connect -> disconnect;
  • auth -> disconnect;

       上述生命周期中的每一个阶段都包含了多种协议状态变迁。以鉴权过程为例,其包含了至少 3 个包:

life-cycle 中涉及的实体: Client, Proxy, Server;

Client -> Proxy [ label = "accept()" ];
Proxy -> Proxy [ label = "script: connect_server()" ];
Proxy -> Server [ label = "connect()" ];
...;

Server -> Proxy [ label = "recv(auth-challenge)" ];
Proxy -> Proxy [ label = "script: read_handshake()" ];

Proxy -> Client [ label = "send(auth-challenge)" ];
Client -> Proxy [ label = "recv(auth-response)" ];
Proxy -> Proxy [ label = "script: read_auth()" ];
Server -> Proxy [ label = "send(auth-response)" ];
Server -> Proxy [ label = "recv(auth-result)" ];
Proxy -> Proxy [ label = "script: read_auth_result()" ];
Proxy -> Client [ label = "send(auth-result)" ];
...;


      当核心层 core 面对大量 connection 的时候是具备自由伸缩特性时,plugin/scripting 层就能够轻易对 end-users 隐藏细节,并简化客户端的实现。


MySQL Proxy 是通过各种库(Chassis, libraries and Plugins)构建出来的协议栈:

其中 chassis 提供了命令行和作为 daemon 应用所需的所有通用函数实现,包括:
  1. 命令行和配置文件(commandline and configfiles)
  2. 日志(logging)
  3. 支持 daemon/service 方式运行(daemon/service support)
  4. plugin 加载(plugin loading)

同时 MySQL Procotol 的 libraries 还实现了实现了各种编码解码功能:
  1. 客户端协议(client protocol)
  2. binlog 协议(binlog protocol)
  3. myisam 文件处理(myisam files)
  4. frm 文件处理(frm files)
  5. masterinfo 文件处理(masterinfo files)






转载于:https://my.oschina.net/moooofly/blog/114160

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值