etcd版本:etcd-v3.3.9-linux-amd64.tar.gz
etcd各版本下载地址:https://github.com/etcd-io/etcd/releases
本次集群中使用3台服务器节点,分别是:
节点1:192.168.108.128
节点2:192.168.108.129
节点3:192.168.108.130
#创建etcd配置文件目录
#mkdir /etc/etcd
#创建etcd配置文件
#vi /etc/etcd/conf.yml
节点1配置文件内容如下:
name: etcd-1
data-dir: /opt/etcd-v3.3.9/data
listen-client-urls: http://192.168.108.128:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.108.128:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.108.128:2380
initial-advertise-peer-urls: http://192.168.108.128:2380
initial-cluster: etcd-1=http://192.168.108.128:2380,etcd-2=http://192.168.108.129:2380,etcd-3=http://192.168.108.130:2380
initial-cluster-token: etcd-cluster-token
initial-cluster-state: new
节点2配置文件内容如下:
name: etcd-2
data-dir: /opt/etcd-v3.3.9/data
listen-client-urls: http://192.168.108.129:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.108.129:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.108.129:2380
initial-advertise-peer-urls: http://192.168.108.129:2380
initial-cluster: etcd-1=http://192.168.108.128:2380,etcd-2=http://192.168.108.129:2380,etcd-3=http://192.168.108.130:2380
initial-cluster-token: etcd-cluster-token
initial-cluster-state: new
节点3配置文件内容如下:
name: etcd-3
data-dir: /opt/etcd-v3.3.9/data
listen-client-urls: http://192.168.108.130:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.108.130:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.108.130:2380
initial-advertise-peer-urls: http://192.168.108.130:2380
initial-cluster: etcd-1=http://192.168.108.128:2380,etcd-2=http://192.168.108.129:2380,etcd-3=http://192.168.108.130:2380
initial-cluster-token: etcd-cluster-token
initial-cluster-state: new
更新etcd系统默认配置
当前使用的是etcd v3版本,系统默认的是v2,通过下面命令修改配置。
# vi /etc/profile
在文件末尾追加:
export ETCDCTL_API=3
让更改生效:
# source /etc/profile
集群启动:
在每台服务器节点上执行命令:
# ./etcd --config-file=/etc/etcd/conf.yml
集群启动成功后,
查看集群成员信息:
# ./etcdctl member list