etcd集群安装

新买笔记本,重新安装etcd,记录一下吧;

三台系统是centos7.3的虚拟机:ip地址分别是:192.168.23.128-130

介绍一下比较笨拙的方式,适合初学者

安装步骤:

1)yum install -y etcd

2)修改配置文件中的9个参数

node1节点:

[root@bxhvm01 ~]# grep -v "^#" /etc/etcd/etcd.conf 
ETCD_NAME=etcd01
ETCD_DATA_DIR="/var/lib/etcd/etcd01"
ETCD_LISTEN_PEER_URLS="http://192.168.23.128:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.23.128:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.23.128:2380"
ETCD_INITIAL_CLUSTER="etcd01=http://192.168.23.128:2380,etcd02=http://192.168.23.129:2380,etcd03=http://192.168.23.130:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.23.128:2379"

node2节点:

[root@bxhvm02 ~]# grep -v "^#" /etc/etcd/etcd.conf
ETCD_NAME=etcd02
ETCD_DATA_DIR="/var/lib/etcd/etcd02"
ETCD_LISTEN_PEER_URLS="http://192.168.23.129:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.23.129:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.23.129:2380"
ETCD_INITIAL_CLUSTER="etcd01=http://192.168.23.128:2380,etcd02=http://192.168.23.129:2380,etcd03=http://192.168.23.130:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.23.129:2379"
node3节点:

[root@bxhvm03 ~]# grep -v "^#" /etc/etcd/etcd.conf
ETCD_NAME=etcd03
ETCD_DATA_DIR="/var/lib/etcd/etcd03"
ETCD_LISTEN_PEER_URLS="http://192.168.23.130:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.23.130:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.23.130:2380"
ETCD_INITIAL_CLUSTER="etcd01=http://192.168.23.128:2380,etcd02=http://192.168.23.129:2380,etcd03=http://192.168.23.130:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.23.130:2379"

3)配置完成后,编辑文件:vim /usr/lib/systemd/system/etcd.service中execStart部分

ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\" --data-dir=\"${ETCD_DATA_DIR}\"
 --listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\"
 --listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" --initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" 
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\"  --initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\" 
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\"  --initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
4)关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

5)重启etcd

systemctl daemon-reload
systemctl restart etcd

6)确认etcd正常运行

[root@bxhvm01 ~]# etcdctl member list
55f302e63e1512d6: name=etcd03 peerURLs=http://192.168.23.130:2380 clientURLs=http://192.168.23.130:2379 isLeader=true
9d319d1404567e7c: name=etcd01 peerURLs=http://192.168.23.128:2380 clientURLs=http://192.168.23.128:2379 isLeader=false
a29cf32d55bf9ea2: name=etcd02 peerURLs=http://192.168.23.129:2380 clientURLs=http://192.168.23.129:2379 isLeader=false

[root@bxhvm01 ~]# etcdctl cluster-health
member 55f302e63e1512d6 is healthy: got healthy result from http://192.168.23.130:2379
member 9d319d1404567e7c is healthy: got healthy result from http://192.168.23.128:2379
member a29cf32d55bf9ea2 is healthy: got healthy result from http://192.168.23.129:2379




阅读更多
个人分类: docker kubernetes
想对作者说点什么? 我来说一句

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

关闭
关闭
关闭