• 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面向对象高级编程
    Python面向对象编程
    Anaconda的安装
    Python模块
    Python函数式编程
    Python高级特性
    hdu 3065 病毒侵袭持续中 ac自动机
    hdu 2896 病毒侵袭 ac自动机
    poj 3667 Hotel 线段树
    hdu 4322 Candy 费用流
  • 原文地址:https://www.cnblogs.com/ilifeilong/p/11606757.html
Copyright © 2020-2023  润新知