以下是 etcd 单节点配置文件的示例:
# This is an example configuration file for etcd v3.4.0
# The data directory for persistent data
data-dir=/var/lib/etcd
# The hostname or IP address to advertise to clients
advertise-client-urls=http://localhost:2379
# The hostname or IP address to advertise to peers
advertise-peer-urls=http://localhost:2380
# The URLs to listen on for client traffic
listen-client-urls=http://localhost:2379
# The URLs to listen on for peer traffic
listen-peer-urls=http://localhost:2380
# Configuration for the embedded HTTP server
#[http]
# Configuration for the embedded gRPC server
#[grpc]
# Initial cluster configuration for bootstrapping
initial-cluster=my-etcd=http://localhost:2380
# The initial token used during the first-time setup of a new etcd cluster
#initial-cluster-token=
# The timeout for detecting when a leader has failed
election-timeout=5000
在实际应用中,需要根据具体环境和需求进行相应的修改。例如,需要根据实际情况修改 data-dir 为 etcd 数据目录的绝对路径、修改 advertise-client-urls 和 listen-client-urls 为 etcd 客户端访问的地址等。




