故障处理
下面列出常见的故障以及应对方案
HTTP 502 故障
502 Bad Gateway
常见在LNMP上或者使用Nginx/Apache做反向代理;
故障定位:
处理方法:
LNMP 重启PHP-FPM 运行命令
systemctl restart php-fpm
重启被代理的程序
HTTP 403 故障
403 Forbidden
故障定位:
处理方法:
检查网站目录用户和用户组是否正确目录权限,文件权限是否正确.网站目录用户和组一般为
apache
/nginx
/www
文件权限一般为640
文件夹权限为750
; 运行命令chown apache:apache -R /data/wwwroot
将/data/wwwroot
目录下所有的文件和文件夹设置用户和组为apache
; 运行命令find /data/wwwroot -type d -exec chmod 750 {} \;
和find /data/wwwroot -not -type d -exec chmod 640 {} \;
设置/data/wwwroot
目录下文件夹权限750
文件权限640
检查站点的配置文件,是否做了访问控制
apache
检查站点配置文件中是否存在Require all denied
Require host
Require ip
Require not ip
等配置,Require all granted
设置允许所有访问请求Nginx
检查站点配置文件中是否存在deny all
deny xxx.xxx.xxx.xxx
(xxx.xxx.xxx.xxx
为IP地址),如果需要访问请删掉这些参数
检查服务器上Apache是否安装有
mod_evasive
模块,卸载yum remove -y mod_evasive
HTTP 404 故障
404 Not Found
故障定位:
处理方法:
检查网站的路径或文件名是否正确,输入正确的路径
检查伪静态规则,正确设置伪静态规则
HTTP 500 故障
500 HTTP-Internal Server Error
故障定位:
处理方法:
检查数据库服务器是否正常 运行命令
netstat -anopt | grep 3306
检查MySQL
是否运行,没有运行的话systemctl start mysqld
启动MySQL检查数据库连接文件,数据库用户名/密码/数据库名称/host地址是否有误
检查伪静态规则,或关闭伪静态
网站/服务器访问速度慢,卡
故障定位:
服务器配置过低/服务器宽带低
DDOS攻击故障检测:查看监控网卡流量,网络延迟/丢包,数据包个数/s 检查参考
CC攻击故障故障检测: 查看监控网卡流量,Nginx 连接状态,CPU 负载
看所有80端口的连接数
netstat -nat|grep -i "80"|wc -l
对连接的IP按连接数量进行排序
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
查看TCP连接状态
netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
netstat -n | awk '/^tcp/ {++S[$NF]};END {for(a in S) print a, S[a]}'
netstat -n | awk '/^tcp/ {++state[$NF]}; END {for(key in state) print key,"\t",state[key]}'
netstat -n | awk '/^tcp/ {++arr[$NF]};END {for(k in arr) print k,"\t",arr[k]}'
netstat -n |awk '/^tcp/ {print $NF}'|sort|uniq -c|sort -rn
netstat -ant | awk '{print $NF}' | grep -v '[a-z]' | sort | uniq -c
查看80端口连接数最多的20个IP
netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
netstat -ant |awk '/:80/{split($5,ip,":");++A[ip[1]]}END{for(i in A) print A,i}' |sort -rn|head -n20
查找较多time_wait连接
netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
查找较多的SYN连接
netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | more
Last updated