简体   繁体   English

作为Windows服务运行时,如何增加Tomcat 7上的内存?

[英]How do I increase memory on Tomcat 7 when running as a Windows Service?

I am trying to run Tomcat 7 as a Windows Service (XP and Windows 7). 我正在尝试将Tomcat 7作为Windows服务(XP和Windows 7)运行。

I see places to set the -Xmx and -Xms jvm args in catalina.bat, but I'm not sure how to do it when using $CATALINA_HOME/bin/service.bat install service-name. 我在catalina.bat中看到了设置-Xmx和-Xms jvm args的地方,但是我不确定在使用$ CATALINA_HOME / bin / service.bat安装service-name时该怎么做。 I looked around but the best I could find was that I needed to update windows registry key, though I'm not sure which one to edit. 我环顾四周,但我能找到的最好的是我需要更新Windows注册表项,但我不确定要编辑哪一个。

I'm hoping there's an easier way, is there? 我希望有一种更简单的方法,是吗?

Update: I'm not using the windows installer mainly because I'm running multiple instances of tomcat on the same machine but with different ports (for reasons I'd rather not go into here). 更新:我没有使用Windows安装程序主要是因为我在同一台计算机上运行多个tomcat实例但是有不同的端口(原因我不想进入这里)。 If I can use the installer with multiple instances using different ports, then I'd like to know how, but regardless, is it possible to do increase the memory on a tomcat windows service without the UI tools that come with the installer? 如果我可以使用具有不同端口的多个实例的安装程序,那么我想知道如何在没有安装程序附带的UI工具的情况下增加tomcat windows服务上的内存,但无论如何?

Assuming that you've downloaded and installed Tomcat as Windows Service Installer exe file from the Tomcat homepage , then check the Apache feather icon in the systray (or when absent, run Monitor Tomcat from the start menu). 假设您已经从Tomcat主页下载并安装了Tomcat作为Windows Service Installer exe文件,然后检查系统托盘中的Apache feather图标(或者当缺席时,从开始菜单运行Monitor Tomcat )。 Doubleclick the feather icon and go to the Java tab. 双击羽毛图标并转到Java选项卡。 There you can configure the memory. 在那里你可以配置内存。

在此输入图像描述

Restart the service to let the changes take effect. 重新启动服务以使更改生效。

The answer to my own question is, I think, to use tomcat7.exe: 我认为,我自己的问题的答案是使用tomcat7.exe:

cd $CATALINA_HOME
.\bin\service.bat install tomcat
.\bin\tomcat7.exe //US//tomcat7 --JvmMs=512 --JvmMx=1024 --JvmSs=1024

Also, you can launch the UI tool mentioned by BalusC without the system tray or using the installer with tomcat7w.exe 此外,您可以在没有系统托盘或使用tomcat7w.exe安装程序的情况下启动BalusC提到的UI工具

.\bin\tomcat7w.exe //ES//tomcat

An additional note to this: 另外要注意的是:

Setting the --JvmXX parameters (through the UI tool or the command line) may not be enough. 设置--JvmXX参数(通过UI工具或命令行)可能还不够。 You may also need to specify the JVM memory values explicitly. 您可能还需要明确指定JVM内存值。 From the command line it may look like this: 从命令行看,它可能如下所示:

bin\tomcat7w.exe //US//tomcat7 --JavaOptions=-Xmx=1024;-Xms=512;..

Be careful not to override the other JavaOption values. 注意不要覆盖其他JavaOption值。 You can try updating bin\\service.bat or use the UI tool and append the java options (separate each value with a new line). 您可以尝试更新bin \\ service.bat或使用UI工具并附加java选项(用新行分隔每个值)。

//ES/tomcat -> This may not work if you have changed the service name during the installation. //ES/tomcat - >如果在安装过程中更改了服务名称,则可能无法使用。

Either run the command without any service name 运行没有任何服务名称的命令

.\bin\tomcat7w.exe //ES

or with exact service name 或者具有确切的服务名称

.\bin\tomcat7w.exe //ES/YourServiceName

According to catalina.sh customizations should always go into your own setenv.sh (or setenv.bat respectively) eg: 根据catalina.sh自定义应该总是进入你自己的setenv.sh(或setenv.bat),例如:

CATALINA_OPTS='-Xms512m -Xmx1024m'

My guess is that setenv.bat will also be called when starting a service.I might be wrong, though, since I'm not a windows user. 我的猜测是,在启动服务时也会调用setenv.bat。但是,我可能错了,因为我不是Windows用户。

If you are running a custom named service, you should see two executables in your Tomcat/bin directory 如果您正在运行自定义命名服务,则应在Tomcat / bin目录中看到两个可执行文件
In my case with Tomcat 8 在我的情况下与Tomcat 8

08/14/2019  10:24 PM           116,648 Tomcat-Custom.exe
08/14/2019  10:24 PM           119,720 Tomcat-Customw.exe
               2 File(s)        236,368 bytes

Running the "w" terminated executable will let you configure Xmx in the Java tab 运行“w”终止的可执行文件将允许您在Java选项卡中配置Xmx
在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM