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)