etcdctl是一個提供簡潔命令的etcd客戶端,使用etcdctl能夠直接和etcd服務打交道,對etcd中的鍵值對進行增刪改查。linux
下載地址:etcdctl工具git
tar -xzvf etcd-xxx-linux-amd64.tar.gz
cd etcd-xxx-linux-amd64
cp etcdctl /usr/local/bin/github
$ etcdctl -h
NAME:
etcdctl - A simple command line client for etcd.工具WARNING:
Environment variable ETCDCTL_API is not set; defaults to etcdctl v2.
Set environment variable ETCDCTL_API=3 to use v3 API or ETCDCTL_API=2 to use v2 API.測試USAGE:
etcdctl [global options] command [command options] [arguments...]getVERSION:
3.3.10it
使用etcdctl v3版本,須要設置環境變量ETCDCTL_API=3io
使用方法:export ETCDCTL_API=3或在etcdctl命令前加ETCDCTL_API=3table
命令 | 說明 |
---|---|
etcdctl --endpoints=$ENDPOINTS put foo "Hello World" | 將{key:foo, value: Hello World!}的鍵值對寫入etcd |
etcdctl --endpoints=$ENDPOINTS get foo | 查找etcd key爲foo對應的value |
etcdctl --endpoints=$ENDPOINTS delete foo | 刪除key爲foo的鍵值對 |