• Etcdctl v3.x命令参数


    1、etcdctl具体命令帮助信息

    # etcdctl --help
    NAME:
            etcdctl - A simple command line client for etcd3.
    
    USAGE:
            etcdctl [flags]
    
    VERSION:
            3.4.0
    
    API VERSION:
            3.4
    
    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`标志中指定的端点的状态
        endpoint hashkv     Prints the KV history hash for each endpoint in --endpoints
                            在--endpoints中为每个端点打印KV历史记录哈希
        move-leader     Transfers leadership to another etcd cluster member.
                        将领导转移到另一个etcd集群成员。
        watch           Watches events stream on keys or prefixes
                        在键或前缀上观察事件流
        version         Prints the version of etcdctl
                        输出版本号
        lease grant     Creates leases
                        创造租约
        lease revoke        Revokes leases
                            撤销租约
        lease timetolive    Get lease information
                            获取租赁信息
        lease list      List all active leases
                        列出所有有效租约
        lease keep-alive    Keeps leases alive (renew)
                            让租约保持活力(续订)
        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
                        获取角色的详细信息
        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捆绑包验证启用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
                                        拨打客户端连接超时
      -d, --discovery-srv=""            domain name to query for SRV records describing cluster endpoints
                                        用于查询描述集群端点的SRV记录的域名
          --endpoints=[127.0.0.1:2379]      gRPC endpoints
                                            gRPC端点
          --hex[=false]             print byte strings as hex encoded strings
                                    将字节串打印为十六进制编码字符串
          --insecure-discovery[=true]       accept insecure SRV records describing cluster endpoints
                                            接受描述集群端点的不安全SRV记录
          --insecure-skip-tls-verify[=false]    skip server certificate verification
                                                跳过服务器证书验证
          --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
                                            客户端连接的keepalive超时
          --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)
                                        设置输出格式(字段,json,protobuf,简单,表)

    2、指定etcd集群

    HOST_1=192.168.1.1
    HOST_2=192.168.1.2
    HOST_3=192.168.1.3
    ENDPOINTS=$HOST_1:2379,$HOST_2:2379,$HOST_3:2379
    
    etcdctl --endpoints=$ENDPOINTS member list

    3、指定etcd增减改查

    (1)增加

    etcdctl --endpoints=$ENDPOINTS put foo "Hello World!"

    (2)查询

    etcdctl --endpoints=$ENDPOINTS get hello
    etcdctl --endpoints=$ENDPOINTS --write-out="json" get hello

    基于相同前缀查找

    etcdctl --endpoints=$ENDPOINTS put test01 value1
    etcdctl --endpoints=$ENDPOINTS put test02 value2
    etcdctl --endpoints=$ENDPOINTS put test03 value3
    
    etcdctl --endpoints=$ENDPOINTS get test --prefix

    列出所有的key

    etcdctl --endpoints=$ENDPOINTS get / --prefix --keys-only

    (3)删除

    etcdctl --endpoints=$ENDPOINTS put key myvalue
    etcdctl --endpoints=$ENDPOINTS del key
    
    etcdctl --endpoints=$ENDPOINTS put test01 value1
    etcdctl --endpoints=$ENDPOINTS put test02 value2
    etcdctl --endpoints=$ENDPOINTS del test --prefix

    4、集群状态查询

    集群状态主要是etcdctl endpoint status 和etcdctl endpoint health两条命令

    # etcdctl --cacert=/opt/kubernetes/ssl/ca.pem --cert=/opt/kubernetes/ssl/etcd.pem --key=/opt/kubernetes/ssl/etcd-key.pem --endpoints="https://192.168.56.2:2379,https://192.168.56.3:2379,https://192.168.56.4:2379" endpoint health
    https://192.168.56.4:2379 is healthy: successfully committed proposal: took = 22.495386ms
    https://192.168.56.2:2379 is healthy: successfully committed proposal: took = 26.166914ms
    https://192.168.56.3:2379 is healthy: successfully committed proposal: took = 24.951082ms
    
    # etcdctl --write-out=table --cacert=/opt/kubernetes/ssl/ca.pem --cert=/opt/kubernetes/ssl/etcd.pem --key=/opt/kubernetes/ssl/etcd-key.pem --endpoints="https://192.168.56.2:2379,https://192.168.56.3:2379,https://192.168.56.4:2379" endpoint status
    +---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
    |         ENDPOINT          |        ID        | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
    +---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
    | https://192.168.56.2:2379 | 3ec8d20e7e3a97b3 |   3.4.0 |   20 kB |      true |      false |         3 |         12 |                 12 |        |
    | https://192.168.56.3:2379 | 5df9e4d0fd9f3fab |   3.4.0 |   16 kB |     false |      false |         3 |         12 |                 12 |        |
    | https://192.168.56.4:2379 | 211eb42bd3bd2042 |   3.4.0 |   20 kB |     false |      false |         3 |         12 |                 12 |        |
    +---------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
    
    

    5、集群成员查询

    跟集群成员相关的命令如下:

    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

    例:etcdctl member list列出集群成员的命令。

    # etcdctl --cacert=/opt/kubernetes/ssl/ca.pem --cert=/opt/kubernetes/ssl/etcd.pem --key=/opt/kubernetes/ssl/etcd-key.pem --endpoints=https://192.168.56.2:2379 member list -w table           
    +------------------+---------+--------+---------------------------+---------------------------+------------+
    |        ID        | STATUS  |  NAME  |        PEER ADDRS         |       CLIENT ADDRS        | IS LEARNER |
    +------------------+---------+--------+---------------------------+---------------------------+------------+
    | 211eb42bd3bd2042 | started | etcd03 | https://192.168.56.4:2380 | https://192.168.56.4:2379 |      false |
    | 3ec8d20e7e3a97b3 | started | etcd01 | https://192.168.56.2:2380 | https://192.168.56.2:2379 |      false |
    | 5df9e4d0fd9f3fab | started | etcd02 | https://192.168.56.3:2380 | https://192.168.56.3:2379 |      false |
    +------------------+---------+--------+---------------------------+---------------------------+------------+
    一入运维深似海,从此不见彼岸花
  • 相关阅读:
    LVM磁盘逻辑卷扩容
    confluence 搭建总结
    GTX1050ti安装tensorflow2.0(gpu)
    sublime text 配置 markdown和预览
    Python 程序打包成 exe 可执行文件
    devc++ 配置openCV
    Ubuntu安装sublime text3
    sublime text 配置Miniconda编译环境
    sublime text 配置devc++ 编译环境
    2013-03-27 problem2 A Famous ICPC Team
  • 原文地址:https://www.cnblogs.com/cn-jasonho/p/13285584.html
Copyright © 2020-2023  润新知