同一服务器启动多个tomcat服务,tomcat启动后即停止

同一服务器启动多个tomcat服务,tomcat启动后即停止

结论,由于同一个服务器上启动了多个tomcat服务,造成端口占用,故tomcat启动失败。只需要把两个tomcat冲突的端口修改成不一样的端口即可。

异常日志

01-Nov-2018 19:37:30.651 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.28
01-Nov-2018 19:37:30.657 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Feb 6 2018 23:10:25 UTC
01-Nov-2018 19:37:30.657 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.28.0
01-Nov-2018 19:37:30.657 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
01-Nov-2018 19:37:30.657 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            2.6.32-642.6.2.el6.x86_64
01-Nov-2018 19:37:30.657 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
01-Nov-2018 19:37:30.658 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /home/webwork/software/jre
01-Nov-2018 19:37:30.658 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_162-b12
01-Nov-2018 19:37:30.658 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
01-Nov-2018 19:37:30.658 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /home/webwork/software/apache-tomcat-8.5.28
01-Nov-2018 19:37:30.658 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /home/webwork/software/apache-tomcat-8.5.28
01-Nov-2018 19:37:30.658 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/home/webwork/software/apache-tomcat-8.5.28/conf/logging.properties
01-Nov-2018 19:37:30.659 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
01-Nov-2018 19:37:30.660 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
01-Nov-2018 19:37:30.660 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
01-Nov-2018 19:37:30.661 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
01-Nov-2018 19:37:30.661 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/home/webwork/software/apache-tomcat-8.5.28
01-Nov-2018 19:37:30.661 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/home/webwork/software/apache-tomcat-8.5.28
01-Nov-2018 19:37:30.662 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/home/webwork/software/apache-tomcat-8.5.28/temp
01-Nov-2018 19:37:30.662 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
01-Nov-2018 19:37:30.955 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
01-Nov-2018 19:37:30.975 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
01-Nov-2018 19:37:30.997 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
01-Nov-2018 19:37:31.004 SEVERE [main] org.apache.catalina.core.StandardService.initInternal Failed to initialize connector [Connector[AJP/1.3-8009]]
 org.apache.catalina.LifecycleException: Failed to initialize component [Connector[AJP/1.3-8009]]
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:113)
    at org.apache.catalina.core.StandardService.initInternal(StandardService.java:549)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
    at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:875)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:632)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:655)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:309)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: org.apache.catalina.LifecycleException: Protocol handler initialization failed
    at org.apache.catalina.connector.Connector.initInternal(Connector.java:996)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107)
    ... 12 more
Caused by: java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:433)
    at sun.nio.ch.Net.bind(Net.java:425)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:210)
    at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1086)
    at org.apache.tomcat.util.net.AbstractJsseEndpoint.init(AbstractJsseEndpoint.java:268)
    at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:581)
    at org.apache.catalina.connector.Connector.initInternal(Connector.java:993)
    ... 13 more
01-Nov-2018 19:37:31.006 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1145 ms
01-Nov-2018 19:37:31.060 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
01-Nov-2018 19:37:31.061 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.28
01-Nov-2018 19:37:31.106 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/home/webwork/software/apache-tomcat-8.5.28/webapps/hotfix-console.war]
01-Nov-2018 19:37:35.145 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
01-Nov-2018 19:37:46.301 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/home/webwork/software/apache-tomcat-8.5.28/webapps/hotfix-console.war] has finished in [15,191] ms
01-Nov-2018 19:37:46.302 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/home/webwork/software/apache-tomcat-8.5.28/webapps/hotfix-apis.war]
01-Nov-2018 19:37:56.689 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/home/webwork/software/apache-tomcat-8.5.28/webapps/hotfix-apis.war] has finished in [10,387] ms
01-Nov-2018 19:37:56.695 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/home/webwork/software/apache-tomcat-8.5.28/webapps/ROOT]
01-Nov-2018 19:37:56.791 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/home/webwork/software/apache-tomcat-8.5.28/webapps/ROOT] has finished in [96] ms
01-Nov-2018 19:37:56.796 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
01-Nov-2018 19:37:56.822 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 25814 ms
01-Nov-2018 19:37:56.825 SEVERE [main] org.apache.catalina.core.StandardServer.await StandardServer.await: create[localhost:8005]: 
 java.net.BindException: Address already in use (Bind failed)
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387)
    at java.net.ServerSocket.bind(ServerSocket.java:375)
    at java.net.ServerSocket.(ServerSocket.java:237)
    at org.apache.catalina.core.StandardServer.await(StandardServer.java:441)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:769)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:715)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
01-Nov-2018 19:37:56.825 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
01-Nov-2018 19:37:56.839 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
01-Nov-2018 19:37:56.841 INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
01-Nov-2018 19:37:56.912 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
01-Nov-2018 19:37:56.925 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]
01-Nov-2018 19:37:56.926 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
01-Nov-2018 19:37:56.926 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]

修改conf/server.xml文件里面的设置的端口号

修改前

    
    

修改后

    
    

查看端口占用命令

netstat -alnp | grep 8125

示例

[root@iZm5ea1lcr5b9y4dpa30v7Z ~]# netstat -alnp | grep 8009
tcp        0      0 0.0.0.0:8009                0.0.0.0:*                   LISTEN      21153/java          
tcp        0      0 0.0.0.0:18009               0.0.0.0:*                   LISTEN      20849/java  

上面可以看出 两个java进程 (pid 21153 和 pid 20849)目前分别占用了 8009 端口 和 18009 端口

强制杀死某个java进程

kill -9 21153

你可能感兴趣的:(linux)