How to tune Tomcat 5.5 JVM Memory settings without

2019-01-03 09:48发布

I need to configure Tomcat memory settings as part of a larger installation, so manually configuring tomcat with the configuration app after the fact is out of the question. I thought I could just throw the JVM memory settings into the JAVA_OPTS environment variable, but I'm testing that with jconsole to see if it works and it... doesn't.

As per the comment below, CATALINA_OPTS doesn't work either. So far, the only way I can get it to work is via the Tomcat configuration GUI, and that's not an acceptable solution for my problem.

13条回答
别忘想泡老子
2楼-- · 2019-01-03 10:11

Just edit your your catalina/bin/startup.sh script. Add the following commands in it:

#Adjust it to the size you want. Ignore the from bit.
export CATALINA_OPTS="-Xmx1024m"
#This should point to your catalina base directory 
export CATALINA_BASE=/usr/local/tomcat
#This is only used if you editing the instance of your tomcat
/usr/share/tomcat6/bin/startup.sh

Sailab: http://www.facejar.com/member/page-id-477.html

查看更多
来,给爷笑一个
3楼-- · 2019-01-03 10:12

Serhii's suggestion works and here is some more detail.

If you look in your installation's bin directory you will see catalina.sh or .bat scripts. If you look in these you will see that they run a setenv.sh or setenv.bat script respectively, if it exists, to set environment variables. The relevant environment variables are described in the comments at the top of catalina.sh/bat. To use them create, for example, a file $CATALINA_HOME/bin/setenv.sh with contents

export JAVA_OPTS="-server -Xmx512m"

For Windows you will need, in setenv.bat, something like

set JAVA_OPTS=-server -Xmx768m

Hope this helps, Glenn

查看更多
贪生不怕死
4楼-- · 2019-01-03 10:14

Not sure that it will be applicable solution for you. But the only way for monitoring tomcat memory settings as well as number of connections etc. that actually works for us is Lambda Probe.

It shows most of informations that we need for Tomcat tunning. We tested it with Tomcat 5.5 and 6.0 and it works fine despite beta status and date of last update in end of 2006.

查看更多
再贱就再见
5楼-- · 2019-01-03 10:19

Handy for linux virtual machines; Use 75% of your total system memory for Tomcat. Yay AWK.

Put at start of "{tomcat}/bin/startup.sh"

export CATALINA_OPTS="-Xmx`cat /proc/meminfo | grep MemTotal | awk '{ print $2*0.75 } '`k"
查看更多
Summer. ? 凉城
6楼-- · 2019-01-03 10:20

I use following setenv.bat contents:

==============setenv.bat============

    set JAVA_OPTS=-XX:MaxPermSize=256m -Xms256M -Xmx768M -Xdebug -Xnoagent  -Xrunjdwp:transport=dt_socket,address=7777,server=y,suspend=n %JAVA_OPTS%

====================================

It also enables debugging and sets debug port to 7777, and appends previous content of JAVA_OPTS.

查看更多
我想做一个坏孩纸
7楼-- · 2019-01-03 10:22

If you using Ubuntu 11.10 and apache-tomcat6 (installing from apt-get), you can put this configuration at /usr/share/tomcat6/bin/catalina.sh

# -----------------------------------------------------------------------------

JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1024m \
-Xmx1024m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m \
-XX:MaxPermSize=512m -XX:+DisableExplicitGC"

After that, you can check your configuration via ps -ef | grep tomcat :)

查看更多
登录 后发表回答