centos 关闭swap

错误 >> failed to run Kubelet: Running with swap on is not supported, please disable swap! or set –fail-swap-on flag to false >>> 解决方法如下

检查swap是否开启

cat /proc/swaps
#关闭Swap,机器重启后不生效
swapoff -a
#修改/etc/fstab永久关闭Swap
cp -p /etc/fstab /etc/fstab.bak$(date '+%Y%m%d%H%M%S')
#Redhat
sed -i "s/\/dev\/mapper\/rhel-swap/#\/dev\/mapper\/rhel-swap/g" /etc/fstab
#CentOS
sed -i "s/\/dev\/mapper\/centos-swap/#\/dev\/mapper\/centos-swap/g" /etc/fstab
#修改后重新挂载全部挂载点
mount -a
#查看Swap
free -m
cat /proc/swaps

在Kubernetes集群master和nodes上禁用Swap后,运行下面命令重启Kubelet:

systemctl daemon-reload 
systemctl restart kubelet
分享你的喜爱