etcdctl直接在github下载二进制文件即可,大概17M
etcdctl命令分为数据库操作命令(CURD操作)和非数据库操作命令
一、常用命令
1、数据库操作命令
put/get/del/txn
2、非数据库操作命令
watch
3、命令选项参数
–debug 输出CURL命令,显示执行命令的时候发起的请求
–no-sync 发出请求之前不同步集群信息
–output, -o ‘simple’ 输出内容的格式(simple 为原始信息,json 为进行json格式解码,易读性好一些)
–peers, -C 指定集群中的同伴信息,用逗号隔开(默认为: “127.0.0.1:4001”)
–cert-file HTTPS下客户端使用的SSL证书文件
–key-file HTTPS下客户端使用的SSL密钥文件
–ca-file 服务端使用HTTPS时,使用CA文件进行验证
–help, -h 显示帮助命令信息
–version, -v 打印版本信息
二、常用操作
1、连接服务器
./etcdctl --endpoints=https://10.1.xx.xx:3379, https://10.2.xx.xx:3379 --user=username:passwd --cacert=ca.pem --cert=cert.pem --key=key.pem get /config/ --prefix
2、添加值
./etcdctl put /config/redis ' Server = "10.xx.xx.xxx:6379" Password = "" ' OK
3、获取值
./etcdctl get /config/redis /config/redis Server = "10.xx.xx.xxx:6379" Password = ""
4、删除值
./etcdctl del /config/redis 1
5、可以在命令前面指定版本号
ETCDCTL_API=3 ./etcdctl get /config/redis
三、更多命令参考
1、命令列表
./etcdctl -h COMMANDS: alarm disarm Disarms all alarms alarm list Lists all alarms auth disable Disables authentication auth enable Enables authentication check datascale Check the memory usage of holding data for different workloads on a given server endpoint. check perf Check the performance of the etcd cluster compaction Compacts the event history in etcd defrag Defragments the storage of the etcd members with given endpoints del Removes the specified key or range of keys [key, range_end) elect Observes and participates in leader election endpoint hashkv Prints the KV history hash for each endpoint in --endpoints endpoint health Checks the healthiness of endpoints specified in `--endpoints` flag endpoint status Prints out the status of endpoints specified in `--endpoints` flag get Gets the key or a range of keys help Help about any command lease grant Creates leases lease keep-alive Keeps leases alive (renew) lease list List all active leases lease revoke Revokes leases lease timetolive Get lease information lock Acquires a named lock make-mirror Makes a mirror at the destination etcd cluster member add Adds a member into the cluster member list Lists all members in the cluster member promote Promotes a non-voting member in the cluster member remove Removes a member from the cluster member update Updates a member in the cluster migrate Migrates keys in a v2 store to a mvcc store move-leader Transfers leadership to another etcd cluster member. put Puts the given key into the store role add Adds a new role role delete Deletes a role role get Gets detailed information of a role role grant-permission Grants a key to a role role list Lists all roles role revoke-permission Revokes a key from a role snapshot restore Restores an etcd member snapshot to an etcd directory snapshot save Stores an etcd node backend snapshot to a given file snapshot status Gets backend snapshot status of a given file txn Txn processes all the requests in one transaction user add Adds a new user user delete Deletes a user user get Gets detailed information of a user user grant-role Grants a role to a user user list Lists all users user passwd Changes password of user user revoke-role Revokes a role from a user version Prints the version of etcdctl watch Watches events stream on keys or prefixes OPTIONS: --cacert="" verify certificates of TLS-enabled secure servers using this CA bundle --cert="" identify secure client using this TLS certificate file --command-timeout=5s timeout for short running command (excluding dial timeout) --debug[=false] enable client-side debug logging --dial-timeout=2s dial timeout for client connections -d, --discovery-srv="" domain name to query for SRV records describing cluster endpoints --discovery-srv-name="" service name to query when using DNS discovery --endpoints=[127.0.0.1:2379] gRPC endpoints -h, --help[=false] help for etcdctl --hex[=false] print byte strings as hex encoded strings --insecure-discovery[=true] accept insecure SRV records describing cluster endpoints --insecure-skip-tls-verify[=false] skip server certificate verification (CAUTION: this option should be enabled only for testing purposes) --insecure-transport[=true] disable transport security for client connections --keepalive-time=2s keepalive time for client connections --keepalive-timeout=6s keepalive timeout for client connections --key="" identify secure client using this TLS key file --password="" password for authentication (if this option is used, --user option shouldn't include password) --user="" username[:password] for authentication (prompt if password is not supplied) -w, --write-out="simple" set the output format (fields, json, protobuf, simple, table)