etcd的基本使用
etcdctl
- 
etcdctl是一个命令行客户端,它能提供一些简洁的命令,供用户直接跟etcd服务打交道,而无需基于 HTTP API方式。可以方便我们在对服务进行测试或者手动修改数据库内容。这些操作跟HTTP API基本上是对应的。
 - 
etcd项目二进制发行包中已经包含了etcdctl工具,etcdctl支持的命令大体上分为数据库操作和非数据库操作两类。
 
/ # etcd --version
etcd Version: 3.3.8
Git SHA: 33245c6b5
Go Version: go1.9.7
Go OS/Arch: linux/amd64
/ # etcdctl --help
NAME:
        etcdctl - A simple command line client for etcd3.
USAGE:
        etcdctl
VERSION:
        3.2.10
API VERSION:
        3.2
COMMANDS:
        get                     Gets the key or a range of keys
                                #获取键或键的范围
        put                     Puts the given key into the store
                                ##将给定的键放入存储
        del                     Removes the specified key or range of keys [key, range_end)
                                ##删除指定的键或键范围[key, range_end)
        txn                     Txn processes all the requests in one transaction
                                ## txn在一个事务中处理所有请求
        compaction              Compacts the event history in etcd
                                ## 将etcd中的事件历史记录压缩
        alarm disarm            Disarms all alarms
                                ##解除所有警报
        alarm list              Lists all alarms
                                ##告警列表列出所有告警信息
        defrag                  Defragments the storage of the etcd members with given endpoints
                                ##整理碎片整理具有给定端点的etcd成员的存储碎片
        endpoint health         Checks the healthiness of endpoints specified in `--endpoints` flag
                                ##端点运行状况检查“--endpoints”标志中指定的端点的运行状况
        endpoint status         Prints out the status of endpoints specified in `--endpoints` flag
                                ##端点状态打印'——endpoints '标志中指定的端点状态
        watch                   Watches events stream on keys or prefixes
                                ##监视键或前缀上的事件流
        version                 Prints the version of etcdctl
                                ##version打印etcdctl的版本
        lease grant             Creates leases
                                ## 批地租约创建租约
        lease revoke            Revokes leases
                                ##lease revoke撤消租赁
        lease timetolive        Get lease information
                                ## lease timetolive获取租赁信息
        lease keep-alive        Keeps leases alive (renew)
                                ##lease keep-alive使租约保持有效(更新)
        member add              Adds a member into the cluster
                                ##成员添加向集群中添加一个成员
        member remove           Removes a member from the cluster
                                ##成员移除从集群中移除一个成员
        member update           Updates a member in the cluster
                                ##成员更新更新集群中的成员
        member list             Lists all members in the cluster
                                ##列出集群中的所有成员
        snapshot save           Stores an etcd node backend snapshot to a given file
                                ##将etcd节点后端快照存储到给定文件
        snapshot restore        Restores an etcd member snapshot to an etcd directory
                                ##将etcd成员快照恢复到etcd目录
        snapshot status         Gets backend snapshot status of a given file
                                ##获取给定文件的后端快照状态
        make-mirror             Makes a mirror at the destination etcd cluster
                                ##在目标etcd集群上做一个镜像
        migrate                 Migrates keys in a v2 store to a mvcc store
                                ##将v2存储中的键迁移到mvcc存储中
        lock                    Acquires a named lock
                                ##获取一个命名的锁
        elect                   Observes and participates in leader election
                                ##观察并参与领导人选举
        auth enable             Enables authentication
                                ##启用认证功能
        auth disable            Disables authentication
                                ##禁用认证
        user add                Adds a new user
                                ##添加一个新用户
        user delete             Deletes a user
                                ##删除用户
        user get                Gets detailed information of a user
                                ##获取用户的详细信息
        user list               Lists all users
                                ##列出所有用户
        user passwd             Changes password of user
                                ##修改用户密码
        user grant-role         Grants a role to a user
                                ##授予用户角色
        user revoke-role        Revokes a role from a user
                                ##取消用户的角色
        role add                Adds a new role
                                ##添加新角色
        role delete             Deletes a role
                                ##删除角色
        role get                Gets detailed information of a role
                                ##t获取角色的详细信息
        role list               Lists all roles
                                ##列出所有角色
        role grant-permission   Grants a key to a role
                                ##向角色授予密钥
        role revoke-permission  Revokes a key from a role
                                ##从角色中取消密钥
        check perf              Check the performance of the etcd cluster
                                ##检查etcd集群的性能
        help                    Help about any command
                                ##帮助关于任何命令的帮助
OPTIONS:
      --cacert=""                               verify certificates of TLS-enabled secure servers using this CA bundle
                                                ##使用这个CA bundle验证启用tls的安全服务器的证书
      --cert=""                                 identify secure client using this TLS certificate file
                                                ##使用此TLS证书文件识别安全客户端
      --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
                                                ##客户端连接拨号超时时间
      --endpoints=[127.0.0.1:2379]              gRPC endpoints
                                                ##gRPC端点
      --hex[=false]                             print byte strings as hex encoded strings
                                                ##将字节字符串打印为十六进制编码的字符串
      --insecure-skip-tls-verify[=false]        skip server certificate erification
                                                ##跳过服务器证书验证
      --insecure-transport[=true]               disable transport security for client connections
                                                ##禁用客户端连接的传输安全性
      --key=""                                  identify secure client using this TLS key file
                                                ##使用此TLS密钥文件识别安全客户端
      --user=""                                 username[:password] for authentication (prompt if password is not supplied)
                                                ##用户名[:密码]用于认证(提示如果不提供密码)
      -w, --write-out="simple"                  set the output format (fields, json, protobuf, simple, table)
                                                ##设置输出格式(fields, json, protobuf, simple, table)
                
            
        
浙公网安备 33010602011771号