How to configure Tomcat 5.5 JVM memory settings without using a configuration program

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

According to the comment below, CATALINA_OPTS also does not work. So far, the only way to make it work is with the Tomcat configuration GUI, and this is not an acceptable solution for my problem.

+42
java memory tomcat jvm
Nov 13 '08 at 1:17
source share
13 answers

Sergei's suggestion works, and here are a few more details.

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

export JAVA_OPTS="-server -Xmx512m" 

For Windows, you'll need, in setenv.bat, something like

 set JAVA_OPTS=-server -Xmx768m 

Hope this helps, Glenn

+70
Dec 03 '08 at 17:34
source share

Create a setenv file. (sh | bat) in the tomcat / bin directory with the environment variables you want to change.

The Catalina script checks to see if a setenv script exists and runs it to set environment variables. Thus, you can change the settings only for one instance of tomcat and it is easier to copy it to another instance.

Perhaps your configuration application created a setenv script, which is why tomcat ignores environment variables.

+24
Nov 28 '08 at 9:11
source share

Use the CATALINA_OPTS environment CATALINA_OPTS .

+5
Nov 13 '08 at 1:20
source share

If you are using Ubuntu 11.10 and apache-tomcat6 (installation from apt-get), you can put this configuration in /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 :)

+5
Nov 21 2018-11-11T00:
source share

I use the 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 allows you to debug and sets the debug port to 7777 and adds the previous JAVA_OPTS content.

+3
Sep 06 2018-10-06T00:
source share

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

Start "{tomcat} /bin/startup.sh"

 export CATALINA_OPTS="-Xmx`cat /proc/meminfo | grep MemTotal | awk '{ print $2*0.75 } '`k" 
+3
Oct 19 2018-10-10T00:
source share

To add to the previous comment, the documentation for the command line tool to update the settings of the Tomcat service (if Tomcat works as a service on Windows). This tool updates the registry with the appropriate settings. Therefore, if you want to update the maximum memory setting for the Tomcat service, you can run it (from the tomcat / bin directory), assuming the default service name is Tomcat5:

 tomcat5 //US//Tomcat5 --JvmMx=512 
+2
Nov 18 '08 at 18:00
source share

I like the idea of ​​installing tomcat6 memory based on available server memory (this is cool because I don't need to change the setting after upgrading the hardware). Here is my (slightly advanced memory setting):

export CATALINA_OPTS = "- Xmx` `cat /proc/meminfo | grep MemTotal | awk '{ print $2*0.75 } '` k -Xms `cat /proc/meminfo | grep MemTotal | awk '{ print $2*0.75 } '` k -XX: NewSize = `cat /proc/meminfo | grep MemTotal | awk '{ print $2*0.15 } '` k -XX: NewSize = `cat /proc/meminfo | grep MemTotal | awk '{ print $2*0.15 } '` k -XX: PermSize = `cat /proc/meminfo | grep MemTotal | awk '{ print $2*0.15 } '` k -XX: PermSize = `cat /proc/meminfo | grep MemTotal | awk '{ print $2*0.15 } '` to "

Put it in: "{tomcat} /bin/startup.sh" (for example, "/ usr / share / tomcat6 / bin" for Ubuntu 10.10)

+2
Nov 13 '11 at 13:32
source share

Not sure if this will be the right solution for you. But the only way to monitor tomcat memory parameters, as well as the number of connections, etc., which really works for us, is Lambda Probe .

This shows most of the information we need to configure Tomcat. We tested it with Tomcat 5.5 and 6.0, and it works great, despite the beta status and the date of the last update at the end of 2006.

+1
Nov 13 '08 at 6:53
source share

If you started Tomcat manually (not as a service), then the CATALINA_OPTS environment variable is the way to go. If you run it as a service, the settings are likely to be stored somewhere in the registry. I have Tomcat 6 installed on my machine and I found the settings using the key HKLM\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat6\Parameters\Java .

+1
Nov 13 '08 at 7:15
source share

If you run Tomcat on Windows, you can use the neat Tomcat Monitor application that comes with Tomcat.

Go to the Java tab. At the bottom, below the Java Parameters text box, you will find 3 input fields:

  • Initial memory pool ___ MB
  • Maximum memory pool ___ MB
  • Row Stack Size _____ KB
+1
Jun 20 2018-12-12T00:
source share

Just edit your directory /bin/startup.sh script. Add the following commands to 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

0
Apr 30 2018-12-12T00:
source share

In my case, there was a file / etc / sysconfig / tomcat 5.conf overwriting all the settings in the file / etc / tomcat5 / tomcat5.conf

0
Mar 22 '16 at 18:45
source share



All Articles