设置Java / Tomcat堆大小(Xmx),而无需修改catalina.sh [英] Set Java / Tomcat heap size (Xmx) without modifying catalina.sh

查看:520
本文介绍了设置Java / Tomcat堆大小(Xmx),而无需修改catalina.sh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大多数人似乎建议通过编辑/usr/share/tomcat6/bin/catalina.sh文件并添加以下内容来设置Tomcat6的Java / Tomcat堆内存大小:

Most people seem to suggest setting the Java/Tomcat heap memory size for Tomcat6 by editing the /usr/share/tomcat6/bin/catalina.sh file, and adding something like:

# Set specific memory requirements for Tomcat6 (for server with ~512MB RAM).
CATALINA_OPTS="$CATALINA_OPTS -server -Xms128m -Xmx256m"

我正在尝试构建Ansible剧本来在Ubuntu上配置基于Tomcat的服务器,在我看来,拥有一个完整的自定义catalina.sh文件不是理想选择-Tomcat是否使用了其他一些配置文件或本地设置文件/系统, /或Java获得 Xms Xmx 值?

I am trying to build an Ansible playbook to configure a Tomcat-based server on Ubuntu, and it doesn't seem to me like having an entire custom catalina.sh file would be ideal—is there some other configuration file or local settings file/system used by Tomcat and/or Java to get the Xms and Xmx values?

或者...大多数人是否使用自定义的catalina.sh文件,而我只是从小丘上爬出来?

Or... do most people use a custom catalina.sh file, and I'm just making a mountain out of a molehill?

推荐答案

如果通过 catalina.sh脚本(直接或间接)启动,则有两个选择:

If you are launching via the "catalina.sh" script (directly or indirectly), then you have two options:


  • 根据建议修改(破解!)脚本。

  • Modify ("hack"!) the script as suggested.

查找脚本的调用位置,并确保 CATALINA_OPTS 设置为包括 -mx选项...并导出...

Find where the script is being invoked, and ensuring that CATALINA_OPTS is set to include the "-mx" option ... and exported ...

后者可能是清洁工,但是要获得该变量集并导出,这不是一种简单的,一刀切的方法。如果要将Tomcat作为服务启动,则取决于您的发行版包装Tomcat的方式。

The latter is probably "cleaner", but there is no simple, one-size-fits-all way to get that variable set and exported. If you are launching Tomcat as a service, it depends on how your distro has wrapped Tomcat.


[Am I]只是在爬山??

[Am I] just making a mountain out of a molehill?

这取决于。如果您只是在非生产平台上执行此操作,则可以。如果您试图构建一个可以继续进行软件包升级和发行版升级的生产系统,请选择否。(在后一种情况下,有必要针对您的具体情况找出最佳的方法发行版。)

It depends. If you are just doing this on a non-production platform, then Yes. If you are trying to build a production system that will continue to work over package upgrades and upgrades in your distro version, then No. (In the latter case, it is worth figuring out the best way to do this for your particular distro.)

这篇关于设置Java / Tomcat堆大小(Xmx),而无需修改catalina.sh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