Linux之centos7.3安装tomcat7

版权声明:转载麻烦告知。 https://blog.csdn.net/qq_40064948/article/details/84593057

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

猜你喜欢

转载自blog.csdn.net/qq_40064948/article/details/84593057