ETCD(二)配置文件说明

ETCD是一个分布式键值存储系统,用于共享配置和服务发现。配置文件中,name定义节点名称,data-dir指定数据存储位置,wal-dir是预写式日志的路径。listen-peer-urls和listen-client-urls分别设定集群内部和客户端的通讯接口,initial-cluster定义集群初始成员和地址,initial-cluster-state指明集群是否新创建。每个节点配置需包含其自身的URLs和其他集群成员的信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

从配置文件参数了解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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Aries_Ro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值