$ ls
Documentation etcd etcdctl README-etcdctl.md README.md READMEv2-etcdctl.md
如果在测试环境,启动一个单节点的etcd服务,只需要运行etcd命令就行。
$ ./etcd
2017-04-1011:46:44.772465 I | etcdmain: etcd Version:3.1.52017-04-1011:46:44.772512 I | etcdmain:Git SHA:20490ca
2017-04-1011:46:44.772607 I | etcdmain:Go Version: go1.7.52017-04-1011:46:44.772756 I | etcdmain:Go OS/Arch: linux/amd64
2017-04-1011:46:44.772817 I | etcdmain: setting maximum number of CPUs to 2, total number of available CPUsis22017-04-1011:46:44.772851 W | etcdmain: no data-dir provided,usingdefault data-dir ./default.etcd
2017-04-1011:46:44.773298 I | embed: listening for peers on http://localhost:23802017-04-1011:46:44.773583 I | embed: listening for client requests on localhost:23792017-04-1011:46:44.775967 I | etcdserver: name =default2017-04-1011:46:44.775993 I | etcdserver: data dir =default.etcd
2017-04-1011:46:44.776167 I | etcdserver: member dir =default.etcd/member
2017-04-1011:46:44.776253 I | etcdserver: heartbeat =100ms
2017-04-1011:46:44.776264 I | etcdserver: election =1000ms
2017-04-1011:46:44.776270 I | etcdserver: snapshot count =100002017-04-1011:46:44.776285 I | etcdserver: advertise client URLs = http://localhost:23792017-04-1011:46:44.776293 I | etcdserver: initial advertise peer URLs = http://localhost:23802017-04-1011:46:44.776306 I | etcdserver: initial cluster =default=http://localhost:23802017-04-1011:46:44.781171 I | etcdserver: starting member 8e9e05c52164694d in cluster cdf818194e3a8c32
2017-04-1011:46:44.781323 I | raft:8e9e05c52164694d became follower at term 02017-04-1011:46:44.781351 I | raft: newRaft 8e9e05c52164694d [peers:[], term:0, commit:0, applied:0, lastindex:0, lastterm:0]2017-04-1011:46:44.781883 I | raft:8e9e05c52164694d became follower at term 12017-04-1011:46:44.795542 I | etcdserver: starting server...[version:3.1.5, cluster version: to_be_decided]2017-04-1011:46:44.796453 I | etcdserver/membership: added member 8e9e05c52164694d [http://localhost:2380] to cluster cdf818194e3a8c32
2017-04-1011:46:45.083350 I | raft:8e9e05c52164694d is starting a new election at term 12017-04-1011:46:45.083494 I | raft:8e9e05c52164694d became candidate at term 22017-04-1011:46:45.083520 I | raft:8e9e05c52164694d received MsgVoteRespfrom8e9e05c52164694d at term 22017-04-1011:46:45.083598 I | raft:8e9e05c52164694d became leader at term 22017-04-1011:46:45.083654 I | raft: raft.node:8e9e05c52164694d elected leader 8e9e05c52164694d at term 22017-04-1011:46:45.084544 I | etcdserver: published {Name:default ClientURLs:[http://localhost:2379]} to cluster cdf818194e3a8c32
2017-04-1011:46:45.084638 I | etcdserver: setting up the initial cluster version to 3.12017-04-1011:46:45.084857 I | embed: ready to serve client requests
2017-04-1011:46:45.085918 E | etcdmain: forgot to set Type=notify in systemd service file?2017-04-1011:46:45.086668 N | embed: serving insecure client requests on 127.0.0.1:2379,thisis strongly discouraged!2017-04-1011:46:45.087004 N | etcdserver/membership:set the initial cluster version to 3.12017-04-1011:46:45.087195 I | etcdserver/api: enabled capabilities for version 3.1
$ etcd --version
etcd Version:3.1.5
Git SHA:20490ca
Go Version: go1.7.5
Go OS/Arch: linux/amd64
$ etcdctl -h
NAME:
etcdctl - A simple command line client for etcd.
USAGE:
etcdctl [global options] command [command options][arguments...]
VERSION:3.1.5
COMMANDS:
backup backup an etcd directory
cluster-health check the health of the etcd cluster
mk make a new key with a given value
mkdir make a new directory
rm remove a key or a directory
rmdir removes the key if it is an empty directory or a key-value pair
get retrieve the value of a key
ls retrieve a directory
set set the value of a key
setdir create a new directory or update an existing directory TTL
update update an existing key with a given value
updatedir update an existing directory
watch watch a key for changes
exec-watch watch a key for changes and exec an executable
member member add, remove and list subcommands
user user add, grant and revoke subcommands
role role add, grant and revoke subcommands
auth overall auth controls
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:--debug output cURL commands which can be used to reproduce the request
--no-sync don't synchronize cluster information before sending request
--output simple,-o simple output response in the given format (simple, `extended` or `json`)(default:"simple")--discovery-srv value,-D value domain name to query for SRV records describing cluster endpoints
--insecure-discovery accept insecure SRV records describing cluster endpoints
--peers value,-C value DEPRECATED -"--endpoints" should be used instead
--endpoint value DEPRECATED -"--endpoints" should be used instead
--endpoints value a comma-delimited list of machine addresses in the cluster (default:"http://127.0.0.1:2379,http://127.0.0.1:4001")--cert-file value identify HTTPS client usingthis SSL certificate file
--key-file value identify HTTPS client usingthis SSL key file
--ca-file value verify certificates of HTTPS-enabled servers usingthis CA bundle
--username value,-u value provide username[:password]and prompt if password is not supplied.--timeout value connection timeout per request (default:2s)--total-timeout value timeout for the command execution (except watch)(default:5s)--help,-h show help
--version,-v print the version