On the basis of the above articles, this article will mainly teach novices how to deploy and optimize tomcat on Centos system
# wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz
Unzip apache-tomcat-7.0.79.tar.gz
# tar -xvf apache-tomcat-7.0.79.tar.gz
Analogous to tomcat startup on Windows, start tomcat through the startup.sh script in the bin directory
# cd apache-tomcat-7.0.79/bin
# . /startup.sh && tail -f ../logs/catalina.out
You can see the usual log printing from the window. After a while, tomcat can be started. Open the server's ip:8080 with a browser to see the cat's logo.
# vim $JAVA_HOME/jre/lib/security/java.security
or
# vim $JRE_HOME/lib/security/java.security
Find securerandom.source=file:/dev/random and change to
securerandom.source=file:/dev/urandom
: wq save and exit
Tomcat Connector supports three modes of operation: BIO, NIO, APR.
One thread processes one request. Disadvantages: When the amount of concurrency is high, there are more threads, which wastes resources.
Tomcat7 or below, this method is used by default in Linux systems.
Using Java's asynchronous IO processing, a large number of requests can be processed through a small number of threads.
Tomcat8 uses this method by default in Linux systems.
Tomcat7 must modify the Connector configuration to start:
That is, Apache Portable Runtime, which solves the io blocking problem from the operating system level.
Tomcat7 or Tomcat8 starts this way by default in Win7 or above systems.
If Linux is installed with apr and native, Tomcat will support apr when started directly
In the traditional sense, Tomcat under Linux requires a lot of compilation work to enable APR mode, and the knowledge points involved in the middle are too extensive, so the following directly uses the compiled library in the centos source to enable Tomcat to enable APR mode
# yum install tcnative
Restart tomcat and see "Starting ProtocolHandler ["http-apr-8080"]" displayed on the console, which means the optimization is successful!
Recommended Posts