etcd伪集群搭建

  • etcd版本: v3.4.14
  • 部署平台: 单台云服务器(ipaddr使用内网ip)
  • copy时需要将集群启动cli中的一下参数做出修改:
    1.data-dir
    2.listen-peer-urls
    3.listen-client-urls
    4.initial-advertise-peer-urls
    5.advertise-client-urls

1.pkg以及目录

mkdir /data/etcd_clustr/
cd /data/etcd_clustr/
wget https://github.com/etcd-io/etcd/releases/download/v3.4.14/etcd-v3.4.14-linux-amd64.tar.gz

tar xf etcd-v3.4.14-linux-amd64.tar.gz -C

mv etcd-v3.4.14-linux-amd64 etcd1

cp -r /data/etcd_cluster/etcd1 /data/etcd_cluster/etcd2
cp -r /data/etcd_cluster/etcd1 /data/etcd_cluster/etcd3

集群启动

1.etcd1

  • 以下为一条命令
nohup cd /data/etcd_cluster/etcd1 \
&& ./etcd --name="etcd-1" \
--data-dir="/data/etcd_cluster/etcd1/default.etcd" \
--listen-peer-urls="http://192.168.0.51:3002" \
--listen-client-urls="http://192.168.0.51:3001" \
--initial-advertise-peer-urls="http://192.168.0.51:3002" \
--advertise-client-urls="http://192.168.0.51:3001" \
--initial-cluster="etcd-1=http://192.168.0.51:3002,etcd-2=http://192.168.0.51:3004,etcd-3=http://192.168.0.51:3006" \
>/dev/null 2>&1 &

2.etcd2

nohup cd /data/etcd_cluster/etcd2 \
&& ./etcd --name="etcd-2" \
--data-dir="/data/etcd_cluster/etcd2/default.etcd" \
--listen-peer-urls="http://192.168.0.51:3004" \
--listen-client-urls="http://192.168.0.51:3003" \
--initial-advertise-peer-urls="http://192.168.0.51:3004" \
--advertise-client-urls="http://192.168.0.51:3003" \
--initial-cluster="etcd-1=http://192.168.0.51:3002,etcd-2=http://192.168.0.51:3004,etcd-3=http://192.168.0.51:3006" \
>/dev/null 2>&1 &

3.etcd3

nohup cd /data/etcd_cluster/etcd3 \
&& ./etcd --name="etcd-3" \
--data-dir="/data/etcd_cluster/etcd3/default.etcd" \
--listen-peer-urls="http://192.168.0.51:3006" \
--listen-client-urls="http://192.168.0.51:3005" \
--initial-advertise-peer-urls="http://192.168.0.51:3006" \
--advertise-client-urls="http://192.168.0.51:3005" \
--initial-cluster="etcd-1=http://192.168.0.51:3002,etcd-2=http://192.168.0.51:3004,etcd-3=http://192.168.0.51:3006" \
>/dev/null 2>&1 &

集群状态

  • ENV
echo "export EP=--endpoints=192.168.0.51:3001,192.168.0.51:3003,192.168.0.51:3005" >> /etc/profile && source /etc/profile
  • status
# status:
etcdctl --write-out=table $EP endpoint status

# health
etcdctl --write-out=table $EP endpoint health
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值