[Linux] Linux下谁在消耗我们的cache
一、缘由:
曾经看到MySQL服务器上Cache占用特别大,其实大家都知道这是合理的,这些都是可用内存;
那么问题来了,是谁在占用这些Cache呢?如果去掉不合理的Cache占用,系统内存会更充分的得到利用。
total used free shared buffers cached
Mem:
-/+ buffers/cache:
Swap:
由上图可见,Cache占用了42G内存,猛地一看很可怕。实际上他还属于memfree之列。具体说明,可以看这里:
http://www.linuxatemyram.com/。
二、解决办法:
这里有两个工具可以查看某个文件是否占用了Page Cache,占用了多少:fincore和vmtouch
1、fincore
这是linux-ftools工具的一部分,你给出文件(夹)名作为输入,他会告诉你他有多少文件(数据)被系统缓存起来。
因为不太会安装,这里不做推荐,具体看这里https://code.google.com/p/linux-ftools/。
2、vmtouch
vmtouch可以查到缓存的文件和目录、把文件推入缓存和驱逐缓存中的文件等等。(推荐)
安装方法:
$ git clone https://github.com/hoytech/vmtouch
$ cd vmtouch
$ make
$ sudo make install
使用方法:
$ vmtouch
vmtouch: no files or directories specified vmtouch v1.0.2 - the Virtual Memory Toucher by Doug Hoyte
Portable file system cache diagnostics and control Usage: vmtouch [OPTIONS] ... FILES OR DIRECTORIES ... Options:
-t touch pages into memory
-e evict pages from memory
-l lock pages in physical memory with mlock()
-L lock pages in physical memory with mlockall()
-d daemon mode
-m max file size to touch
-p use the specified portion instead of the entire file
-f follow symbolic links
-h also count hardlinked copies
-w wait until all pages are locked (only useful together with -d)
-v verbose
-q quiet
例子:
1)查看/tmp目录在内存中的缓存:
$ vmtouch /tmp/
vmtouch: WARNING: skipping non-regular file: /tmp/ssh-GgJnCEkWMQC2/agent. Files:
Directories:
Resident Pages: / 18M/18M %
Elapsed: 0.001006 seconds
详细信息查看可使用-v参数 例如:vmtouch -v /tmp/
2)查看一个文件被缓存了多少:
$ vmtouch -v ~/Downloads/phoronix-test-suite_6..1_all.deb
/home/neo/Downloads/phoronix-test-suite_6..1_all.deb
[ ] / Files:
Directories:
Resident Pages: / /528K %
Elapsed: 0.000117 seconds
3)把文件缓存起来:
$ vmtouch -vt ~/Downloads/phoronix-test-suite_6..1_all.deb
/home/neo/Downloads/phoronix-test-suite_6..1_all.deb
[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] / Files:
Directories:
Touched Pages: (528K)
Elapsed: 0.007935 seconds
4)把缓存中的数据驱逐出去:
$ vmtouch -ve ~/Downloads/phoronix-test-suite_6..1_all.deb
Evicting /home/neo/Downloads/phoronix-test-suite_6..1_all.deb Files:
Directories:
Evicted Pages: (528K)
Elapsed: 0.000109 seconds
附:
具体信息参考官网:https://hoytech.com/vmtouch/
另一个参考页面:vmtouch: portable file cache analyzer
[Linux] Linux下谁在消耗我们的cache的更多相关文章
- Linux环境下的CPU消耗分析
在Linux系统中, CPU 主要用于中断,内核以及用户进程的任务处理,优先级为 中断 > 内核 > 用户进程.在CPU消耗分析中,我们还经常遇到下面几个概念. 上下文切换 ...
- 性能测试分析过程(三)linux下查看最消耗CPU/内存的进程
linux下查看最消耗CPU 内存的进程 1.CPU占用最多的前10个进程: ps auxw|head -1;ps auxw|sort -rn -k3|head -10 2.内存消耗最多的前10 ...
- linux下定位异常消耗的线程实战分析
前言: 之前分享过一篇Linux开发coredump文件分析实战分享 ,今天再来分享一篇实战文章. 在我们嵌入式linux开发过程中,开发过程中我们经常会使用多进程.多线程开发.那么多线程使用过程中, ...
- 在Linux操作系统下备份恢复技术的应用 转自https://yq.aliyun.com/articles/50205?spm=5176.100239.blogcont24250.9.CfBYE9
摘要: 安全防护:在Linux操作系统下备份恢复技术的应用 原文参见:http://linux.chinaunix.net/techdoc/system/2005/12/19/925898.shtm ...
- Ruby入门--Linux/Windows下的安装、代码开发及Rails实战
Ruby入门--Linux/Windows下的安装.代码开发及Rails实战 http://www.linuxidc.com/Linux/2014-04/100242.htm Ubuntu 13.04 ...
- 【云和恩墨】性能优化:Linux环境下合理配置大内存页(HugePage)
原创 2016-09-12 熊军 [云和恩墨]性能优化:Linux环境下合理配置大内存页(HugePage) 熊军(老熊) 云和恩墨西区总经理 Oracle ACED,ACOUG核心会员 PC S ...
- 【原创】Linux环境下的图形系统和AMD R600显卡编程(1)——Linux环境下的图形系统简介
Linux/Unix环境下最早的图形系统是Xorg图形系统,Xorg图形系统通过扩展的方式以适应显卡和桌面图形发展的需要,然而随着软硬件的发展,特别是嵌入式系统的发展,Xorg显得庞大而落后.开源社区 ...
- Windows环境和Linux环境下Redis主从复制配置
Windows环境下和Linux环境下配置Redis主从复制基本上一样,都是更改配置文件.Windows环境下修改的配置文件是:redis.windows.conf.redis.windows-ser ...
- Linux环境下Java应用性能分析定位-CPU使用篇
1 CPU热点分析定位背景 CPU资源还是很昂贵的,为了深刻感受到这种昂贵,间下图当前CPU的资源售价: 所以对于程序猿们来说,需要让程序合理高效的使用CPU资源.利用有限的CPU资源来解决完 ...
随机推荐
- css——手机端图片正确显示
这两天遇到的问题汇总(一): 1.图片在app端显示有差异:如下 左边图片是:图片显示太大,以至于让整个页面都失真的效果:右边是调好样式之后的效果,知道增 ...
- linux 下mysql的启动 、调试、排错
Linux 下 MySQL 启动与关闭 说明 一.启动 1.1 MySQL 进程 可以用ps 命令查看进程: [root@rac2 ~]# ps -ef|grep mysql root 21 ...
- select document library from certain list 分类: Sharepoint 2015-07-05 07:52 6人阅读 评论(0) 收藏
S using System; using Microsoft.SharePoint; namespace Test { class ConsoleApp { static void Main(str ...
- linux命令每日一练习-rmdir mv
rmdir 删除一个空的文件夹,当目标文件夹非空的时候不能删除 mv 移动文件或目录 mv source target mv -i *** *** 如果目标文件存在则询问是否覆盖 mv -f *** ...
- HttpURLConnection网络请求
//创建访问的方法 public String Check_json(){ //创建一个结果字符串 String result=""; //拼接字符串 StringBuffer s ...
- Android Studio Tips and Tricks
Android Studio Delete Module 1.选中Module右击,选择 Open Module Settings,打开Project Structure 窗空.(或者选中Module ...
- bigworld源码分析(4)——BaseAppMgr分析
BaseAppMgr是用来管理BaseApp的,在整个bigworld中只有一个.本篇就BaseAppMgr的一些核心功能进行分析: (1) BaseAppMgr是如何通知BaseApp创建Entit ...
- leetcode(144,94,145,102)中迭代版的二叉树的前、中、后、层级遍历
//前序遍历class Solution{ public: vector<int> preorderTraversal(TreeNode *root){ vector<int> ...
- IT行业的正式入门
虽然我是计算机专业毕业的大学生,但我自己认为我连什么是 IT都不了解,我热爱Java程序的设计,所以我现在在努力学习,今天是上Java程序设计的第一天,我正式进入IT业,踏上了这条“不归路”.figh ...
- andriod学习之一
今天安装了Android Studio, 但PinyinIME没有导入成功.然后看了Android的一些基础. 知道了Android的基本组件: Activity,服务,内容提供程序,广播接收器. 大 ...