环境:
etcd01:192.168.93.201,centos7.2
etcd02:192.168.93.203,centos7.2
etcd03:192.168.93.203,centos7.2
软件版本:
etcd:2.3.7
以etcd1部署为例,其他2个主机步骤一样:
安装etcd
[root@kube ~]# yum install etcd -y
修改配置文件
vi /etc/etcd//etcd.conf
ETCD_NAME=etcd01
ETCD_DATA_DIR="/var/lib/etcd/etcd01"
ETCD_LISTEN_PEER_URLS="http://192.168.93.201:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.93.201:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.93.201:2380"
ETCD_INITIAL_CLUSTER="etcd01=http://192.168.93.201:2380,etcd02=http://192.168.93.202:2380,etcd03=http://192.168.93.203:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.93.201:2379"
###########################################################################
ETCD_NAME=etcd02
ETCD_DATA_DIR="/var/lib/etcd/etcd01"
ETCD_LISTEN_PEER_URLS="http://192.168.93.202:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.93.202:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.93.202:2380"
ETCD_INITIAL_CLUSTER="etcd01=http://192.168.93.201:2380,etcd02=http://192.168.93.202:2380,etcd03=http://192.168.93.203:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.93.202:2379"
####################################################################
ETCD_NAME=etcd03
ETCD_DATA_DIR="/var/lib/etcd/etcd01"
ETCD_LISTEN_PEER_URLS="http://192.168.93.203:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.93.203:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.93.203:2380"
ETCD_INITIAL_CLUSTER="etcd01=http://192.168.93.201:2380,etcd02=http://192.168.93.202:2380,etcd03=http://192.168.93.203:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.93.203:2379"
##################################################################################
注意别因为复制时少内容导致集群起不来
确认etcd启动文件
less /usr/lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
# set GOMAXPROCS to number of processors
ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\" --data-dir=\"${ETCD_DATA_DIR}\" --listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\""
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
更新启动:
systemctl daemon-reload systemctl start etcd systemctl enable etcd
校验状态:
etcdctl member list etcdctl cluster-health
原文地址:http://mxlmgl.blog.51cto.com/9834691/1883283