重複啟動Tomcat時,大機率出現Deploying web application direct

來源:互聯網
上載者:User

標籤:tomcat

由前一篇文章開始折騰supervisor,想玩玩tomcat異常退出後使用supervisor自動讓tomcat重新啟動,
隨即丟了一個tomcat在伺服器裡面,本來就沒有放任何項目,空跑在那邊,只是tomcat有個介面就看看起沒起來。
 
於是手動停止tomcat的進程觸發supervisor自動拉起服務,應該是沒有問題的,但是,來來回回啟動了個兩三次,突然發現,tomcat竟然起不來了!

隨即查閱下日誌:
 

[email protected] bin]# tail -f ../logs/catalina.out19-Jun-2018 15:57:06.666 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]19-Jun-2018 15:57:06.667 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read19-Jun-2018 15:57:06.667 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 535 ms19-Jun-2018 15:57:06.684 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina19-Jun-2018 15:57:06.684 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.1.1519-Jun-2018 15:57:06.690 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/apache-tomcat-8.1.15-server/webapps/ROOT

 
卡在這個啟動狀態至少由10分鐘才能完全啟動起來,而且每次都這樣。。。空跑都能這麼操蛋?部署個項目還得了?難道要半小時?

網上查閱到有個大神寫的文章,大意就是下面這句話:
 

The library used for random number generation in Sun‘s JVM relies on /dev/random by default for UNIX platforms. This can potentially block the Oracle WebLogic Communication Services process because on some operating systems /dev/random waits for a certain amount of "noise" to be generated on the host machine before returning a result. Although /dev/random is more secure, Oracle recommends using /dev/urandom if the default JVM configuration delays Oracle WebLogic Communication Services startup.To determine if your operating system exhibits this behavior, try displaying a portion of the file from a shell prompt:head -n 1 /dev/randomOpen the $JAVA_HOME/jre/lib/security/java.security file in a text editor.Change the line:securerandom.source=file:/dev/randomto read:securerandom.source=file:/dev/urandomSave your change and exit the text editor.

 
就是linux提供隨機數裝置是/dev/random 和/dev/urandom,一般我們都只是都使用"/dev/random",這個參數做隨機數(因為每本操蛋的書都是這麼寫的!也沒人說過為啥。)
 
兩個有區別,urandom安全性沒有random高,但random需要時間間隔產生隨機數。jdk預設調用random。
 
所以根據上面的說法,修改設定檔:
 

find / -name securerandom.source

 
找到Java.security檔案,在檔案中找到securerandom.source這個設定項,將其改為:
 

securerandom.source=file:/dev/urandom

 
修改完畢後,重啟tomcat,瞬間啟動完畢。

重複啟動Tomcat時,大機率出現Deploying web application direct

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.