Etcd命令
docker exec -u root -it etcd容器id sh
export ETCDCTL_API=3
alias myetcd="etcdctl --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key --endpoints https://127.0.0.1:2379"
get
# 查询所有key
myetcd get --prefix --keys-only ""
# 按 key 前缀查询
myetcd get key名称 --prefix
# 按key查询
myetcd get key名称
# 获取key的json详情
myetcd get key名称 -w json
# 获取key的某个版本的值
myetcd get key名称 --rev={reversion}
put
myetcd put {key} {value}
del
# 按key精准删除
myetcd del {key}
# 按key前缀删除
myetcd del {key} --prefix
查看etcd的状态
# 成员查找
myetcd endpoint status -w table
# 健康状态
myetcd endpoint health
压缩etcd空间
# 获取当前版本并压缩所有旧版本
rev=$(myetcd endpoint status --write-out="json" | egrep -o '"revision":[0-9]*' | egrep -o '[0-9].*')
myetcd compact $rev
# 整理多余空间
myetcd defrag
# 查看告警
myetcd alarm list
# 取消告警
myetcd alarm disarm