首页 > 代码库 > 00-ETCD安装配置

00-ETCD安装配置

1. 环境信息:CentOS 7.3 最小化安装

node50 192.168.1.50;node51 192.168.1.51;node52 192.168.1.52

2. yum安装etcd:

[root@node52 ~]# yum install etcd

技术分享

3. 编辑etcd配置文件:

[root@node52 ~]# vi /etc/etcd/etcd.conf

4. 各节点配置如下:

node51:

ETCD_NAME=etcd01
ETCD_DATA_DIR="/var/lib/etcd/etcd01.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.1.51:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.1.51:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.1.51:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.51:2379"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster1"
ETCD_INITIAL_CLUSTER="etcd01=http://192.168.1.51:2380,etcd02=http://192.168.1.50:2380,etcd03=http://192.168.1.52:2380"

node50:

ETCD_NAME=etcd02
ETCD_DATA_DIR="/var/lib/etcd/etcd02.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.1.50:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.1.50:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.1.50:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.50:2379"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster1"
ETCD_INITIAL_CLUSTER="etcd01=http://192.168.1.51:2380,etcd02=http://192.168.1.50:2380,etcd03=http://192.168.1.52:2380"

node52:

ETCD_NAME=etcd03
ETCD_DATA_DIR="/var/lib/etcd/etcd03.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.1.52:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.1.52:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.1.52:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.52:2379"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster1"
ETCD_INITIAL_CLUSTER="etcd01=http://192.168.1.51:2380,etcd02=http://192.168.1.50:2380,etcd03=http://192.168.1.52:2380"

5. 分别在三个节点更新配置,设置开机自启动,启动etcd服务:

[root@node51 ~]# systemctl daemon-reload

[root@node51 ~]# systemctl start etcd

[root@node51 ~]# systemctl enable etcd

6. 验证:

[root@node51 ~]# etcd

技术分享

[root@node51 ~]# etcdctl member list

技术分享

 

00-ETCD安装配置