在k8s集群中部署mysq集群,问题汇总

[root@kub-k8s-master mysql]# kubectl describe pod mysql-0 -n mysql

问题一:

最后面报错:

Events:

Warning  FailedScheduling  23s (x2 over 23s)  default-scheduler  0/3 nodes are available: 3 pod has unbound immediate PersistentVolumeClaims.

Events:
  Type     Reason            Age                From               Message
  ----     ------            ----               ----               -------
  Warning  FailedScheduling  23s (x2 over 23s)  default-scheduler  0/3 nodes are available: 3 pod has unbound immediate PersistentVolumeClaims.

发现问题:因为pvc一直处于pending状态,没有创建好,所以pod一直处于pending状态

尝试解决问题:

pvc之所以处于pending状态是因为我的k8s.gcr.io/kube-apiserver版本是: v1.20.2。

而如果是 v1.20 版本以上 apiserver 默认是禁止使用 selfLink,所以需要

 vim /etc/kubernetes/manifests/kube-apiserver.yaml  手动配置

- --feature-gates=RemoveSelfLink=false 开启。如下图所示

修改过后,pvc创建成功,如图所示: 

问题二:

pod的状态虽然不是pending,但是发现第一容器mysql-0还是没有创建成功,报错如下:

Output: mount.nfs: mounting 192.168.89.66:/home/data/mysql-data-mysql-0-pvc-73d8ba2c-5c4e-44bf-9550-39e00451c020 failed, reason given by server: No such file or directory

(这个问题两个容器在创建的时候都会遇到,遇到之后操作方法:mkdir  /home/data/文件名,例第一个容器的解决方法如下:)

解决方法:

[root@kub-k8s-master ~]# mkdir /home/data/mysql-data-mysql-0-pvc-73d8ba2c-5c4e-44bf-9550-39e00451c020

[root@kub-k8s-master mysql]# systemctl enable rpcbind && systemctl restart nfs
[root@kub-k8s-master mysql]# 
[root@kub-k8s-master mysql]# systemctl enable nfs-server && systemctl restart rpcbind
[root@kub-k8s-master mysql]# 


  问题三:Warning  FailedMount  15h                 kubelet  Unable to attach or mount volumes: unmounted volumes=[data], unattached volumes=[default-token-dtj2b data conf config-map]: timed out waiting for the condition

这个还没等解决,pod就running了,目前两个容器都running了

问题四:

  Warning  BackOff           5m32s (x9 over 7m)    kubelet            Back-off restarting failed container

解决尝试:

在statfulset.yaml文件中添加

command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]

问题五:找不到hostname

解决尝试:注释掉:hostname

删除之前的pod,重新kubectl apply -f ,结果如下,这个报错也就消失了~

  • 43
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值