2021-07-27更新:
-----------------------------------------------------------
今天又遇到这个异常了,前端站点打不开,抛出同样的异常错误。查看连接数,只有8465个(最大连接数设置的是40960)。为了恢复网站,暂时先重启httpd服务。
service httpd start 启动
service httpd restart 重新启动
service httpd stop 停止服务
重启后,连接数降到5001个。网上找到个统计某个进程的所有打开的文件数和明细,下次出问题时,执行这个命令查看下。
#!/bin/bash if [ $# -eq 0 ] then echo "No PID specified" echo "Run command with PID, for example:" echo "lsof-script.sh 12345" exit 2 fi JAVA_PROCESS_PID=$1 lsof -p $JAVA_PROCESS_PID > lsof-output-$JAVA_PROCESS_PID.txt echo "Files open by the process:" cat lsof-output-$JAVA_PROCESS_PID.txt | wc -l echo "Generated output file with counts of grouped open files lsof-sorted-counts-$JAVA_PROCESS_PID.txt" cat lsof-output-$JAVA_PROCESS_PID.txt | awk '{print $9}' | sed -e "s/\(^.*\)\(segmentstore\).*$/\1\2/" | sed -e "s/\(^.*\)\(repository[/]index\).*$/\1\2/" | sed -e "s/\(^.*\)\(felix[/]bundle\).*$/\1\2/" | sed -e "s/\(^.*\)\([/]lib\).*$/\1\2/" | sed -e "s/\(^.*\)\([/]logs\).*$/\1\2/" | sed -e "s/\(^.*\)\([/]ext\).*$/\1\2/" | sort | uniq -c | sort -rn -k1 > lsof-sorted-counts-$JAVA_PROCESS_PID.txt echo "Total open files in OS:" lsof | wc -l