解决:centos7.3 tomcat7启动巨慢问题
目前公司大部分服务器操作系统还是centos6.5,tomcat用的是7,平时基本上没什么问题,启动也比较快,但是,最近有部分项目服务器更新至centos7.3 ,有些机器启动tomcat的时候巨慢无比,甚至达到10分钟左右,无法忍受,于是想办法解决这个问题,网上帖子也比较多,基本上能解决问题,还是简单记录一下吧:
tomcat wiki上有这么一段话:
Entropy Source Tomcat 7+ heavily relies on SecureRandom class to provide random values for its session ids and in other places. Depending on your JRE it can cause delays during startup if entropy source that is used to initialize SecureRandom is short of entropy. You will see warning in the logs when this happens, e.g.: <DATE> org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [5172] milliseconds.
There is a way to configure JRE to use a non-blocking entropy source by setting the following system property: -Djava.security.egd=file:/dev/./urandom Note the "/./" characters in the value. They are needed to work around known Oracle JRE bug #6202721. See also JDK Enhancement Proposal 123. It is known that implementation of SecureRandom was improved in Java 8 onwards. Also note that replacing the blocking entropy source (/dev/random) with a non-blocking one actually reduces security because you are getting less-random data. If you have a problem generating entropy on your server (which is common), consider looking into entropy-generating hardware products such as "EntropyKey".
从这段话中,可以找到解决方案,在启动的时候添加一个参数: -Djava.security.egd=file:/dev/./urandom
另外一种方式,网上帖子也有说,那就是修改jre/lib/security/java.security文件:
#securerandom.source=file:/dev/urandom
securerandom.source=file:/dev/./urandom
有人还推荐了另外一种方式,前提是需要服务器cpu支持DRNG特性:
1、查看是否支持:
cat /proc/cpuinfo | grep rdrand
2、如果支持,安装rngd服务(熵服务):
yum install rngd-tools
3、启动服务
systemctl start rngd
如果你的CPU不支持DRNG特性或者使用虚拟机,可以使用/dev/unrandom来模拟。
cp /usr/lib/systemd/system/rngd.service /etc/systemd/system
编辑/etc/systemd/system/rngd.service service,ExecStart=/sbin/rngd -f -r /dev/urandom
systemctl daemon-reload重新载入服务
systemctl restart rngd重启服务
观察/proc/sys/kernel/random/entropy_avail:
watch -n 1 cat /proc/sys/kernel/random/entropy_avail
新打开一个shell,用dd命令测试随机数。dd if=/dev/random of=random.dat count=40960
参考:
https://wiki.apache.org/tomcat/HowTo/FasterStartUp
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6202721
http://udn.yyuap.com/thread-129351-1-1.html
解决:centos7.3 tomcat7启动巨慢问题的更多相关文章
- 解决centos7下tomcat启动正常,无法访问项目的问题
centos7防火墙不再采用iptables命令,改用firewalld 禁用防火墙命令: # systemctl stop firewalld.service # systemctl disable ...
- CentOS7的网卡启动不起来的问题
这个问题在刚学Linux遇到的,centOS7的网卡启动不起来,导致建不了集群.如下图没有ifconf-env33网卡的IP 还有下面这个图>>> 如果你遇到了,呵呵呵,迷之微笑. ...
- 解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist
解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist 早上在linux下用selenium启动Chro ...
- tomcat7 启动项目报错 java.lang.NoSuchMethodError: javax.servlet.ServletContext.getSessionCookieConfig()
JDK版本:jdk1.8.0_77 Tomcat 版本:apache-tomcat-7.0.47 异常重现步骤: 1.完成项目部署 2.启动Tomcat 异常头部信息:java.lang.NoSuch ...
- 【技术贴】第二篇 :解决使用maven jetty启动后无法加载修改过后的静态资源
之前写过第一篇:[技术贴]解决使用maven jetty启动后无法加载修改过后的静态资源 一直用着挺舒服的,直到今天,出现了又不能修改静态js,jsp等资源的现象.很是苦闷. 经过调错处理之后,发现是 ...
- 解决idea的项目启动报404的问题
最近在学习IDEA,由于之前一直使用的是Eclipse,所以初次接触IDEA就接触到了不少的坑,其中最让人头疼的大概就是如何让IDEA顺利的启动起来了,这方面我就不细讲了,网上已经有了不少的教程,稍后 ...
- gedit 没有preference项,使preference回归,并用命令行设置行号,解决centos7下中文乱码,text wrapping等问题
1. 最简单的,使preference选项回来: gsettings set org.gnome.settings-daemon.plugins.xsettings overrides '@a{sv} ...
- 解决不联网无法启动struts2问题
Unable to load configuration. - Class: java.net.PlainSocketImplFile: PlainSocketImpl.javaMethod: con ...
- 【运维技术】VM虚拟机上使用centos7安装docker启动gogs服务教程【含B站视频教程】
VM虚拟机上使用centos7安装docker启动gogs服务视频教程 BiliBili视频教程链接飞机票,点我 使用VMware Workstation安装Centos7 MinMal系统 第一步: ...
随机推荐
- 【iOS开发】动态添加子视图 UIView 的正确方法
很多时候哥比较喜欢用代码添加视图,特别是要同时加很多UIView时,而且跟 xib 比起来代码更容易管理,在多人的项目中代码不容易 conflict. 但小牛哥最近发现很多新人都不太清楚正确的使用方法 ...
- CubieTruck使用笔记--SD卡中使用lubuntu
http://docs.cubieboard.org/tutorials/ct1/installation/install_lubuntu_desktop_server_to_sd_card 按照上面 ...
- 为Ubuntu安装FTP服务
打开"终端窗口",输入"sudo apt-get update"-->回车-->"输入当前登录用户的管理员密码"-->回车 ...
- Eclipse打不开,闪退
自己编写了个程序,运行巨慢..无语,输出太多,后来冒出一个错误,不知什么原因啊,再后来Eclipse就打不开了,到workbench闪退... 百度后解决方案: 进入目录:workspace/.met ...
- NS产品演进
NS产品演进 Citrix产品体系================ Citrix产品类别================ NS产品演进================ 产品联系方式========== ...
- [洛谷P4291][HAOI2008]排名系统
题目大意:三种操作: $+Name\;Socore:$上传最新得分记录,把以前的记录删除. $?Name:$ 查询玩家排名.如果两个玩家的得分相同,则先得到该得分的玩家排在前面. $?Index:$ ...
- [AHOI2013]作业 & Gty的二逼妹子序列 莫队
---题面--- 题解: 题目要求统计一个区间内数值在[a, b]内的数的个数和种数,而这个是可以用树状数组统计出来的,所以可以考虑莫队. 考虑区间[l, r]转移到[l, r + 1],那么对于维护 ...
- 洛谷 P2827 蚯蚓 解题报告
P2827 蚯蚓 题目描述 本题中,我们将用符号 \(\lfloor c \rfloor\) 表示对 \(c\) 向下取整,例如:\(\lfloor 3.0 \rfloor = \lfloor 3.1 ...
- 【CF edu 30 D. Merge Sort】
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- Angular白名单&&Angular拦截器 全局通用
//angular 白名单全局通用 app.config([ '$compileProvider', function ($compileProvider) { $compileProvider.aH ...