架构篇(architecture)
MySQL Proxy 的定位是存在于 mysql client 和 mysql server 之间的一个简单的程序,能够对从其上通过的数据进行检查、转换和直接进行相应操作。
应用范围包括:
(应该有个图,但是,额,太监了)
基于这个 core 能够将 protocol 的各个 phase 暴露给 plugin 。
上述生命周期中的每一个阶段都包含了多种协议状态变迁。以鉴权过程为例,其包含了至少 3 个包:
life-cycle 中涉及的实体: Client, Proxy, Server;
当核心层 core 面对大量 connection 的时候是具备自由伸缩特性时,plugin/scripting 层就能够轻易对 end-users 隐藏细节,并简化客户端的实现。
MySQL Proxy 是通过各种库(Chassis, libraries and Plugins)构建出来的协议栈:
其中 chassis 提供了命令行和作为 daemon 应用所需的所有通用函数实现,包括:
同时 MySQL Procotol 的 libraries 还实现了实现了各种编码解码功能:
MySQL Proxy 的定位是存在于 mysql client 和 mysql server 之间的一个简单的程序,能够对从其上通过的数据进行检查、转换和直接进行相应操作。
应用范围包括:
- 负载均衡(load balancing)
- 故障处理(fail over)
- 查询追踪(query tracking)
- 查询分析(query analysis)
- (...)
(应该有个图,但是,额,太监了)
基于这个 core 能够将 protocol 的各个 phase 暴露给 plugin 。
- connect -> auth;
- auth -> command;
- command -> disconnect;
- command -> command;
- connect -> disconnect;
- auth -> disconnect;
上述生命周期中的每一个阶段都包含了多种协议状态变迁。以鉴权过程为例,其包含了至少 3 个包:
life-cycle 中涉及的实体: Client, Proxy, Server;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
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 应用所需的所有通用函数实现,包括:
- 命令行和配置文件(commandline and configfiles)
- 日志(logging)
- 支持 daemon/service 方式运行(daemon/service support)
- plugin 加载(plugin loading)
同时 MySQL Procotol 的 libraries 还实现了实现了各种编码解码功能:
- 客户端协议(client protocol)
- binlog 协议(binlog protocol)
- myisam 文件处理(myisam files)
- frm 文件处理(frm files)
- masterinfo 文件处理(masterinfo files)