ETCD的常用命令

雨燕双飞 提交于 2019-12-01 07:47:12

Note that any key that was created using the v2 API will not be able to be queried via the v3 API. A v3 API etcdctl get of a v2 key will exit with 0 and no key data, this is the expected behaviour.

export ETCDCTL_API=3

etcdctl version

1、etcdctl put foo bar

2、etcdctl put foo1 bar1 --lease=1234abcd(创建的租约ID)

3、etcdctl get foo

4、etcdctl get foo --hex

5、$ etcdctl get --prefix foo

     foo bar

     foo1 bar1

     foo2 bar2

     foo3 bar3

6、etcdctl get --prefix --limit=2 foo

7、版本,每次修订KEY,都会全局版本加一

Suppose an etcd cluster already has the following keys:

foo = bar         # revision = 2
foo1 = bar1       # revision = 3
foo = bar_new     # revision = 4
foo1 = bar1_new   # revision = 5

Here are an example to access the past versions of keys:

$ etcdctl get --prefix foo # access the most recent versions of keys
foo
bar_new
foo1
bar1_new

$ etcdctl get --prefix --rev=4 foo # access the versions of keys at revision 4
foo
bar_new
foo1
bar1

$ etcdctl get --prefix --rev=3 foo # access the versions of keys at revision 3
foo
bar
foo1
bar1

$ etcdctl get --prefix --rev=2 foo # access the versions of keys at revision 2
foo
bar

$ etcdctl get --prefix --rev=1 foo # access the versions of keys at revision 18、读取》=KEY

Suppose an etcd cluster already has the following keys:

a = 123
b = 456
z = 789

   Here is the command to read keys which are greater than or equal to the byte value of key b :

$ etcdctl get --from-key b
b
456
z
7899、etcdctl  del foo1 foo9--范围删除10、$ etcdctl del --prev-kv zoo

Here is the command to delete key zoo with the deleted key value pair returned

1   # one key is deleted
zoo # deleted key
val # the value of the deleted key11、$ etcdctl del --from-key b

        Here is the command to delete keys which are greater than or equal to the byte value of key b :

   2 # two keys are deleted
 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!