apache服务器有时候http进程突然增长到特别大

时间:2022-10-20 21:43:50
感觉网站服务器很不正常啊,各位帮我看看,分析一下什么问题。
服务器装了apache 集成了 tomcat,还装了mysql
主要问题是:最近几个月网站服务器经常出现网站访问不了,但是能ping通的情况,
原来访问量比较少的时候大概一个月出现一次到2次,但是最近访问量比较大的时候经常一天出现好多次。通过几次查看发现,每次出现这样的情况的时候,都是http进程突然增长到很大,平时http进程大概在300左右,但是出现问题的时候服务器的http进程突然增加到很大,然后服务器反应很慢,网站打不开。遇到这种情况的时候重新启动apache就会恢复,但是有时候重起apache的时候要等很久,只能kill掉所有的http进程,然后再start apache。平常http的进程基本保持在300左右,出现问题的时候http进程会超过500,达到700多,900多,1000多,超过900的时候,ftp打不开,ssh也登不上,网站更是打不开。
查看了网站的log,连接的请求没有突然增加很多。每次出现问题的时候服务器cpu的iowait基本都在80%以上,idle基本是0-5%
原来怀疑是有人在攻击,然后装了snort和guard,做了iptables的策略。但是问题依然存在。
现在觉得要不就是有人用下载工具下载网站的图片等信息,要不就是服务器硬盘问题,要不就是apache的问题。或者是真的有人在攻击。大家帮忙分析一下是什么问题,或者谁有没有遇到这样的问题,分享一下经验。

今天更让我吃惊,http进程一下增到2700多个。
下面是top出来的信息:
top - 21:53:44 up 14 days,  4:19,  1 user,  load average: 2493.23, 2356.68, 1995.14
Tasks: 2854 total,  57 running, 2797 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.7% us, 37.7% sy,  0.0% ni,  0.0% id, 60.1% wa,  0.2% hi,  1.4% si
Mem:   2056328k total,  2033364k used,    22964k free,     2988k buffers
Swap:  4200988k total,  3541084k used,   659904k free,    16912k cached
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                
20882 daemon    16   0  146m 8060 5188 R 10.6  0.4   0:01.65 httpd                                                                  
20964 daemon    15   0  146m 8212 5164 D  9.6  0.4   0:01.13 httpd                                                                  
21846 daemon    15   0  145m 8504 5120 D  7.7  0.4   0:00.65 httpd                                                                  
21998 daemon    15   0  146m 8060 4872 D  7.3  0.4   0:01.23 httpd                                                                  
20550 daemon    15   0  145m 8556 5268 D  7.2  0.4   0:01.59 httpd                                                                  
21990 daemon    15   0  145m 8248 4872 D  6.7  0.4   0:01.42 httpd                                                                  
21589 daemon    15   0  145m 8504 5244 D  6.5  0.4   0:02.65 httpd                                                                  
23884 daemon    15   0  144m 7772 4496 D  5.9  0.4   0:00.85 httpd                                                                  
21599 daemon    15   0  147m 9.9m 5236 D  5.0  0.5   0:01.74 httpd                                                                  
21606 daemon    15   0  146m 8016 4896 D  5.0  0.4   0:00.58 httpd                                                                  
23363 daemon    15   0  144m 8236 4812 D  4.9  0.4   0:03.16 httpd                                                                  
22228 daemon    15   0  145m 8212 4876 D  4.7  0.4   0:01.98 httpd                                                                  
22082 daemon    15   0  145m 8576 5244 D  4.6  0.4   0:02.68 httpd                                                                  
23613 daemon    15   0  146m 9916 5128 D  4.6  0.5   0:02.71 httpd                                                                  
20989 daemon    15   0  145m 8696 5244 D  4.4  0.4   0:02.63 httpd                                                                  
31385 root      20   0  144m 7728 4564 R  4.2  0.4   3:32.32 httpd                                                                  
23458 daemon    15   0  146m 9780 5216 D  4.2  0.5   0:01.48 httpd                                                                  
21183 daemon    15   0  147m  10m 5248 D  3.9  0.5   0:03.40 httpd                                                                  
21933 daemon    15   0  145m 8696 5244 D  3.9  0.4   0:01.67 httpd                                                                  
  558 root      16   0  5776  652  552 D  3.4  0.0  89:31.25 portsentry                                                             
23963 daemon    15   0  144m 8280 4892 D  3.4  0.4   0:01.51 httpd                                                                  
   47 root      16   0     0    0    0 R  3.2  0.0  55:40.33 kswapd0                                                                
22074 daemon    15   0  145m 8504 5196 D  3.2  0.4   0:00.42 httpd                                                                  
24078 daemon    18   0  144m 8480 4920 R  3.2  0.4   0:00.27 httpd                                                                  
23915 daemon    15   0  144m 8704 5276 D  3.0  0.4   0:00.62 httpd                                                                  
24094 daemon    17   0  144m 8788 5292 D  3.0  0.4   0:00.51 httpd                                                                  
24517 daemon    17   0  145m 8716 4940 D  3.0  0.4   0:00.95 httpd                                                                  
24770 daemon    18   0  144m 7784 4584 R  2.9  0.4   0:00.20 httpd                                                                  
24899 daemon    18   0  144m 7912 4624 R  2.9  0.4   0:00.20 httpd                                                                  
24900 daemon    17   0  144m 7916 4624 D  2.9  0.4   0:00.20 httpd                                                                  
14025 daemon    15   0  146m 9036 5388 D  2.7  0.4   0:05.82 httpd                                                                  
22454 daemon    17   0  145m 8756 5248 R  2.7  0.4   0:00.48 httpd                                                                  
24769 daemon    17   0  144m 7864 4584 D  2.7  0.4   0:00.57 httpd

4 个解决方案

#1


看是哪个IP连的呀.BAN掉即可.

#2


mrshelly(Shelly) ,能不能详细说一下啊。不知道怎么看啊。先谢谢啊。

#3


netstat --help 

查看一下哪些IP在与你服务器连接.如果哪个IP超过30个连接的话,一般都是采集器在采集你的网站啦.

#4


刚才刚加上了防火墙iptables -I FORWARD -p tcp --syn -m limit --limit 10/s -j ACCEPT
不允许每个ip每秒的tcp连接超过10个。
等我监控一段时间,出现问题的时候再用netstate查看一下,谢谢shelly。

#1


看是哪个IP连的呀.BAN掉即可.

#2


mrshelly(Shelly) ,能不能详细说一下啊。不知道怎么看啊。先谢谢啊。

#3


netstat --help 

查看一下哪些IP在与你服务器连接.如果哪个IP超过30个连接的话,一般都是采集器在采集你的网站啦.

#4


刚才刚加上了防火墙iptables -I FORWARD -p tcp --syn -m limit --limit 10/s -j ACCEPT
不允许每个ip每秒的tcp连接超过10个。
等我监控一段时间,出现问题的时候再用netstate查看一下,谢谢shelly。