Tomcat 不一致 +设置路径的不确定性

发布于 2024-12-16 01:19:58 字数 2458 浏览 0 评论 0原文

背景

由于这是我发布的第一个问题,我会尽力将其分解,对于任何不正确的格式,我深表歉意。我还应该指出,我对 Linux、Tomcat 和 Java 都是全新的(都是在过去几周内),所以如果您确实有答案,请尽可能简化它。谢谢!

这个问题实际上是几个问题,但我觉得这些问题在某种程度上是相关的,所以我将它们全部包括在内。至于我的环境,我正在运行 EC2 Amazon Linux 实例。使用返回的详细信息 cat /proc/version 是:

  • Linux 版本 2.6.35.14-97.44.amzn1.x86_64 ([电子邮件受保护])
  • (gcc 版本 4.4.5 20110214(红帽) 4.4.5-6)(GCC)

java -version给我:

  • java版本“1.6.0_29”Java(TM)SE运行时环境(构建 1.6.0_29-b11)
  • Java HotSpot(TM) 64 位服务器虚拟机(版本 20.4-b02,混合模式)

问题 哪些

  1. 情况允许我有时停止/重新启动 Tomcat,但不能 其他的?我更改配置参数后需要重新启动 Tomcat,我使用 /etc/init.d/tomcat6 restartservice tomcat6 重新启动并取得不同程度的成功:有时是漂亮的绿色 好的,其他的红色失败了。似乎没有任何押韵或理由 为什么有时有效,有时无效。当它不起作用时我检查 service tomcat6 status 的状态,会产生一些结果 就像tomcat6(pid ####)正在运行。另外值得注意的是我的 无论何时,Putty SSH 会话都会同时显着减慢 我无法阻止 Tomcat。我真的必须等待每次击键被处理!
  2. 我无法使用任何 JVM 特定的 -XX 参数。我收到一个错误 每次无法创建 Java 虚拟机。 我读过有关此的线程,大多数围绕堆内存分配 问题,但我不认为这是我的问题,因为当我运行 java 时 -XX,它应该给我一个可用命令的列表,就像 java -X 一样,我只需得到:

    无法识别的选项:-XX 无法创建 Java 虚拟机。

我应该注意到,我在这个操作系统上至少有两个版本的 Java - 它附带了 Open JDK,但我需要 Sun Java,因为建议使用 Sun Java 来提高 Geoserver 的性能(这就是我学习所有这些的全部目的) )。我读到,只要我的 JAVA_HOME 路径指向正确的目录,拥有两个版本就不是问题,但是否有可能它仍然以某种方式查看原始配置中的某些内容?这就是我的想法,所以为了排除它,我做了一个 yum remove java,它删除了原始版本(由于依赖关系,还删除了 Tomcat,但无论如何,我可以稍后将其恢复),运行java -version 以确保我仍然拥有我想要的版本。我这样做了,然后运行 ​​java -XX,希望它在清理干净并删除不需要的 OpenJDK 后能够神奇地自行修复,但是不,与以前相同的错误。

结论

我现在假设旧路径没有问题。我还尝试在每个可以想象的位置将 JAVA_HOME 变量更改为适当的路径(/usr/java/jre1.6.0_29):

  • tomcat6.conf 中的bash_profile 中
  • 在bashrc
  • java.conf
  • (好吧,之前我删除了 Tomcat,即)
  • 可能还有其他一些文件。真的一切都很模糊。
  • 在 shell 中 export JAVA_HOME

...除了使用 export JAVA_HOME=/usr/java/jre1.6.0_29 之外,所有影响都为零。每次我运行 echo $JAVA_HOME 时,我仍然会得到原始的 JAVA_HOME 路径,我很确定这不是我想要的。即使重置变量成功(通过 shell 中的导出),我仍然收到 -XX 错误。我还尝试设置一些 JAVA_OPTS 参数,特别是内存设置,然后运行 ​​echo $JAVA_OPTS 但没有返回任何内容。

我已经在这上面花了整整两天的时间,准备放弃了。如果可能的话,我真的很想避免重新安装和重新配置一大堆东西,更不用说我什至不知道这是否能解决我的问题,但我真的非常想知道为什么我会遇到这些问题以及是否它们不相关,所以如果你们中的任何人对此有任何建议或我做错的任何事情,请告诉我。谢谢!

Background

As this is the first question I have posted, I will try to break it down as well as possible, and I apologize for any incorrect formats. I should also point out that I am brand-new to Linux, Tomcat, and Java (all within the last few weeks), so if you do have an answer please dumb it down as much as you can. Thanks!

