#!/bin/sh # 定时整理 etcd 空间防止 etcd 服务挂掉 # 将此脚本加入定时任务(每日1次, 一次一片) # crontab -e # 15 * * * * /bin/sh /home/milvus/resize.sh # 查看 Milvus 及其依賴的狀態(etcd 和 MinIO) # sudo systemctl status milvus # sudo systemctl status milvus-etcd # sudo systemctl status milvus-minio echo "使用API3:" export ETCDCTL_API=3 echo "查看空间占用:" etcdctl endpoint status --write-out table echo "查看告警状态:" etcdctl alarm list echo "获取当前版本:" rev=$(etcdctl --endpoints=http://127.0.0.1:2379 endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9].*') echo "压缩掉所有旧版本:" etcdctl --endpoints=http://127.0.0.1:2379 compact $rev echo "整理多余的空间:" etcdctl --endpoints=http://127.0.0.1:2379 defrag echo "取消告警信息:" etcdctl --endpoints=http://127.0.0.1:2379 alarm disarm echo "再次查看空间占用:" etcdctl endpoint status --write-out table echo "再次查看告警状态:" etcdctl alarm list