Linux之centos7.3安裝tomcat7

1.使用filezilla軟件將tomcat7的安裝包上傳到Linux主機的指定文件夾下

2.解壓tomcat安裝包,複製到/usr/local目錄下

cp -r apache-tomcat-7.0.68 /usr/local/tomcat7

3.編輯profile配置文件,配置tomcat7的配置信息

vim /etc/profile

4.在jdk的配置後面加上如下:

export TOMCAT_HOME=/usr/local/tomcat7
export CATALINA_HOME=/usr/local/tomcat7

5.重新加載profile配置文件

source /etc/profile

6.如果使用的阿里雲服務器 需要在阿里雲服務器的控制檯:

放行8080端口號

7.如果是在自己電腦上裝的虛擬機 則需要

①編輯防火牆配置文件:

vim /ect/sysconfig/iptables

②複製22端口的放行,改爲放行8080

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

③重新啓動防火牆

service iptables restart

8.啓動tomcat服務器,在tomcat的bin目錄下輸入:

使用命令 ./startup.sh 啓動
使用命令 ./shutdown.sh 關閉服務

9.在客戶機的瀏覽器中輸入:

linux主機ip:8080  如果出現廣告頁則表示安裝成功


10.如果訪問失敗查看Tomcat的日誌,如果tomcat啓動以後卡在INFO:Deploying web application directory(解決辦法來源:https://blog.csdn.net/njchenyi/article/details/46641141?tdsourcetag=s_pcqq_aiomsg

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 正常

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章