Java 改善 JBoss 5 启动缓慢

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1927071/
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-08-13 01:30:14  来源:igfitidea点击:

Improving JBoss 5 slow startup

javajbossjboss5.x

提问by LiorH

We upgraded from JBoss 4 (and JDK 5) to JBoss 5 (and JDK 6). The problem is that the start time has gone from 1.5 minutes (on JBoss 4) to more than 4 minutes.

我们从 JBoss 4(和 JDK 5)升级到 JBoss 5(和 JDK 6)。问题是开始时间从 1.5 分钟(在 JBoss 4 上)变成了 4 多分钟。

18:53:35,444 INFO  [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221053)] Started in 3m:9s:262ms

It seems like the component that is taking JBoss the longest time to initialize is the JMX

似乎 JBoss 初始化时间最长的组件是 JMX

18:50:41,926 INFO  [LogNotificationListener] Adding notification listener for logging mbean "jboss.system:service=Logging,type=Log4jService" to server org.jboss.mx.server.MBeanServerImpl@1adc122[ defaultDomain='jboss' ]
18:52:38,797 INFO  [JMXConnectorServerService] JMX Connector server: service:jmx:rmi://lharel2/jndi/rmi://lharel2:1090/jmxconnector

From the DEBUG server log, I get these lines at the problematic time:

从调试服务器日志中,我在有问题的时间得到这些行:

2009-12-18 18:51:00,886 DEBUG [org.jboss.deployment.MappedReferenceMetaDataResolverDeployer] (main) vfsfile:/C:/QC/Views/QCDev/jboss-5.1.0.GA/server/default/deploy/jmx-console.war/ endpoint mappings:
2009-12-18 18:51:00,886 DEBUG [org.jboss.deployment.MappedReferenceMetaDataResolverDeployer] (main) Processing unit=jmx-console.war, structure: jmx-console.war
2009-12-18 18:52:35,209 DEBUG [org.jboss.deployment.OptAnnotationMetaDataDeployer] (main) Deployment is metadata-complete, skipping annotation processing, ejbJarMetaData=null, jbossWebMetaData=org.jboss.metadata.web.spec.Web23MetaData@1f, jbossClientMetaData=null, metaDataCompleteIsDefault=false

There is no EJB in the project.

项目中没有 EJB。

The memory settings are:

内存设置为:

 -Xms128m -Xmx512m -XX:MaxPermSize=256m

Do you have any idea how JBoss start time can be improved?

您知道如何改进 JBoss 启动时间吗?

Update:so far no luck, I tried shreeni's suggestion (changed the scanning xmls). The server is not running in debug mode so MicSim's suggestion is not relevant

更新:到目前为止没有运气,我尝试了 shreeni 的建议(更改了扫描 xmls)。服务器未在调试模式下运行,因此 MicSim 的建议不相关

采纳答案by mhaller

A shot into the blue sky without more information

在没有更多信息的情况下拍摄蓝天

  • Network timeouts:1,5 minutes of delay when deploying jmx-console.war may indicate a network timeout (e.g. 3 x 30 seconds). Try to start JBoss and bind it to a specific IP address using the -bcommand line argument or the jboss.bind.addresssystem property. Also, try to make sure your host and DNS resolution settings on your system are correct.

  • JMX is also using RMI and you may want to set the RMI server host name as system property. On some Linux distributions, RMI has problems with looking up the correct hostname and jmx-console.war may try to connect to the 'wrong localhost'. The system property is java.rmi.server.hostname

  • System tracing:If that does not help, you may want to use straceto start the java process, so you can see the point where the system hangs (if it really does hang due to a network timeout or similar).

  • 网络超时:部署 jmx-console.war 时的 1.5 分钟延迟可能表示网络超时(例如 3 x 30 秒)。尝试启动 JBoss 并使用-b命令行参数或jboss.bind.address系统属性将其绑定到特定的 IP 地址。此外,请尝试确保系统上的主机和 DNS 解析设置正确。

  • JMX 也使用 RMI,您可能希望将RMI 服务器主机名设置为系统属性。在某些 Linux 发行版上,RMI 在查找正确的主机名方面存在问题,并且 jmx-console.war 可能会尝试连接到“错误的本地主机”。系统属性是java.rmi.server.hostname

  • 系统跟踪:如果这没有帮助,您可能希望使用strace来启动 java 进程,这样您就可以看到系统挂起的点(如果它确实由于网络超时或类似原因而挂起)。

回答by skaffman

That is an awfully big gap in the logs. I suggest changing the log configuration to log everything at DEBUG level, rather than INFO. This will generate an awful lot more log entries, but hopefully will help you narrow it down.

这是日志中的一个非常大的差距。我建议更改日志配置以在 DEBUG 级别记录所有内容,而不是 INFO。这将生成大量的日志条目,但希望能帮助您缩小范围。

The easiest way to do this is to set the -Djboss.server.log.threshold=DEBUGsystem property when you start JBoss

最简单的方法是-Djboss.server.log.threshold=DEBUG在启动 JBoss 时设置系统属性

回答by Dani Cricco

I'm using JBoss 5.1.0 with a Macbook pro (2.26ghz 4gb) without applications it start in 54s

我在 Macbook pro (2.26ghz 4gb) 上使用 JBoss 5.1.0,没有应用程序,它在 54 秒内启动

