今天查看生产某个服务器的负载的时候,发现内存的使用情况有些异常。
top - 12:00:08 up 15 days, 12:04, 13 users, load average: 63.31, 55.12, 43.39
Tasks: 5542 total, 21 running, 5511 sleeping, 0 stopped, 10 zombie
Cpu(s): 13.6%us, 3.7%sy, 0.0%ni, 81.1%id, 0.1%wa, 0.3%hi, 1.2%si, 0.0%st
Mem: 363033360k total, 257187848k used, 105845512k free, 1368028k buffers
Swap: 377487328k total, 0k used, 377487328k free, 167742788k cached
这个参数在前几天可是200多G,那100多G到哪去了呢?
使用ipcs来查看共享段的情况,没有发现异常的情况。
> ipcs -a ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x00000000 500105218 root 644 80 2 0x00000000 500137988 root 644 16384 2 0x00000000 500170757 root 644 280 2 0x550002fb 500203526 root 644 256064 1 locked 0xba17ff18 500760585 xxxxx 660 35704012800 3963 0xd9152b54 500695050 xxxxx 660 3542089728 37 0x91442618 500826123 xxxx 660 4096 0 0xdb22d1bc 500957196 xxxxxx 660 3340763136 32 |
使用free -m来查看剩余内容情况,剩余268913M的内容,这个和期望的结果还是一致的。
total used free shared buffers cached
Mem: 354524 250998 103526 0 1336 164050
-/+ buffers/cache: 85611 268913
Swap: 368639 0 368639
关于top和free的命令解释,我觉得http://blog.itpub.net/34596/viewspace-588857/这个帖子解释得很好,
free命令显示在操作系统中使用和空闲的内存数量。
Top 显示是和Linux 对内存使用的方式关系紧密,linux 尽可能的要求
使用物理内存来提高Buffer 和Cache 对Disk 的I/O操作。Linux 将尽可能多的将I/O 操作磁盘上的信息保存在内存当中,如果Oracle(其他程序也一样)需要更多的内存空间,Linux 才会将一些内存使用LRU 算法清理出来,如果不需要则继续保持这些数据信息在内存中。
尽管从这个解释来看,不是问题,从vmstat来看也没有发现swap的异常。总算松了口气,但是还是希望能够查出倒底那100多G的空间都消耗到哪了。
> vmstat 1 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
49 1 0 105913072 1368380 167977888 0 0 1330 81 0 0 10 3 87 0 0
525 1 0 105816848 1368380 167978320 0 0 138008 10340 40898 90606 17 6 77 0 0
22 0 0 105814304 1368380 167978544 0 0 225004 6875 37504 78706 12 5 83 0 0
8 0 0 105782352 1368380 167978672 0 0 112008 12034 39147 86160 13 4 83 0 0
11 0 0 105787408 1368380 167978896 0 0 237008 6868 38895 84063 13 4 83 0 0
这个时候还是使用top命令 直接使用shift+M能够查看出使用内存的进程情况。