【ETCD】etcd简单入门之基础操作基于etcdctl进行操作

这里将使用etcdctl命令行工具来进行演示,

1、使用put命令向etcd写入kv对

使用etcdctl put命令来设置键值对。put命令接受两个参数:键和值

使用方法:

NAME:
        put - Puts the given key into the store

USAGE:
        etcdctl put [options] <key> <value> (<value> can also be given from stdin) [flags]

DESCRIPTION:
        Puts the given key into the store.

        When <value> begins with '-', <value> is interpreted as a flag.
        Insert '--' for workaround:

        $ put <key> -- <value>
        $ put -- <key> <value>

        If <value> isn't given as a command line argument and '--ignore-value' is not specified,
        this command tries to read the value from standard input.

        If <lease> isn't given as a command line argument and '--ignore-lease' is not specified,
        this command tries to read the value from standard input.

        For example,
        $ cat file | put <key>
        will store the content of the file to <key>.

OPTIONS:
  -h, --help[=false]            help for put
      --ignore-lease[=false]    updates the key using its current lease
      --ignore-value[=false]    updates the key using its current value
      --lease="0"               lease ID (in hexadecimal) to attach to the key
      --prev-kv[=false]         return the previous key-value pair before modification

示例:

# 写入一个键为foo 值为 hello world数据
[root@localhost etcd]# ./etcdctl put foo "hello world"
OK
# 使用put命令需要注意的事项为,当需要插入以“-”开通的值时,将被解释为一个标志,需要先插入--标志来解决该问题
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值