Tomcat 7: ¿Cómo configurar correctamente el tamaño inicial del montón?


Estaba tratando de ajustar el tamaño inicial del montón de una instancia tomcat 7 (CentOS, java-version: 1.6.0_25-b06) agregando la siguiente línea a catalina.sh:

export CATALINA_OPTS="-Xms=512M -Xmx=1024M"

El inicio de tomcat falla y registra el siguiente mensaje a catalina.fuera:

Invalid initial heap size: -Xms=512m
Could not create the Java virtual machine.

¿Qué hay de malo con estas opciones?

Author: GLA, 2011-08-01

9 answers

No debe usar =. Simplemente use esto:

export CATALINA_OPTS="-Xms512M -Xmx1024M"
 105
Author: Joachim Sauer,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-08-01 11:03:00

Utilice el siguiente comando para aumentar el tamaño del montón de java para tomcat7 (distribuciones de linux) correctamente:

echo 'export CATALINA_OPTS="-Xms512M -Xmx1024M"' > /usr/share/tomcat7/bin/setenv.sh
 25
Author: MeJ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-12-16 13:03:51

Es posible que no necesite tener exportar , simplemente agregue esta línea en catalina.sh :

CATALINA_OPTS="-Xms512M -Xmx1024M"
 10
Author: Phat H. VU,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-25 03:46:31

Setenv.sh es mejor, porque puede portar fácilmente dicha configuración de una máquina a otra, o de una versión de Tomcat a otra. catalina.sh cambia de una versión de Tomcat a otra. Pero usted puede mantener su setenv.sh sin cambios con cualquier versión de Tomcat.

Otra ventaja es que es más fácil rastrear el historial de sus cambios si lo agrega a su sistema de copia de seguridad o control de versiones. Si miras cómo setenv.sh cambios a lo largo de la historia, usted verá sólo su propia cambio. Mientras que si utiliza catalina.sh, siempre verá no solo sus cambios, sino también los cambios que vienen con cada nueva versión del Tomcat.

 3
Author: mentallurg,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-02-01 00:59:48

Tenga cuidado con el cambio en las distribuciones Debian! Traté de cambiar CATALINA_OPTS en mi Debian 7 y los resultados donde ese tomcat ya no comenzó. Así resolví este problema cambiando la propiedad JAVA_OPTS en lugar de CATALINA_OPTS, así

export JAVA_OPTS="-Xms512M -Xmx1024M"
 1
Author: Roberto Carlos Rodriguez Hidal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-20 02:59:45

Acabo de encontrar esto y he implementado la solución de Nathan:

Agregue la línea (cambiando los valores según sea necesario):

export JAVA_OPTS="-Xms512M -Xmx1024M"

A /usr/share/tomcat7/bin/setenv.sh

Si ese archivo no existe entonces crearlo y

chown root:root it
chmod 755 it

Y luego reinicie tomcat y compruébelo con

ps aux | grep logging

Que debería simplemente recoger la instancia y mostrar el parms de java

 1
Author: APA,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-21 12:21:39

Funciona incluso sin usar la palabra clave 'exportar'. Esto es lo que tengo en mi setenv.sh (/usr/share/tomcat7/bin/setenv.sh) y funciona.

OS: 14.04.1-Ubuntu Versión del servidor: Apache Tomcat / 7.0.52 (Ubuntu) Servidor construido:Jun 30 2016 01: 59: 37 Número de servidor: 7.0.52.0

JAVA_OPTS="-Dorg.apache.catalina.security.SecurityListener.UMASK=`umask` -server -Xms6G -Xmx6G -Xmn1400m -XX:HeapDumpPath=/Some/logs/ -XX:+HeapDumpOnOutOfMemoryError -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:SurvivorRatio=8 -XX:+UseCompressedOops -Dcom.sun.management.jmxremote.port=8181 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
JAVA_OPTS="$JAVA_OPTS -Dserver.name=$HOSTNAME"
 1
Author: mdev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-24 23:42:06

Vaya a"Tomcat Directory" /bin directory

Si Linux crea setenv.sh de lo contrario, si Windows crea setenv.mtd

Contenido de setenv.* archivo :

export CATALINA_OPTS="$CATALINA_OPTS -Xms512m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx8192m"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=256m"

Después de esto reinicie tomcat con nuevos parámetros.

La explicación y la información completa están aquí

Http://crunchify.com/how-to-change-jvm-heap-setting-xms-xmx-of-tomcat /

 0
Author: Musa,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-20 20:14:43

Después de pasar un buen tiempo en esto . Encontré esto es lo que el setenv.bat debe parecer . No se aceptan caracteres " en el archivo por lotes.

Set CATALINA_OPTS= - Xms512m-Xmx1024m-XX: PermSize = 128m-XX: MaxPermSize=768m

Echo hello "%CATALINA_OPTS%"

 0
Author: Dinesh Rajendran,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-01-28 07:45:51