etcd键值操作
程序员文章站
2022-03-07 13:29:24
...
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
上一篇: php数字如何转换大写
下一篇: kubernetes 初始化
推荐阅读