MySQL Proxy 的定位是存在于 mysql client 和 mysql server 之间的一个简单的程序,能够对从其上通过的数据进行检查、转换和直接进行相应操作。 应用范围包括:
内部实现上讲,MySQL Proxy 是这样的一个协议栈: 基于这个 core 能够将 protocol 的各个 phase 暴露给 plugin 。
上述生命周期中的每一个阶段都包含了多种协议状态变迁。以鉴权过程为例,其包含了至少 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 应用所需的所有通用函数实现,包括:
同时 MySQL Procotol 的 libraries 还实现了实现了各种编码解码功能:
转载请保留固定链接: https://linuxeye.com/database/1393.html |