k8s启动异常running with swap on is not supported. Please disable swap

异常信息

W0221 11:53:36.804893    6324 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
[init] Using Kubernetes version: v1.18.0
[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR Swap]: running with swap on is not supported. Please disable swap
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

分析原因

  • 不支持在swap分区,请禁用swap分区

解决方法

  • 永久关闭swap分区
cp -a /etc/fstab /etc/fstab.bak
sed -ri 's/.*swap.*/#&/' /etc/fstab
  • 等价于,在包含swap的字符的首字母加入注释#
vi /etc/fstab

#/dev/mapper/centos-swap swap                    swap    defaults        0 0
Logo

开源、云原生的融合云平台

更多推荐