How to Check Memory Usage in Linux based Server如何檢查記憶體使用量在基於Linux的服務器
Memory is one of the most critical resource components on a server to ensure that the smooth and fast operation.記憶是最重要的組成部分資源在伺服器上,以確保平穩和快速行動。 Thus, the availability of adequate and abundant physical memory size is vital especially for any server, especially high load web host that are also running database server such as Oracle or MySQL, which is famous for memory intensive.因此,有足夠的和豐富的物理內存大小是至關重要的特別是對任何服務器,特別是高負載網絡主機,也運行數據庫服務器,如Oracle或MySQL的,這是著名的內存密集型的。 Linux, including CentOS which is popular on cPanel and Plesk web hosting server, comes with several commands and tools to check memory usage on server. Linux操作系統,包括CentOS這是流行的cPanel和Plesk網絡託管服務器上,還帶有一些命令和工具,以檢查記憶體使用量在服務器上。
free 自由的
free command displays amount of total, free and used physical memory (RAM) in the system, as well as shoing information on shared memory, buffers, cached memory and swap space used by the Linux kernel.免費命令顯示的總金額,自由和使用物理內存( RAM )系統,以及shoing信息共享內存,緩衝區,緩存內存和交換空間使用的Linux內核。
Syntax of free 語法免費
free -[options]免費-[選項]
Example usage of free 例如免費使用
free -m自由米
The command will display information about physical memory in MB.該命令將顯示有關物理內存以MB 。
free -m -s 5無米比較五日
The command will activate continuous polling delay at 5 seconds apart, and then display memory status in megabytes on terminal.該命令將持續激活投票站延遲5秒,然後顯示記憶體的地位兆字節的終端。 Any floating point number for delay can be specified.任何浮點數拖延,不能指定。
free -t -m自由噸米
Same with “free -m”, but -t switch will display a line containing the totals of physical memory and swap space.同樣的“自由米” ,但- t開關就會顯示一行總數的物理內存和交換空間。
vmstat vmstat
vmstat reports report virtual memory statistics, which has information about processes, swap, free, buffer and cache memory, paging space, disk IO activity, traps, interrupts, context switches and CPU activity. vmstat報告虛擬內存的報告統計,該進程的信息,互換,自由,緩衝區和高速緩存,頁面空間,磁盤IO活動,陷阱,中斷,上下文切換和CPU活動。 With vmstat command, administrators can has instantaneous reports on memory usage.隨著vmstat命令,系統管理員可以有瞬間的報告內存的使用。
Syntax of vmstat 語法vmstat
vmstat -[options] [delay count] vmstat -[選項] [拖延數]
Example usage of vmstat 例如使用vmstat
vmstat
The command will display report based on averages since last reboot.該命令將顯示報告的基礎上平均自去年重新啟動。
vmstat 5 vmstat 5
The command will pool average system resources usage level for a sampling period of 5 seconds at interval of 5 seconds, except the first result that is averages since the last reboot.該命令將池平均系統資源的使用水平為採樣週期為5秒,間隔5秒,除了第一個結果是平均自上次重新啟動。
top 頂端
top command displays dynamic real-time view of the running tasks managed by kernel and system information in Linux system.頂端命令顯示動態實時的運行管理任務的內核和系統信息的Linux系統。 The memory usage stats by top command include real-time live total, used and free physical memory and swap memory with their buffers and cached memory size respectively.內存使用狀態的最高指揮包括實時直播總額,使用和自由物理內存和交換內存的緩衝區和緩存內存大小分別。
Syntax and example usage of top 例如語法和用法頂端
top頂端
Using top is simple, simply type top at command shell, and constantly update stats page will be shown.用最簡單,只需輸入前在命令外殼,並不斷更新的統計資料網頁會顯示。
ps aux ps的輔助
ps command reports a snapshot on information of the current active processes. ps的命令報告的快照信息當前活躍的進程。 Advantage of ps command is that system admins will be able to see where the memory is used.利用ps的命令是,系統管理員將能夠看到的內存使用。 ps will show the percentage of memory resource that is used by each process or task running in the system. ps的將顯示與記憶的資源,所使用的每一個進程或任務運行的系統。 With this command, top memory hogging processes can be identified.在此命令中,最大內存佔用進程可以查明。
Syntax and example of ps aux 語法和例子ps的輔助
aux is actually already the options for ps command to see every process on the system.輔助實際上是已經選擇的ps命令看到每一個進程的系統。 So the typical command to type the following in the command shell:因此,典型的命令,鍵入以下的命令:
ps aux
To see only the memory resources occupied by each category of processes, such as Apache httpd, MySQL mysqld or Java, use the following command:看到只有內存資源佔用的每一類程序,如Apache的httpd , MySQL的mysqld或Java ,使用下面的命令:
ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort -nr
The all mentioned ways of check memory usage should works on most Unix and Linux variant of operating systems.所有提到的方法檢查內存的使用應適用於大多數Unix和Linux版本的操作系統。 However, if you’re running a VPS (Virtual Private Server) or VDS (Virtual Dedicated Server) or Hybrid Server, especially those powered by Virtuozzo or OpenVZ, the above commands will retrieve data from the host machine, ie the entire server the virtual environment is running on.然而,如果您正在運行定位系統(虛擬專用服務器)或辛(虛擬專用服務器)或混合型服務器,特別是那些採用Virtuozzo軟件或OpenVZ的,上述命令將檢索數據從主機,即整個服務器的虛擬環境上運行。 In these virtualization system, the memory usage info has to be calculated from control panel or /proc/user_beancounters file.在這些虛擬化系統,對內存的使用信息已經被計算出來的控制面板或/進程/ user_beancounters文件。
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要說明:這是一台機器翻譯網頁這是“原樣”提供,無保修。 Machine translation may be difficult to understand.機器翻譯可能很難理解。 Please refer to請參閱 original English article英文原文的文章 whenever possible.只要有可能。
Share and contribute or get technical support and help at共享和貢獻或獲得技術支持和幫助 My Digital Life Forums 我的數字生活論壇 . 。
Related Articles相關文章
- Ubuntu 6.06 Reviews Ubuntu的6.06評述
- Open, Extract and Convert DAA, ISO and BIN Files in Linux with Free PowerISO for Linux打開,提取和轉換的DAA ,國際標準化組織和本文件在Linux與自由PowerISO為Linux
- Novell SUSE Linux Enterprise Server 10 Reviews Novell公司的SUSE Linux Enterprise Server 10評語
- Cheapest Linux Box Ever最便宜的Linux方塊以往任何時候都
- Find Out Linux Orphan Processes了解Linux的孤兒進程
- How to Check if Telnet Is Running on a Server如何檢查,如果遠程登錄上運行的服務器
- Paessler Router Traffic Grapher PRTG 5.3 Review by Computing Paessler路由器交通Grapher PRTG 5.3審查通過計算
- How to Mount USB Disk Drive in UNIX or Linux如何安裝的USB磁盤驅動器在UNIX或Linux操作系統
- Download Free VMWare Server Virtualization Software免費下載VMware服務器虛擬化軟件
- Start, Stop and Restart Crond Daemon in Linux啟動,停止和重新啟動Crond守護在Linux

































