Tomcat7 在 Ubuntu 14.04 x64 [Digitalocean] 上启动太晚 [英] Tomcat7 starts too late on Ubuntu 14.04 x64 [Digitalocean]

查看:27
本文介绍了Tomcat7 在 Ubuntu 14.04 x64 [Digitalocean] 上启动太晚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 digitalocean 并尝试在 ubuntu 上安装和启动 tomcat,但不幸的是我无法做到.(创建新的液滴并尝试了 10 次)

i am using digitalocean and trying to install and start tomcat on ubuntu but unfortunately i can not do it. (created new droplets and tried 10 times)

1GB Ram 30GB SSD Disk Amsterdam 2 Ubuntu 14.04 x64

当我启动 tomcat 时,它说Tomcat 已启动".但我无法从浏览器访问页面.和 ./shutdown.sh 返回错误.

When i start tomcat, it says "Tomcat started". But i can not access page from browser. and ./shutdown.sh returns error.

可能是什么问题?

我现在注意到了一些事情.在我写这个问题时,显示了 tomcat 页面.显示页面花了 28 分钟

catalina.out 说:信息:使用 [SHA1PRNG] 为会话 ID 生成创建 SecureRandom 实例花了 [1,718,769] 毫秒.

catalina.out says: INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [1,718,769] milliseconds.

以下是我的安装步骤(这些步骤适用于不同的 vps,但不适用于 digitalocean droplets):

Here are my installation steps (These steps works on different vps but doesn't work on digitalocean droplets):

安装 oracle jdk

Install oracle jdk

 sudo apt-get install python-software-properties
 sudo add-apt-repository ppa:webupd8team/java
 sudo apt-get update
 sudo apt-get install oracle-java7-installer
 sudo apt-get install oracle-java7-set-default
      java -version
      java version "1.7.0_72"
      Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)

设置java路径

      sudo nano /etc/environment
      JAVA_HOME="/usr/lib/jvm/java-7-oracle"
      source /etc/environment
      wget http://ftp.itu.edu.tr/Mirror/Apache/tomcat/tomcat-7/v7.0.56/bin/apache-tomcat-7.0.56.tar.gz
      tar xvzf apache-tomcat-7.0.56.tar.gz
      mv apache-tomcat-7.0.56/ apache-tomcat-7.0.56-server-1/

启动Tomcat

        ./startup.sh
            Using CATALINA_BASE:   /usr/local/apache-tomcat-7.0.56-server-1
            Using CATALINA_HOME:   /usr/local/apache-tomcat-7.0.56-server-1
            Using CATALINA_TMPDIR: /usr/local/apache-tomcat-7.0.56-server-1/temp
            Using JRE_HOME:        /usr/lib/jvm/java-7-oracle/jre
            Using CLASSPATH:       /usr/local/apache-tomcat-7.0.56-server-1/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.56-server-1/bin/tomcat-juli.jar
            Tomcat started.

结帐端口 8080

        netstat -ln 
            tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
            tcp6       0      0 :::8009                 :::*                    LISTEN
            tcp6       0      0 :::8080                 :::*                    LISTEN
            tcp6       0      0 :::22                   :::*                    LISTEN

结帐流程

            ps -ef | grep tomcat
            root      2825     1  1 14:23 pts/0    00:00:03 /usr/lib/jvm/java-7-oracle/jre/bin/java -Djava.util.logging.config.file=/usr/local/apache-tomcat-7.0.56-server-1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/apache-tomcat-7.0.56-server-1/endorsed -classpath /usr/local/apache-tomcat-7.0.56-server-1/bin/bootstrap.jar:/usr/local/apache-tomcat-7.0.56-server-1/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/apache-tomcat-7.0.56-server-1 -Dcatalina.home=/usr/local/apache-tomcat-7.0.56-server-1 -Djava.io.tmpdir=/usr/local/apache-tomcat-7.0.56-server-1/temp org.apache.catalina.startup.Bootstrap start

在 8080 端口打开网站 http://5.101.107.56:8080/ 页面正在等待... [28 分钟或更长时间后显示内容]

Open web site at port 8080 http://5.101.107.56:8080/ Page is waiting... [content is displayed after 28 minute or more]

如果内容尚未显示(在tomcat正常启动之前),请尝试关闭tomcat.

Try to shutdown tomcat if content is not displayed yet (before tomcat starts properly).

      ./shutdown.sh 
            SEVERE: Could not contact localhost:8005. Tomcat may not be running.
            Oct 17, 2014 2:40:29 PM org.apache.catalina.startup.Catalina stopServer
            SEVERE: Catalina.stop:
                java.net.ConnectException: Connection refused
                at java.net.PlainSocketImpl.socketConnect(Native Method)
                at java.net.AbstractPlainSoc