This question is actually several questions, but I feel the issues are somehow related so I will include them all. As for my environment, I am running an EC2 Amazon Linux instance. Details returned using
cat /proc/version are:

  • Linux version 2.6.35.14-97.44.amzn1.x86_64
    ([email protected])
  • (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC)

java -version gives me:

  • java version "1.6.0_29" Java(TM) SE Runtime Environment (build
    1.6.0_29-b11)
  • Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)

Issue(s)

  1. What would allow me to stop/restart Tomcat sometimes, but not
    others? After I change configuration parameters and need to restart
    Tomcat, I use /etc/init.d/tomcat6 restart or service tomcat6
    restart
    with varying degrees of success: sometimes the nice green
    OK, others the red FAILED. There seems to be no rhyme or reason to
    why it works sometimes and not others. When it doesn't work I check
    the status with service tomcat6 status, which yields something
    like tomcat6 (pid ####) is running. Also worth noting is that my
    Putty SSH session slows down significantly at the same time whenever
    I am unable to stop Tomcat. I literally have to wait for each keystroke to be processed!
  2. I cannot use any of the JVM-specific -XX parameters. I get an error
    every time of Could not create the Java virtual machine. Of the
    threads I've read about this, most surround heap memory allocation
    issues, but I don't think that's my problem because when I run java
    -XX
    , which should give me a list of available commands just like java -X does, I simply get:

    Unrecognized option: -XX Could not create the Java virtual machine.

I should note that I had at least two versions of Java on this OS- it came with Open JDK, but I needed Sun Java as that was recommended for performance in Geoserver (which is the whole point of me learning all this). I read that it is not an issue to have two versions, as long as my JAVA_HOME path points to the correct directory, but is it possible that it was still somehow looking at something from the original configuration? That's what I thought, so to rule it out I did a yum remove java, which erased the original version (along with Tomcat due to the dependency, but whatevs, I can get it back later), ran java -version to make sure I still had the version I wanted. I did, then ran java -XX, hoping that it magically fixed itself after cleaning house with the unwanted OpenJDK removal, but NOPE, same error as before.

Conclusions

I am now assuming that there was no issue with old paths. I've also tried changing my JAVA_HOME variable to the appropriate path (/usr/java/jre1.6.0_29) in every conceivable location:

  • in bash_profile
  • in bashrc
  • java.conf
  • tomcat6.conf (well, before I deleted Tomcat, that is)
  • probably some other files. It's all a blur really.
  • export JAVA_HOME in the shell

... all with zero impact, with the exception of using export JAVA_HOME=/usr/java/jre1.6.0_29. Every time I ran echo $JAVA_HOME I would still get the original JAVA_HOME path, which I'm pretty sure is not what I want. Even when resetting the variable was successful (via export in the shell), I still got my -XX error. I also tried setting some JAVA_OPTS parameters, specifically for memory settings, then ran an echo $JAVA_OPTS that returned nothing.

I have spent a solid two days on this and am about ready to give up. I would really like to avoid reinstalling and reconfiguring a whole bunch of stuff if possible, not to mention I don't even know if that would fix my problem, but I would really, really like to know WHY I having these issues and whether or not they're related, so if any of you have suggestions on this or anything in general that I'm doing incorrectly, please let me know. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转角预定愛 2024-12-23 01:19:58

我无法帮助您解决第一个问题,但关于您的第二个问题:“我无法使用任何特定于 JVM 的 -XX 参数。”:

启动 JVM 时 tomcat 使用环境变量 CATALINA_OPTS。因此,如果您想使用 512mb 堆和 128mb 永久代空间,您可以在 bash shell 上发出以下命令,以使用一些自定义 java 选项启动 tomcat。

#> CATALINA_OPTS="$CATALINA_OPTS -Xmx512m -XX:MaxPermSize=128m" $TOMCAT_HOME/bin/catalina.sh run

您还可以通过更改 tomcat 启动脚本中的 CATALINA_OPTS 来更改默认参数,或者可以将参数添加到您的环境中(例如 $HOME/.bashrc)。

希望有帮助。

I can't help you with the first issue but in regard to your second issue: "I cannot use any of the JVM-specific -XX parameters.":

the environment variable CATALINA_OPTS is used by tomcat when starting the JVM. So if you want to use 512mb of heap and 128mb of perm gen space you can issue the follwing command on a bash shell to start tomcat with some custom java options.

#> CATALINA_OPTS="$CATALINA_OPTS -Xmx512m -XX:MaxPermSize=128m" $TOMCAT_HOME/bin/catalina.sh run

you can also change the default parameters by changing CATALINA_OPTS in tomcat's startup script or you can add the paramenter to your environment (e.g. $HOME/.bashrc).

hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文