etcd 集群安装

关闭防火墙:systemctl stop firewalld.service

禁止防火墙开机启动:systemctl disable firewalld.service

centos同步系统时间
yum install ntpdate -y
ntpdate cn.ntp.org.cn

开机启动时自动同步时间
systemctl start ntpdate
systemctl enable ntpdate

https://github.com/etcd-io/etcd/releases

下载:https://github.com/etcd-io/etcd/releases/download/v3.5.2/etcd-v3.5.2-linux-amd64.tar.gz

解压:tar xfv etcd-v3.5.2-linux-amd64.tar.gz -C /opt/k8s/

进入:cd /opt/k8s/etcd

拷贝:cp etcd etcdctl /usr/bin/ (把etcd 和etcdctl拷贝到/usr/bin/)

配置systemd服务文件:vim /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
# User=etcd
ExecStart=/usr/bin/etcd --config-file=/etc/etcd/etcd.conf.yml
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

配置启动文件:/etc/etcd/etcd.conf.yml

创建数据保存目录:mkdir -p /var/lib/etcd

节点一:配置
name: etcd1
data-dir: /var/lib/etcd
listen-client-urls: http://192.168.202.146:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.202.146:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.202.146:2380
initial-advertise-peer-urls: http://192.168.202.146:2380
initial-cluster: etcd1=http://192.168.202.146:2380,etcd2=http://192.168.202.147:2380,etcd3=http://192.168.202.148:2380
initial-cluster-token: etcd-cluster-token
initial-cluster-state: new
节点二:配置
name: etcd2
data-dir: /var/lib/etcd
listen-client-urls: http://192.168.202.147:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.202.147:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.202.147:2380
initial-advertise-peer-urls: http://192.168.202.147:2380
initial-cluster: etcd1=http://192.168.202.146:2380,etcd2=http://192.168.202.147:2380,etcd3=http://192.168.202.148:2380
initial-cluster-token: etcd-cluster-token
initial-cluster-state: new
节点三:配置
name: etcd3
data-dir: /var/lib/etcd
listen-client-urls: http://192.168.202.148:2379,http://127.0.0.1:2379
advertise-client-urls: http://192.168.202.148:2379,http://127.0.0.1:2379
listen-peer-urls: http://192.168.202.148:2380
initial-advertise-peer-urls: http://192.168.202.148:2380
initial-cluster: etcd1=http://192.168.202.146:2380,etcd2=http://192.168.202.147:2380,etcd3=http://192.168.202.148:2380
initial-cluster-token: etcd-cluster-token
initial-cluster-state: new
data-dir                     指定节点的数据存储目录

listen-peer-urls             监听URL,用于与其他节点通讯

listen-client-urls           对外提供服务的地址:比如 http://ip:2379,http://127.0.0.1:2379 ,客户端会连接到这里和 etcd 交互

initial-advertise-peer-urls  该节点member(同伴)监听地址,这个值会告诉集群中其他节点

initial-cluster              集群中所有节点的信息,格式为 node1=http://ip1:2380,node2=http://ip2:2380,… 。注意:这里的 node1 是节点的 --name 指定的名字;后面的 ip1:2380 是 --initial-advertise-peer-urls 指定的值

initial-cluster-state        新建集群的时候,这个值为 new ;假如已经存在的集群,这个值为 existing

initial-cluster-token        创建集群的 token,这个值每个集群保持唯一。这样的话,如果你要重新创建集群,即使配置和之前一样,也会再次生成新的集群和节点 uuid;否则会导致多个集群之间的冲突,造成未知的错误

advertise-client-urls      对外公告的该节点客户端监听地址,这个值会告诉集群中其他节点

systemctl daemon-reload

systemctl start etcd.service

systemctl enable etcd.service

systemctl restart etcd.service

systemctl stop etcd.service

systemctl status etcd.service

查看集群leader的节点:etcdctl -w table endpoint status --cluster

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值