搭建etcd集群

一、环境准备

节点IP
node110.1.43.1
node210.1.43.2
node310.1.43.3

所需安装包:etcd-v3.4.15-linux-amd64.tar.gz

二、部署步骤

1、下载安装包
etcd-v3.4.15-linux-amd64.tar.gz

2、解压

# tar -zxvf etcd-v3.4.15-linux-amd64.tar.gz
# cp -r etcd-v3.4.15-linux-amd64 /data/etcd

3、三个节点创建目录

# mkdir -p /data/etcd/node1(按节点更改)
# mkdir -p /data/etcddata/

4、在每个节点上创建etcd的systemd unit文件/usr/lib/systemd/system/etcd.service

# vim /usr/lib/systemd/system/etcd.service #如果没有system目录则新创建一个
[Unit]
Description=etcd server
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
Type=notify
WorkingDirectory=/data/etcddata/
EnvironmentFile=-/data/etcd/nodefile.yml
ExecStart=/data/etcd/etcd  --config-file=/data/etcd/nodefile.yml

Restart=on-failure
RestartSec=5
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

4、编写nodefile.yml(按节点更改)

name: node1
data-dir: /data/etcd/node1
listen-client-urls: 'http://192.168.120.100:12379'
advertise-client-urls: 'http://192.168.120.100:12379'
listen-peer-urls: 'http://192.168.120.100:12380'
initial-advertise-peer-urls: 'http://192.168.120.100:12380'
initial-cluster: node1=http://192.168.120.100:12380,node2=http://192.168.120.101:12380,node3=http://192.168.120.102:12380
initial-cluster-token: etcd-cluster-1
initial-cluster-state: new

5、开启etcd服务

# systemctl daemon-reload && systemctl enable etcd && systemctl start etcd

6、检查集群情况

# etcdctl --endpoints='10.1.43.1:12379,10.1.43.2:12379,10.1.43.3:12379' endpoint health
10.1.43.2:12379 is healthy: successfully committed proposal: took = 2.645184ms
10.1.43.1:12379 is healthy: successfully committed proposal: took = 1.897015ms
10.1.43.3:12379 is healthy: successfully committed proposal: took = 1.869879ms
# etcdctl --endpoints='10.1.43.1:12379,10.1.43.2:12379,10.1.43.3:12379' -w table endpoint status
+-----------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
|    ENDPOINT     |        ID        | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+-----------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| 10.1.43.1:12379 | 23b295581f086091 |  3.4.15 |  192 kB |      true |      false |         2 |        785 |                785 |        |
| 10.1.43.2:12379 | 72aef3b68b361b6c |  3.4.15 |  192 kB |     false |      false |         2 |        785 |                785 |        |
| 10.1.43.3:12379 | 6781172eef7f4de0 |  3.4.15 |  205 kB |     false |      false |         2 |        785 |                785 |        |
+-----------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
1个leader正常
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值