etcd控制台基本操作

增删改查key-values

1、插入数据测试

# etcdctl put name1 james
# etcdctl put name11 alice
# etcdctl put name12 seli
# etcdctl put name2 jetty
# etcdctl put name3 tom
# etcdctl put name4 cris
# etcdctl put avg_age 25

2、查询数据

2.1 按key值查询

# etcdctl get name1
name1
james

2.2 不显示key只限制values

# etcdctl get --print-value-only name1
james

2.3 按key前缀查找

# etcdctl get --prefix name
name1
james
name11
alice
name12
seli
name2
jetty
name3
tom
name4
cris

2.4 按key的字节排序的前缀查找>=

# etcdctl get --from-key name2
name2
jetty
name3
tom
name4
cris

2.5 按key的字节排序区间查找<= value <

# etcdctl get name1 name3
name1
james
name11
alice
name12
seli
name2
jetty

2.6 查找所有key

# etcdctl get --from-key ""
avg_age
25
name1
james
name11
alice
name12
seli
name2
jetty
name3
tom
name4
cris

3.删除数据

3.1 删除key name11

# etcdctl del name11

3.2 删除key name12时并返回被删除的键值对

# etcdctl del --prev-kv name12
1
name12
seli

3.3 删除指定字节排序起始值后的key

# etcdctl del --prev-kv --from-key name3
2
name3
tom
name4
cris

3.4 删除指定前缀的key

# etcdctl del --prev-kv --prefix name
2
name1
james
name2
jetty

3.5 删除所有数据

# etcdctl del --prefix ""
9

4.更新数据

直接用put即可

# etcdctl get --prefix ""
avg_age
25
# etcdctl put avg_age 30
OK
# etcdctl get --prefix ""
avg_age
30

参考: ilifeilong

posted @ 2020-03-19 22:39  Sebuntin  阅读(1374)  评论(0编辑  收藏  举报