influxdb的data节点是AP一致性,可用性优先,然而数据要最终统一。
anti-entropy意为“反熵”,熵简略的了解成shard间的不统一;anit-entropy运行在data节点上,通过比照shard间的不统一,进行shard数据修复,实现数据的最终统一。
anti-entropy的配置
anti-entropy默认是敞开的:
### [anti-entropy]
### Anti Entropy is used to check missing shards on data node.
### If missing shards are found it will copy the shards from other replications.
### Please don't enable anit-entropy if replication is 1.
###
[anti-entropy]
enabled = false
# check-interval = "30s" # The anti entropy service will check the missing shards very check-interval seconds.
当被开启时,node上失落的分片会被主动修复,而内容不统一的分片须要手动(命令行)确认修复。
shard修复策略
失落的分片:
- goroutine定期检查node上短少的分片(元数据中有,然而本地没有shard文件);
- 对短少的每个分片,启动1个goroutine从peer节点copy这个分片;
内容不统一的分片:分片熵的检测和修复流程如下
典型利用场景
Data节点因为磁盘故障等起因不可用,则只需将新的data节点退出集群,新节点上的anti-entropy会主动从其它节点copy分片。
因为硬件降级等起因,替换正在运行的data节点,新节点上的anti-entropy会主动从其它节点copy分片。
anti-entropy与hinted-handoff
anti-entropy和hinted-handoff都用来保障data节点AP一致性,最终达到数据的最终统一。
-
hh不能解决节点更换的场景;
- hh解决的是远端节点临时无响应时,先在本机缓存下来,待远端节点复原时,再将数据发往远端节点;
- anti-entropy能够主动修复整个分片短少的场景,当产生分片内容不统一时,须要手动命令行修复。