什么是在这个Ubuntu 12.04.2服务器上使用内存?

我在Nginx,PHP5-FPM和Memcached的池中有两台服务器。 出于某种原因,池中的第一台服务器似乎莫名其妙地丢失了大约2GB的RAM。 我无法解释它在哪里。

重新启动会使一切恢复正常,但在几个小时之后RAM又被使用了。

起初,我认为这是memcached,但最终我杀了每一个进程,我可以合理杀死,内存不释放。 即使init 1没有释放内存。

ipcs -m是空的,slabtop看起来和在内存中的服务器很相似。

df在tmpfs中显示大约360K

在相关的情况下,两台服务器几乎完全相同,它们在不同主机上的相同pipe理程序(VMWare ESXi 4.1)上运行同一操作系统,但硬件相同。 不同之处在于:

  • 第一台服务器有一个NFS挂载。 我试着卸载这个和删除模块,但没有改变内存使用情况
  • 第一台服务器监听HTTP和HTTPS站点,而第二台监听HTTP。

这是免费-m的输出

total used free shared buffers cached Mem: 3953 3458 494 0 236 475 -/+ buffers/cache: 2746 1206 Swap: 1023 0 1023 

这里是/ proc / meminfo …

 MemTotal: 4048392 kB MemFree: 506576 kB Buffers: 242252 kB Cached: 486796 kB SwapCached: 8 kB Active: 375240 kB Inactive: 369312 kB Active(anon): 12320 kB Inactive(anon): 3596 kB Active(file): 362920 kB Inactive(file): 365716 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 1048572 kB SwapFree: 1048544 kB Dirty: 0 kB Writeback: 0 kB AnonPages: 15544 kB Mapped: 3084 kB Shmem: 412 kB Slab: 94516 kB SReclaimable: 75104 kB SUnreclaim: 19412 kB KernelStack: 632 kB PageTables: 1012 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 3072768 kB Committed_AS: 20060 kB VmallocTotal: 34359738367 kB VmallocUsed: 281340 kB VmallocChunk: 34359454584 kB HardwareCorrupted: 0 kB AnonHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 59392 kB DirectMap2M: 4134912 kB 

