欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Kubernetes 中配置集群 ETCD 碰到的一些问题的解决!

程序员文章站 2023-12-29 09:53:52
...

前提:
  配置2个节点:
   cat /etc/hosts
   192.168.200.80 vmnote0
   192.168.200.81 vmnote1

(我这里出现问题是在我安装kubernetes过程中,有CSRFF 公私**的加入 )

我碰到的问题

1. etcd 服务一直启动失败(主从2台机子上面都是)

Kubernetes 中配置集群 ETCD 碰到的一些问题的解决!

分析:1. 启动失败是不是因为 etcd.service 文件异常
   2. 是不是因为 /var -data 的历史文件影响了启动
   3. 会不会端口被占用

开始检查问题

1. 检查etcd.service 配置文件(使用这种方式整合的比较紧密)

Kubernetes 中配置集群 ETCD 碰到的一些问题的解决!

一顿修改之后,问题变了(错误太低级,不好意思展示,下面是我的配置文件)

[aaa@qq.com system]# cat /usr/lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
Documentation=https://github.com/coreos

[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
ExecStart=/usr/local/bin/etcd \
  --name vmnode0 \
  --cert-file=/etc/kubernetes/ssl/kubernetes.pem \
  --key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
  --peer-cert-file=/etc/kubernetes/ssl/kubernetes.pem \
  --peer-key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
  --trusted-ca-file=/etc/kubernetes/ssl/ca.pem \
  --peer-trusted-ca-file=/etc/kubernetes/ssl/ca.pem \
  --initial-advertise-peer-urls https://192.168.200.80:2380 \
  --listen-peer-urls https://192.168.200.80:2380 \
  --listen-client-urls https://192.168.200.80:2379,http://127.0.0.1:2379 \
  --advertise-client-urls https://192.168.200.80:2379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster vmnode0=https://192.168.200.80:2380,vmnode1=https://192.168.200.81:2380 \
  --initial-cluster-state new \
  --data-dir=/var/lib/etcd
Restart=on-failure
RestartSec=5
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
[aaa@qq.com system]# cat /usr/lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
Documentation=https://github.com/coreos

[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
ExecStart=/usr/local/bin/etcd \
  --name vmnode1 \
  --cert-file=/etc/kubernetes/ssl/kubernetes.pem \
  --key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
  --peer-cert-file=/etc/kubernetes/ssl/kubernetes.pem \
  --peer-key-file=/etc/kubernetes/ssl/kubernetes-key.pem \
  --trusted-ca-file=/etc/kubernetes/ssl/ca.pem \
  --peer-trusted-ca-file=/etc/kubernetes/ssl/ca.pem \
  --initial-advertise-peer-urls https://192.168.200.81:2380 \
  --listen-peer-urls https://192.168.200.81:2380 \
  --listen-client-urls https://192.168.200.81:2379,http://127.0.0.1:2379 \
  --advertise-client-urls https://192.168.200.81:2379 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-cluster vmnode0=https://192.168.200.80:2380,vmnode1=https://192.168.200.81:2380 \
  --initial-cluster-state new \
  --data-dir=/var/lib/etcd
Restart=on-failure
RestartSec=5
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

2. 还是启动不了,查看日志

journalctl -xe -u etcd   //查看日志细节
netstat -nal       //查看接口

ZERO:

6月 08 03:46:26 vmnode1 etcd[46641]: publish error: etcdserver: request timed out

FIRST:

608 11:09:36 vmnode0 etcd[11820]: rejected connection from "192.168.200.81:48552" (error "remote error: tls: bad certificate", ServerName "")
608 11:09:36 vmnode0 etcd[11820]: rejected connection from "192.168.200.81:48554" (error "remote error: tls: bad certificate", ServerName "")
608 11:09:36 vmnode0 etcd[11820]: request sent was ignored (cluster ID mismatch: peer[39a8adcf41828c16]=bf653702878aa654, local=aff16232db8b0940)
608 11:09:36 vmnode0 etcd[11820]: request sent was ignored (cluster ID mismatch: peer[39a8adcf41828c16]=bf653702878aa654, local=aff16232db8b0940)

SECOND:

6月 08 04:01:46 vmnode1 etcd[46706]: request cluster ID mismatch (got aff16232db8b0940 want bf653702878aa654)
6月 08 04:01:46 vmnode1 etcd[46706]: request cluster ID mismatch (got aff16232db8b0940 want bf653702878aa654)
6月 08 04:01:46 vmnode1 etcd[46706]: request cluster ID mismatch (got aff16232db8b0940 want bf653702878aa654)

先查看防火墙是否开启,firewalld
在查看 data-dir=/var/lib/etcd 的缓存情况,清除一下

我暂时就碰到这几个问题,不要相信自己的眼睛,有些配置可以复制不要手打,错了不好找

相关标签: kubernetes config

上一篇:

下一篇: