Linux command
etcdctl 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Set a key
etcdctl put [mykey] "[myvalue]"
Get a key
etcdctl get [mykey]
Get all keys with prefix
etcdctl get --prefix [/myapp/]
Delete a key
etcdctl del [mykey]
Watch for changes
etcdctl watch [mykey]
List cluster members
etcdctl member list
Check cluster health
etcdctl endpoint health
说明
etcdctl is the command-line client for etcd, a distributed key-value store used for shared configuration and service discovery. It's a core component of Kubernetes for storing cluster state. etcd provides strong consistency through the Raft consensus algorithm. etcdctl manages keys, watches for changes, and administers the cluster.
参数
- put _key_ _value_
- Set key to value.
- get _key_
- Get key value.
- del _key_
- Delete key.
- watch _key_
- Watch key for changes.
- --prefix
- Apply operation to keys with prefix.
- member list
- List cluster members.
- member add _name_ _urls_
- Add cluster member.
- member remove _id_
- Remove cluster member.
- endpoint health
- Check endpoint health.
- snapshot save _file_
- Save cluster snapshot.
- snapshot restore _file_
- Restore from snapshot.
- --endpoints _urls_
- etcd endpoints.
- --cacert _file_
- CA certificate.
- --cert _file_
- Client certificate.
- --key _file_
- Client key.
FAQ
What is the etcdctl command used for?
etcdctl is the command-line client for etcd, a distributed key-value store used for shared configuration and service discovery. It's a core component of Kubernetes for storing cluster state. etcd provides strong consistency through the Raft consensus algorithm. etcdctl manages keys, watches for changes, and administers the cluster.
How do I run a basic etcdctl example?
Run `etcdctl put [mykey] "[myvalue]"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does put _key_ _value_ do in etcdctl?
Set key to value.