Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
 
在用jstack工具查看jvm线程的运行情况时出现上述错误。就是因为该进程长时间没有启停,在/tmp/hsperfdata_'username'/文件夹下的该进程文件被Linux自身的机制(tmp下面不能存放很多文件)删除,需重新启停。所以要注意/etc/cron.daily/tmpwatch改文件在生产的情况。否则出现内存泄漏,或者内存溢出时,很难排查,或者出现系统运行缓慢时,想要观察系统运行情况也没办法,再或者,想把现场保存至dump文件中,等待大神解决也不能做。
解决办法:
 
对线上服务器的java应用dump操作时发现,以下报错,不能dump。jps也获取不到java进程的pid。
# jmap -dump:file=/data/dump/jvm_en.hprof 20176
20176: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
重启后,jps可以获得该java进程的pid,jstack也可以dump线程。
而tomcat:
jdk1.6.24版本下的,jps、jstack都无法操作
jdk1.6.18版本可以执行jps、jstack。
二、原因分析
jvm运行时会生成一个目录hsperfdata_$USER($USER是启动java进程的用户),在linux中默认是/tmp。目录下会有些pid文件,存放jvm进程信息。
jps、jstack等工具读取/tmp/hsperfdata_$USER下的pid文件获取连接信息。
2.1jstack报错原因
jstack报错:Unable to open socket file。是因为这个java进程的pid文件删除了。
为什么会被删除呢?这是因为linux操作系统为了防止/tmp目录文件过多,有个删除管理机制:tmpwatch。
查看关键配置/etc/cron.daily/tmpwatch:
flags=-umc /usr/sbin/tmpwatch "$flags"
-x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix
-x /tmp/.Test-unix 240 /tmp /usr/sbin/tmpwatch "$flags" 720 /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?};
do if [ -d "$d" ]; then /usr/sbin/tmpwatch "$flags" -f 720 "$d" fi done
系统每天会用tmpwatch命令检查并删除 /tmp 下超过240小时未访问过的文件和目录。
2.2高版本jps、jstack不能工作原因
这是一个从Java 6 update 21 引入的bug sunbug 7009828,在Java 6 update 25修复。具体原因是:
jdk16_21/24开始,jvm启动时产生进程号的临时文件目录优先使用-Djava.io.tmpdir指定的目录,没有指定-Djava.io.tmpdir参数才使用/tmp/hsperfdata_$USER。
正好tomcat指定了-Djava.io.tmpdir=${tomcat_home}/tmp/。而jps、jstack从/tmp/hsperfdata_$USER目录读取不到pid信息,所以才报错。
三、解决办法
3.1 修改tmpwatch设置
排查对应的/tmp/hsperfdata_*的目录,让jvm自己来管理,保证jps,jstat等命令可用。
修改/etc/cron.daily/tmpwatch
/usr/sbin/tmpwatch "$flags" -x /tmp/hsperfdata_* -x /tmp/.X11-unix -x /tmp/.XIM-unix
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix 240 /tmp
3.2 修改tomcat配置或者升级jdk
1)修改tomcat的Djava.io.tmpdir参数,统一使用/tmp目录。
修改catalina.sh添加
CATALINA_TMPDIR=/tmp
重启tomcat
2)升级jdk到Java 6 update 25.
3.3 其他java程序重启
重启java进程,重新生成pid文件。
参考URl:
另外说明:
1、在JDK 64bit 1.7.0_01版本也出现了这个问题。
2、在CentOS6以后,/etc/cron.daily/tmpwatch有所改变
#! /bin/sh 
flags=-umc 
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \ 
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \ 
-X '/tmp/hsperfdata_*' 10d /tmp 
/usr/sbin/tmpwatch "$flags" 30d /var/tmp 
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do 
if [ -d "$d" ]; then 
/usr/sbin/tmpwatch "$flags" -f 30d "$d" 
fi 
done
上面红色字体就是新加入的。
目录/etc/cron.daily/,这个目录是每天执行一次计划任务的目录,所以说,如果设置了比一天更短的清理时间,它是不起作用的。

