k8s集群部署-禁用swap分区

说明

swap分区指的是虚拟内存分区,它的作用是物理内存使用完,之后将磁盘空间虚拟成内存来使用

缺点

启用swap设备会对系统的性能产生非常负面的影响,因此kubernetes要求每个节点都要禁用swap设备,但是如果因为某些原因确实不能关闭swap分区,就需要在集群安装过程中通过明确的参数进行配置说明

master 服务器

编辑分区配置文件 /etc/fstab,注释掉swap分区一行
注意: 修改完毕之后需要重启linux服务

vim /etc/fstab

在倒数第1行的前面加 # 号,表示注释:

# /dev/mapper/centos-swap swap

按 esc 键,:wq 保存退出

重启服务器

reboot now

查看是否生效

free -m

看到下面提示说明成功:

              total        used        free      shared  buff/cache   available
Mem:           9983         154        9686           8         142        9592
Swap:             0           0           0

Swap 一行,都是 0

node1 服务器

执行上面操作

重启服务器

reboot now

查看是否生效

free -m

看到下面提示说明成功:

              total        used        free      shared  buff/cache   available
Mem:           9983         154        9686           8         142        9592
Swap:             0           0           0

Swap 一行,都是 0

node2 服务器

执行上面操作

重启服务器

reboot now

查看是否生效

free -m

看到下面提示说明成功:

              total        used        free      shared  buff/cache   available
Mem:           9983         154        9686           8         142        9592
Swap:             0           0           0

Swap 一行,都是 0


原文出处:/show_1IX6JH4UJtan.html