etcd 集群安装

etcd集群搭建
下载二进制软件包

https://github.com/etcd-io/etcd/releases/download/v3.3.10/etcd-v3.3.10-linux-amd64.tar.gz

解压

tar -zxvf etcd-v3.3.10-linux-amd64.tar.gz

将两个执行文件复制到/usr/bin/
etcd和etcdctl文件复制到/usr/bin目录

cd etcd-v3.3.10-linux-amd64
cp etcd etcdctl /usr/bin/

mkdir -p /app/etcd/data
mkdir -p /app/etcd/work

 

配置etcd-1

ETCD_NAME=etcd1
DATA_DIR="app/etcd/data/k8setcd.etcd"
ETCD_LISTEN_CLIENT_URLS="http://192.168.1.251:2379,http://127.0.0.1:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.251:2379,http://127.0.0.1:2379"

ETCD_LISTEN_PEER_URLS="http://192.168.1.251:2380"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.1.251:2380"
ETCD_INITIAL_CLUSTER="etcd1=http://192.168.1.251:2380,etcd2=http://192.168.1.240:2380,etcd3=http://192.168.1.247:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="k8s-etcd-cluster"

etcd --config-file=/etc/etcd/etcd.yml &

 

配置etcd-2
vim /etc/etcd/etcd.yml

name: etcd-2
data-dir: app/etcd/data/k8setcd.etcd
listen-client-urls: http://192.168.1.240:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.1.240:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.1.240:2380
initial-advertise-peer-urls: http://192.168.1.240:2380
initial-cluster: etcd-1=http://192.168.1.251:2380,etcd-2=http://192.168.1.240:2380,etcd-3=http://192.168.1.247:2380
initial-cluster-token: etcd-cluster-token
initial-cluster-state: new
etcd --config-file=/etc/etcd/etcd.yml &

配置etcd-3
vim /etc/etcd/etcd.yml

name: etcd-3
data-dir: app/etcd/data/k8setcd.etcd
listen-client-urls: http://192.168.1.247:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.1.247:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.1.247:2380
initial-advertise-peer-urls: http://192.168.1.247:2380
initial-cluster: etcd-1=http://192.168.1.251:2380,etcd-2=http://192.168.1.240:2380,etcd-3=http://192.168.1.247:2380
initial-cluster-token: etcd-cluster-token
initial-cluster-state: new

etcd --config-file=/etc/etcd/etcd.yml &

 

当所有节点启动成功,etcd才会运行成功,否则是失败的

etcdctl member list

etcdctl cluster-health

没有更多推荐了,返回首页