【ETCD】【实操篇(三)】【ETCDCTL】如何向集群中写入数据

在分布式系统中,etcd 是一个高可用的键值存储,用于存储和共享配置信息、服务发现、协调等。向 etcd 写入数据可以通过多种方式进行,常见的方式是使用 etcd 提供的 HTTP API 或者通过客户端库来进行操作。

一、使用EtcdCtl工具来写入数据

1.1、设置环境变量(可选)
export ETCDCTL_API=3
export ETCDCTL_ENDPOINTS=http://localhost:2379
1.2、使用etcdctl put写入数据
etcdctl put <key> <value>
etcdctl put /config/db/host "192.168.1.100"
1.3、通过etcdctl put -h来查看相关帮助信息
etcdctl put -h
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>.

以下是 etcdctl put -h 命令帮助信息的中文翻译::

---

### 名称:
`put` - 将给定的键值对写入存储中

### 用法:
​```bash
etcdctl put [选项] <key> <value> (<value> 也可以通过标准输入给出) [标志]
​```

### 描述:
将给定的键值对写入存储中。

- 当 `<value>` 以 `-` 开
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值