环球热点评!Linux下Tomcat8如何修改JVM内存配置

2023-04-16 06:07:12   来源:脚本之家


【资料图】

目录
Tomcat8如何修改JVM内存配置所以如果我们想要修改jvm的内存配置设置之后在Tomcat启动总结

Tomcat8如何修改JVM内存配置

Tomcat并不建议直接在catalina.sh里配置变量,而是写在与catalina同级目录(bin目录)下的setenv.sh里。

所以如果我们想要修改jvm的内存配置

那么我们就需要修改setenv.sh文件(默认没有,需新建一个setenv.sh),写入(大小根据自己情况修改):

export CATALINA_OPTS="$CATALINA_OPTS -Xms1000m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx1000m"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=256m"

设置之后在Tomcat启动

你会发现:

cation directory [/usr/local/apache-tomcat-8.5.33/webapps/manager] has finished in [11] ms
06-Sep-2018 14:18:17.690 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8088"]
06-Sep-2018 14:18:17.702 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
06-Sep-2018 14:18:17.707 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 10577 ms
[INFO] Working directory is /usr/local/apache-tomcat-8.5.33
[INFO] War root is /usr/local/apache-tomcat-8.5.33/webapps/cat
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
06-Sep-2018 14:55:15.068 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.5.33
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Aug 12 2018 08:20:08 UTC
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.5.33.0
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.10.0-229.el7.x86_64
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/local/jdk1.8.0_171/jre
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_171-b11
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /usr/local/apache-tomcat-8.5.33
06-Sep-2018 14:55:15.073 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /usr/local/apache-tomcat-8.5.33
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/apache-tomcat-8.5.33/conf/logging.properties
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms1000m
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx1000m
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -XX:MaxPermSize=256m
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
06-Sep-2018 14:55:15.074 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/apache-tomcat-8.5.33
06-Sep-2018 14:55:15.075 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/apache-tomcat-8.5.33
06-Sep-2018 14:55:15.075 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/apache-tomcat-8.5.33/temp
06-Sep-2018 14:55:15.075 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
06-Sep-2018 14:55:15.236 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8088"]
06-Sep-2018 14:55:15.248 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
06-Sep-2018 14:55:15.255 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
06-Sep-2018 14:55:15.257 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
06-Sep-2018 14:55:15.259 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 602 ms
06-Sep-2018 14:55:15.302 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
06-Sep-2018 14:55:15.302 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.33
06-Sep-2018 14:55:15.327 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/apache-tomcat-8.5.33/webapps/cat.war]
06-Sep-2018 14:55:18.042 信息 [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
06-Sep-2018 14:55:33.944 警告 [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [15,876] milliseconds.
Logger file /data/applogs/cat/cat_20180906.log

[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/apache-tomcat-8.5.33
Using CATALINA_HOME: /usr/local/apache-tomcat-8.5.33
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.33/temp
Using JRE_HOME: /usr/local/jdk1.8.0_171/jre
Using CLASSPATH: /usr/local/apache-tomcat-8.5.33/bin/bootstrap.jar:/usr/local/apache-tomcat-8.5.33/bin/tomcat-juli.jar
Tomcat started.
[root@localhost bin]# uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost bin]#

参考:How to Change JVM Heap Setting (-Xms -Xmx) of Tomcat – Configure setenv.sh file – Run catalina.sh

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

标签:

X 关闭

X 关闭