etcd鍵值操作

etcd 刪除鍵值

1、查詢所有鍵值

curl http://10.0.2.255:9001/v2/keys/services/?recursive=true

2、刪除鍵值

curl http://10.0.22.39:9001/v2/keys/key?recursive=true -XDELETE

如查詢到的key是:/services/clock/0/10611/255:10611
curl http://10.0.22.39:9001/v2/keys/services/clock/0/10611/255:10611/?recursive=true -XDELETE

3、使用etcdctl命令:

  • 使用etcdctlv3的版本時,需設置環境變量ETCDCTL_API=3
查詢版本:etcdctl version
export ETCDCTL_API=3

或者在`/etc/profile`文件中添加環境變量
vi /etc/profile
...
ETCDCTL_API=3
...
source /etc/profile
指定etcd集羣:
HOST_1=10.240.0.17
HOST_2=10.240.0.18
HOST_3=10.240.0.19
ENDPOINTS=$HOST_1:2379,$HOST_2:2379,$HOST_3:2379
etcdctl --endpoints=$ENDPOINTS member list

查詢集羣狀態
etcdctl endpoint status 、etcdctl endpoint health

增:etcdctl --endpoints=$ENDPOINTS put foo "Hello World!"
查:etcdctl --endpoints=$ENDPOINTS get foo
刪:etcdctl --endpoints=$ENDPOINTS del foo


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章