部署第二个Java应用
部署方式类似与nginx应用部署(IP/端口/域名)
基于域名#修改配置文件,添加host域名
[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安装应用
基于端口
[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
curl测试
[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
- 网页访问zrlog.featue.com:8081
基于IP(更换IP网卡)
- 备注
#vim $JAVA_HOME/jre/lib/security/java.security
将securerandom.source=file:/dev/random
改为securerandom.source=file:/dev/urandom
- 关于$JAVA_HOME路径