Windows安装tomcat,以服务的方式管理,如何设置虚拟内存

之前工作中,部署tomcat都是使用Linux服务器,最近遇到个客户,提供的服务器是Windows server,并且需要通过服务的方式管理tomcat;以自己多年的码农经验,感觉应该没有问题,结果啪啪打脸了,遇到的核心问题是配置的虚拟内存没有生效,最终还是解决了,以下问解决方案:

1、环境及软件

Windows server 2016 Datacenter、jdk=1.8.0_181、apache-tomcat-8.5.59-windows-x64.zip

2、配置虚拟内存

jdk安装及环境配置变量、tomcat解压及配置环境变量,这就不过多描述,详细请自行百度。

2.1、使用startup.bat启动

修改bin\catalina.bat文件,在最上面添加这样一句:

set JAVA_OPTS=-Xms256m -Xmx512m

bash 复制代码
@echo off

set JAVA_OPTS=-Xms256m -Xmx512m

rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

启动tomcat,有如下信息,说明虚拟内存设置成功。

2.2、使用服务的方式启动

首先、将tomcat安装成系统服务,打开cmd,使用超级管理员权限,执行命令:service.bat install

打开系统服务,可以看到已经注册成功的tomcat服务

启动服务,并查看日志(位置:logs\catalina.2024-03-26.log)

通过日志发现,我们在catalina.bat文件中,配置的虚拟内存没有生效;解决方案,打开bin\tomcat8w.exe程序(前提条件,必须将tomcat注册成系统服务)

将默认的最小和最大内存调整成256和512,然后重启服务,并查看日志

到这里,核心问题就解决了

相关推荐
tumeng0711几秒前
Spring详解
java·后端·spring
深邃-8 分钟前
【Web安全】-基础环境安装:虚拟机安装,JDK环境安装(1)
java·开发语言·计算机网络·安全·web安全·网络安全·安全架构
小雅痞9 分钟前
[Java][Leetcode hard] 135. 分发糖果
java·算法·leetcode
jwt79392793714 分钟前
Spring之DataSource配置
java·后端·spring
逻辑驱动的ken23 分钟前
Java高频面试场景题07
java·开发语言·面试·职场和发展·求职招聘·春招
slarymusic28 分钟前
解决报错net.sf.jsqlparser.statement.select.SelectBody
java
callJJ30 分钟前
JVM 内存区域划分详解——从生活比喻到运行时数据区全景图
java·jvm·面试·内存区域划分
小江的记录本33 分钟前
【网络安全】《网络安全与数据安全核心知识体系》(包括数据脱敏、数据加密、隐私合规、等保2.0)
java·网络·后端·python·算法·安全·web安全
北漂Zachary34 分钟前
PHP vs Python vs Java:三大编程语言终极对比
java·python·php
Paxon Zhang36 分钟前
JavaEE初阶学习web开发的第一步**计算机组成原理,操作系统,进程(基础扫盲)**
java·后端·学习·java-ee