1 运行环境
目标节点为位于同一局域网内的3台安装了ubuntu server 18.04 x86_64的服务器,且已安装好docker组件。三台机器的机器名与IP对应关系如下表所示。
序号 | 节点名 | IP地址 |
---|---|---|
1 | node0 | 172.24.152.17 |
2 | node1 | 172.24.149.46 |
3 | node2 | 172.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