Tomcat啟動時卡在“INFO: Deploying web application directory ......”的解決方案

來源:互聯網
上載者:User

標籤:pen   try   .sh   應該   預設   shell   splay   ems   mmu   

轉載地址:http://blog.csdn.net/njchenyi/article/details/46641141

第一次遇到Tomcat在Linux伺服器啟動卡住的情況,情況很簡單,tomcat啟動以後卡在INFO: Deploying web application directory ......這句話,具體會卡多久就沒測試了。google、baidu都沒找到解決方案。

幸虧UCloud的技術支援人員給出瞭解決方案。

找到jdk1.x.x_xx/jre/lib/security/Java.security檔案,在檔案中找到securerandom.source這個設定項,將其改為:

securerandom.source=file:/dev/./urandom

這時候根據修改內容就可以查到因為此原因不僅可以造成tomcat卡住,也會造成weblogic啟動緩慢,

linux或者部分unix系統提供隨機數裝置是/dev/random 和/dev/urandom ,兩個有區別,urandom安全性沒有random高,但random需要時間間隔產生隨機數。jdk預設調用random。
再後來,終於在weblogic的官方文檔中 Monitoring and Troubleshooting 找到了 Avoiding JVM Delays Caused By Random Number Generation 這樣一個標題。摘錄如下:
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/random
Open the $JAVA_HOME/jre/lib/security/java.security file in a text editor.
Change the line:
securerandom.source=file:/dev/random
to read:
securerandom.source=file:/dev/urandom
Save your change and exit the text editor.
其中說到:可通過 head -n 1 /devrandom 查看是否你的系統會出現偽隨機數提供等待。OK就這個,試了一下,果然,在伺服器第一次啟動後,這個可以快速提供一個值,但當再次調用時發生等待。
解決辦法:
永久:oracle 說修改 $JAVA_HOME/jre/lib/security/java.security 檔案,替換securerandom.source=file:/dev/random 為 securerandom.source=file:/dev/urandom。對所有使用JVM的應用生效。(這個永久的方法,這裡面有個問題,就是設定時候實際應該設定為securerandom.source=file:/dev/./urandom,否則不生效)
DOMAIN臨時:修改startWeblogic.sh檔案,JAVA_OPTIONS="${SAVE_JAVA_OPTIONS} -Djava.security.egd=file:/dev/./urandom"
後繼的SecureRandom 測試學習
編寫JAVA類如下,運行測試,第一次正常,第二次等待,重啟伺服器後第一次又正常。啟動加入參數 -Djava.security.egd=file:/dev/./urandom 正常

Tomcat啟動時卡在“INFO: Deploying web application directory ......”的解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.