简体   繁体   English

Tomcat 不会停止或重新启动

[英]Tomcat won't stop or restart

I tried stopping tomcat. It failed with this message:我尝试停止 tomcat。失败并显示以下消息:

  • Tomcat did not stop in time. Tomcat没有及时停车。 PID file was not removed. PID 文件未被删除。

I then tried again and got this:然后我再次尝试并得到了这个:

  • PID file (/opt/tomcat/work/catalina.pid) found but no matching process was found.找到 PID 文件 (/opt/tomcat/work/catalina.pid) 但未找到匹配的进程。 Stop aborted.停止中止。

I then tried starting tomcat in debug mode and got this:然后我尝试在调试模式下启动 tomcat 并得到这个:

  • PID file (/opt/tomcat/work/catalina.pid) found.找到 PID 文件 (/opt/tomcat/work/catalina.pid)。 Is Tomcat still running? Tomcat 还在运行吗? Start aborted.开始中止。

I them deleted /opt/tomcat/work/catalina.pid and tried restarting and got this:我删除了 /opt/tomcat/work/catalina.pid 并尝试重新启动并得到了这个:

  • $CATALINA_PID was set (/opt/tomcat/work/catalina.pid) but the specified file does not exist. $CATALINA_PID 已设置 (/opt/tomcat/work/catalina.pid) 但指定的文件不存在。 Is Tomcat running? Tomcat 正在运行吗? Stop aborted.停止中止。

Anyone know how to get tomcat restarted?有人知道如何重新启动 tomcat 吗?

I had this error message having started up a second Tomcat server on a Linux server.我在 Linux 服务器上启动了第二个Tomcat 服务器时收到此错误消息。

$CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted.

When starting up the 2nd Tomcat I had set CATALINA_PID as asked but my mistake was to set it to a directory (I assumed Tomcat would write a default file name in there with the pid).启动第二个 Tomcat 时,我按照要求设置了 CATALINA_PID,但我的错误是将其设置为目录(我假设 Tomcat 会在其中写入带有 pid 的默认文件名)。

The fix was simply to change my CATALINA_PID to add a file name to the end of it (I chose catalina.pid from the above examples).修复只是更改我的 CATALINA_PID 以在其末尾添加文件名(我从上面的示例中选择了 catalina.pid)。 Next I went to the directory and did a simple:接下来我去目录并做了一个简单的:

touch catalina.pid

creating an empty file of the correct name.创建一个正确名称的空文件。 Then when I did my shutdown.sh I got the message back saying:然后,当我执行 shutdown.sh 时,我收到消息说:

PID file is empty and has been ignored.
Tomcat stopped.

I didn't have the option to kill Tomcat as the JVM was in use so I was glad I found this.我没有选择杀死 Tomcat,因为 JVM 正在使用中,所以我很高兴我发现了这一点。

It seems Tomcat was actually stopped.看起来Tomcat实际上已经停止了。 I started it and it started fine.我开始了它,它开始得很好。 Thanks all.谢谢大家。

Recent I have met several times of stop abnormal.最近我遇到了几次停止异常。 Although shutdown.sh provides some information, The situations are:虽然shutdown.sh提供了一些信息,但情况是:

  • result of the command ps -ef| grep java命令ps -ef| grep java ps -ef| grep java is Null. ps -ef| grep java为空。
  • result of the command ps -ef| grep java命令ps -ef| grep java ps -ef| grep java is not null. ps -ef| grep java不为空。

My opinion is just kill the process of Catalina and remove the pid file (In your situation is /opt/tomcat/work/catalina.pid.)我的意见是杀死 Catalina 的进程并删除 pid 文件(在您的情况下是 /opt/tomcat/work/catalina.pid。)

The result seems not so seriously to influence others.结果好像没那么严重影响别人。

Make sure Tomcat is not currently running and the PID file is removed.确保 Tomcat 当前没有运行并且 PID 文件已被删除。 Them you should start Tomcat successfully.他们应该成功启动Tomcat。

