`
ssxxjjii
  • 浏览: 950371 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

tomcat jvm优化设置

 
阅读更多

tomcat实例CATALINA_BASE/bin下的setenv.sh文件中设置

export CATALINA_OPTS="$CATALINA_OPTS -Xms1024m"

export CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m"

export CATALINA_OPTS="$CATALINA_OPTS -Xmn128m"

export CATALINA_OPTS="$CATALINA_OPTS -XX:PermSize=128m"

export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=128m"

export CATALINA_OPTS="$CATALINA_OPTS -server"

export CATALINA_OPTS="$CATALINA_OPTS -Dfile.encoding=UTF8"

export CATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=true"

echo "Using CATALINA_OPTS:$CATALINA_OPTS"

 

tomcat服务器端jvm优化设置

可以在对应tomcat实例CATALINA_BASE/bin下的setenv.sh文件中设置,如果没有该文件先创建该脚本文件

然后在其中设置jvm的优化参数。

http://doc.cloveretl.com/documentation/UserGuide/index.jsp?topic=/com.cloveretl.server.docs/docs/tomcat.html

如:

  • It is strongly recommended you change default limits for the heap and perm gen memory spaces.

    See section the section called “Memory Settings” for details.

    You can set the minimum and maximum memory heap size by adjusting the "Xms" and "Xmx" JVM parameters. You can set JVM parameters for Tomcat by setting the environment variable JAVA_OPTS in the [TOMCAT_HOME]/bin/setenv.sh file (if it does not exist, you may create it).

    Create setenv file:

    Unix-like systems: [tomcat]/bin/setenv.sh

    export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=512m -Xms128m -Xmx1024m" 
    export CATALINA_OPTS="$CATALINA_OPTS -Dderby.system.home=$CATALINA_HOME/temp -server"
    echo "Using CATALINA_OPTS: $CATALINA_OPTS"
    

    Windows systems: [tomcat]/bin/setenv.bat

    set "CATALINA_OPTS=%CATALINA_OPTS% -XX:MaxPermSize=512m -Xms128m -Xmx1024m" 
    set "CATALINA_OPTS=%CATALINA_OPTS% -Dderby.system.home=%CATALINA_HOME%/temp -server"
    echo "Using CATALINA_OPTS: %CATALINA_OPTS%"
    

     

    As visible in the settings above, there is also switch -server. For performance reasons, it is recommended to run the container in the "server" mode.

示例2:

https://gist.github.com/terrancesnyder/986029

#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
 
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
# and enterprise use with large-scale deployments.
 
# Credits:
# Google -> Couldn't survive without it
# Stackoverflow.com -> Community support
# SpringSource -> Specifically best-practices and seminars (Expert Series)
 
# Based On:
# http://www.springsource.com/files/uploads/tomcat/tomcatx-performance-tuning.pdf
# http://www.springsource.com/files/u1/PerformanceTuningApacheTomcat-Part2.pdf
# http://www.springsource.com/files/uploads/tomcat/tomcatx-large-scale-deployments.pdf
 
# Created By: Terrance A. Snyder
# URL: http://www.terranceasnyder.com, http://shutupandcode.net
 
# Best Practice Documentation:
# http://terranceasnyder.com/2011/05/tomcat-best-practices/
 
# Looking for the latest version?
# github @ https://github.com/terrancesnyder
 
# ==================================================================
 
# discourage address map swapping by setting Xms and Xmx to the same value
# http://confluence.atlassian.com/display/DOC/Garbage+Collector+Performance+Issues
export CATALINA_OPTS="$CATALINA_OPTS -Xms64m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx512m"
 
# Increase maximum perm size for web base applications to 4x the default amount
# http://wiki.apache.org/tomcat/FAQ/Memoryhttp://wiki.apache.org/tomcat/FAQ/Memory
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=256m"
 
# Reset the default stack size for threads to a lower value (by 1/10th original)
# By default this can be anywhere between 512k -> 1024k depending on x32 or x64
# bit Java version.
# http://www.springsource.com/files/uploads/tomcat/tomcatx-large-scale-deployments.pdf
# http://www.oracle.com/technetwork/java/hotspotfaq-138619.html
export CATALINA_OPTS="$CATALINA_OPTS -Xss192k"
 
# Oracle Java as default, uses the serial garbage collector on the
# Full Tenured heap. The Young space is collected in parallel, but the
# Tenured is not. This means that at a time of load if a full collection
# event occurs, since the event is a 'stop-the-world' serial event then
# all application threads other than the garbage collector thread are
# taken off the CPU. This can have severe consequences if requests continue
# to accrue during these 'outage' periods. (specifically webservices, webapps)
# [Also enables adaptive sizing automatically]
export CATALINA_OPTS="$CATALINA_OPTS -XX:+UseParallelGC"
 
# This is interpreted as a hint to the garbage collector that pause times
# of <nnn> milliseconds or less are desired. The garbage collector will
# adjust the Java heap size and other garbage collection related parameters
# in an attempt to keep garbage collection pauses shorter than <nnn> milliseconds.
# http://java.sun.com/docs/hotspot/gc5.0/ergo5.html
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxGCPauseMillis=1500"
 
# A hint to the virtual machine that it.s desirable that not more than:
# 1 / (1 + GCTimeRation) of the application execution time be spent in
# the garbage collector.
# http://themindstorms.wordpress.com/2009/01/21/advanced-jvm-tuning-for-low-pause/
export CATALINA_OPTS="$CATALINA_OPTS -XX:GCTimeRatio=9"
 
# The hotspot server JVM has specific code-path optimizations
# which yield an approximate 10% gain over the client version.
export CATALINA_OPTS="$CATALINA_OPTS -server"
 
# Disable remote (distributed) garbage collection by Java clients
# and remove ability for applications to call explicit GC collection
export CATALINA_OPTS="$CATALINA_OPTS -XX:+DisableExplicitGC"
 
# Check for application specific parameters at startup
if [ -r "$CATALINA_BASE/bin/appenv.sh" ]; then
. "$CATALINA_BASE/bin/appenv.sh"
fi
 
echo "Using CATALINA_OPTS:"
for arg in $CATALINA_OPTS
do
echo ">> " $arg
done
echo ""
 
echo "Using JAVA_OPTS:"
for arg in $JAVA_OPTS
do
echo ">> " $arg
done
echo "_______________________________________________"
echo ""
分享到:
评论

相关推荐

    Tomcat JVM内存设置方法

    ### Tomcat JVM内存设置方法详解 #### 一、前言 Tomcat作为一款广泛使用的Java应用服务器,其性能优化一直是开发者关注的重点之一。而在性能优化的过程中,合理设置JVM(Java Virtual Machine)内存是非常关键的一...

    Tomcat JVM的参数调优

    【标题】"Tomcat JVM参数调优"涉及的是在运行Apache Tomcat服务器时优化Java虚拟机(JVM)性能的过程。Tomcat是一个流行的开源Java应用服务器,它用于部署和运行Java Servlets和JavaServer Pages(JSP)。由于JVM是...

    eclipse与tomcat的JVM设置

    ### Eclipse与Tomcat的JVM设置详解 #### 一、引言 在开发Java应用程序时,经常需要使用集成开发环境(IDE)与应用服务器进行配合。Eclipse是一款非常流行的Java IDE,而Tomcat则作为轻量级的应用服务器被广泛采用...

    tomcat6.0 修改启动内存设置 java jvm参数配置

    ### Tomcat 6.0 修改启动内存设置及 Java JVM 参数配置详解 #### 一、背景与目的 在部署和运行 Java Web 应用时,合理地配置应用服务器(如 Apache Tomcat)的内存是非常重要的。这不仅可以提升应用程序的性能,还...

    ECLIPSE,TOMCAT,JVM内存设置

    标题 "ECLIPSE,TOMCAT,JVM内存设置" 涉及到的是在开发Java Web应用程序时,如何配置Eclipse集成开发环境(IDE)、Apache Tomcat服务器以及Java虚拟机(JVM)的内存参数,以优化性能和避免内存溢出等问题。...

    关于tomcat乱码以及tomcat jvm 内存溢出问题的解决方案和理论

    标题中的“关于tomcat乱码以及...综上所述,解决Tomcat的乱码问题需要正确配置字符编码,而处理JVM内存溢出则需优化内存分配和垃圾收集策略。对于MySQL的配置,理解`my.cnf`文件的内容对于数据库的高效运行也至关重要。

    eclipse中对jvm进行设置

    在Eclipse这样的集成开发环境中,对Java虚拟机(JVM)进行设置是非常关键的,因为它直接影响到应用程序的性能和稳定性。Eclipse中的JVM内存设置涉及到多个参数,这些参数用于控制JVM如何分配和管理内存资源。以下是...

    Tomcat JVM内存优化(Linux环境)

    ### Tomcat JVM内存优化(Linux环境) 在Linux环境下运行Tomcat服务器时,经常会遇到与Java虚拟机(JVM)相关的内存溢出问题。这些问题通常表现为`java.lang.OutOfMemoryError`异常,具体又分为两类:`PermGen ...

    tomcat7安装使用及jvm连接数参数调优

    Tomcat7 安装使用及 JVM 连接数参数调优 Tomcat7 是一个流行的 Java Web 服务器,主要用于部署和管理基于 Java 的 Web 应用程序。为了确保 Tomcat7 的稳定运行和高效性能,需要对其进行合理的安装、配置和优化。...

    java缓存代码,tomcat JVM配置

    其次,Tomcat JVM配置对于优化Web应用性能至关重要。JVM(Java Virtual Machine)是Java程序运行的环境,其配置直接影响到应用的启动速度、运行效率和稳定性。在`tomcat连接池设定.docx`文档中,可能包含以下几方面...

    java虚拟机jvm及Tomcat中的jvm有关内存的设置与调优

    以下是在Tomcat环境中优化JVM内存的具体步骤: 1. **环境变量设置**:通过设置`CATALINA_OPTS`环境变量,可以在系统级别全局地调整Tomcat中JVM的内存参数。 2. **编辑catalina.bat**:在Tomcat的bin目录下,直接...

    设置tomcat的jvm虚拟机大小

    设置 Tomcat 的 JVM 虚拟机大小 ...9. Tomcat 优化:Tomcat 的优化可以通过设置连接器参数、JVM 的内存大小和垃圾回收机制来实现。此外,还可以通过调整堆的大小、垃圾回收机制和连接器参数来优化 Tomcat 的性能。

    tomcat-jvm优化

    ### Tomcat-JVM优化策略详解 #### 一、理解Tomcat与JVM的关系 Tomcat作为一款开源的Servlet容器,其运行依赖于JVM(Java虚拟机)。这意味着,要优化Tomcat的性能,首先需要对JVM进行合理的配置。本文将深入探讨...

    tomcat jvm内存修改

    ### Tomcat JVM 内存调整方法与原理 #### 一、背景介绍 在日常的运维工作中,经常会遇到 Tomcat 应用服务器出现内存溢出的问题,表现为 `java.lang.OutOfMemoryError` 异常。这类问题通常是由于 JVM(Java 虚拟机...

    Tomcat JVM调优-TomcatJVM.zip

    然而,为了确保应用的高性能和稳定性,对Tomcat的JVM进行优化是必不可少的环节。本文将深入探讨Tomcat JVM调优的关键技术和实践策略。 一、理解JVM Java虚拟机(JVM)是Java程序运行的基础,它负责执行字节码、...

    JVM优化3(Tomcat参数调优,JVM参数调优,jvm字节码,代码优化).pdf

    本篇文件内容主要介绍了JVM优化的第三部分,重点围绕Tomcat参数调优、JVM参数调优、JVM字节码优化以及代码优化等几个方面。下面是针对这些知识点的详细解释: 1. Tomcat参数调优 在Tomcat参数调优部分,首先介绍了...

    如何设置Tomcat的JVM虚拟机内存大小

    Tomcat JVM 虚拟机内存设置 在讨论 Tomcat JVM 虚拟机内存设置前,需要了解 Tomcat 的运行机制。Tomcat 本身不能直接在计算机上运行,需要依赖于硬件基础之上的操作系统和一个 Java 虚拟机。用户可以选择自己的操作...

    Tomcat 55 Tomcat 6 安装64 JVM

    此外,为了优化性能,你可能还需要调整Tomcat的内存设置。在Tomcat 55和Tomcat 6中,这可以通过修改`bin/catalina.bat`或`bin/setenv.bat`文件来实现。添加或修改以下行,根据你的物理内存大小设定合适的值: ```...

    Tomcat性能优化及JVM内存工作原理

    Tomcat性能优化及JVM内存工作原理 Tomcat性能优化是指通过调整Tomcat服务器的配置和JVM的参数,以提高Tomcat服务器的性能和响应速度。Tomcat性能优化主要包括代码层优化、JVM内存优化和应用配置优化三方面。 代码...

Global site tag (gtag.js) - Google Analytics