docker安装快速安装etcd集群

1 运行环境

目标节点为位于同一局域网内的3台安装了ubuntu server 18.04 x86_64的服务器,且已安装好docker组件。三台机器的机器名与IP对应关系如下表所示。

序号节点名IP地址
1node0172.24.152.17
2node1172.24.149.46
3node2172.24.155.15

2 安装集群

2.1 拉取etcd镜像

访问etcd发行页找到docker安装方式,使用备用register拉取etcd docker镜像

docker pull quay.io/coreos/etcd:v3.4.14

2.2 启动node0

sudo su -

mkdir -p /tmp/etcd-data.tmp
chown -R 700 /tmp/etcd-data.tmp

docker run \
  -p 2379:2379 \
  -p 2380:2380 \
  --mount type=bind,source=/tmp/etcd-data.tmp,destination=/etcd-data \
  --name etcd_node0 \
  quay.io/coreos/etcd:v3.4.14 \
  /usr/local/bin/etcd \
  --name etcd_node0 \
  --data-dir /etcd-data \
  --listen-client-urls http://0.0.0.0:2379 \
  --advertise-client-urls http://172.24.152.17:2379 \
  --listen-peer-urls http://0.0.0.0:2380 \
  --initial-advertise-peer-urls http://172.24.152.17:2380 \
  --initial-cluster-token etcd-cluster-k8s \
  --initial-cluster-state new \
  --initial-cluster etcd_node0=http://172.24.152.17:2380,etcd_node1=http://172.24.149.46:2380,etcd_node2=http://172.24.155.15:2380 \
  --log-level info \
  --logger zap \
  --log-outputs stderr

2.3 启动node1

sudo su -

mkdir -p /tmp/etcd-data.tmp
chown -R 700 /tmp/etcd-data.tmp

docker run \
  -p 2379:2379 \
  -p 2380:2380 \
  --mount type=bind,source=/tmp/etcd-data.tmp,destination=/etcd-data \
  --name etcd_node1 \
  quay.io/coreos/etcd:v3.4.14 \
  /usr/local/bin/etcd \
  --name etcd_node1 \
  --data-dir /etcd-data \
  --listen-client-urls http://0.0.0.0:2379 \
  --advertise-client-urls http://172.24.149.46:2379 \
  --listen-peer-urls http://0.0.0.0:2380 \
  --initial-advertise-peer-urls http://172.24.149.46:2380 \
  --initial-cluster-token etcd-cluster-k8s \
  --initial-cluster-state new \
  --initial-cluster etcd_node0=http://172.24.152.17:2380,etcd_node1=http://172.24.149.46:2380,etcd_node2=http://172.24.155.15:2380 \
  --log-level info \
  --logger zap \
  --log-outputs stderr

2.4 启动node2

sudo su -

mkdir -p /tmp/etcd-data.tmp
chown -R 700 /tmp/etcd-data.tmp

docker run \
  -p 2379:2379 \
  -p 2380:2380 \
  --mount type=bind,source=/tmp/etcd-data.tmp,destination=/etcd-data \
  --name etcd_node2 \
  quay.io/coreos/etcd:v3.4.14 \
  /usr/local/bin/etcd \
  --name etcd_node2 \
  --data-dir /etcd-data \
  --listen-client-urls http://0.0.0.0:2379 \
  --advertise-client-urls http://172.24.155.15:2379 \
  --listen-peer-urls http://0.0.0.0:2380 \
  --initial-advertise-peer-urls http://172.24.155.15:2380 \
  --initial-cluster-token etcd-cluster-k8s \
  --initial-cluster-state new \
  --initial-cluster etcd_node0=http://172.24.152.17:2380,etcd_node1=http://172.24.149.46:2380,etcd_node2=http://172.24.155.15:2380 \
  --log-level info \
  --logger zap \
  --log-outputs stderr

参考

  • https://github.com/etcd-io/etcd/releases
  • https://blog.csdn.net/feinifi/article/details/105511075
  • https://my.oschina.net/u/4344316/blog/3361000
  • https://blog.51cto.com/1666898/2156165
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值