If you start fresh then:如果你重新开始,那么:

  1. Create setenv.sh file in <CATALINA_HOME>/bin .<CATALINA_HOME>/bin创建setenv.sh文件。
  2. In it I set CATALINA_PID=/tmp/tomcat.pid (or other directory of your choice) so you have more control over the Tomcat process.我在其中设置了CATALINA_PID=/tmp/tomcat.pid (或您选择的其他目录),这样您就可以更好地控制 Tomcat 进程。

Then to start Tomcat find catalina.sh in <CATALINA_HOME>/bin and execute:然后启动 Tomcat 在<CATALINA_HOME>/bin找到catalina.sh并执行:

./catalina.sh start

and to stop it run:并停止它运行:

./catalina.sh stop 10 -force

From catalina.sh script's doc:来自catalina.sh脚本的文档:

./catalina.sh

Usage: catalina.sh ( commands ... )
commands:

start             Start Catalina in a separate window
stop              Stop Catalina, waiting up to 5 seconds for the process to end
stop n            Stop Catalina, waiting up to n seconds for the process to end
stop -force       Stop Catalina, wait up to 5 seconds and then use kill -KILL if still running
stop n -force     Stop Catalina, wait up to n seconds and then use kill -KILL if still running

Note: If you want to use -force flag then setting CATALINA_PID is mandatory.注意:如果要使用-force标志,则必须设置CATALINA_PID

You can go to the location ${CATALINA_HOME}/logs/ open catalina.pid.你可以到位置${CATALINA_HOME}/logs/打开catalina.pid。 Here we will get the pid.在这里我们将得到pid。 then terminate the process.然后终止进程。 kill -9 pid杀死 -9 pid

Have you try $ sudo ./catalina.sh stop ?您是否尝试过$ sudo ./catalina.sh stop It worked in my case.它在我的情况下有效。

FIRST --> rm catalina.engine第一 --> rm catalina.engine

THEN --> ./startup.sh然后 --> ./startup.sh

NEXT TIME you restart --> ./shutdown.sh -force下次重新启动时 --> ./shutdown.sh -force

sometimes if the same pid is running after reboot tomcat will not start有时如果重新启动后运行相同的pid tomcat将无法启动

my pid file was at apache-tomcat/temp/tomcat.pid我的 pid 文件在 apache-tomcat/temp/tomcat.pid

 change file apache-tomcat/bin/catalina.sh about line 386 
 from "ps -p $PID >/dev/null 2>&1"
 to "ps -fp $PID |grep catalina >/dev/null 2>&1"

excerpt from catalina.sh file摘自 catalina.sh 文件

 if [ ! -z "$CATALINA_PID" ]; then
    if [ -f "$CATALINA_PID" ]; then
      if [ -s "$CATALINA_PID" ]; then
        echo "Existing PID file found during start."
        if [ -r "$CATALINA_PID" ]; then
          PID=`cat "$CATALINA_PID"`
          ps -fp $PID |grep catalina >/dev/null 2>&1  #this line
          if [ $? -eq 0 ] ; then
            echo "Tomcat appears to still be running with PID $PID. Start aborted."
            echo "If the following process is not a Tomcat process, remove the PID file and try again:"
            ps -f -p $PID
            exit 1
          else
            echo "Removing/clearing stale PID file."
            rm -f "$CATALINA_PID" >/dev/null 2>&1
            if [ $? != 0 ]; then
              if [ -w "$CATALINA_PID" ]; then
                cat /dev/null > "$CATALINA_PID"
              else
                echo "Unable to remove or clear stale PID file. Start aborted."
                exit 1
              fi
            fi
          fi
        else
          echo "Unable to read PID file. Start aborted."

The catalina.pid is missing in your case.您的情况缺少 catalina.pid。

This file is located under {your_jira_dir}/work/catalina.pid and it contains the pid of the current instance of jira.该文件位于 {your_jira_dir}/work/catalina.pid 下,它包含当前 jira 实例的 pid。

so所以

ps aux | grep jira
  • find the correct entry找到正确的条目
  • Copy the PID of the output and create a file that only contains this PID.复制输出的 PID 并创建一个仅包含此 PID 的文件。 - Make sure it can be read and written by the user which runs jira. - 确保它可以被运行 jira 的用户读取和写入。
  • Try to shutdown jira again.再次尝试关闭 jira。

