Tomcat starts with slow optimization methods
Tomcat started today and found that the start is very slow, take a few minutes, the problem worthy of attention, so go to view the log, found that time is caused by a random number caused by the problem. Tomcat Session ID calculated by SHA1 algorithm, the time to calculate Session ID must have a secret key, in order to improve the security Tomcat at startup time through the random number generated secret key.
First, the environment introduced
System version: CentOS 7.2
Software version: Tomcat 8
Second, the log analysis, troubleshooting reasons are as follows:
4-Mayr-2017 8:07:49 .623 INFO [localhost-startStop-1] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandominstance for session ID generation using [SHA1PRNG] took [55,507] milliseconds.
4- Mayr-2017 8:07:49 .653 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectoryDeployment of web application directory / application / apache-tomcat-8.0.27 / webapps / ROOT has finished In 165,935 ms
The main reason:
is generated by the random number of the key when the card stuck, causing Tomcat to start slow or failure.
# Affect the strength of the random number is generated with the entropy, the specific meaning of their own daughters check, not here to elaborate.
To see if there is enough entropy to generate a random number, you can use the
following command to see [root @ qiuyuetao tools] # cat /proc/sys/kernel/random/entropy_avail
7
In order to speed up /dev/random to provide the speed of random numbers, you can operate the device peripherals,
let it produce a lot of interrupt (such as network transmission data,
press the button, move the mouse, at the command line to knock on several different commands, commonly known as poly Gas
cat /dev/random ## can consume energy
Third,
there are three ways to deal with and optimize the solution;
Method 1: Use rngd software to increase the entropy pool *****
Recommended to use grep rdrand /proc/cpuinfo # Need cpu support
yum install rng-tools # Install rngd service (entropy service , Increase the entropy pool)
systemctl start rngd # start the service
Method 2: java
environment to modify the configuration file vim $JAVA_HOME/jre/lib/security/java.security
securerandom.source = file: /dev/random
to
securerandom.source = file: /dev/urandom
Method 3: You can
configure a JRE using a non-blocking Entropy Source: vim $TOMCAT_HOME/bin/catalina.sh
if [[$ JAVA_OPTS “! = * – Djava.security.egd = *]]; then
JAVA_OPTS =” $ JAVA_OPTS -Djava.security.egd = file: /dev/urandom ”
fi
## This system attribute egd said entropy collection daemon (entropy gathering daemon)
Recent Comments