这是当时的进程列表…

 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 24336 2160 ? Ss Jul22 0:09 /sbin/init root 2 0.0 0.0 0 0 ? S Jul22 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S Jul22 0:38 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S Jul22 0:00 [kworker/u:0] root 6 0.0 0.0 0 0 ? S Jul22 0:04 [migration/0] root 7 0.0 0.0 0 0 ? S Jul22 0:32 [watchdog/0] root 8 0.0 0.0 0 0 ? S Jul22 0:04 [migration/1] root 10 0.0 0.0 0 0 ? S Jul22 0:22 [ksoftirqd/1] root 11 0.0 0.0 0 0 ? S Jul22 0:15 [kworker/0:1] root 12 0.0 0.0 0 0 ? S Jul22 0:31 [watchdog/1] root 13 0.0 0.0 0 0 ? S Jul22 0:04 [migration/2] root 15 0.0 0.0 0 0 ? S Jul22 0:04 [ksoftirqd/2] root 16 0.0 0.0 0 0 ? S Jul22 0:14 [watchdog/2] root 17 0.0 0.0 0 0 ? S Jul22 0:04 [migration/3] root 19 0.0 0.0 0 0 ? S Jul22 0:04 [ksoftirqd/3] root 20 0.0 0.0 0 0 ? S Jul22 0:11 [watchdog/3] root 21 0.0 0.0 0 0 ? S< Jul22 0:00 [cpuset] root 22 0.0 0.0 0 0 ? S< Jul22 0:00 [khelper] root 23 0.0 0.0 0 0 ? S Jul22 0:00 [kdevtmpfs] root 24 0.0 0.0 0 0 ? S< Jul22 0:00 [netns] root 25 0.0 0.0 0 0 ? S Jul22 0:02 [sync_supers] root 26 0.0 0.0 0 0 ? S Jul22 0:21 [kworker/u:1] root 27 0.0 0.0 0 0 ? S Jul22 0:00 [bdi-default] root 28 0.0 0.0 0 0 ? S< Jul22 0:00 [kintegrityd] root 29 0.0 0.0 0 0 ? S< Jul22 0:00 [kblockd] root 30 0.0 0.0 0 0 ? S< Jul22 0:00 [ata_sff] root 31 0.0 0.0 0 0 ? S Jul22 0:00 [khubd] root 32 0.0 0.0 0 0 ? S< Jul22 0:00 [md] root 34 0.0 0.0 0 0 ? S Jul22 0:04 [khungtaskd] root 35 0.0 0.0 0 0 ? S Jul22 0:15 [kswapd0] root 36 0.0 0.0 0 0 ? SN Jul22 0:00 [ksmd] root 37 0.0 0.0 0 0 ? SN Jul22 0:00 [khugepaged] root 38 0.0 0.0 0 0 ? S Jul22 0:00 [fsnotify_mark] root 39 0.0 0.0 0 0 ? S Jul22 0:00 [ecryptfs-kthrea] root 40 0.0 0.0 0 0 ? S< Jul22 0:00 [crypto] root 48 0.0 0.0 0 0 ? S< Jul22 0:00 [kthrotld] root 50 0.0 0.0 0 0 ? S Jul22 2:59 [kworker/1:1] root 51 0.0 0.0 0 0 ? S Jul22 0:00 [scsi_eh_0] root 52 0.0 0.0 0 0 ? S Jul22 0:00 [scsi_eh_1] root 57 0.0 0.0 0 0 ? S Jul22 0:09 [kworker/3:1] root 74 0.0 0.0 0 0 ? S< Jul22 0:00 [devfreq_wq] root 114 0.0 0.0 0 0 ? S Jul22 0:00 [kworker/3:2] root 128 0.0 0.0 0 0 ? S Jul22 0:00 [kworker/1:2] root 139 0.0 0.0 0 0 ? S Jul22 0:00 [kworker/0:2] root 249 0.0 0.0 0 0 ? S< Jul22 0:00 [mpt_poll_0] root 250 0.0 0.0 0 0 ? S< Jul22 0:00 [mpt/0] root 259 0.0 0.0 0 0 ? S Jul22 0:00 [scsi_eh_2] root 273 0.0 0.0 0 0 ? S Jul22 0:20 [jbd2/sda1-8] root 274 0.0 0.0 0 0 ? S< Jul22 0:00 [ext4-dio-unwrit] root 377 0.0 0.0 0 0 ? S Jul22 0:26 [jbd2/sdb1-8] root 378 0.0 0.0 0 0 ? S< Jul22 0:00 [ext4-dio-unwrit] root 421 0.0 0.0 17232 584 ? S Jul22 0:00 upstart-udev-bridge --daemon root 438 0.0 0.0 21412 1176 ? Ss Jul22 0:00 /sbin/udevd --daemon root 446 0.0 0.0 0 0 ? S< Jul22 0:00 [rpciod] root 448 0.0 0.0 0 0 ? S< Jul22 0:00 [nfsiod] root 612 0.0 0.0 21408 772 ? S Jul22 0:00 /sbin/udevd --daemon root 613 0.0 0.0 21728 924 ? S Jul22 0:00 /sbin/udevd --daemon root 700 0.0 0.0 0 0 ? S< Jul22 0:00 [kpsmoused] root 849 0.0 0.0 15188 388 ? S Jul22 0:00 upstart-socket-bridge --daemon root 887 0.0 0.0 0 0 ? S Jul22 0:00 [lockd] root 919 0.0 0.0 14504 952 tty4 Ss+ Jul22 0:00 /sbin/getty -8 38400 tty4 root 922 0.0 0.0 14504 952 tty5 Ss+ Jul22 0:00 /sbin/getty -8 38400 tty5 root 924 0.0 0.0 14504 944 tty2 Ss+ Jul22 0:00 /sbin/getty -8 38400 tty2 root 925 0.0 0.0 14504 944 tty3 Ss+ Jul22 0:00 /sbin/getty -8 38400 tty3 root 930 0.0 0.0 14504 952 tty6 Ss+ Jul22 0:00 /sbin/getty -8 38400 tty6 root 940 0.0 0.0 0 0 ? S Jul22 0:07 [flush-8:0] root 1562 0.0 0.0 58792 1740 tty1 Ss Jul22 0:00 /bin/login -- root 12969 0.0 0.0 0 0 ? S 07:18 0:02 [kworker/2:2] root 30051 0.0 0.0 0 0 ? S 10:13 0:00 [flush-8:16] root 30909 0.0 0.0 0 0 ? S 10:14 0:00 [kworker/2:1] johncc 30921 0.2 0.2 26792 9360 tty1 S 10:17 0:00 -bash root 31089 0.0 0.0 0 0 ? S 10:18 0:00 [kworker/0:0] root 31099 0.0 0.0 42020 1808 tty1 S 10:19 0:00 sudo -i root 31100 0.2 0.1 22596 5168 tty1 S 10:19 0:00 -bash root 31187 0.0 0.0 0 0 ? S 10:19 0:00 [kworker/2:0] root 31219 0.0 0.0 16880 1252 tty1 R+ 10:22 0:00 ps aux root 31220 0.0 0.0 53924 536 tty1 R+ 10:22 0:00 curl -F sprunge=<- http://sprunge.us 

任何人都可以提出什么尝试下一步,或者如何debugging这个问题? 我不知所措

该计算机是在ESXipipe理程序上运行的虚拟客户机。 内存膨胀怎么样? 首先,我build议您检查此guest虚拟机的ESXi / vCenter内存/气球统计信息。

虚拟机pipe理程序可能会要求客人“膨胀”气球,以便分配一些额外的内存,例如用于其他正在运行的客人。 但是这需要加载一个可用作内核模块vmmemctl的气球驱动程序。

最后,显而易见的问题可能是guest虚拟机是否安装了vmware工具,因为在您提供的进程列表中看不到任何相关的进程。 通过改变,在开始杀死它们之前,没有任何vmware-guestd进程吗?

watch命令可能很有用。 尝试观看-n 5免费监视内存使用情况,每五秒更新一次。

htop是最好的解决scheme。

  sudo apt-get install htop 

这样你会注意到哪些程序正在使用大多数RAM。 你可以很容易地终止一个,如果你想。