linux – 服务器的内存几乎占用了8GB

前端之家收集整理的这篇文章主要介绍了linux – 服务器的内存几乎占用了8GB前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
最近,我们的服务器面临内存问题.从几周前开始,我们的服务器加载非常慢.访问电子邮件和网站真的需要太长时间.然后我们请求服务器技术支持为我们重启服务器.重启后,事情恢复正常.我们认为现在是我们升级RAM的时候了.最初我们的服务器上只有2GB RAM,因此我们将其升级到8GB.

我们认为问题已经解决了.但是,升级RAM后,内存使用量不断增加.它总是达到其最大使用率(例如,从7.8 GB内存中免费456.5 MB).第二天,服务器完全关闭,我们不得不请求技术支持再次为我们重启服务器.每当我们遇到问题时,我们都要请支持人员为我们重启服务器.据支持人员介绍,如果他们进行了sql访问,内存将恢复正常.但如果他们再次上场,记忆力将再次升高.因此,他们怀疑问题与SQL查询有关.

我想问一下,问题真的是SQL查询吗?还是硬件问题?如果是sql,我怎么知道哪些查询占用了如此巨大的内存?我怎么检查呢?我们的服务器正在运行以下详细信息:

  1. OS: Linux 2.6.18
  2. cpu: GenuineIntel,Intel(R)Xeon(R)cpu W3550 @ 3.07GHz
  3. Average Load: 808.18;674.21;587.18
  4. database records: 421,031 with 58 tables

查询我可以从PHPMyAdmin提供的统计信息:

  1. select 314 k 11.98 k 66.37%
  2. set option 34 k 1,296.59 7.18%
  3. show fields 19 k 712.00 3.94%
  4. update 16 k 620.61 3.44%
  5. alter table 16 k 610.32 3.38%
  6. change db 15 k 569.08 3.15%
  7. insert 15 k 560.20 3.10%
  8. show variables 11 k 434.01 2.40%
  9. show tables 9,752 371.66 2.06%
  10. begin 7,172 273.33 1.51%

执行’top’的结果:

  1. top - 15:20:07 up 1 day,6:13,1 user,load average: 497.30,512.17,542.15
  2. Tasks: 7743 total,5 running,7738 sleeping,0 stopped,0 zombie
  3. cpu(s): 23.9%us,50.9%sy,0.1%ni,25.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st
  4. Mem: 8173372k total,8048380k used,124992k free,1816952k buffers
  5. Swap: 2096376k total,216k used,2096160k free,533876k cached

我希望有人可以给我一些建议,因为我已经面对这个问题一段时间了,我没有人可以寻求指导.先感谢您.

更新:dmesg

  1. cpu5: Temperature above threshold,cpu clock throttled
  2. cpu7: Temperature/speed normal
  3. cpu2: Temperature/speed normal
  4. cpu6: Temperature/speed normal
  5. cpu1: Temperature above threshold,cpu clock throttled
  6. cpu3: Temperature/speed normal
  7. cpu0: Temperature/speed normal
  8. cpu4: Temperature/speed normal
  9. cpu6: Temperature/speed normal
  10. cpu5: Temperature/speed normal
  11. cpu1: Temperature/speed normal
  12. cpu2: Temperature/speed normal
  13. cpu4: Temperature/speed normal
  14. cpu7: Temperature/speed normal
  15. cpu0: Temperature/speed normal
  16. cpu3: Temperature/speed normal
  17. brute[19592]: segfault at 0000000000000028 rip 00000000080a592f rsp 00000000ffae3a28 error 6
  18. brute[19539]: segfault at 0000000000000028 rip 00000000080a592f rsp 00000000ffae3a28 error 6
  19. cpu2: Temperature/speed normal
  20. cpu4: Temperature/speed normal
  21. cpu7: Temperature/speed normal
  22. cpu1: Temperature/speed normal
  23. cpu5: Temperature/speed normal
  24. cpu3: Temperature/speed normal
  25. cpu6: Temperature/speed normal
  26. cpu0: Temperature/speed normal
  27. cpu0: Temperature/speed normal
  28. cpu7: Temperature/speed normal
  29. cpu6: Temperature/speed normal
  30. cpu1: Temperature/speed normal
  31. cpu2: Temperature/speed normal
  32. cpu3: Temperature/speed normal
  33. cpu5: Temperature/speed normal
  34. cpu4: Temperature/speed normal
  35. brute[21368]: segfault at 0000000000000000 rip 0000000008048f03 rsp 00000000ffb82db0 error 4

