centos7部署etcd集群
本文内容纲要:
- node1 etcd 配置- node2 etcd 配置
- node3 etcd 配置
- 启动 etcd
实验环境:centos7.4纯净版
192.168.216.130 node1 master
192.168.216.132 node2 slave
192.168.216.134 node3 slave
yum安装etcd
yum install etcd yum list installed |grep -i etcd
node1 etcd 配置
cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bakcd /etc/etcd/
[root@localhost etcd]# egrep ^[A-Z] ./etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/node1.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.216.130:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.216.130:2379,http://127.0.0.1:2379"
ETCD_NAME="node1"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.216.130:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.216.130:2379"
ETCD_INITIAL_CLUSTER="node1=http://192.168.216.130:2380,node2=http://192.168.216.132:2380,node3=http://192.168.216.134:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
node2 etcd 配置
cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bakcd /etc/etcd/
[root@localhost etcd]# egrep ^[A-Z] ./etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/node2.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.216.132:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.216.132:2379,http://127.0.0.1:2379"
ETCD_NAME="node2"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.216.132:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.216.132:2379"
ETCD_INITIAL_CLUSTER="node1=http://192.168.216.130:2380,node2=http://192.168.216.132:2380,node3=http://192.168.216.134:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
node3 etcd 配置
cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bakcd /etc/etcd/
[root@localhost etcd]# egrep ^[A-Z] ./etcd.conf
ETCD_DATA_DIR="/var/lib/etcd/node3.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.216.134:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.216.134:2379,http://127.0.0.1:2379"
ETCD_NAME="node3"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.216.134:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.216.134:2379"
ETCD_INITIAL_CLUSTER="node1=http://192.168.216.130:2380,node2=http://192.168.216.132:2380,node3=http://192.168.216.134:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
修改 etcd.service
[root@localhost etcd]# cat /usr/lib/systemd/system/etcd.service[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-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\" \
--initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" \
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\" \
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" \
--initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\" \
--initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
Restart=on-failure
LimitNOFILE=65536
以上操作在 node1、node2、node3 节点上都需要操作,需要修改对应的ip
启动 etcd
依次启动 node1、node2、node3 节点的 etcd
systemctl start etcd.servicesystemctl status etcd.service
systemctl enable etcd.service
验证 etcd
etcdctl cluster-health
etcdctl member list
各个节点配置crontab 定时同步时间,否则可能会出现node1 etcd[1657]: the clock difference against peer f63afbe816fb463d is too hig问题
yum install ntpcrontab -e
0 1 * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn >> /var/log/ntpdate.log 2>&1 &
本文内容总结:node1 etcd 配置,node2 etcd 配置,node3 etcd 配置,启动 etcd,
原文链接:https://www.cnblogs.com/caidingyu/p/11408389.html
以上是 centos7部署etcd集群 的全部内容, 来源链接: utcz.com/z/297022.html