结帐日志

      catalina.out
            Oct 17, 2014 2:31:47 PM org.apache.coyote.AbstractProtocol init
            INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
            Oct 17, 2014 2:31:47 PM org.apache.catalina.startup.Catalina load
            INFO: Initialization processed in 1492 ms
            Oct 17, 2014 2:31:47 PM org.apache.catalina.core.StandardService startInternal
            INFO: Starting service Catalina
            Oct 17, 2014 2:31:47 PM org.apache.catalina.core.StandardEngine startInternal
            INFO: Starting Servlet Engine: Apache Tomcat/7.0.56
            Oct 17, 2014 2:31:47 PM org.apache.catalina.startup.HostConfig deployDirectory
            INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.56-server-1/webapps/host-manager

我也安装了nginx并导航到http://5.XXX.XXX.XX/ nginx欢迎页面立即打开

I also installed nginx and navigate to http://5.XXX.XXX.XX/ nginx welcome page is opened immediately

当我在浏览器中看到页面时,我检查了 catalina.out,它说:

I checked catalina.out when i see the page in browser, it says:

    Oct 17, 2014 2:31:47 PM org.apache.catalina.startup.HostConfig deployDirectory
    INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.56-server-1/webapps/host-manager
    Oct 17, 2014 3:00:27 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
    INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took **[1,718,769] milliseconds.**

内存:

               total       used       free     shared    buffers     cached
  Mem:       1017912     849512     168400        332      18780     688468

推荐答案

securerandom.source=file:/dev/./替换 securerandom.source=file:/dev/urandom$JAVA_PATH/jre/lib/security/java.security 中的 urandom 解决了我的问题.

Replacing securerandom.source=file:/dev/urandom with securerandom.source=file:/dev/./urandom in $JAVA_PATH/jre/lib/security/java.security has solved my problem.

即使指定了 file:/dev/urandom,JRE 仍将使用 /dev/random 进行 SHA1PRNG(请参阅错误 JDK-4705093):

Even when file:/dev/urandom is specified, JRE will still use /dev/random for SHA1PRNG (see bug JDK-4705093):

在 SHA1PRNG 中,有一个 SeedGenerator 可以做各种事情取决于配置.

In SHA1PRNG, there is a SeedGenerator which does various things depending on the configuration.

  1. 如果 java.security.egd 或 securerandom.source 指向file:/dev/random"或file:/dev/urandom",我们将使用NativeSeedGenerator,它调用 super() 调用SeedGenerator.URLSeedGenerator(/dev/random).(内部的嵌套类SeedGenerator.)这个错误中唯一改变的是urandom 也会触发使用此代码路径.

  1. If java.security.egd or securerandom.source point to "file:/dev/random" or "file:/dev/urandom", we will use NativeSeedGenerator, which calls super() which calls SeedGenerator.URLSeedGenerator(/dev/random). (A nested class within SeedGenerator.) The only things that changed in this bug was that urandom will also trigger use of this code path.

如果这些属性指向另一个存在的 URL,我们将初始化 SeedGenerator.URLSeedGenerator(url).这就是为什么file:///dev/urandom"、file:/./dev/random"等都可以使用.

If those properties point to another URL that exists, we'll initialize SeedGenerator.URLSeedGenerator(url). This is why "file:///dev/urandom", "file:/./dev/random", etc. will work.

来自 维基百科/dev/random:

在这个实现中,生成器保持对数字的估计熵池中的噪声位.从这个熵池随机数字被创建.读取时,/dev/random 设备只会在估计的噪声比特数内返回随机字节熵池./dev/random 应该适合需要的用途非常高质量的随机性,例如一次性填充或密钥生成.

In this implementation, the generator keeps an estimate of the number of bits of noise in the entropy pool. From this entropy pool random numbers are created. When read, the /dev/random device will only return random bytes within the estimated number of bits of noise in the entropy pool. /dev/random should be suitable for uses that need very high quality randomness such as one-time pad or key generation.

当熵池为空时,从/dev/random读取会阻塞直到收集到额外的环境噪音. 目的是作为加密安全的伪随机数生成器,以尽可能大的熵提供输出.这是建议用于生成高价值或长期的加密密钥保护.

When the entropy pool is empty, reads from /dev/random will block until additional environmental noise is gathered. The intent is to serve as a cryptographically secure pseudorandom number generator, delivering output with entropy as large as possible. This is suggested for use in generating cryptographic keys for high-value or long-term protection.

环境噪音?

随机数生成器从设备收集环境噪声 驱动程序和其他来源进入熵池.发电机也保持对熵池中噪声位数的估计.从这个熵池中创建随机数.

The random number generator gathers environmental noise from device drivers and other sources into an entropy pool. The generator also keeps an estimate of the number of bits of noise in the entropy pool. From this entropy pool random numbers are created.

这意味着在实践中,有可能阻止 tomcat 一段未知的时间.

这篇关于Tomcat7 在 Ubuntu 14.04 x64 [Digitalocean] 上启动太晚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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