阿里云虚拟主机内存占用大问题解决

今年买了一台2核4G的主机,把4核8G的降配下来。

结果:机器没有启动任务程序,就占用2.5G内存。
 

total used free shared buff/cache available Mem: 

3.7G 2.5G 1.0G 64M 159M 972M Swap: 0B 0B 0B

阿里工程师回复:

1、top,然后按大写的M对占用内存的进程进行排序

2、free -m

top:

Tasks:  97 total,   1 running,  96 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.0 us,  0.5 sy,  0.0 ni, 98.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3881688 total,   929616 free,  2645168 used,   306904 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   922736 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                                                                  
  889 root      20   0  474660  32132     72 S   0.0  0.8   0:11.79 dockerd                                                                                                                                                                                                  
  453 root      20   0  341060  27364    716 S   0.0  0.7   0:00.91 firewalld                                                                                                                                                                                                
 1288 root      10 -10  144920  20652   3620 S   3.3  0.5  20:44.46 AliYunDun                                                                                                                                                                                                
  944 root      20   0  343864  15812    176 S   0.0  0.4   0:05.04 containerd                                                                                                                                                                                               
  885 root      20   0  562884  12900     80 S   0.0  0.3   0:04.87 tuned                                                                                                                                                                                                    
  812 root      20   0  113568  12492      0 S   0.0  0.3   0:00.00 dhclient                                                                                                                                                                                                 
  894 root      20   0  806092   9336   3784 S   0.0  0.2   0:37.64 aliyun-service                                                                                                                                                                                           
  395 polkitd   20   0  535040   8392   1264 S   0.0  0.2   0:00.24 polkitd                                                                                                                                                                                                  
  405 root      20   0  295512   5968   4012 S   0.0  0.2   0:10.61 rsyslogd                                                                                                                                                                                                 
27180 root      20   0  148688   5740   4428 S   0.0  0.1   0:00.10 sshd                                                                                                                                                                                                     
  336 root      20   0   37284   5400   4924 S   0.0  0.1   0:17.93 systemd-journal                                                                                                                                                                                          
 1252 root      20   0  214292   3972     16 S   0.0  0.1   0:01.35 php-fpm                                                                                                                                                                                                  
 1266 www       20   0  214292   3968      8 S   0.0  0.1   0:00.00 php-fpm                                                                                                                                                                                                  
 1267 www       20   0  214292   3968      8 S   0.0  0.1   0:00.00 php-fpm                                                                                                                                                                                                  
 1261 www       20   0  214292   3964      8 S   0.0  0.1   0:00.00 php-fpm                                                                                                                                                                                                  
 1262 www       20   0  214292   3964      8 S   0.0  0.1   0:00.00 php-fpm                                                                                                                                                                                                  
 1263 www       20   0  214292   3964      8 S   0.0  0.1   0:00.00 php-fpm  

free -m