sudo systemctl stop tomcat

为我做的

You can always try to kill the process in case you see this kind of issues.如果您看到此类问题,您可以随时尝试终止该进程。 You can get the process ID either from PS or from pid file and kill the process.您可以从 PS 或 pid 文件获取进程 ID 并终止该进程。

In my case, the tomcat.pid is under /opt/tomcat/temp/.就我而言,tomcat.pid 位于 /opt/tomcat/temp/ 下。 Tried to delete it manually.尝试手动删除它。 Still didn't work.还是没用。 After check setnev.sh in /opt/tomcat/bin/, notice there is a line of code to define JAVA_HOME:检查/opt/tomcat/bin/中的setnev.sh后,注意到有一行代码定义了JAVA_HOME:

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre

Commented out this line, restart Tomcat.注释掉这行,重启Tomcat。 It works!有用! Since I did a yum update and a new minor version of Java update coming from 1.8.0.212 to 1.8.0.222.因为我做了一个 yum 更新和一个新的 Java 次要版本更新,从 1.8.0.212 到 1.8.0.222。 Lessons learned: Hard-code should be avoided.经验教训:应该避免硬编码。

I faced the same problem as mentioned below.我遇到了与下面提到的相同的问题。

PID file found but no matching process was found.找到 PID 文件,但没有找到匹配的进程。 Stop aborted.停止中止。

Solution is to find the free space of the linux machine by using the following command解决方法是使用以下命令查找linux机器的空闲空间

df -h df -h

The above command shows my home directory was 100% used.上面的命令显示我的主目录被 100% 使用。 Then identified which files to be removed by using the following command然后使用以下命令确定要删除的文件

du -h .杜-h。

After removing, it was able to perform IO operation on the linux machine and the tomcat was able to start.删除后,可以在linux机器上进行IO操作,tomcat也可以启动了。

Follow this :)按照这个:)

  1. Open : /etc/systemd/system/tomcat.service打开/etc/systemd/system/tomcat.service

Can you see JAVA_HOME ?你能看到JAVA_HOME吗? : modify it like below : 修改如下

Environment="JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64"

At 1.11.0 - insert your own Jdk version在 1.11.0 - 插入你自己的 Jdk 版本

  1. systemctl daemon-reload

  2. sudo systemctl start tomcat


Now, in eclipse -> Add Server -> .....现在,在 eclipse -> Add Server -> .....

Got struck at tomcat installation directory ??tomcat installation directory ??击中了tomcat installation directory ??

  1. Extract the tomcat tar file you already downloaded. Extract你已经下载的 tomcat tar 文件。
  2. Now go back to eclipse -> add server -> Browse -> Point to extracted file (done in step 1 above :)现在回到 Eclipse -> 添加服务器 ->浏览-> Point to extracted file (在上面的步骤 1 中完成:)

Comment if you get struck in somewhere else too )如果您在其他地方也被击中,请发表评论)

To make sure apache tomcat is not running, you could use following in Linux.要确保 apache tomcat 没有运行,您可以在 Linux 中使用以下命令。

ps -ef | grep tomcat // it will return output if tomcat is up and running

If it is running, use either one of the options to stop tomcat:如果它正在运行,请使用任一选项来停止 tomcat:

./catalina.sh stop

Passing "stop" argument for catalina.sh --> stops the Tomcat in the foreground and displays the running logs in the same console .为 catalina.sh 传递“停止”参数 --> 在前台停止 Tomcat 并在同一控制台中显示运行日志 when the console terminal is closed it will terminate the tomcat .当控制台终端关闭时,它将终止 tomcat

./shutdown.sh 

This way is firing the shutdown.sh to stop your Tomcat server and finally the last way is using service tomcat stop as below.这种方式是触发 shutdown.sh 来停止您的 Tomcat 服务器,最后一种方式是使用服务 tomcat 停止,如下所示。

sudo service tomcat stop

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

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