tomcat进程启动之后,端口没有被监听

今日发现cc-k145.bokecces.com 上的tomcat进程启动之后,端口没有被监听

1. 查看tomcat的日志
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /var/www/dream/jdk1.6.0_29/jre/lib/amd64
/server:/var/www/dream/jdk1.6.0_29/jre/lib/amd64:/var/www/dream/jdk1.6.0_29/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
May 24, 2018 2:07:01 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8098
May 24, 2018 2:07:01 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 400 ms
May 24, 2018 2:07:01 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
May 24, 2018 2:07:01 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.36
May 24, 2018 2:07:03 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8098
May 24, 2018 2:07:03 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1344 ms
May 24, 2018 2:07:03 PM org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[8088]:
java.net.BindException: Cannot assign requested address
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
at java.net.ServerSocket.bind(ServerSocket.java:328)
at java.net.ServerSocket.<init>(ServerSocket.java:194)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:406)
at org.apache.catalina.startup.Catalina.await(Catalina.java:676)
at org.apache.catalina.startup.Catalina.start(Catalina.java:628)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
May 24, 2018 2:07:03 PM org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8098
May 24, 2018 2:07:04 PM org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
May 24, 2018 2:07:04 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [] registered the JDBC driver [org.logicalcobwebs.proxool.ProxoolDriver] but failed to unregister it when the web application was stopped. To prevent a memory le
ak, the JDBC Driver has been forcibly unregistered.
May 24, 2018 2:07:04 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver
has been forcibly unregistered.
May 24, 2018 2:07:04 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [HouseKeeper] but has failed to stop it. This is very likely to create a memory leak.
May 24, 2018 2:07:04 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [Thread-5] but has failed to stop it. This is very likely to create a memory leak.

从上面报错来的看可能系端口或者地址被占用了,但是lsof -i:8000 lsof -i:8090端口均没有被占用,地址被占用了?? ping localhost 发现情况不妙啊

root@cc-k145:/var/www/dream/tomcat/conf# cat /etc/hosts|head -10
127.0.0.1 localhost
127.0.1.1 cc-k145.bokecces.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
root@cc-k145:/var/www/dream/tomcat/conf# ping cc-k145.bokecces.com
PING cc-k145.bokecces.com (58.221.11.145) 56(84) bytes of data.
64 bytes from 58.221.11.145: icmp_req=1 ttl=64 time=0.016 ms
64 bytes from 58.221.11.145: icmp_req=2 ttl=64 time=0.008 ms
--- cc-k145.bokecces.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.008/0.012/0.016/0.004 ms
root@cc-k145:/var/www/dream/tomcat/conf# ping localhost
PING localhost.bokecces.com (106.14.113.110) 56(84) bytes of data.
64 bytes from 106.14.113.110: icmp_req=1 ttl=52 time=11.1 ms
64 bytes from 106.14.113.110: icmp_req=2 ttl=52 time=11.0 ms
64 bytes from 106.14.113.110: icmp_req=3 ttl=52 time=11.1 ms
--- localhost.bokecces.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 11.084/11.120/11.168/0.035 ms

发现/etc/hosts根本不生效啊,通过strace ping localhost 进行追踪查看整个过程,发现虽然/etc/host.conf配置了读的顺序(见下面标红字样),但是根本没有打开/etc/hosts文件这个过程(可通过strace 追踪一个正常的ping查看)

root@cc-k145:~# cat /etc/host.conf
# The "order" line is only used by old versions of the C library.
order hosts,bind 配置了先读/etc/hosts再读/etc/resolv.conf
multi on

再问下查看追踪过程发现会读/etc/nsswitch.conf 这个文件,发现不知为啥被注释了
root@cc-k145:~# cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
#hosts: files dns 意思先找/etc/hosts 再找dns服务
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files

  DNS系统的客户端被称为DNS解析器 (DNS Resolver)。在Linux系统上,解析器并不是特指某个应用程序,而是指解析器库。这个库包含了标准C库中的一系列函数,最主要的两个函数是gethostbyname()和gethostbyaddr()。可以对DNS解析器进行配置,使得它们查找/etc/hosts中的信息、查询DNS服务器或者使用网络信息服务系统的配置信息。libc使用/etc/host.conf配置文件;glibc使用/etc/nsswitch.conf配置文件。

  /etc/host.conf中主要的选项有:(1) order指定域名解析的查找顺序,其中hosts表示/etc/hosts配置文件;bind表示查询DNS服务器;nis表示查询NIS系统的配置信息。(2) multi [on|off]指定/etc/hosts中的主机是否可以有多个IP地址。
  /etc/nsswitch.conf是名字服务开关 (name service switch) 的配置文件,其中对应DNS解析器的数据库名字是hosts:。它的主要选项有:(1) dns表示使用DNS解析地址 (2) files表示使用/etc/hosts和/etc/network配置文件 (3) nis或nisplus。

将其注释取消掉,再次ping localhost可以正常解析为127.0.0.1 重启tomcat后,端口能正常监听到问题解决 

猜你喜欢

转载自www.cnblogs.com/benevolencedoctor/p/9083291.html
今日推荐