etcd鍵值操作
阿新 • • 發佈:2019-01-04
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