0

我正在尝试在我们的 unix 机器上安装一个 Tomcat 服务器(远程访问),该服务器将用于测试项目。

我用过Tomcat 5.0.25(因为我们的产品使用的是相同的版本)。

现在我不想通过 Apache 运行它,而只想直接访问 tomcat。

所以我已经部署了 Tomcat 并配置了 server.xml(见下文),但是当我启动它时,我无法使用这个 URL 看到 tomcat 5 欢迎页面:global.int.com:9082

<?xml version='1.0' encoding='utf-8'?>

<Server port="9007" shutdown="SHUTDOWN">

  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
            debug="0"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
            debug="0"/>

  <!-- Global JNDI resources -->
  <GlobalNamingResources>

    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
      <parameter>
        <name>factory</name>
        <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
      </parameter>
      <parameter>
        <name>pathname</name>
        <value>conf/tomcat-users.xml</value>
      </parameter>
    </ResourceParams>

  </GlobalNamingResources>

  <Service name="Catalina">


    <Connector port="9082" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />


    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="9020" protocol="AJP/1.3" redirectPort="9444" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    <Engine name="Catalina" defaultHost="localhost">


      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

      </Host>
    </Engine>
  </Service>
</Server>

我可以看到 Tomcat 正在运行,Catalina.out 说:

Jan 27, 2012 8:21:56 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-9082 Jan 27, 2012 8:21:56 PM org.apache.jk.common.ChannelSocket init INFO: JK2: ajp13 listening on /0.0.0.0:9020 Jan 27, 2012 8:21:56 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=1/14 config=/home/tomcat/tomcat5_fcl_uat/conf/jk2.properties Jan 27, 2012 8:21:56 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 2173 ms

和命令 lsof -i TCP显示:

java 29923 tomcat 5u IPv6 373023 TCP *:9082 (LISTEN)

我不知道为什么我看不到 tomcat 页面。我在端口 9081 上运行了另一个 Tomcat 服务器,我们可以使用 url 访问它global.int.com:9081 ,上面的 server.xml 是它的副本,除了端口号被更改。谁能给我一个关于事情在哪里分崩离析的提示。谢谢

更新2:

远程桌面wget -S的结果:

    --2012-01-30 17:35:42--  http://global.int.com:9082/
    Resolving global.int.com... 10.215.222.78
    Connecting to global.int.com|10.215.222.78|:9082... failed: No route
    to host.

以下是wget -SLocalHost 机器上的结果:

    [tomcat@global logs]$ wget -S  http://global.int.com:9082/
    --16:17:03--  http://global.int.com:9082/
    Resolving global.int.com:9082... 10.213.210.78
    Connecting to global.int.com:9082|10.213.210.78|:9082... connected.
    HTTP request sent, awaiting response...
      HTTP/1.1 200 OK
      Content-Type: text/html;charset=ISO-8859-1
      Date: Sat, 28 Jan 2012 05:17:03 GMT
      Server: Apache-Coyote/1.1
      Connection: close
    Length: unspecified [text/html]
    Saving to: `index.html'

        [ <=>                                                                                          ] 9,312       --.-K/s   in 0s

    16:17:03 (297 MB/s) - `index.html' saved [9312]

    [tomcat@global logs]$

更新3:结果iptables -L -v -n

  106  5920 ACCEPT     tcp  --  *      *       10.0.0.0/8           0.0.0.0/0           tcp dpt:8080
    6   312 ACCEPT     tcp  --  *      *       10.0.0.0/8           0.0.0.0/0           tcp dpt:8180
    0     0 ACCEPT     tcp  --  *      *       10.0.0.0/8           0.0.0.0/0           tcp dpt:9080
   19   988 ACCEPT     tcp  --  *      *       10.0.0.0/8           0.0.0.0/0           tcp dpt:9081

如果我错了,请纠正我 - 但上面的结果显示了我无法访问 tomcat 的原因,因为我已将端口 9082 分配给 tomcat 并且该端口在上面的列表中不存在。

中使用的所有端口号server.xml都是唯一的(我已经仔细检查过)。关于为什么我无法看到 Tomcat 主页以及如何修复它的任何建议?

4

1 回答 1

1

原来这是阻止传入连接的防火墙问题。iptables -L -v -n(在 Linux 上)有助于揭示实际问题。有关详细信息,请参阅文章下方的评论。

于 2012-01-31T09:54:31.053 回答