1. etcdctl 的安装
etcdctl 的文件可以从官方发布页面选择对应的版本下载,例如可以执行以下 install_etcdctl.sh 的脚本,修改其中的版本信息。
#!/bin/bash
ETCD_VER=v3.3.4
ETCD_DIR=etcd-download
DOWNLOAD_URL=https://github.com/coreos/etcd/releases/download
# Download
mkdir ${ETCD_DIR}
cd ${ETCD_DIR}
wget ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar -xzvf etcd-${ETCD_VER}-linux-amd64.tar.gz
# install
cd etcd-${ETCD_VER}-linux-amd64
cp etcdctl /usr/local/bin/
2. etcdctl V3
使用 etcdctl v3 的版本时,需设置环境变量 ETCDCTL_API=3。
export ETCDCTL_API=3
或者在 /etc/profile 文件中添加环境变量
vi /etc/profile
...
ETCDCTL_API=3
...
source /etc/profile
查看当前 etcdctl 的版本信息 etcdctl version。
[root@k8s-dbg-master-1 etcd]# etcdctl version
etcdctl version: 3.3.4
API version: 3.3
更多命令帮助可以查询 etcdctl --help。
[root@k8s-dbg-master-1 etcd]# etcdctl --help
NAME:
etcdctl - A simple command line client for etcd3.
USAGE:
etcdctl
VERSION:
3.3.4
API VERSION:
3.3
COMMANDS:
get Gets the key or a range of keys
put Puts the given key into the store


