目录
1. 查看swap分区信息
2. 关闭swap分区
1. 查看swap分区信息
通过free -h 命令查看
[root@k8s-master-02 ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 131M 1.4G 8.9M 212M 1.5G
Swap: 2.0G 0B 2.0G
2. 关闭swap分区
2.1 临时关闭( swapoff -a )
[root@k8s-master-02 ~]# swapoff -a && sysctl -w vm.swappiness=0
vm.swappiness = 0
[root@k8s-master-02 ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 130M 1.4G 8.9M 212M 1.5G
Swap: 0B 0B 0B
[root@k8s-master-02 ~]#
2.2 永久关闭
1. swapoff -a临时关闭
2. 修改 /etc/fstab
[root@k8s-master-02 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Mar 16 07:02:59 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=b0ccc2ce-e243-4fba-b70a-f73250c006f0 / xfs defaults 0 0
UUID=9f7a36a9-28dc-48dc-b070-6b229daffab2 /boot xfs defaults 0 0
#UUID=752a1d2f-0a88-4e62-aa4c-49fc3c57a8e9 swap swap defaults 0 0
[root@k8s-master-02 ~]#
3. vim /etc/sysctl.conf # 永久生效
修改 vm.swappiness 的修改为 0
vm.swappiness=0
sysctl -p # 使配置生效,如果不生效,只能重启
[root@k8s-master-02 ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 128M 1.4G 8.8M 245M 1.5G
Swap: 0B 0B 0B