02-etcd安装和配置
【摘要】 yum安装:https://centos.pkgs.org/7/centos-extras-x86_64/离线下载:yum install --downloadonly etcd.x86_64下载位置:./var/cache/yum/x86_64/7/extras/packages/etcd-3.3.11-2.el7.centos.x86_64.rpm本地安装:yum install et...
yum安装:
离线下载:
yum install --downloadonly etcd.x86_64
下载位置:
./var/cache/yum/x86_64/7/extras/packages/etcd-3.3.11-2.el7.centos.x86_64.rpm
本地安装:
yum install etcd-3.3.11-2.el7.centos.x86_64.rpm -y
et
# --enable-v2=true
#etcd.conf更改配置文件:
cp /etc/etcd/etcd.conf /etc/etcd/etcd.conf.bak
#2380集群通信
#2379用户访问
修改参数:
#本机ip地址:
ETCD_DATA_DIR
ETCD_LISTEN_CLIENT_URLS
ETCD_INITIAL_ADVERTISE_PEER_URLS
ETCD_ADVERTISE_CLIENT_URLS
#节点名称:
ETCD_NAME
#集群所有ip地址
ETCD_INITIAL_CLUSTER
ETCD_DATA_DIR="/var/lib/etcd/node1.etcd"
#与其他节点通信
ETCD_LISTEN_PEER_URLS="http://192.168.5.201:2380"
#对外提供的地址
ETCD_LISTEN_CLIENT_URLS="http://192.168.5.201:2379,http://127.0.0.1:2379"
ETCD_NAME="node1"
#该节点成员对等URL地址,且会通告群集的其余成员节点。
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.5.201:2380"
#对外公告的该节点客户端监听地址。
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.5.201:2379,http://127.0.0.1:2379"
#集群中所有节点的信息。
ETCD_INITIAL_CLUSTER="node1=http://192.168.5.201:2380,node2=http://192.168.5.202:2380,node3=http://192.168.5.203:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_DATA_DIR="/var/lib/etcd/node2.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.5.202:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.5.202:2379,http://127.0.0.1:2379"
ETCD_NAME="node2"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.5.202:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.5.202:2379,http://127.0.0.1:2379"
ETCD_INITIAL_CLUSTER="node1=http://192.168.5.201:2380,node2=http://192.168.5.202:2380,node3=http://192.168.5.203:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_DATA_DIR="/var/lib/etcd/node3.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.5.203:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.5.203:2379,http://127.0.0.1:2379"
ETCD_NAME="node3"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.5.203:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.5.203:2379,http://127.0.0.1:2379"
ETCD_INITIAL_CLUSTER="node1=http://192.168.5.201:2380,node2=http://192.168.5.202:2380,node3=http://192.168.5.203:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
/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-peer-urls=\"${ETCD_LISTEN_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}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\""
Restart=on-failure
LimitNOFILE=65536
#删除无效的服务!!!
rm -rf /usr/lib/systemd/system/etcd.service
systemctl stop etcd.service
systemctl disable etcd.service
systemctl reset-failed
systemctl |grep etcd
删除:
rm -rf /usr/lib/systemd/system/etcd.service
systemctl stop etcd.service
systemctl disable etcd.service
systemctl reset-failed
systemctl daemon-reload
systemctl |grep etcd
rm -rf /etc/etcd/etcd.conf
systemctl stop etcd.service
rm -rf /var/lib/etcd/*
#启动服务
systemctl daemon-reload
systemctl start etcd.service
systemctl status etcd.service
systemctl enable etcd.service
检查etcd的健康度和成员列表
etcdctl member list
etcdctl cluster-health
etcdctl member list
-bash-4.2# etcdctl cluster-health
member 1b522fbd4f8c6893 is healthy: got healthy result from http://127.0.0.1:2379
member 235dfe2c4007ba42 is healthy: got healthy result from http://127.0.0.1:2379
member 2b2972666144b54d is healthy: got healthy result from http://127.0.0.1:2379
cluster is healthy
-bash-4.2# etcdctl member list
1b522fbd4f8c6893: name=node1 peerURLs=http://192.168.5.201:2380 clientURLs=http://127.0.0.1:2379,http://192.168.5.201:2379 isLeader=true
235dfe2c4007ba42: name=node2 peerURLs=http://192.168.5.202:2380 clientURLs=http://127.0.0.1:2379,http://192.168.5.202:2379 isLeader=false
2b2972666144b54d: name=node3 peerURLs=http://192.168.5.203:2380 clientURLs=http://127.0.0.1:2379,http://192.168.5.203:2379 isLeader=false
-bash-4.2#
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)