ETCD一台机器上起集群(多台机器一个原理)

本文档展示了如何配置和启动一个由三个节点组成的ETCD集群,并提供了检查集群状态的步骤。配置文件包括etcd1.conf、etcd2.conf和etcd3.conf,每个节点的配置包括数据目录、监听地址和初始集群设置。启动命令和检查集群状态的etcdctl命令也在文中给出。

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

昨天本来想部署一台测试的ETCD 但是网上搜了半天也没个资料 大多数据都是复制粘贴的没办法凡事都得靠自己

etcd1.conf

name: etcd1
data-dir: /usr/local/etcd1/data
listen-client-urls: http://127.0.0.1:12379
advertise-client-urls: http://127.0.0.1:12379
listen-peer-urls: http://127.0.0.1:12380
initial-advertise-peer-urls: http://127.0.0.1:12380
initial-cluster: etcd1=http://127.0.0.1:12380,etcd2=http://127.0.0.1:22380,etcd3=http://127.0.0.1:32380
initial-cluster-token: etcd-cluster-1
initial-cluster-state: new

etcd2.conf

name: etcd2
data-dir: /usr/local/etcd2/data
listen-client-urls: http://127.0.0.1:22379
advertise-client-urls: http://127.0.0.1:22379
listen-peer-urls: http://127.0.0.1:22380
initial-advertise-peer-urls: http://127.0.0.1:22380
initial-cluster: etcd1=http://127.0.0.1:12380,etcd2=http://127.0.0.1:22380,etcd3=http://127.0.0.1:32380
initial-cluster-token: etcd-cluster-1
initial-cluster-state: new

etce3.conf

name: etcd3
data-dir: /usr/local/etcd3/data
listen-client-urls: http://127.0.0.1:32379
advertise-client-urls: http://127.0.0.1:32379
listen-peer-urls: http://127.0.0.1:32380
initial-advertise-peer-urls: http://127.0.0.1:32380
initial-cluster: etcd1=http://127.0.0.1:12380,etcd2=http://127.0.0.1:22380,etcd3=http://127.0.0.1:32380
initial-cluster-token: etcd-cluster-1
initial-cluster-state: new

启动

/usr/local/etcd1/etcd/etcd --config-file=/usr/local/etcd1/etcd.conf

/usr/local/etcd2/etcd/etcd --config-file=/usr/local/etcd2/etcd.conf

/usr/local/etcd3/etcd/etcd --config-file=/usr/local/etcd3/etcd.conf

查看etcd 状态

(随便一个客户端都可以)
 /usr/local/etcd1/etcd/etcdctl --endpoints=http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 endpoint status --write-out=table
 
+------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
|        ENDPOINT        |        ID        | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| http://127.0.0.1:12379 | 8211f1d0f64f3269 |   3.5.4 |   20 kB |      true |      false |         8 |         52 |                 52 |        |
| http://127.0.0.1:22379 | 91bc3c398fb3c146 |   3.5.4 |   20 kB |     false |      false |         8 |         52 |                 52 |        |
| http://127.0.0.1:32379 | fd422379fda50e48 |   3.5.4 |   20 kB |     false |      false |         8 |         52 |                 52 |        |
+------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值