etcd默認的空間配額限制為2G,超出空間配額限制就會影響服務,所以需要定期清理
以下是etcd磁盤清理的步驟:
1. 顯示空間配額: ETCDCTL_API=3 etcdctl --endpoints=$ip:$port --write-out=table endpoint status
2.查看告警: ETCDCTL_API=3 etcdctl --endpoints=$ip:$port alarm list
3.獲取當前etcd數據的修訂版本(revision)
1)rev=$(ETCDCTL_API=3 etcdctl --endpoints=$ip:$port endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9].*')
2)echo $rev
4.整合壓縮舊版本數據 :ETCDCTL_API=3 etcdctl --endpoints=$ip:$port compact $rev
5. 執行碎片整理: ETCDCTL_API=3 etcdctl --endpoints=$ip:$port defrag
6.解除告警 : ETCDCTL_API=3 etcdctl --endpoints=$ip:$port alarm disarm
7.驗證可以添加新數據:ETCDCTL_API=3 etcdctl --endpoints=$ip:$port put newkeytestfornospace 123