etcd經常使用命令-增刪改查

增刪改查key-values

插入數據測試

# 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

查詢數據

按key值查詢

# etcdctl get name1
name1
james

不顯示key只限制values測試

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

按key前綴查找

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

按key的字節排序的前綴查找>=

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

按key的字節排序區間查找<= value <

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

查找全部key

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

刪除數據

刪除key name11spa

# etcdctl del name11

刪除key name12時並返回被刪除的鍵值對code

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

刪除指定字節排序起始值後的keyblog

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

刪除指定前綴的key排序

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

刪除全部數據get

# etcdctl del --prefix ""
9

 更新數據

直接用put便可class

# etcdctl get --prefix ""
avg_age
25
# etcdctl put avg_age 30
OK
# etcdctl get --prefix ""
avg_age
30
相關文章
相關標籤/搜索