[root@izwz9947gr37kg75oe64tkz ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           3790        2584         906          72         299         899
Swap:             0           0           0

卸载宝塔后:
[root@izwz9947gr37kg75oe64tkz ~]# top 
top - 13:28:49 up 13:38,  4 users,  load average: 0.07, 0.09, 0.07
Tasks:  89 total,   2 running,  87 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.3 sy,  0.0 ni, 99.0 id,  0.0 wa,  0.0 hi,  0.3 si,  0.0 st
KiB Mem :  3881688 total,   801700 free,  2637216 used,   442772 buff/cache
KiB Swap:        0 total,        0 free,        0 used.   928240 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                                                                  
  889 root      20   0  474660  32132     72 S   0.0  0.8   0:11.86 dockerd                                                                                                                                                                                                  
  453 root      20   0  341060  27364    716 S   0.0  0.7   0:00.91 firewalld                                                                                                                                                                                                
 1288 root      10 -10  144920  21148   4116 S   1.9  0.5  20:55.11 AliYunDun                                                                                                                                                                                                
  944 root      20   0  343864  15812    176 S   0.0  0.4   0:05.07 containerd                                                                                                                                                                                               
  885 root      20   0  562884  12900     80 S   0.0  0.3   0:04.90 tuned                                                                                                                                                                                                    
  812 root      20   0  113568  12492      0 S   0.0  0.3   0:00.00 dhclient                                                                                                                                                                                                 
  894 root      20   0  806092   9364   3808 S   0.0  0.2   0:37.87 aliyun-service                                                                                                                                                                                           
  395 polkitd   20   0  535040   8580   1452 S   0.0  0.2   0:00.25 polkitd                                                                                                                                                                                                  
  405 root      20   0  295512   6484   4520 S   0.0  0.2   0:10.73 rsyslogd                                                                                                                                                                                                 
  336 root      20   0   37284   5992   5516 S   0.0  0.2   0:18.13 systemd-journal                                                                                                                                                                                          
27180 root      20   0  148688   5740   4428 S   0.0  0.1   0:00.12 sshd                                                                                                                                                                                                     
27667 root      20   0  148688   5740   4428 S   0.0  0.1   0:00.06 sshd                                                                                                                                                                                                     
27710 root      20   0  145788   4928   3696 S   0.0  0.1   0:00.00 sshd                                                                                                                                                                                                     
27712 root      20   0  145788   4788   3556 S   0.0  0.1   0:00.00 sshd                                                                                                                                                                                                     
    1 root      20   0  191064   3104   1584 S   0.0  0.1   0:03.12 systemd                                                                                                                                                                                                  
27711 sshd      20   0  106200   2444   1428 S   0.0  0.1   0:00.00 sshd  

差不了多少:

   total        used        free      shared  buff/cache   available
Mem:           3790        2576         780          72         433         905
Swap:             0           0           0

查占用内存详情,前10:

[root@izwz9947gr37kg75oe64tkz ~]# ps aux|head -1; ps aux | sort -k4nr | head -10

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       889  0.0  0.8 474660 32132 ?        Ssl  Nov06   0:11 /usr/bin/dockerd -H fd://
root       453  0.0  0.7 341060 27364 ?        Ssl  Nov06   0:00 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
root      1288  2.5  0.5 144920 21148 ?        S<sl Nov06  21:01 /usr/local/aegis/aegis_client/aegis_11_13/AliYunDun
root       944  0.0  0.4 343864 15812 ?        Ssl  Nov06   0:05 /usr/bin/containerd
root       812  0.0  0.3 113568 12492 ?        Ss   Nov06   0:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid -H izwz9947gr37kg75oe64tkz eth0
root       885  0.0  0.3 562884 12900 ?        Ssl  Nov06   0:04 /usr/bin/python -Es /usr/sbin/tuned -l -P
polkitd    395  0.0  0.2 535040  8580 ?        Ssl  Nov06   0:00 /usr/lib/polkit-1/polkitd --no-debug
root       894  0.0  0.2 806092  9412 ?        Ssl  Nov06   0:38 /usr/local/share/aliyun-assist/2.2.3.247/aliyun-service
postfix  27752  0.0  0.1  95204  5088 ?        S    13:29   0:00 pickup -l -t unix -u
root     27180  0.0  0.1 148688  5740 ?        Ss   13:20   0:00 sshd: root@pts/2

阿里工程师回复2:

firewalld:不需要,先停止
aegis_client:卸载云安全中心插件
重启服务器

          只释放了不几M内存。

阿里工程师回复3:

/proc/meminfo中看到有hugepage占用了内存查看/etc/sysctl.conf中有相应的参数设置。您可以在/etc/sysctl.conf中把该参数注释,然后重启系统再查看一下内存使用情况。

重启服务器后:

[root@izwz9947gr37kg75oe64tkz ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:           3790         154        3323           8         313        3404
Swap:             0           0           0

结论:hugepage是大页内存,不是虚拟内存,ECS对配置hugepage没有限制,但是配置之后,系统会为hugepage预留内存。

总结解决问题,还得找专业人的。