Linux下Tomcat8如何修改JVM内存配置

吾爱主题 阅读:163 2024-04-05 15:07:23 评论:0

Tomcat8如何修改JVM内存配置

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

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

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

?
1 2 3 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

总结

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

原文链接:https://kubernetes.blog.csdn.net/article/details/82462014

可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

【腾讯云】云服务器产品特惠热卖中
搜索
标签列表
    关注我们

    了解等多精彩内容