java 在 CentOS 6 中 JVM 总是超过 100% CPU 使用率

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11283271/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 04:31:15  来源:igfitidea点击:

JVM always beyond 100% CPU usage in CentOS 6

javajvmcentoscpu-usagecentos6

提问by Protected

Good afternoon. I'm having a really baffling issue with the Java VM on my CentOS 6 (64bit) server. It's a server with a quad-core CPU (with hyperthreading), 16GB of RAM and 2TB hard drive space (on software RAID1). I figured I'd ask here because, according to the FAQ, questions about "common tools" used by developers are appropriate. Hopefully someone can shed some light on the issue.

下午好。我的 CentOS 6(64 位)服务器上的 Java VM 遇到了一个非常令人困惑的问题。这是一个带有四核 CPU(带超线程)、16GB RAM 和 2TB 硬盘空间(在软件 RAID1 上)的服务器。我想我会在这里问,因为根据常见问题解答,关于开发人员使用的“常用工具”的问题是合适的。希望有人可以对这个问题有所了解。

I run a piece of Java software on the server, 24h/day. Earlier today (detected a few hours after midnight on the server's locale, which is notable because it's the first day of the month) I received reports by users connecting to this software as clients about it suddenly having become unusable. The JVM was never interrupted or restarted. It had been last restarted only a few days ago, and it had been running normally since then (using about 5% or less CPU, which is normal).

我每天 24 小时在服务器上运行一个 Java 软件。今天早些时候(在服务器的语言环境午夜后几个小时检测到,这是值得注意的,因为这是一个月的第一天)我收到了用户作为客户端连接到该软件的报告,关于它突然变得无法使用。JVM 从未中断或重新启动。上次重启也是几天前,从那以后一直正常运行(CPU使用率在5%左右,属于正常)。

This time, when I checked the process, it was essentially gobbling up all the CPU time it could wrestle from the other applications running on the server (as reported by top), or, way over 100% (as reported by ps). I tried stopping and restarting the application, but as soon as it was running, CPU usage would immediately shoot up to above 100% again. Memory usage is normal. I experimented with different JVM flags, to no avail. I tried downloading the latest version of the software and making a fresh install, but this didn't help either. Finally, I tried downloading another, completely distinct piece of Java software, but when I ran it on the server, it suffered from the same problem.

这一次,当我检查该进程时,它基本上吞噬了它可以从服务器上运行的其他应用程序中获取的所有 CPU 时间(由 top 报告),或者超过 100%(由 ps 报告)。我尝试停止并重新启动应用程序,但一旦它运行,CPU 使用率会立即再次飙升至 100% 以上。内存使用正常。我尝试了不同的 JVM 标志,但无济于事。我尝试下载最新版本的软件并进行全新安装,但这也无济于事。最后,我尝试下载另一个完全不同的 Java 软件,但是当我在服务器上运行它时,它遇到了同样的问题。

When I downloaded the software and ran it on my computer, CPU usage was normal. Therefore, I am assuming is wrong in the server, but I can't imagine what it could possibly be. The server's JVM is up to date, from a standard, repository package (no customization whatsoever).

当我下载软件并在我的计算机上运行它时,CPU使用率是正常的。因此,我假设服务器是错误的,但我无法想象它可能是什么。服务器的 JVM 是最新的,来自标准的存储库包(没有任何定制)。

From java -version:

从 java -version:

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.3) (rhel-1.48.1.11.3.el6_2-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

From uname -a:

来自 uname -a:

2.6.32-131.21.1.el6.x86_64 #1 SMP Tue Nov 22 19:48:09 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux

From centos-release/redhat-release/system-release:

来自 centos-release/redhat-release/system-release:

CentOS release 6.2 (Final)

free reports about 14.5gb free RAM. df reports about 1.4tb free disk space in the /home partition (where the software in question and all their files were located).

免费报告有关 14.5GB 可用 RAM。df 报告 /home 分区(有问题的软件及其所有文件所在的位置)中有大约 1.4tb 的可用磁盘空间。

Any ideas? Please ask if you need more data, and feel free to suggest procedures for me to try out/check. When looking up the problem, I found several instances of people having trouble with JVM stealing all the CPU on CentOS, but none of them seemed to match my problem.

有任何想法吗?请询问您是否需要更多数据,并随时建议我尝试/检查的程序。在查找问题时,我发现有几个人在使用 JVM 窃取 CentOS 上的所有 CPU 时遇到问题,但似乎没有一个与我的问题相符。

回答by kc0

You probably want to try the following commands

您可能想尝试以下命令

# service ntpd stop; date -s "`date`";service ntpd start;

I have CentOS6 with kernel 2.6.32-220.el6.x86_64 and jdk1.7.0_04, high CPU was observed and resolved by above command. no need of restart OS.

我有内核为 2.6.32-220.el6.x86_64 和 jdk1.7.0_04 的 CentOS6,通过上述命令观察并解决了高 CPU。无需重新启动操作系统。

This appears to be a bug with the linux kernel as described at https://access.redhat.com/knowledge/solutions/154793. The above fix is described at http://blog.wpkg.org/2012/07/01/java-leap-second-bug-30-june-1-july-2012-fix/

这似乎是 linux 内核的一个错误,如https://access.redhat.com/knowledge/solutions/154793 所述。上述修复在http://blog.wpkg.org/2012/07/01/java-leap-second-bug-30-june-1-july-2012-fix/ 中有所描述

回答by metaforge

I can also confirm the issue present in RHEL 6, Tomcat 7, and Sun/Oracle Java 7 & Java 6.

我还可以确认 RHEL 6、Tomcat 7 和 Sun/Oracle Java 7 & Java 6 中存在的问题。

ntpd stop; date; ntpd startcommand worked.

ntpd stop; date; ntpd start命令有效。

uname:
2.6.32-220.2.1.el6.x86_64 #1 SMP Fri Dec 23 02:21:33 CST 2011 x86_64 x86_64 x86_64 GNU/Linux

回答by dbcooper

I can confirm this issue is present on Fedora 14, Tomcat 6 and OpenJDK 1.6. Mysticial's solution worked for me as well.

我可以确认这个问题存在于 Fedora 14、Tomcat 6 和 OpenJDK 1.6。Mysticial 的解决方案也适用于我。

uname -ar:

uname -ar:

2.6.35.14-103.fc14.x86_64 #1 SMP Thu Oct 27 15:41:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

java -version:

java - 版本:

java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.10) (fedora-55.1.9.10.fc14-x86_64)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)