Build a high-performance and high-availability Tomcat server from scratch
Objectives:
Tomcat + Nginx + Memcached
Ubuntu 16.04 passed the 64-bit Test
Dynamic/static classification, load balancing, cluster, Javolution serialization, high performance, high availability
Configuration environment (currently the latest stable version ):
Jdk-8u131-linux-x64
Apache -- tomcat-8.5.14
Nginx-1.12.0
Memcached-1.4.36
Preface:
I originally planned to configure the kryo serialization framework, but it was not successful. I had to use Javolution.
If the final failure is found, the problem usually occurs in Tomcat. Check the log to solve the problem.
You can deploy multiple projects under tomcat, and the categories are still dynamic and static.
Nginx is configured to assign the suffix of jsp, servlet, And do files to Tomcat for processing. You can add
If you do not use the root account to run nginx, The nginx user configuration is useless.
Tomcat and nginx are all optimized. You can directly put them in Tomcat/webapps without modifying any content of the original project.
Process:
The process is long. Please be careful
# Sudo passwd # Use the Administrator to configure sudo su # update the software list apt-get update # install the required dependency file apt-get install gcc zlib1g zlib1g-dev openssl libssl-dev libpcre3 libpcre3-dev libevent-dev # restart (recommended) rebootsudo su # install and configure JDK ,: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htmltar-zxvf jdk-8u131-linux-x64.tar.gzmv jdk1.8.0 _ 131/usr/local/jdk # configure JDK environment variable sed-I '$ a ulimit-n 6666'/etc/profilesed-I' $ a export JAV A_HOME =/usr/local/jdk '/etc/profilesed-I' $ a export JRE_HOME = $ JAVA_HOME/jre '/etc/profilesed-I' $ a export CLASSPATH =.: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH '/etc/profilesed-I' $ a export PATH = $ JAVA_HOME/bin: $ JRE_HOME/bin: $ PATH '/etc/profilesource/etc/profilerm jdk-8u131-linux-x64.tar.gz # install and configure memcachedwget http://www.memcached.org/files/memcached-1.4.36.tar.gztar-zxvf memcached-1.4.36.tar.gzcd Memcached-1.4.36. /configure -- prefix =/usr/local/memcachedmake & make installcd .. & rm-rf memcached-1.4.36 & rm memcached-1.4.36.tar.gz # Install configuration Tomcatwget http://apache.fayea.com/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gztar-zxvf apache-tomcat-8.5.14.tar.gz # download add lib file to support sharing sessioncd apache-tomcat-8.5.14/libwget http://central.maven.org/maven2/de/javakaffee/msm/memcached-session-manage R/2.1.1/memcached-session-manager-2.1.1.jarwget http://central.maven.org/maven2/de/javakaffee/msm/memcached-session-manager-tc8/2.1.1/memcached-session-manager-tc8-2.1.1.jarwget http://central.maven.org/maven2/net/spy/spymemcached/2.11.1/spymemcached-2.11.1.jarwget http://central.maven.org/maven2/de/javakaffee/msm/msm-javolution-serializer/2.1.1/msm-javolution-serializer-2.1.1.jarwget http: // centr Al.maven.org/maven2/javolution/javolution/5.4.5/javolution-5.4.5.jarcd .. & cd .. # disable TLDs from scanning the newly added jar package sed-I '134c xom -*. jar, javolution-5.4.5.jar, memcached-session-manager-2.1.1.jar, memcached-session-manager-tc8-2.1.1.jar, msm-javolution-serializer-2.1.1.jar 'apache-tomcat-8.5.14/conf/catalina. properties # tomcat Optimization Configuration, insert the content sed-I '102c export JAVA_OPTS = "-server-Xms1000M-Xm in line 102 X1000M-Xss512k-XX: + AggressiveOpts-XX: + UseBiasedLocking-XX: + DisableExplicitGC-XX: Counter = 15-XX: + UseConcMarkSweepGC-XX: + UseParNewGC-XX: + CMSParallelRemarkEnabled-XX: + UseCMSCompactAtFullCollection-XX: LargePageSizeInBytes = 128 m-XX: + UseFastAccessorMethods-XX: + UseCMSInitiatingOccupancyOnly-Djava. awt. headless = true "'apache-tomcat-8.5.14/bin/catalina. shrm-rf apache-tomcat-8.5.14/w Ebatemkdir-vp apache-tomcat-8.5.14/webapps/ROOTcp-r apache-tomcat-8.5.14/usr/local/tomcatmv apache-tomcat-8.5.14/usr/local/tomcat2chown ubuntu. ubuntu-R/usr/local/tomcatchown ubuntu. ubuntu-R/usr/local/tomcat2rm apache-tomcat-8.5.14.tar.gz # create test web page touch/usr/local/tomcat/webapps/ROOT/index. jspecho '<% @ page language = "java" contentType = "text/html; charset = UTF-8" pageEncoding = "UTF-8" %>