etcd参数详解
etcd 可以通過命令行標記和環境變量來配置。命令行上設置的選項優先于環境變量。
對于標記--my-flag環境變量的格式是ETCD_MY_FLAG。 適用于所有標記。
正式的ectd端口是 2379 用于客戶端連接,而 2380 用于伙伴通訊。etcd 端口可以設置為接受 TLS 通訊,non-TLS 通訊,或者同時有 TLS 和 non-TLS 通訊。
為了在 linux 啟動試使用自定義設置自動啟動 etcd ,強烈推薦使用systemd單元。
成員標記
—name
成員的可讀性的名字.
默認: “default”
環境變量: ETCD_NAME
這個值被作為這個節點自己的入口中被引用, 在--initial-cluster標記(例如,default=http://localhost:2380)中列出。如果使用static bootstrapping,這需要匹配在標記中使用的key。當使用發現時,每個成員必須有唯一名字。Hostname或machine-id可以是一個好選擇。
—data-dir
到數據目錄的路徑.
默認: “${name}.etcd”
環境變量: ETCD_DATA_DIR
—wal-dir
到專用的 wal 目錄的路徑。如果這個標記被設置,etcd將寫 WAL 文件到 walDIR 而不是 dataDIR。這容許使用專門的硬盤,并幫助避免日志和其他IO操作之間的IO競爭。
默認: “”
環境變量: ETCD_WAL_DIR
—snapshot-count
觸發快照到硬盤的已提交事務的數量.
默認: “10000”
環境變量: ETCD_SNAPSHOT_COUNT
—heartbeat-interval
心跳間隔時間 (單位 毫秒).
默認: “100”
環境變量: ETCD_HEARTBEAT_INTERVAL
—election-timeout
選舉的超時時間(單位 毫秒). 閱讀Documentation/tuning.md得到更多詳情.
默認: “1000”
環境變量: ETCD_ELECTION_TIMEOUT
—listen-peer-urls
用于監聽伙伴通訊的URL列表。這個標記告訴 etcd 在特定的 scheme://IP:port 組合上從它的伙伴接收進來的請求。scheme 可是 http 或者 https。如果IP被指定為0.0.0.0,etcd 在所有接口上監聽給定端口。如果給定IP地址和端口,etcd 將監聽在給定端口和接口上。多個URL可以用來指定多個地址和端口來監聽。etcd將從任何列出來的地址和端口上應答請求。
默認: “http://localhost:2380“
環境變量: ETCD_LISTEN_PEER_URLS
例子: “http://10.0.0.1:2380“
無效例子: “http://example.com:2380“ (對于綁定域名無效)
—listen-client-urls
用于監聽客戶端通訊的URL列表。這個標記告訴 etcd 在特定的 scheme://IP:port 組合上從客戶端接收進來的請求。scheme 可是 http 或者 https。如果IP被指定為 0.0.0.0,etcd 在所有接口上監聽給定端口。如果給定IP地址和端口,etcd 將監聽在給定端口和接口上。多個 URL 可以用來指定多個地址和端口來監聽。etcd 將從任何列出來的地址和端口上應答請求。
默認: “http://localhost:2379“
環境變量: ETCD_LISTEN_CLIENT_URLS
例子: “http://10.0.0.1:2379“
無效例子: “http://example.com:2379“ (對于綁定域名無效)
—max-snapshots
保持的快照文件的最大數量 (0 表示不限制)
默認: 5
環境變量: ETCD_MAX_SNAPSHOTS
對于 windows 用戶默認不限制,而且推薦手工降低到5(或者某些安全偏好)。
—max-wals
保持的 wal 文件的最大數量 (0 表示不限制)
默認: 5
環境變量: ETCD_MAX_WALS
對于windows用戶默認不限制,而且推薦手工降低到5(或者某些安全偏好)。
—cors
逗號分割的 origin 白名單,用于 CORS (cross-origin resource sharing/跨 origin 資源共享).
默認: none
環境變量: ETCD_CORS
集群標記
--initial前綴標記用于啟動(static bootstrap, [discovery-service bootstrap])(clustering.md#discovery) 或runtime reconfiguration) 新成員, 然后當重新啟動一個已有的成員時被忽略。
--discovery前綴標記在使用發現服務需要設置.
—initial-advertise-peer-urls
列出這個成員的伙伴 URL 以便通告給集群的其他成員。這些地方用于在集群中通訊 etcd 數據。至少有一個必須對所有集群成員可以路由的。這些 URL 可以包含域名。
默認: “http://localhost:2380“
環境變量: ETCD_INITIAL_ADVERTISE_PEER_URLS
例子: “http://example.com:2380,http://10.0.0.1:2380“
—initial-cluster
為啟動初始化集群配置。
默認: “default=http://localhost:2380“
環境變量: ETCD_INITIAL_CLUSTER
key是每個提供的節點的--name標記的值. 默認為這個 key 使用default因為這是--name標記的默認值.
—initial-cluster-state
初始化集群狀態(“new” or “existing”)。在初始化靜態(initial static)或者 DNS 啟動 (DNS bootstrapping) 期間為所有成員設置為new。如果這個選項被設置為existing, etcd 將試圖加入已有的集群。如果設置為錯誤的值,etcd 將嘗試啟動但安全失敗。
默認: “new”
環境變量: ETCD_INITIAL_CLUSTER_STATE
—initial-cluster-token
在啟動期間用于 etcd 集群的初始化集群記號(cluster token)。
默認: “etcd-cluster”
環境變量: ETCD_INITIAL_CLUSTER_TOKEN
—advertise-client-urls
列出這個成員的客戶端URL,通告給集群中的其他成員。這些 URL 可以包含域名。
默認: “http://localhost:2379“
環境變量: ETCD_ADVERTISE_CLIENT_URLS
例子: “http://example.com:2379,http://10.0.0.1:2379“
小心,如果來自集群成員的通告 URL 比如http://localhost:2379正在使用 etcd 的 proxy 特性。這將導致循環,因為代理將轉發請求給它自己直到它的資源(內存,文件描述符)最終耗盡。
—discovery
用于啟動集群的發現URL。
默認: none
環境變量: ETCD_DISCOVERY
—discovery-srv
用于啟動集群的 DNS srv 域名。
默認: none
環境變量: ETCD_DISCOVERY_SRV
—discovery-fallback
當發現服務失敗時的期待行為(“exit” 或 “proxy”). “proxy” 僅支持 v2 API.
默認: “proxy”
環境變量: ETCD_DISCOVERY_FALLBACK
—discovery-proxy
用于請求到發現服務的 HTTP 代理。
默認: none
環境變量: ETCD_DISCOVERY_PROXY
—strict-reconfig-check
拒絕將導致法定人數丟失的重配置請求。
默認: false
環境變量: ETCD_STRICT_RECONFIG_CHECK
—auto-compaction-retention
自動壓縮用于 mvcc 鍵值存儲的保持力(注:應該指多版本保存),單位小時。 0 表示關閉自動壓縮。
默認: 0
環境變量: ETCD_AUTO_COMPACTION_RETENTION
注: 對于服務注冊等只保存運行時動態信息的場合,建議開啟。完全沒有理由損失存儲空間和效率來保存之前的版本信息。推薦設置為1,每小時壓縮一次。
Proxy flags
--proxy前綴標記配置 etcd 以代理模式運行. “proxy” 僅支持 v2 API.
—proxy
代理模式設置(“off”, “readonly” or “on”).
默認: “off”
環境變量: ETCD_PROXY
—proxy-failure-wait
在被重新考慮之前,終端將被視為失敗狀態的時間(單位 毫秒),用于被代理的請求。
默認: 5000
環境變量: ETCD_PROXY_FAILURE_WAIT
—proxy-refresh-interval
終端刷新間隔時間(單位 毫秒)
默認: 30000
環境變量: ETCD_PROXY_REFRESH_INTERVAL
—proxy-dial-timeout
請求的撥號(dial)超時時間(單位 毫秒),或者 0 禁用超時。
默認: 1000
環境變量 ETCD_PROXY_DIAL_TIMEOUT
—proxy-write-timeout
寫操作的超時時間(單位 毫秒),或者 0 禁用超時。
默認: 5000
環境變量: ETCD_PROXY_WRITE_TIMEOUT
—proxy-read-timeout
讀操作的超時時間(單位 毫秒),或者 0 禁用超時。
不要修改這個值,如果在使用 watch,因為 watch 將使用 long polling 請求。
默認: 0
環境變量: ETCD_PROXY_READ_TIMEOUT
安全標記
安全標記用于幫助搭建安全 etcd 集群.
—ca-file [棄用]
客戶端服務器 TLS 證書文件的路徑。--ca-file ca.crt可以被--trusted-ca-file ca.crt --client-cert-auth替代,而 etcd 同樣工作。
默認: none
環境變量: ETCD_CA_FILE
—cert-file
客戶端服務器 TLS 證書文件的路徑。
默認: none
環境變量: ETCD_CERT_FILE
—key-file
客戶端服務器 TLS key 文件的路徑。
默認: none
環境變量: ETCD_KEY_FILE
—client-cert-auth
開啟客戶端證書認證。
默認: false
環境變量: ETCD_CLIENT_CERT_AUTH
—trusted-ca-file
客戶端服務器 TLS 信任證書文件的路徑。
默認: none
環境變量: ETCD_TRUSTED_CA_FILE
—auto-tls
使用生成證書的客戶端 TLS。
默認: false
環境變量: ETCD_AUTO_TLS
—peer-ca-file [棄用]
peer server TLS 證書文件的路徑.--peer-ca-file ca.crt可以被--peer-trusted-ca-file ca.crt --peer-client-cert-auth替代,而 etcd 同樣工作.
默認: none
環境變量: ETCD_PEER_CA_FILE
—peer-cert-file
peer server TLS 證書文件的路徑.
默認: none
環境變量: ETCD_PEER_CERT_FILE
—peer-key-file
peer server TLS key 文件的路徑.
默認: none
環境變量: ETCD_PEER_KEY_FILE
—peer-client-cert-auth
開啟 peer client 證書驗證.
默認: false
環境變量: ETCD_PEER_CLIENT_CERT_AUTH
—peer-trusted-ca-file
peer server TLS 信任證書文件路徑.
默認: none
環境變量: ETCD_PEER_TRUSTED_CA_FILE
—peer-auto-tls
使用生成證書的peer TLS。
默認: false
環境變量: ETCD_PEER_AUTO_TLS
日志標記
—debug
設置所有子包的默認日志級別為 DEBUG
默認: false (所有包為 INFO)
環境變量: ETCD_DEBUG
—log-package-levels
設置個人 etcd 子包為指定日志級別。例如etcdserver=WARNING,security=DEBUG
默認: none (所有包為 INFO)
環境變量: ETCD_LOG_PACKAGE_LEVELS
不安全的標記
請謹慎使用不安全標記,因為它將打破一致性協議提供的保證。
例如,它可能驚慌,如果集群中的其他成員還活著。
當使用這些標記時,遵循操作指南。
—force-new-cluster
強制創建新的單一成員的集群。它提交配置修改來強制移除集群中的所有現有成員然后添加自身。當restore a backup時需要設置。
默認: false
環境變量: ETCD_FORCE_NEW_CLUSTER
其他標記
—version
打印版本并退出.
默認: false
—config-file
從文件中裝載服務器配置.
默認: none
分析標記
—enable-pprof
通過 HTTP 服務器開啟運行時分析數據。地址是 client URL + “/debug/pprof/“
默認: false
—metrics
為導出的度量,設置詳情的等級,指定 ‘extensive’ 來包含柱狀圖
默認: basic
[root@hdss7-12 system]# /opt/etcd/etcd --version
etcd Version: 3.4.14
Git SHA: 8a03d2e96
Go Version: go1.12.17
Go OS/Arch: linux/amd64
Usage:
etcd [flags]
Start an etcd server.
etcd --version #查看etcd版本
Show the version of etcd.
etcd -h | --help #獲取幫助信息
Show the help information about etcd.
etcd --config-file #從文件加載配置信息。
Path to the server configuration file. Note that if a configuration file is provided, other command line flags and environment variables will be ignored.
etcd gateway
Run the stateless pass-through etcd TCP connection forwarding proxy.
etcd grpc-proxy
Run the stateless etcd v3 gRPC L7 reverse proxy.
Member:
--name 'default' #成員的可讀性的名字
Human-readable name for this member.
--data-dir '${name}.etcd'
Path to the data directory.
--wal-dir ''
Path to the dedicated wal directory.
--snapshot-count '100000'
Number of committed transactions to trigger a snapshot to disk.
--heartbeat-interval '100'
Time (in milliseconds) of a heartbeat interval.
--election-timeout '1000'
Time (in milliseconds) for an election to timeout. See tuning documentation for details.
--initial-election-tick-advance 'true'
Whether to fast-forward initial election ticks on boot for faster election.
--listen-peer-urls 'http://localhost:2380'
List of URLs to listen on for peer traffic.
--listen-client-urls 'http://localhost:2379'
List of URLs to listen on for client traffic.
--max-snapshots '5'
Maximum number of snapshot files to retain (0 is unlimited).
--max-wals '5'
Maximum number of wal files to retain (0 is unlimited).
--quota-backend-bytes '0'
Raise alarms when backend size exceeds the given quota (0 defaults to low space quota).
--backend-batch-interval ''
BackendBatchInterval is the maximum time before commit the backend transaction.
--backend-batch-limit '0'
BackendBatchLimit is the maximum operations before commit the backend transaction.
--max-txn-ops '128'
Maximum number of operations permitted in a transaction.
--max-request-bytes '1572864'
Maximum client request size in bytes the server will accept.
--grpc-keepalive-min-time '5s'
Minimum duration interval that a client should wait before pinging server.
--grpc-keepalive-interval '2h'
Frequency duration of server-to-client ping to check if a connection is alive (0 to disable).
--grpc-keepalive-timeout '20s'
Additional duration of wait before closing a non-responsive connection (0 to disable).
Clustering:
--initial-advertise-peer-urls 'http://localhost:2380'
List of this member's peer URLs to advertise to the rest of the cluster.
--initial-cluster 'default=http://localhost:2380'
Initial cluster configuration for bootstrapping.
--initial-cluster-state 'new'
Initial cluster state ('new' or 'existing').
--initial-cluster-token 'etcd-cluster'
Initial cluster token for the etcd cluster during bootstrap.
Specifying this can protect you from unintended cross-cluster interaction when running multiple clusters.
--advertise-client-urls 'http://localhost:2379'
List of this member's client URLs to advertise to the public.
The client URLs advertised should be accessible to machines that talk to etcd cluster. etcd client libraries parse these URLs to connect to the cluster.
--discovery ''
Discovery URL used to bootstrap the cluster.
--discovery-fallback 'proxy'
Expected behavior ('exit' or 'proxy') when discovery services fails.
"proxy" supports v2 API only.
--discovery-proxy ''
HTTP proxy to use for traffic to discovery service.
--discovery-srv ''
DNS srv domain used to bootstrap the cluster.
--discovery-srv-name ''
Suffix to the dns srv name queried when bootstrapping.
--strict-reconfig-check 'true'
Reject reconfiguration requests that would cause quorum loss.
--pre-vote 'false'
Enable to run an additional Raft election phase.
--auto-compaction-retention '0'
Auto compaction retention length. 0 means disable auto compaction.
--auto-compaction-mode 'periodic'
Interpret 'auto-compaction-retention' one of: periodic|revision. 'periodic' for duration based retention, defaulting to hours if no time unit is provided (e.g. '5m'). 'revision' for revision number based retention.
--enable-v2 'false'
Accept etcd V2 client requests.
Security:
--cert-file ''
Path to the client server TLS cert file.
--key-file ''
Path to the client server TLS key file.
--client-cert-auth 'false'
Enable client cert authentication.
--client-crl-file ''
Path to the client certificate revocation list file.
--client-cert-allowed-hostname ''
Allowed TLS hostname for client cert authentication.
--trusted-ca-file ''
Path to the client server TLS trusted CA cert file.
--auto-tls 'false'
Client TLS using generated certificates.
--peer-cert-file ''
Path to the peer server TLS cert file.
--peer-key-file ''
Path to the peer server TLS key file.
--peer-client-cert-auth 'false'
Enable peer client cert authentication.
--peer-trusted-ca-file ''
Path to the peer server TLS trusted CA file.
--peer-cert-allowed-cn ''
Required CN for client certs connecting to the peer endpoint.
--peer-cert-allowed-hostname ''
Allowed TLS hostname for inter peer authentication.
--peer-auto-tls 'false'
Peer TLS using self-generated certificates if --peer-key-file and --peer-cert-file are not provided.
--peer-crl-file ''
Path to the peer certificate revocation list file.
--cipher-suites ''
Comma-separated list of supported TLS cipher suites between client/server and peers (empty will be auto-populated by Go).
--cors '*'
Comma-separated whitelist of origins for CORS, or cross-origin resource sharing, (empty or * means allow all).
--host-whitelist '*'
Acceptable hostnames from HTTP client requests, if server is not secure (empty or * means allow all).
Auth:
--auth-token 'simple'
Specify a v3 authentication token type and its options ('simple' or 'jwt').
--bcrypt-cost 10
Specify the cost / strength of the bcrypt algorithm for hashing auth passwords. Valid values are between 4 and 31.
--auth-token-ttl 300
Time (in seconds) of the auth-token-ttl.
Profiling and Monitoring:
--enable-pprof 'false'
Enable runtime profiling data via HTTP server. Address is at client URL + "/debug/pprof/"
--metrics 'basic'
Set level of detail for exported metrics, specify 'extensive' to include histogram metrics.
--listen-metrics-urls ''
List of URLs to listen on for the metrics and health endpoints.
Logging:
--logger 'capnslog'
Specify 'zap' for structured logging or 'capnslog'. [WARN] 'capnslog' will be deprecated in v3.5.
--log-outputs 'default'
Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd, or list of comma separated output targets.
--log-level 'info'
Configures log level. Only supports debug, info, warn, error, panic, or fatal.
v2 Proxy (to be deprecated in v4):
--proxy 'off'
Proxy mode setting ('off', 'readonly' or 'on').
--proxy-failure-wait 5000
Time (in milliseconds) an endpoint will be held in a failed state.
--proxy-refresh-interval 30000
Time (in milliseconds) of the endpoints refresh interval.
--proxy-dial-timeout 1000
Time (in milliseconds) for a dial to timeout.
--proxy-write-timeout 5000
Time (in milliseconds) for a write to timeout.
--proxy-read-timeout 0
Time (in milliseconds) for a read to timeout.
Experimental feature:
--experimental-initial-corrupt-check 'false'
Enable to check data corruption before serving any client/peer traffic.
--experimental-corrupt-check-time '0s'
Duration of time between cluster corruption check passes.
--experimental-enable-v2v3 ''
Serve v2 requests through the v3 backend under a given prefix.
--experimental-backend-bbolt-freelist-type 'array'
ExperimentalBackendFreelistType specifies the type of freelist that boltdb backend uses(array and map are supported types).
--experimental-enable-lease-checkpoint 'false'
ExperimentalEnableLeaseCheckpoint enables primary lessor to persist lease remainingTTL to prevent indefinite auto-renewal of long lived leases.
--experimental-compaction-batch-limit 1000
ExperimentalCompactionBatchLimit sets the maximum revisions deleted in each compaction batch.
--experimental-peer-skip-client-san-verification 'false'
Skip verification of SAN field in client certificate for peer connections.
--experimental-watch-progress-notify-interval '10m'
Duration of periodical watch progress notification.
Unsafe feature:
--force-new-cluster 'false'
Force to create a new one-member cluster.
CAUTIOUS with unsafe flag! It may break the guarantees given by the consensus protocol!
TO BE DEPRECATED:
--debug 'false'
Enable debug-level logging for etcd. [WARN] Will be deprecated in v3.5. Use '--log-level=debug' instead.
--log-package-levels ''
Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG').
參考文檔https://www.bookstack.cn/read/etcd/README.md
總結
- 上一篇: C语言高级编程:如何确定一个变量是有符号
- 下一篇: webpack之polyfill踩坑之路