1.动静读写拆散介绍
1.1 介绍
读写拆散是业界应用 MySQL 高可用最罕用的计划之一,在理论场景中能够进步查问性能,升高服务器负载。本次版本在 v0.1.0 动态规定根底上减少了动静感知读写拆散性能。
在动静感知的读写拆散中,须要配置读写拆散的规定。Pisa-Proxy 会依据规定进行 SQL 路由。如图1.1 Pisa-Proxy 后端会启动 4个 Monitor 对后端集群状态进行感知。Monitor Reconcile 会对 Monitor 上报的数据进行计算聚合并得出后端集群最终状态,再由 Monitor Reconcile 将状态信息通过 channel 下发给 RulesMatch,RulesMatch 拿到音讯后会动静调整后端数据源列表。
这里的概念有:
- 节点: 指后端数据库节点。
- RulesMatch:RulesMatch 引擎通过编写的规定集,与 Pisa-Proxy 接管到的 SQL 查问语句做匹配。
- TargetRole: 指通过规定匹配引擎匹配到的 TargetRole 组,每个 TargetRole 组里可能会有一个或多个节点。
- LoadBalance:负载平衡模块会依照相应的算法从 TargetRole 组里选取一个适合的节点。
- TargetInstance:指由 LoadBalance 模块选出的节点。
- Discovery:发现类型,对应于后端数据源应用的高可用策略,例如: MHA,RDS,MGR等等,本版本中次要反对了 MHA。
Monitor: 指 Pisa-Proxy 对后端的探测模块,在 MHA 中次要依赖于4种 Monitor:
- Connect Monitor: 探测数据库连通性。
- Ping Monitor: 探测数据库是否衰弱。
- Replication Lag Monitor: 探测主从复制提早状态。
- Read Only Monitor: 探测主从数据库角色
1.2 读写拆散配置
读写拆散配置规定配置形式同动态读写拆散保持一致,动静读写拆散配置项如下:
参数 | 类型 | 是否依赖 | 默认值 | 含意 |
---|---|---|---|---|
user | string | 是 | None | 探测模块执行查看 SQL 语句用户名 |
password | string | 是 | None | 探测模块执行查看 SQL 语句明码 |
monitor_period | u64 | 是 | 1000 | 探测模块更新感知后端数据源状态周期(毫秒) |
connect_period | u64 | 是 | 1000 | Connect 模块探测周期(毫秒) |
connect_timeout | u64 | 是 | 6000 | Connect 模块探测超时工夫(毫秒) |
connect_failure_threshold | u64 | 是 | 1 | Connect 模块探测失败重试次数 |
ping_period | u64 | 是 | 1000 | Ping 模块探测周期(毫秒) |
ping_timeout | u64 | 是 | 6000 | Ping 模块探测超时工夫(毫秒) |
ping_failure_threshold | u64 | 是 | 1 | Ping 模块探测失败重试次数 |
replication_lag_period | u64 | 是 | 1000 | Replication Lag 模块探测周期(毫秒) |
replication_lag_timeout | u64 | 是 | 6000 | Replication Lag 模块探测超时工夫(毫秒) |
replication_lag_failure_threshold | u64 | 是 | 1 | Replication Lag 探测失败重试次数 |
max_replication_lag | u64 | 是 | 10000 | 用户定义主从最大延迟时间阈值(毫秒) |
read_only_period | u64 | 是 | 1000 | Read Only 探测周期(毫秒) |
read_only_timeout | u64 | 是 | 6000 | Read Only 探测超时工夫(毫秒) |
read_only_failure_threshold | u64 | 是 | 3 | Read Only 探测失败重试次数 |
CRD 配置示例:
apiVersion: core.database-mesh.io/v1alpha1kind: TrafficStrategymetadata: name: catalogue namespace: demotestspec: selector: matchLabels: source: test loadBalance: readWriteSplitting: dynamic: defaultTarget: readwrite discovery: masterHighAvailability: connectionProbe: failureThreshold: 3 periodMilliseconds: 1000 timeoutMilliseconds: 6000 monitorPeriod: 1000 pingProbe: failureThreshold: 3 periodMilliseconds: 1000 timeoutMilliseconds: 6000 readOnlyProbe: failureThreshold: 3 periodMilliseconds: 1000 timeoutMilliseconds: 6000 replicationLagProbe: failureThreshold: 3 maxReplicationLag: 3 periodMilliseconds: 1000 timeoutMilliseconds: 6000 user: monitor password: monitor rules: - algorithmName: roundrobin name: write-rule regex: - ^insert target: readwrite type: regex - algorithmName: roundrobin name: read-rule regex: - ^select target: read type: regex
2. Pisanix v0.2.0 版本阐明
新个性
Pisa-Controller
- 在 TrafficStrategy CRD ReadWriteSplitting 字段中,减少了对动静读写拆散的反对 #208
Pisa-Proxy
- 反对动静感知读写拆散 #204
- 减少了
daemon
sidecar
子命令 #190
加强
- 重构了 Pisa-Proxy 配置文件 #182
- 欠缺 SHOW SQL 语句解析 #183
- 减少 Pisa-Controller 代码覆盖率查看 #192
- 减少对后端数据源连贯失败重连 #215
改良
Pisa-Controller
- 修复 webhook tls #221
Pisa-Proxy
- 修复 MySQL8 认证切换申请失败问题 #170
- MySQL 协定 EOF 包解决异样 #166
- 修复了 Charset 字符集 #154
- 修复注入环境变量 #223
其余
Docs
- 新增读写拆散阐明文档:https://www.pisanix.io/docs/v...
- 更新单机部署文档:https://www.pisanix.io/docs/v...
Charts
- 更新至 v0.2.0
3. 社区
本次版本公布共蕴含62个 PR,感激各位贡献者:
- mlycore
- xuanyuan300
- wbtlb
- windghoul
- lltgo
- tuichenchuxin
- dongzl
[下载链接]
(https://github.com/database-m...)