无法远程启动Apache Tomcat服务器(Linux)

时间:2018-10-11 03:42:36

标签: tomcat ssh remote-server

我尝试了以下方法,但收效甚微:

  1. 远程运行catalina.sh启动命令

$ ssh -t server-name sudo -H -u myuser sh /catalina/home/path/bin/catalina.sh start Using CATALINA_BASE: /catalina/home/path Using CATALINA_HOME: /catalina/home/path Using CATALINA_TMPDIR: /catalina/home/path/temp Using JRE_HOME: /usr/lib/jvm/java-1.8.0-openjdk-amd64 Using CLASSPATH: /catalina/home/path/../extraclasspathfiles:/catalina/home/path/bin/bootstrap.jar:/catalina/home/path/bin/tomcat-juli.jar Tomcat started. $ ssh -t server-name 'ps ax | grep java' 24322 pts/0 S+ 0:00 grep --color=auto java

没有运气

  1. 创建远程启动脚本并远程运行

这是remote.sh(位于服务器上)的内容

#!/bin/sh
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64"
export CATALINA_HOME="/catalina/home/path"
/catalina/home/path/bin/startup.sh

然后我们远程运行脚本

$ ssh -t server-name sudo -H -u myuser sh /catalina/home/path/bin/remote.sh/bin/remote.sh
Using CATALINA_BASE:   Using CATALINA_BASE:   /catalina/home/path
Using CATALINA_HOME:   Using CATALINA_HOME:   /catalina/home/path
Using CATALINA_TMPDIR: Using CATALINA_TMPDIR: /catalina/home/path/temp/temp
Using JRE_HOME:        /usr/lib/jvm/java-1.8.0-openjdk-amd64
Using CLASSPATH:       Using JRE_HOME:        /usr/lib/jvm/java-1.8.0-openjdk-amd64/../extraclasspathfiles:Using CLASSPATH:       /catalina/home/path/../extraclasspathfiles:/catalina/home/path/bin/bootstrap.jar:/catalina/home/path/bin/tomcat-juli.jar/bin/bootstrap.jar:Tomcat started./bin/tomcat-juli.jar
Tomcat started.
$ ssh -t server-name 'ps ax | grep java'
24322 pts/0    S+     0:00 grep --color=auto java

再次,没有运气

我在这里想念什么?

2 个答案:

答案 0 :(得分:1)

您正在server-name上启动Tomcat并在本地执行ps

要查看Java是否在远程计算机上运行

ssh -t server-name 'ps ax | grep java'

答案 1 :(得分:0)

我找到了答案:

ssh server-name sudo -H -u username sh /path/to/generated/bin/startup.sh

-t引起了问题。

-t      Force pseudo-terminal allocation.  This can be used to execute arbitrary screen-based programs on a remote machine,
             which can be very useful, e.g. when implementing menu services.  Multiple -t options force tty allocation, even if ssh
             has no local tty.