今天的TOP结果:

  1. top - 10:42:47 up 3 days,1:35,load average: 4.35,4.53,4.59
  2. Tasks: 187 total,182 sleeping,0 zombie
  3. cpu(s): 12.7%us,38.5%sy,0.0%ni,48.7%id,7800156k used,373216k free,1653768k buffers
  4. Swap: 2096376k total,2723732k cached
  5.  
  6. PID USER PR NI VIRT RES SHR S %cpu %MEM TIME+ COMMAND
  7. 27913 consulti 25 0 31096 3700 1172 R 100.2 0.0 1484:40 perl
  8. 27916 consulti 25 0 31096 3732 1204 R 100.2 0.0 1051:59 perl
  9. 28213 consulti 25 0 31096 3736 1204 R 100.2 0.0 1073:30 perl
  10. 28210 consulti 23 0 31096 3740 1204 S 86.9 0.0 1016:23 perl
  11. 3205 MysqL 15 0 333m 55m 5416 S 13.6 0.7 143:36.73 MysqLd
  12. 14616 apache 15 0 333m 33m 6056 S 4.7 0.4 1:02.12 httpd
  13. 25104 consulti 18 0 31096 3732 1204 R 4.7 0.0 486:12.74 perl
  14. 2702 root 15 0 12744 1148 808 R 0.3 0.0 0:00.01 top
  15. 1 root 15 0 10352 696 588 S 0.0 0.0 0:01.62 init
  16. 2 root RT -5 0 0 0 S 0.0 0.0 0:00.07 migration/0
  17. 3 root 34 19 0 0 0 S 0.0 0.0 0:00.07 ksoftirqd/0
  18. 4 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
  19. 5 root RT -5 0 0 0 S 0.0 0.0 0:00.00 migration/1
  20. 6 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1
  21. 7 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/1
  22. 8 root RT -5 0 0 0 S 0.0 0.0 0:00.00 migration/2
  23. 9 root 34 19 0 0 0 S 0.0 0.0 0:00.02 ksoftirqd/2
  24. 10 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/2
  25. 11 root RT -5 0 0 0 S 0.0 0.0 0:00.00 migration/3
  26. 12 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/3
  27. 13 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/3
  28. 14 root RT -5 0 0 0 S 0.0 0.0 0:00.05 migration/4
  29. 15 root 34 19 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/4
  30. 16 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/4
  31. 17 root RT -5 0 0 0 S 0.0 0.0 0:00.00 migration/5

解决方法

首先,与评论中的其他几个一样,我非常关注矿工和暴力流程.一个小小的谷歌侦探工作表明,这些名称分别与比特币挖掘和 automated network traffic generation(如:DDoS攻击中的一个节点)相关联,表明其他人可能正在将您的服务器用于自己的目的.

解决这个问题(请快速解决),您也可以通过一些数据库调优来改进.鉴于analysis posted by RandomSeed您可能有未使用的RAM,而是在磁盘上等待,并且注意到您在没有任何其他更改的评论的情况下将RAM添加到服务器,我怀疑您的MysqL缓冲池太小.

这归结为数据库服务器性能调优101:磁盘速度慢,内存速度快.数据库喜欢在内存中预加载或缓冲数据和索引,以减少需要外出到较慢的硬盘驱动器. MysqL有一些配置设置可以控制允许像这样缓存多少数据.如果您向服务器添加内存,但不更改这些MysqL设置,那么通过确保其他(非MysqL)进程有足够的RAM来帮助它会有所帮助,但它不会对您的核心数据库性能有很大帮助;你还需要告诉MysqL添加的新内存.

那么,该怎么做?在MysqL的情况下,它有点棘手,因为MysqL支持多个存储引擎.您可能正在使用InnoDB,但也可能使用MyISAM,甚至可以将两者混合用于不同的表.不幸的是,在不知道哪些表使用什么存储引擎,以及(如果有混合)查询大小和卷的情况下,很难准确地告知如何更改MysqL配置.

猜你在找的Linux相关文章