从配置文件参数了解ETCD的一些特性
如下:
name: "etcdnode1" # 节点名称,需要自定义 data-dir: "/etcd-data/data" # 数据存储目录,可以看出etcd是用反斜杠类似文件目录的形式来分级并存储数据的 wal-dir: "/etcd-data/wal" # 预写式日志存储目录,这是设置WAL日志存储地址,不需要关注 listen-peer-urls: "http://0.0.0.0:12380" # 集群成员之间通讯使用的URL(集群服务节点与服务节点之间通讯) listen-client-urls: "http://0.0.0.0:12379" # 集群提供给外部客户端访问的URL,即外部客户端必须通过指定的IP加端口访问etcd (客户端与服务节点之间通讯) initial-advertise-peer-urls: "http://192.168.239.000:12380" #集群推荐配置地址 initial-cluster:"etcdnode0=http://192.168.239.000:2380,etcdnode1=http://192.168.239.000:12380,etcdnode2=http://192.168.239.000:22380" # 集群初始成员配置,是etcd静态部署的核心初始化配置,它说明了当前集群由哪些URLs组成,此处default为节点名称(以节点名称=节点地址拼接而成,通过这个参数可以找到集群所有节点) initial-cluster-state: "new" # 初始化集群状态(new 或 existing) initial-cluster-token: "etcd-cluster" # 引导期间etcd集群的初始集群令牌,防止不同集群之间产生交互,作为某一个集群的唯一名字标签 advertise-client-urls: "http://192.168.239.000:12379" # 向客户端发布的推荐服务端点 log-level: "warn" # 配置日志级别,仅支持 debug, info, warn, error, panic, or fatal
集群配置文件示例
etcd1: etcd --name ares1 --listen-client-urls http://localhost:12379 --advertise-client-urls http://localhost:12379 --listen-peer-urls http://localhost:12380 --initial-advertise-peer-urls http://localhost:12380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'ares1=http://localhost:12380,ares2=http://localhost:22380,ares3=http://localhost:32380' --initial-cluster-state new etcd2: etcd --name ares2 --listen-client-urls http://localhost:22379 --advertise-client-urls http://localhost:22379 --listen-peer-urls http://localhost:22380 --initial-advertise-peer-urls http://localhost:22380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'ares1=http://localhost:12380,ares2=http://localhost:22380,ares3=http://localhost:32380' --initial-cluster-state new etcd3: etcd --name ares3 --listen-client-urls http://localhost:32379 --advertise-client-urls http://localhost:32379 --listen-peer-urls http://localhost:32380 --initial-advertise-peer-urls http://localhost:32380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'ares1=http://localhost:12380,ares2=http://localhost:22380,ares3=http://localhost:32380' --initial-cluster-state new