gpt4 book ai didi

java - Tomcat7 在 Ubuntu 14.04 x64 [Digitalocean] 上启动太晚了

转载 作者:IT老高 更新时间:2023-10-28 20:34:14 24 4
gpt4 key购买 nike

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

1GB Ram 30GB SSD 磁盘阿姆斯特丹 2 Ubuntu 14.04 x64

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

可能是什么问题?

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

catalina.out 说:INFO:使用 [SHA1PRNG] 为 session ID 生成创建 SecureRandom 实例花费了 [1,718,769] 毫秒。

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

安装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 分钟或更长时间后显示]

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

      ./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 欢迎页面立即打开

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

    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/urandom 替换为 $JAVA_PATH/jre/中的 securerandom.source=file:/dev/./urandom lib/security/java.security 解决了我的问题。

即使指定了 file:/dev/urandom,JRE 仍将 /dev/random 用于 SHA1PRNG(参见 bug JDK-4705093):

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

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

  2. 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.

来自 Wikipedia on /dev/random :

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

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

环境噪音?

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

这意味着在实践中,可能会阻止 Tomcat 一段未知的时间。

关于java - Tomcat7 在 Ubuntu 14.04 x64 [Digitalocean] 上启动太晚了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26431922/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com