同一端口上的多个 tomcat 但本地 IP 不同 [英] multiple tomcats on same port but different local IP

查看:33
本文介绍了同一端口上的多个 tomcat 但本地 IP 不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的 Windows 7 主机文件:

I have windows 7 hosts file like this:

127.0.0.1       localhost
192.168.78.128  cloudera-vm440
127.0.0.61      tomcat61
127.0.0.71      tomcat71

有了这个,我想我可以在不同的本地 IP 但相同的端口 8080 等上启动两个 tomcat.

With this I thought I could bring up two tomcats on different local IP but same port 8080 etc.

这不起作用.我得到

Caused by: java.lang.Exception: Socket bind failed: [730048] Only one usage of each socket address (protocol/network address/port) is normally permitted.  
at org.apache.tomcat.util.net.AprEndpoint.bind(AprEndpoint.java:430)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:623)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:981)

是这样还是我可以做些什么?

Is this the way it is or can I do something about it?

推荐答案

仅仅编写 hosts 文件是不够的.需要在Tomcat中配置Connector指定监听地址.默认情况下,Tomcat 连接器将在 0.0.0.0 侦听.

Just writing a hosts file isn't sufficient. You need to configure the Connector in Tomcat to specify the listen address. By default, a Tomcat Connector will listen at 0.0.0.0.

这篇关于同一端口上的多个 tomcat 但本地 IP 不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