September 24th, 2007 15:20 2007年9月24日15:20
When you are running top there are three fields related to memory usage.當您運行的是頂端有三個領域的有關記憶體使用量。 In order to assay your server memory requirements you have to understand their meaning.為了檢測您的服務器的內存要求你必須了解其含義。
The first thing you have to know is that all the columns (VIRT RES SHR) report memory usage in KB (kilobytes).首先,你必須知道的是,所有列( VIRT水庫自發性高血壓大鼠)報告記憶體使用量以KB (千字節) 。
VIRT column (virtual memory size of the process) means how much memory a particular application has requested, also it counts swapped to the disk memory pages. VIRT欄(虛擬內存大小的過程)指多少內存某一特定的應用要求,同時也罪狀交換到磁盤存儲的網頁。 But this field does NOT mean that this process actually uses that amount of memory, to use it for real this memory has to be initiated for example using memset.但是,這一領域並不意味著這個過程中實際上使用這一數額的內存,使用它真正的這種記憶也將開始使用,例如memset 。 Generally speaking you can disregard this column.一般而言您可以忽略此列。
RES column (resident set size, the non-swapped physical memory that a task has used (in kiloBytes)) is the most important one - it actually shows how much physical RAM is allocated for a process.水庫欄(駐留集大小,非交換物理內存的任務使用(以千字節) )是最重要的是-它實際上表明有多少物理內存是分配給一個進程。
SHR column says how much memory a particular application is sharing with other applications.高血壓柱說多少內存特定應用程序共享同其他應用軟件。 Eg, most applications in Linux depend on libc, and as every application links with it and uses its functions then this library memory space is mapped to all process simultaneously to conserve memory.例如,大多數應用程序在Linux取決於LIBC的,作為每一個應用聯繫,並利用其職能然後這個圖書館的內存空間映射到所有進程同時進行,以節省內存。
Consult with this pages for better understanding:與此網頁更好地理解:
1. 1 。 http://tldp.org/LDP/tlk/mm/memory.html
2. 2 。 http://www.ibm.com/developerworks/linux/library/l-mem26/