【问题标题】:Tomcat long loading time after changing configurationTomcat更改配置后加载时间长
【发布时间】:2019-06-29 12:06:07
【问题描述】:

我正在使用 Tomcat 8.5 和 Jersey 来设置 REST Api。通常启动最多需要 2 分钟。但是,在对配置进行任何更改后,例如启用 CORS 或添加 SSL 密钥,加载时间增加到 4 小时以上,有时根本无法加载。 正常吗?有没有机会减少这个时间?

项目还使用 OpenCV 3.4.2 和 deeplearning4j。 它部署在 Google Cloud 上,机器类型:n1-standard-4(4 个 vCPU,15 GB 内存)在 Ubuntu 18.04 64 位上。

我通过命令启动Tomcat:

$ sudo /opt/tomcat/bin/startup.sh

立即看到结果:

Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Tomcat started.

但是,在浏览器中加载欢迎屏幕或管理器应用程序仍需要几个小时。

@编辑

经过数小时的等待,http 就像一个魅力,但 https 没有响应(超时错误)。

我正在根据this tutorial在tomcat上设置来自letsencrypt.org的SSL证书,并在server.xml中更改端口8443:

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
    maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateFile="conf/cert.pem"
                 certificateKeyFile="conf/privkey.pem"
                 certificateChainFile="conf/chain.pem" />
          </SSLHostConfig>
</Connector>

到端口 443:

<Connector port="443"     protocol="org.apache.coyote.http11.Http11NioProtocol"
    maxThreads="150" SSLEnabled="true">
        ...
</Connector>

【问题讨论】:

  • 没有不正常,你做了什么改变?
  • 启用 CORS 或通过 certbot 添加 SSL 密钥

标签: java ssl tomcat https google-cloud-platform


【解决方案1】:

确切的原因仍然是个谜,但“重新安装一切”做得很好。可能是我在安装 Tomcat 或 Java 的过程中犯了一些错误。

如果有人会遇到类似的问题,这就是我的配置方式。

  1. 安装java via apt

  2. 安装tomcatas service started with systemctl

  3. 添加letsencrypt via certbot

  4. 重定向ports using iptables

  5. 根据documantation启用CORS。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-23
    • 2020-11-12
    相关资源
    最近更新 更多