简体   繁体   English

Tomcat启动,但未在任何端口上监听

[英]tomcat starts but its not listening on any port

I have a tomcat service configured to run on port 8380. This site was running fine until recently. 我已将tomcat服务配置为在端口8380上运行。直到最近,该站点运行良好。 I started to see this in the mod_jk.log on apache: 我开始在apache的mod_jk.log中看到它:

[3409:140197396281344] [info] jk_open_socket::jk_connect.c (627): connect to 127.0.0.1:8309 failed (errno=111)
[3409:140197396281344] [info] ajp_connect_to_endpoint::jk_ajp_common.c (995): Failed opening socket to (127.0.0.1:8309) (errno=111)
[3409:140197396281344] [error] ajp_send_request::jk_ajp_common.c (1630): (worker1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[3409:140197396281344] [info] ajp_service::jk_ajp_common.c (2623): (worker1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)
[3409:140197396281344] [info] jk_open_socket::jk_connect.c (627): connect to 127.0.0.1:8309 failed (errno=111)
[3409:140197396281344] [info] ajp_connect_to_endpoint::jk_ajp_common.c (995): Failed opening socket to (127.0.0.1:8309) (errno=111)
[3409:140197396281344] [error] ajp_send_request::jk_ajp_common.c (1630): (worker1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[3409:140197396281344] [info] ajp_service::jk_ajp_common.c (2623): (worker1) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[3409:140197396281344] [error] ajp_service::jk_ajp_common.c (2643): (worker1) connecting to tomcat failed.
[3409:140197396281344] [info] jk_handler::mod_jk.c (2788): Service error=-3 for worker=worker1

I'm able to start up the tomcat service but the port it's supposed to be listening on is not accepting connections. 我能够启动tomcat服务,但是它应该监听的端口不接受连接。 nmap and netstat don't show the ports as available. nmap和netstat不会显示可用端口。 I've also tried telnetting to to the port just in case but as i expected there's no response. 我还尝试了远程登录到该端口,以防万一,但正如我期望的那样,没有任何反应。 I've stopped the firewall in case it's a iptables rule issue but that too had no effect. 万一这是iptables规则问题,我已经停止了防火墙,但这也没有任何效果。 I've googled similar issues resolved by what i tried above but none of them apply to my issues. 我用谷歌搜索了我上面尝试解决的类似问题,但是没有一个适用于我的问题。 I'm not sure what else to try at this point and so I'm turning to you all! 我不确定目前还可以尝试什么,所以我转向大家!

For this particular host the CATALINA_BASE is from a mounted nfs export. 对于此特定主机,CATALINA_BASE来自已挂载的nfs导出。 I have 2 tomcat sites hosted on this server. 我在此服务器上托管了2个tomcat网站。 For the sake of testing I've disabled one from starting up since they both have same issue. 为了进行测试,我禁用了一个,因为它们都有相同的问题。 i figured if i can get 1 running the other will be work as well. 我想如果我可以让1运行其他也将工作。

server.xml: server.xml中:

<Server port="8105" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8380" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               redirectPort="8443" />
    <Connector port="8309" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      </Host>
      <Host name="mytomcat.site.org" appBase="webapps"
            unpackWARs="true" autoDeploy="true">
      </Host>
    </Engine>
  </Service>
</Server>

My worker.properties in apache. 我在Apache中的worker.properties。 I have 2 workers 1 for each tomcat site. 每个tomcat网站有2个工人1。

workers.tomcat_home=/opt/tomcat
workers.java_home=/usr/local/jdk/jre
ps=/

# Define workers
worker.list=worker1
worker.list=worker2

# Set properties for worker1 - localhost
worker.worker1.type=ajp13
worker.worker1.host=127.0.0.1
worker.worker1.port=8309
worker.worker1.socket_keepalive=True
worker.worker1.socket_timeout=300

# Set properties for worker2 - localhost
worker.worker2.type=ajp13
worker.worker2.host=127.0.0.1
worker.worker2.port=8409
worker.worker2.socket_keepalive=True
worker.worker2.socket_timeout=300

Apache starts up ok and is serving static pages ok. Apache可以正常启动,并且可以正常提供静态页面。 tomcat starts ok but like i said it's not listening on any port. Tomcat启动正常,但就像我说的那样,它不在任何端口上监听。

Any help would be appreciated. 任何帮助,将不胜感激。 TIA! TIA!

MORE INFO: I ran the init script with -debug in the JAVA_OPTS var. 更多信息:我在JAVA_OPTS var中使用-debug运行了初始化脚本。 and I see the following towards the bottom of the output that scrolls out to stdout: 并且我看到以下内容滚动到stdout的输出的底部:

...
user changed to 'daemon'
User 'daemon' validated
Attempting to locate Java Home in /usr/local/jdk
Attempting to locate VM configuration file /usr/local/jdk/jre/lib/jvm.cfg
Attempting to locate VM configuration file /usr/local/jdk/lib/jvm.cfg
Attempting to locate VM configuration file /usr/local/jdk/jre/lib/amd64/jvm.cfg
Found VM configuration file at /usr/local/jdk/jre/lib/amd64/jvm.cfg
Found VM server definition in configuration
Checking library /usr/local/jdk/jre/lib/amd64/server/libjvm.so
Found VM client definition in configuration
Checking library /usr/local/jdk/jre/lib/amd64/client/libjvm.so
Checking library /usr/local/jdk/lib/amd64/client/libjvm.so
Cannot locate library for VM client (skipping)
Found VM hotspot definition in configuration
Checking library /usr/local/jdk/jre/lib/amd64/hotspot/libjvm.so
Checking library /usr/local/jdk/lib/amd64/hotspot/libjvm.so
Cannot locate library for VM hotspot (skipping)
Found VM classic definition in configuration
Checking library /usr/local/jdk/jre/lib/amd64/classic/libjvm.so
Checking library /usr/local/jdk/lib/amd64/classic/libjvm.so
Cannot locate library for VM classic (skipping)
Found VM native definition in configuration
Checking library /usr/local/jdk/jre/lib/amd64/native/libjvm.so
Checking library /usr/localjdk/lib/amd64/native/libjvm.so
Cannot locate library for VM native (skipping)
Found VM green definition in configuration
Checking library /usr/local/jdk/jre/lib/amd64/green/libjvm.so
Checking library /usr/local/jdk/lib/amd64/green/libjvm.so
Cannot locate library for VM green (skipping)
Java Home located in /usr/local/jdk
+-- DUMPING JAVA HOME STRUCTURE ------------------------
| Java Home:       "/usr/local/jdk"
| Java VM Config.: "/usr/local/jdk/jre/lib/amd64/jvm.cfg"
| Found JVMs:      1
| JVM Name:        "server"
|                  "/usr/local/jdk/jre/lib/amd64/server/libjvm.so"
+-------------------------------------------------------
Running w/ LD_LIBRARY_PATH=/usr/local/jdk/jre/lib/amd64/server:/usr/local/jdk/jre/lib/amd64
wait_child 12035
redirecting stdout to /opt/www/mytomcat/logs/catalina-daemon.out and stderr to &1

Then it goes back to the shell prompt. 然后返回到shell提示符。 If it completed successfully it would have additional lines scrolling out: 如果成功完成,将滚动出其他行:

get_pidf: 5 in /opt/www/mytomcat/logs/catalina-daemon.pid
get_pidf: pid 97253
check_tmp_file: /tmp/97253.jsvc_up
get_pidf: 5 in /opt/www/mytomcat/logs/catalina-daemon.pid
get_pidf: pid 97253
check_tmp_file: /tmp/97253.jsvc_up
get_pidf: 5 in /opt/www/mytomcat/logs/catalina-daemon.pid
get_pidf: pid 97253
check_tmp_file: /tmp/97253.jsvc_up
get_pidf: 5 in /opt/www/mytomcat/logs/catalina-daemon.pid
get_pidf: pid 97253
check_tmp_file: /tmp/97253.jsvc_up
get_pidf: 5 in /opt/www/mytomcat/logs/catalina-daemon.pid
get_pidf: pid 97253
check_tmp_file: /tmp/97253.jsvc_up
get_pidf: 5 in /opt/www/mytomcat/logs/catalina-daemon.pid
get_pidf: pid 97253
check_tmp_file: /tmp/97253.jsvc_up

I also noticed both tomcat process are running as root when i expect the child process to be running as daemon . 我还注意到当我希望子进程以daemon身份运行时,两个tomcat进程都以root身份运行。 Not sure why this is happening but it may be related to the issue. 不知道为什么会这样,但可能与问题有关。

Based on the debug output I started to try a bunch of different things specifically around catalina-daemon.out and catalina-daemon.pid files. 基于调试输出,我开始尝试一堆关于catalina-daemon.out和catalina-daemon.pid文件的不同事情。 As it turns out because these files are on the nfs location it causes the odd issue of the service starting but not listening. 事实证明,由于这些文件位于nfs位置,因此导致服务启动但未监听的奇怪问题。 Once I moved these to the local filesystem the service started up AND it was listening on the correct port again. 一旦将它们移到本地文件系统,服务就会启动,并且它再次在正确的端口上进行侦听。 I also noticed the child tomcat process switched to the unprivileged user daemon. 我还注意到子tomcat进程已切换到非特权用户守护程序。 The page is reachable again. 该页面可以再次访问。

Not entirely sure why it was working before but all of a sudden its not when i made no changes to the server. 不能完全确定为什么它以前可以正常工作,但是突然间,当我对服务器没有任何更改时,它却无法正常工作。 Something must have changed in the nfs export from the zfs machine that was serving up the CATALINA_BASE. 从为CATALINA_BASE提供服务的zfs计算机导出的nfs中,必须进行了某些更改。 Somehow this may have exposed a bug that causes this issue on the tomcat server. 不知何故,这可能已经暴露了一个导致tomcat服务器上此问题的错误。

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

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