复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37设置环境变量,版本3,etcdctl的版本2和版本3并不兼容。 export ETCDCTL_API=3 增、查、删 etcdctl put /testdir/testkey "Hello world1" etcdctl get /testdir/testkey etcdctl del /testdir/testkey 可以把key理解成目录 etcdctl put /testdir/testkey1 "Hello world1" etcdctl put /testdir/testkey2 "Hello world2" etcdctl put /testdir/testkey3 "Hello world3" 批量获取目录下的内容 etcdctl get /testdir/ --prefix 只看key etcdctl get /testdir/ --prefix --keys-only 只看value etcdctl get /testdir/ --prefix --print-value-only //watch监听key etcdctl watch /wt/k 开启监听 另一启动一个客户端 etcdctl put /wt/k v1 有反应 etcdctl put /wt/k v2 有反应 etcdctl get /wt/k 没反应 etcdctl del /wt/k 有反应 租约(可以理解成定时器,把key绑定上之后,到时间了key就被删除了) 创建一个 etcdctl lease grant 60 会生成一个id,类似下面 lease 694d6f805c9ed235 granted with TTL(60s) 创建一条数据并绑定到上面租约上 etcdctl put --lease=694d6f805c9ed235 "kkk" "vvv" 马上获取数据 etcdctl get kkk 可以获取到 过一会再执行 etcdctl get kkk 获取的是空数据 可以删除租约(对应的key也会被直接删除) etcdctl lease revoke 694d6f805c9ed235 可以续租(继续续60s) etcdctl lease keep-alive 694d6f805c9ed235
权限控制下一篇单独整理
最后
以上就是友好彩虹最近收集整理的关于etcd常用命令的全部内容,更多相关etcd常用命令内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复