Tomcat,jvm调优

当在Linux服务器上运行Tomcat时遇到内存不足的问题,可以通过调整Tomcat的内存配置来解决。在catalina.sh文件的第一行添加JAVA_OPTS参数,例如:JAVA_OPTS="-Xms512m -Xmx1024m -Xss1024K -XX:PermSize=512m -XX:MaxPermSize=1024m"。此外,如果Java路径不正确导致服务无法正常停止,可以在catalina.sh中设置JAVA_HOME和JRE_HOME,如:JAVA_HOME=/usr/local/bin/jdk1.6.0_33,JRE_HOME=/usr/local/bin/jdk1.6.0_33/jre。
摘要由CSDN通过智能技术生成

有时候我们在linux服务器使用tomcat的时候老出现内存不够,这个时候就需要调整tomcat的内存,修改的文件为catalina.sh

在第一行加上以下代码:

Java代码    收藏代码
  1. JAVA_OPTS="-Xms512m -Xmx1024m -Xss1024K -XX:PermSize=512m -XX:MaxPermSize=1024m"  

还有种情况是 

停止服务的时候java的路径老不对,这时候需要在catalina.sh中手工添加JAVA_HOME和JRE_HOME指定位置

代码如下:

Java代码    收藏代码
  1. JAVA_HOME=/usr/local/bin/jdk1.6.0_33  
  2. JRE_HOME=/usr/local/bin/jdk1.6.0_33/jre  

 完整的内容为:

Java代码    收藏代码
  1. #!/bin/sh  
  2.   
  3. Licensed to the Apache Software Foundation (ASF) under one or more  
  4. contributor license agreements.  See the NOTICE file distributed with  
  5. this work for additional information regarding copyright ownership.  
  6. The ASF licenses this file to You under the Apache License, Version 2.0  
  7. (the "License"); you may not use this file except in compliance with  
  8. the License.  You may obtain copy of the License at  
  9.  
  10.     http://www.apache.org/licenses/LICENSE-2.0  
  11.  
  12. Unless required by applicable law or agreed to in writing, software  
  13. distributed under the License is distributed on an "AS IS" BASIS,  
  14. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  15. See the License for the specific language governing permissions and  
  16. limitations under the License.  
  17.   
  18. -----------------------------------------------------------------------------  
  19. Control Script for the CATALINA Server  
  20.  
  21. Environment Variable Prerequisites  
  22.  
  23.   Do not set the variables in this script. Instead put them into script  
  24.   setenv.sh in CATALINA_BASE/bin to keep your customizations separate.  
  25.  
  26.   CATALINA_HOME   May point at your Catalina "build" directory.  
  27.  
  28.   CATALINA_BASE   (Optional) Base directory for resolving dynamic portions  
  29.                   of Catalina installation.  If not present, resolves to  
  30.                   the same directory that CATALINA_HOME points to.  
  31.  
  32.   CATALINA_OUT    (Optional) Full path to file where stdout and stderr  
  33.                   will be redirected.  
  34.                   Default is $CATALINA_BASE/logs/catalina.out  
  35.  
  36.   CATALINA_OPTS   (Optional) Java runtime options used when the "start" 
  37.                   "run" or "debug" command is executed.  
  38.                   Include here and not in JAVA_OPTS all options, that should  
  39.                   only be used by Tomcat itself, not by the stop process,  
  40.                   the version command etc.  
  41.                   Examples are heap size, GC logging, JMX ports etc.  
  42.  
  43.   CATALINA_TMPDIR (Optional) Directory path location of temporary directory  
  44.                   the JVM should use (java.io.tmpdir).  Defaults to  
  45.                   $CATALINA_BASE/temp.  
  46.  
  47.   JAVA_HOME       Must point at your Java Development Kit installation.  
  48.                   Required to run the with the "debug" argument.  
  49.  
  50.   JRE_HOME        Must point at your Java Runtime installation.  
  51.                   Defaults to JAVA_HOME if empty. If JRE_HOME and JAVA_HOME  
  52.                   are both set, JRE_HOME is used.  
  53.  
  54.   JAVA_OPTS       (Optional) Java runtime options used when any command  
  55.                   is executed.  
  56.                   Include here and not in CATALINA_OPTS all options, that  
  57.                   should be used by Tomcat and also by the stop process,  
  58.                   the version command etc.  
  59.                   Most options should go into CATALINA_OPTS.  
  60.  
  61.   JAVA_ENDORSED_DIRS (Optional) Lists of of colon separated directories  
  62.                   containing some jars in order to allow replacement of APIs  
  63.                   created outside of the JCP (i.e. DOM and SAX from W3C).  
  64.                   It can also be used to update the XML parser implementation.  
  65.                   Defaults to $CATALINA_HOME/endorsed.  
  66.  
  67.   JPDA_TRANSPORT  (Optional) JPDA transport used when the "jpda start"  
  68.                   command is executed. The default is "dt_socket" 
  69.  
  70.   JPDA_ADDRESS    (Optional) Java runtime options used when the "jpda start"  
  71.                   command is executed. The default is 8000 
  72.  
  73.   JPDA_SUSPEND    (Optional) Java runtime options used when the "jpda start"  
  74.                   command is executed. Specifies whether JVM should suspend  
  75.                   execution immediately after startup. Default is "n" 
  76.  
  77.   JPDA_OPTS       (Optional) Java runtime options used when the "jpda start"  
  78.                   command is executed. If used, JPDA_TRANSPORT, JPDA_ADDRESS,  
  79.                   and JPDA_SUSPEND are ignored. Thus, all required jpda  
  80.                   options MUST be specified. The default is:  
  81.  
  82.                   -agentlib:jdwp=transport=$JPDA_TRANSPORT,  
  83.                       address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND  
  84.  
  85.   CATALINA_PID    (Optional) Path of the file which should contains the pid  
  86.                   of the catalina startup java process, when start (fork) is  
  87.                   used  
  88.  
  89.   LOGGING_CONFIG  (Optional) Override Tomcat's logging config file  
  90.                   Example (all one line)  
  91.                   LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"  
  92.  
  93.   LOGGING_MANAGER (Optional) Override Tomcat's logging manager  
  94.                   Example (all one line)  
  95.                   LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"  
  96.  
  97. $Id: catalina.sh 1498485 2013-07-01 14:37:43Z markt  
  98. -----------------------------------------------------------------------------  
  99. JAVA_OPTS="-Xms512m -Xmx1024m -Xss1024K -XX:PermSize=512m -XX:MaxPermSize=1024m"  
  100. JAVA_HOME=/usr/local/bin/jdk1.6.0_33  
  101. JRE_HOME=/usr/local/bin/jdk1.6.0_33/jre  
  102. OS specific support.  $var _must_ be set to either true or false 
  103. cygwin=false  
  104. darwin=false  
  105. os400=false  
  106. case "`uname`" in  
  107. CYGWIN*) cygwin=true;;  
  108. Darwin*) darwin=true;;  
  109. OS400*) os400=true;;  
  110. esac  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值