• 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 name11

    # etcdctl del name11

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

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

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

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

    删除指定前缀的key

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

    删除所有数据

    # etcdctl del --prefix ""
    9

     更新数据

    直接用put即可

    # etcdctl get --prefix ""
    avg_age
    25
    # etcdctl put avg_age 30
    OK
    # etcdctl get --prefix ""
    avg_age
    30
  • 相关阅读:
    数组的反转和二维数组
    初识数组
    Python学习笔记-Day8
    Python学习笔记-Day7
    Python学习笔记-Day6
    Python学习笔记-Day5
    Python学习笔记-Day4
    Python学习笔记-Day3
    Python学习笔记-Day2
    Python学习笔记-Day1
  • 原文地址:https://www.cnblogs.com/ilifeilong/p/11606757.html
Copyright © 2020-2023  润新知