[root@slave159 ~]# free -m
total used free shared buffers cached
Mem: 32076 11842 20233 0 8 3582
-/+ buffers/cache: 8251 23825
Swap: 34255 0 34255
total 内存总数 used 已经使用的内存数 free 空闲的内存数 shared 多个进程共享的内存总额
释放前最好sync一下,防止丢数据。
使用方式 : sync
使用说明 : Linux 系统中欲写入硬盘的资料有的时候会了效率起见,
会写到 filesystem buffer 中,这个 buffer 是一块记忆体空间,
如果欲写入硬盘的资料存于此 buffer 中,而系统又突然断电的话,
那么资料就会流失了,sync 指令会将存于 buffer 中的资料强制写入硬盘中。
/proc是一个虚拟文件系统,我们可以通过对它的读写操作作为与kernel实体间进行通信的一种手段。也就是说可以通过修改/proc中的文件,来对当前kernel的行为做出调整。也就是说我们可以通过调整/proc/sys/vm/drop_caches来释放内存。
0 – 不释放
1 – 释放页缓存
2 – 释放dentries和inodes
3 – 释放所有缓存
数字1是用来清空最近放问过的文件页面缓存
数字2是用来清空文件节点缓存和目录项缓存
数字3是用来清空1和2所有内容的缓存。
关于drop_caches的官方说明如下:
Writing to this file causes the kernel to drop clean caches,dentries and inodes from memory, causing that memory to becomefree.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches;
to free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects are not freeable, the user should run sync first.
Linux内核会将它最近访问过的文件页面缓存在内存中一段时间,这个文件缓存被称为pagecache。
Inode是linux/unix操作系统中的一种数据结构,包含了各文件相关的一些重要信息。在创建文件系统时,就会同时创建大量的inode。一般inode表会占用文件系统磁盘空间的1%。
echo 1 > /proc/sys/vm/drop_caches 可以暂时清空cache和buffer
试试Linux清除ARP缓存
一、 arp -n|awk '/^[1-9]/ {print "arp -d "$1}' | sh
清除所有ARP缓存,推荐!
二、for((ip=2;ip<255;ip++));do arp -d 192.168.0.$ip &>/dev/null;done
清除192.168.0.0网段的所有缓存
三、arp -d IP
这样可以清除单一IP 的ARP缓存
注意:以上均需要root权限,尤其是最后一个,如果不再root下执行,则改为:
arp -n|awk '/^[1-9]/ {print "arp -d "$1}' | sudo sh