15:00:26,449 INFO  [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 54s:720ms

I made a new configuration based on the "default". The JMS dataosurce points to a Postgres database instead of the "Hypersonic Database" (in memory database)

我根据“默认”做了一个新的配置。JMS 数据源指向 Postgres 数据库而不是“Hysonic 数据库”(内存数据库)

回答by MicSim

I suppose you are starting in debug mode. This mode can be up to 3 times slower than normal mode. But there might be also a problem when switching from JDK5 to JDK6. I found this solution hereon the net:

我想你是在调试模式下开始的。此模式最多可比正常模式慢 3 倍。但是从 JDK5 切换到 JDK6 时可能也会出现问题。我发现这个解决方案在这里在网上:

I've solved that. It's a debugging issue. I've changed my debug settings from:

wrapper.java.additional.26=-Xdebug
wrapper.java.additional.27=-Xnoagent
wrapper.java.additional.28=-Djava.compiler=NONE
wrapper.java.additional.27=-Xrunjdwp:transport=dt_socket,address=7199,server=y,suspend=n

to:

wrapper.java.additional.26=-Xdebug
wrapper.java.additional.27=-Xrunjdwp:transport=dt_socket,address=7199,server=y,suspend=n

and JBoss becomes fast again.

我已经解决了。这是一个调试问题。我已将调试设置更改为:

wrapper.java.additional.26=-Xdebug
wrapper.java.additional.27=-Xnoagent
wrapper.java.additional.28=-Djava.compiler=NONE
wrapper.java.additional.27=-Xrunjdwp:transport=dt_socket,address=7199,server=y,suspend=n

到:

wrapper.java.additional.26=-Xdebug
wrapper.java.additional.27=-Xrunjdwp:transport=dt_socket,address=7199,server=y,suspend=n

JBoss 又变快了。

Hope this helps.

希望这可以帮助。

回答by Shreeni

You could refer to this linkto avoid unnecessary annotation scanning which could speedup your server start

您可以参考此链接以避免不必要的注释扫描,这可能会加速您的服务器启动

回答by Zoran Regvart

Do you need the JMX console application? Pragmatic thing would be to un-deploy it from the server, you could still use the jconsole or jvisualvm for basically the same thing.

您需要 JMX 控制台应用程序吗?务实的做法是将它从服务器上取消部署,您仍然可以将 jconsole 或 jvisualvm 用于基本相同的事情。

回答by curious_george

Your suspicion about the jmx-console can be misleading. There may be other components doing work in the background unrelated to the jmx-console. In my experience, we had an issue where a small war file appeared to take 3 minutes to load! It was innocent. The culprit was partly due to an EAR file with many wars and jars.

您对 jmx-console 的怀疑可能会产生误导。可能有其他组件在与 jmx-console 无关的后台工作。根据我的经验,我们遇到了一个问题,一个小的 war 文件似乎需要 3 分钟才能加载!这是无辜的。罪魁祸首部分是由于一个包含许多战争和罐子的 EAR 文件。

While I'm no expert, I would suggest the following:

虽然我不是专家,但我建议如下:

  1. Try turning up the logging to TRACE. By doing this, I witnessed one of the deployers (EJBDeployer, I think) unnecessarily scanning WARs in one of our EARs. I then manually disabled the scanning of those WAR files.
  2. Run wireshark during the startup. I discovered some war files were hanging while waiting for a response from an external DTD request. Those websites were either now non-existent or would not properly serve the DTD files to java-based programs. I could speed it up by either having the programmers use local DTD files or mirroring those DTDs locally and having /etc/host loopback locally.
  1. 尝试将日志记录调至 TRACE。通过这样做,我目睹了其中一个部署者(我认为是 EJBDeployer)在我们的一个 EAR 中不必要地扫描了 WAR。然后我手动禁用了对这些 WAR 文件的扫描。
  2. 在启动期间运行wireshark。我发现一些战争文件在等待来自外部 DTD 请求的响应时挂起。这些网站要么现在不存在,要么无法将 DTD 文件正确地提供给基于 Java 的程序。我可以通过让程序员使用本地 DTD 文件或在本地镜像这些 DTD 并在本地使用 /etc/host 环回来加速它。

回答by Karma police

I had an issue like this but I found a good improvement by setting the initial and max heap size to same values, I mean:

我遇到了这样的问题,但是通过将初始和最大堆大小设置为相同的值,我发现了一个很好的改进,我的意思是:

 -Xms512m -Xmx512m

With this, I improved from 4 to 2 minutes the starting time.

有了这个,我将启动时间从 4 分钟缩短到 2 分钟。

回答by xmedeko

回答by Babu

  1. Turn off annotation scanning and other features you don't need https://community.jboss.org/wiki/jboss5xtuningslimming

  2. When you start/stop JBoss from eclipse, it does not clean up the tmp & work folders correctly. Setup an External Tool configuration and run a batch file to delete everything in tmp & work folders before each startup.

  1. 关闭注释扫描和其他不需要的功能https://community.jboss.org/wiki/jboss5xtuningslimming

  2. 当您从 Eclipse 启动/停止 JBoss 时,它不会正确清理 tmp 和工作文件夹。设置外部工具配置并运行批处理文件以在每次启动之前删除 tmp 和工作文件夹中的所有内容。

I was able to speedup running the "default" profile from 15/20 minutes to 5 minutes.

我能够将运行“默认”配置文件的时间从 15/20 分钟加速到 5 分钟。