jboss启动时java VM参数设置

时间:2023-03-08 20:22:44
jboss启动时java VM参数设置

jboss服务器中jvm参数的设置:

在$JBOSS_HOME/bin下的run.sh里面存在这么一个设置:

  1. # Force IPv4 on Linux systems since IPv6 doesn't work correctly with jdk5 and lower
  2. if [ "$linux" = "true" ]; then
  3. JAVA_OPTS="-Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
  4. fi

该参数就是设置java VM的参数。我们可以在这里修改这个参数;但更一般的我们会在run.conf里面单独设置java VM的参数,而在这边进行引用。

上面的可以做如下修改

  1. # Force IPv4 on Linux systems since IPv6 doesn't work correctly with jdk5 and lower
  2. # if JAVA_OPTS is not setted in run.conf, setting  here; by djq
  3. if [ "x$JAVA_OPTS" = "x" ]; then
  4. JAVA_OPTS="-Xms128m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=36000"
  5. fi
  6. if [ "$linux" = "true" ]; then
  7. JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
  8. fi

而我们需要可以在run.conf里面单独设置java VM的参数了。(一般情况下我们也不需要在run.sh里面做任何修改,只要在run.conf里面确保该有的参数都有了就ok了)。

附:

run.conf的一个设置:

  1. ## -*- shell-script -*- ######################################################
  2. ##                                                                          ##
  3. ##  JBoss Bootstrap Script Configuration                                    ##
  4. ##                                                                          ##
  5. ##############################################################################
  6. ### $Id: run.conf 62747 2007-05-02 17:43:36Z dimitris@jboss.org $
  7. #
  8. # This file is optional; it may be removed if not needed.
  9. #
  10. #
  11. # Specify the maximum file descriptor limit, use "max" or "maximum" to use
  12. # the default, as queried by the system.
  13. #
  14. # Defaults to "maximum"
  15. #
  16. #MAX_FD="maximum"
  17. #
  18. # Specify the profiler configuration file to load.
  19. #
  20. # Default is to not load profiler configuration file.
  21. #
  22. #PROFILER=""
  23. #
  24. # Specify the location of the Java home directory.  If set then $JAVA will
  25. # be defined to $JAVA_HOME/bin/java, else $JAVA will be "java".
  26. #
  27. #JAVA_HOME="/opt/java/jdk"
  28. #set JAVA_HOME here; by djq
  29. JAVA_HOME="/jboss/jdk1.5.0_22"
  30. #
  31. # Specify the exact Java VM executable to use.
  32. #
  33. #JAVA=""
  34. #
  35. # Specify options to pass to the Java VM.
  36. #
  37. #if [ "x$JAVA_OPTS" = "x" ]; then
  38. #   JAVA_OPTS="-Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
  39. #fi
  40. # set options for the JVM; by djq
  41. if  [ "x$JAVA_OPTS" = "x" ]; then
  42. JAVA_OPTS="-Xms1024m -Xmx6120m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=36000"
  43. fi
  44. # Sample JPDA settings for remote socket debuging
  45. #JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
  46. # Sample JPDA settings for shared memory debugging
  47. #JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_shmem,server=y,suspend=n,address=jboss"