Search code examples
javatomcattomcat7catalinaamazon-linux

Confusion over where to set CATALINA_OPTS for tomcat7 on amazon Linux


I've got a working tomcat application on an Amazon Linux EC2 and I've noticed some heap space issues recently. I wanted to try to modify the memory issues but I've discovered that this tomcat setup doesn't seem to have things where expected. I can't find catalina.sh, so I tried getting details using this:

ps aux | grep tomcat and got the following:

tomcat   17305  1.0 15.3 3636764 618456 ?      Sl   13:25   0:31 /usr/lib/jvm/jre/bin/java -classpath :/usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat7 -Dcatalina.home=/usr/share/tomcat7 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat7/temp -Djava.util.logging.config.file=/usr/share/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start ec2-user 17566  0.0  0.0 110520  2152 pts/0    R+   14:13   0:00 grep --color=auto tomcat

In the /usr/share/tomcat7/bin directory I only have bootstrap.jar, catalina-tasks-xml and tomcat-juli.jar

I've tried creating a setenv.sh with export CATALINA_OPTS="-Xms512M -Xmx1024" but I'm not sure this is being picked up and unsure how best to check without trying to hammer the app.

Would rally appreciate some help on A) where are all my normally expected tomcat files and B) how to set CATALINA_OPTS if this is a known setup.


Solution

  • You can update the JVM configurations in /etc/default/tomcat7 file

    JAVA_OPTS="-Djava.awt.headless=true -Xmx1280m -XX:+UseConcMarkSweepGC"
    

    After changing the configuration restart the tomcat and check the memory configuration by doing grep on java