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
View Code

相关文章:

  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2021-06-29
  • 2022-01-14
  • 2021-04-11
猜你喜欢
  • 2021-07-12
  • 2022-01-17
  • 2021-11-03
  • 2022-12-23
  • 2021-09-30
  • 2022-12-23
  • 2021-09-04
相关资源
相似解决方案