解决: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系统 第一步: ...
随机推荐
- 总结java操作MySQL 即JDBC的使用
java.sql包中存在DriverManager类,Connection接口,Statement接口和ResultSet接口.类和接口作用如下: DriverManager:主要用于管理驱动程序和连 ...
- Vue2.0 新手完全填坑攻略——从环境搭建到发布(转载)
强力推荐,详情请点击此链接http://www.jianshu.com/p/5ba253651c3b
- 绝对定位后a、button等hover状态样式不显示问题
<div class="operate"> <el-button>提交项目</el-button> <el-button type=&qu ...
- Action中使用Json
1.前台页面中的ajax: //根据部门查询该部门下的用户列表 function doSelectDept(){ //1.获取部门 var dept = $("#toCompDept opt ...
- HDOJ.2501 Tiling_easy version
Tiling_easy version Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 【TMD模拟赛】上低音号 链表
这道题一看有两个出发现点,一枚举点去找边界,想了一会就Pass了...,二是枚举相框,我们最起码枚举两个边界,然后发现平行边界更好处理,然而仍然只有30分,这个时候就来到了链表的神奇应用,我们枚举上界 ...
- nm用法小记
nm用于显示目标文件的符号,也是二进制工具集(info binutils)里的一员 先来看一个例子,源码和对应的命令结果 四部分分别表示的意义 符号所在的obj文件名 符号的值,这里应该是指符号所在段 ...
- [fzu 2282]置换不动点大于等于k的排列数
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2282 编号1~n的置换,不动点个数大于等于k的方案数. 参考百度百科错排公式,可以知道长度为n,每个数都不在自 ...
- POJ1797:Heavy Transportation(改造Dijkstra)
Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 52728 Accepted: ...
- Astah画时序图
Astah画时序图,666 1.生命线 时序图中表示为从对象图标向下延伸的一条虚线,表示对象存在的时间, 一般用来描述 系统 :如 客户端,代理层,缓存层,服务器层1.....服务器层N,数据库等. ...