ETCD(二)配置文件说明

从配置文件参数了解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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,下面是在 CentOS 中部署 etcd 集群的步骤: 1. 下载 etcd 安装包 可以从 etcd 官网下载最新版的 etcd 安装包,下载地址为:https://github.com/etcd-io/etcd/releases 2. 解压安装包 将下载的 etcd 安装包解压到指定目录,比如 /usr/local/etcd ``` tar -zxvf etcd-v3.4.13-linux-amd64.tar.gz -C /usr/local/etcd --strip-components=1 ``` 3. 创建 etcd 配置文件 在每个节点上创建 etcd 配置文件,比如 /etc/etcd.conf,配置内容如下: ``` name=node1 # 节点名称,每个节点名称不同 data-dir=/var/lib/etcd # 数据存储目录 initial-cluster=node1=http://192.168.1.1:2380,node2=http://192.168.1.2:2380,node3=http://192.168.1.3:2380 # 集群中所有节点的地址和端口号 initial-advertise-peer-urls=http://192.168.1.1:2380 # 当前节点的地址和端口号 listen-peer-urls=http://192.168.1.1:2380 # 监听地址和端口号 listen-client-urls=http://192.168.1.1:2379,http://127.0.0.1:2379 # 监听客户端连接的地址和端口号,可以指定多个 advertise-client-urls=http://192.168.1.1:2379 # 当前节点对外提供服务的地址和端口号 initial-cluster-state=new # 集群状态,new 表示新建集群 ``` 其中,initial-cluster 中的节点名称和地址需要根据实际情况修改。 4. 启动 etcd 集群 在每个节点上启动 etcd 服务: ``` /usr/local/etcd/etcd --config-file /etc/etcd.conf ``` 5. 验证 etcd 集群 使用 etcdctl 工具验证 etcd 集群是否正常运行: ``` export ETCDCTL_API=3 etcdctl --endpoints=http://192.168.1.1:2379,http://192.168.1.2:2379,http://192.168.1.3:2379 member list ``` 如果返回了所有节点的信息,则说明 etcd 集群已经成功启动。 以上是在 CentOS 中部署 etcd 集群的步骤,希望能对你有所帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Aries_Ro

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

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

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

打赏作者

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

抵扣说明:

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

余额充值