部署方式相似與nginx應用部署(IP/端口/域名)html
基於域名 #修改配置文件,添加host域名java
[root@feature1 ~]# vim /usr/local/tomcat/conf/server.xml <Host name="test.feature.com" appBase="/data/wwwroot/teest.feature.com" unpackWARs="true" autoDeploy="true"> </Host> [root@feature1 ~]# /usr/local/tomcat/bin/shutdown.sh [root@feature1 wwwroot]# ps aux |grep java root 4488 99.2 4.6 2530260 85568 pts/0 Sl 12:42 0:04 /usr/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start root 4530 0.0 0.0 112708 976 pts/0 R+ 12:42 0:00 grep --color=auto java [root@feature1 ~]# /usr/local/tomcat/bin/startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar Tomcat started.
#配置的appbase目錄不須要手動建立,重啓tomcat服務後會自動建立 [root@feature1 wwwroot]# netstat -tnlp|grep java #拷貝java應用的war包到webapps目錄下 [root@feature1 wwwroot]# cd /usr/local/tomcat/webapps/ [root@feature1 webapps]# cp zrlog.war /data/wwwroot/test.feature.com/ [root@feature1 webapps]# cd /data/wwwroot/test.feature.com/ [root@feature1 test.feature.com]# mv zrlog ROOT [root@feature1 test.feature.com]# rm -rf zrlog.war
#curl測試 [root@feature1 wwwroot]# curl -x127.0.0.1:8080 -I test.feature.com HTTP/1.1 302 X-ZrLog: 2.1.0 Location: /install Transfer-Encoding: chunked Date: Tue, 19 Feb 2019 05:02:29 GMT #網頁訪問test.feature.com:8080安裝應用
拷貝一個tomcat目錄,修改server.xml裏面的三個端口配置(其中8009端口能夠刪掉,8080和8005端口其餘自定義端口)linux
[root@feature1 wwwroot]# cd /usr/local [root@feature1 local]# cp -r tomcat/ tomcat_2 [root@feature1 local]# vim tomcat_2/conf/server.xml #刪除以前新加的host域名配置,默認的host域名配置能夠自定義,這次實驗環境保持默認,修改默認的三個端口配置 #刪除8009端口配置 #修改8080爲8081 #修改8005爲8006
[root@feature1 local]# /usr/local/tomcat_2/bin/startup.sh Using CATALINA_BASE: /usr/local/tomcat_2 Using CATALINA_HOME: /usr/local/tomcat_2 Using CATALINA_TMPDIR: /usr/local/tomcat_2/temp Using JRE_HOME: /usr Using CLASSPATH: /usr/local/tomcat_2/bin/bootstrap.jar:/usr/local/tomcat_2/bin/tomcat-juli.jar Tomcat started. [root@feature1 local]# firewall-cmd --add-port=8081/tcp --permanent success [root@feature1 local]# firewall-cmd --reload success [root@feature1 local]# netstat -ltnp|grep java tcp6 0 0 :::8009 :::* LISTEN 4599/java tcp6 0 0 :::8080 :::* LISTEN 4599/java tcp6 0 0 :::8081 :::* LISTEN 5080/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 4599/java tcp6 0 0 127.0.0.1:8006 :::* LISTEN 5080/java
[root@feature1 local]# curl -x127.0.0.1:8081 -I zrlog.feature.com HTTP/1.1 200 Content-Type: text/html;charset=UTF-8 Transfer-Encoding: chunked Date: Tue, 19 Feb 2019 05:38:41 GMT
經過java.security.SecureRandom生成隨機數來實現,隨機數算法使用的是"SHA1PRNG",這個算法的提供者在底層依賴到操做系統提供的隨機數據,在linux上,與之相關的是/dev/random和/dev/urandom。/dev/random設備會返回小於熵池噪聲總數的隨機字節。/dev/random可生成高隨機性的公鑰或一次性密碼本。若熵池空了,對/dev/random的讀操做將會被阻塞,直到收集到了足夠的環境噪聲爲止,而 /dev/urandom則是一個非阻塞的發生器。它是/dev/random的一個副本,它會重複使用熵池中的數據以產生僞隨機數據。這表示對/dev/urandom的讀取操做不會產生阻塞,但其輸出的熵可能小於/dev/random。總之,8005端口啓動慢就是由於JVM調用了系統的/dev/random設備生成隨機數,而/dev/random生成隨機數時被block了,天然就會致使8005端口啓動慢,解決辦法是不使用/dev/random,而是使用/dev/urandom。具體步驟以下:nginx
#vim $JAVA_HOME/jre/lib/security/java.security 將securerandom.source=file:/dev/random 改成securerandom.source=file:/dev/urandom
若是是openjdk(yum安裝的),在/usr/lib/jvm/ 若是是下載的二進制包,就是jdk的主目錄(如/usr/local/jdk_1.8)web