Unable to open socket file: target process not responding or HotSpot VM not loaded的更多相关文章

  1. jmap Unable to open socket file解决

    pid:Unable to open socket file: target process not responding or HotSport VM not loadedThe -F option ...

  2. ASP.Net Core 2.2 InProcess托管的Bug:unable to open database file

    最近把项目更新到了ASP.Net Core 2.2,发布之后发现在IIS下使用SQLite数据库不行了,报异常说不能打开数据库."unable to open database file&q ...

  3. ASP.Net Core 2.2使用SQLite数据库unable to open database file

    原文:ASP.Net Core 2.2使用SQLite数据库unable to open database file 最近把项目更新到了ASP.Net Core 2.2,发布之后发现在IIS下使用SQ ...

  4. Unable to find messages file 'cscui.dll' 问题解决

    之前在工作机器上安装VS 2015卡死,结束进程,安装失败一直无法使用,昨天下班开着电脑把VS 2015卸载了,今天早上来,以前正确的项目现在生成都报错 "Unable to find me ...

  5. Sqlite: unable to open database file

    A database connect, there updated both queries (different statement, and regardless of order), after ...

  6. 问题-FireDAC连接Sqlite3提示“unable to open database file”

    相关资料:http://www.dfwlt.com/forum.php?mod=viewthread&tid=1497&extra= 问题现象:FireDAC连接Sqlite3在开发电 ...

  7. [转]Unable to build: the file dx.jar was not loaded from the SDK folder!

    本文转自:http://www.developerbits.com/tag/unable-to-build-the-file-dx-jar-was-not-loaded-from-the-sdk-fo ...

  8. [转]Permission denied: /.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

    原文链接:http://blog.csdn.net/dyw/article/details/6612497 近日,在Apache2环境下部署Rails3应用时碰到此错误: Permission den ...

  9. PHP PDO sqlite ,Unable to Open database file的解决方法

    t.php在网站的根目录. fdy.db在inc文件夹下; t.php中sqlite路径写成相对路径 $db = new PDO('sqlite:inc/fdy.db'); 开始提示 Fatal er ...

随机推荐

  1. Unable to cast COM object of type 'Shell32.ShellClass' to interface type 'Shell32.IShellDispatch6'.

    VS 里面的Interop.Shell32.dll(1.0) 这个版本太低了,需要高版本的(我使用的是1.2.107.0) 具体下载地址  自己找吧

  2. Redis入门到高可用(四)—— Redis的五种数据结构的内部编码

    Redis的五种数据结构的内部编码

  3. vue 获取屏幕宽高 width height

    /**  * 获取屏幕宽高  */ Vue.prototype.getViewportSize = function(){   return {     width: window.innerWidt ...

  4. [django]django models最佳实战

    models class People(models.Model): name = models.CharField(max_length=30) age = models.CharField(max ...

  5. (转)Geth控制台使用及Web3.js使用实战

    在开发以太坊去中心化应用,免不了和以太坊进行交互,那就离不开Web3.Geth 控制台(REPL)实现了所有的web3 API及Admin API,使用好 Geth 就是必修课.结合Geth命令用法阅 ...

  6. maxcompute笔记

    maxcompute安装和配置 https://help.aliyun.com/document_detail/27804.html?spm=a2c4g.11174283.3.5.566a590e0P ...

  7. 【LeetCode每天一题】Median of Two Sorted Arrays(两数组中的中位数)

    There are two sorted arrays nums1 and nums2 of size m and n respectively.  Find the median of the tw ...

  8. 10.C# 构造函数

    1.构造函数 构造函数是用来初始化对象的,只能由new运算符调用.构造函数与类同名,没有返回值,不能用void修饰,可以有public和private两种修饰符,当用private修饰时外界不能访问到 ...

  9. ####### Scripts Summary #######

    Scripts Summary Version: 1.0.1 issueDate: 2017-11-11 modifiedDate: 2017-11-28 0.configuration 1.oper ...

  10. Git branch 分支与合并分支

    Git branch 分支 查看当前有哪些branch bixiaopeng@bixiaopengtekiMacBook-Pro xmrobotium$ git branch * master 新建一 ...