Pisanix 于今天发布了 v0.2.0 版本,在此前版本基础上,本次更新新增了动态读写分离支持,下面将进行详细介绍。
读写分离是业界使用 MySQL 高可用最常用的方案之一,在实际场景中可以提高查询性能,降低服务器负载。本次版本在 v0.1.0 静态规则基础上增加了动态感知读写分离功能。
在动态感知的读写分离中,需要配置读写分离的规则。Pisa-Proxy 会根据规则进行 SQL 路由。如图1.1 Pisa-Proxy 后端会启动 4个 Monitor 对后端集群状态进行感知。Monitor Reconcile 会对 Monitor 上报的数据进行计算聚合并得出后端集群最终状态,再由 Monitor Reconcile 将状态信息通过 channel 下发给 RulesMatch,RulesMatch 拿到消息后会动态调整后端数据源列表。
这里的概念有:

读写分离配置规则配置方式同静态读写分离保持一致,动态读写分离配置项如下:
| 参数 | 类型 | 是否依赖 | 默认值 | 含义 |
|---|---|---|---|---|
| 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/v1alpha1
kind: TrafficStrategy
metadata:
name: catalogue
namespace: demotest
spec:
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
新特性
daemon sidecar 子命令 #190增强
改进
其他
本次版本发布共包含62个 PR,感谢各位贡献者:
[下载链接]
(https://github.com/database-mesh/pisanix/releases/tag/v0.2.0)
| 邮件列表 | https://groups.google.com/g/database-mesh |
|---|---|
| 英文社区双周会(2022年2月16日起),周三 9:00 AM PST | https://meet.google.com/yhv-zrby-pyt |
| 中文社区双周会(2022年4月27日起),周三 9:00 PM GMT+8 | https://meeting.tencent.com/dm/6UXDMNsHBVQO |
| 微信加群小助手 | pisanix |
| 邮件列表 | https://groups.google.com/g/database-mesh |
| Slack | https://join.slack.com/t/databasemesh/shared_invite/zt-19rhvnxkz-USjZamghd_Q0q~8bAJXA |
| 会议记录 | https://bit.ly/39Fqt3x |