Before the company used this, also simply wrote a document, and later found not enough detail to write so that others see my document, always overwhelmed, this time to write a detailed, share to you just contact this technology small partner!!!
Lab environment: Virtual machine centos6.6_x89_64 minal mode
Software version: apache-tomcat-7.0.64.tar.gz
Jdk-7u45-linux-x64.tar.gz
Libevent-2.0.21-stable.tar.gz
Memcached-1.4.21.tar.gz
And the jar packages that are relative to the Tomcat version
Turn off SELinux and firewalls before you experiment
Setenfor 0
Service Iptables Stop
This experiment will also use some basic dependency packages if you feel that they are not installed, you can run the command to prevent the subsequent compilation error.
Yum groupinstall-y Development Tools
All right, no nonsense, go!. Go! Go!
1. All packages are placed in/usr/local/src/
[Email protected] ~]# cd/usr/local/src/
[email protected] src]# LL
Total dosage 144688
-rw-r--r--1 root root 8858187 November 19:39 apache-tomcat-7.0.64.tar.gz
-rw-r--r--1 root root 138094686 November 19:40 jdk-7u45-linux-x64.tar.gz
-rw-r--r--1 root root 850772 November 19:39 libevent-2.0.21-stable.tar.gz
-rw-r--r--1 root root 345892 November 19:39 memcached-1.4.21.tar.gz
Drwxr-xr-x 2 root root 4096 November 19:40 Serssion-jar
2. Install Java and configure environment variables, detect JDK version
[Email protected] src]# tar zxvf jdk-7u45-linux-x64.tar.gz
[Email protected] src]# MV jdk1.7.0_45//USR/LOCAL/JDK7
[Email protected] src]# Vim/etc/profile
..........................................................
Export JAVA_HOME=/USR/LOCAL/JDK7
Export JRE_HOME=/USR/LOCAL/JDK7
Export path= $JAVA _home/bin: $JRE _home/bin: $PATH
Export classpath=.: $JAVA _home/lib: $JRE _home/lib
..........................................................
As shown in the following:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/76/85/wKiom1ZVZlGQJ8y3AABaVgoIRhI598.png "title=" 1.png " alt= "Wkiom1zvzlgqj8y3aabavgoirhi598.png"/>
[Email protected] src]# Source/etc/profile
[Email protected] src]# java-version
Java Version "1.7.0_45"
Java (TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot (TM) 64-bit Server VM (build 24.45-b08, Mixed mode)
3. Install Tomcat
[Email protected] src]# tar zxvf apache-tomcat-7.0.64.tar.gz
[Email protected] src]# MV Apache-tomcat-7.0.64/usr/local/tomcat
[Email protected]test13 src]# vim/usr/local/tomcat/bin/catalina.sh
..........................................................
Java_home=/usr/local/jdk7
Catalina_home=/usr/local/tomcat
Java_opts= "-server-xx:permsize=128m-xx:maxpermsize=512m-xms1024m-xmx1024m-duser.timezone=asia/shanghai- Djava.awt.headless=true "
..........................................................
As shown in the following:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/76/85/wKioL1ZVagCRvRRpAACUHaZEdXw474.png "title=" 2.png " alt= "Wkiol1zvagcrvrrpaacuhazedxw474.png"/>
[[email protected] src]#/usr/local/tomcat/bin/startup.sh//Start Tomcat
Using catalina_base:/usr/local/tomcat
Using Catalina_home:/usr/local/tomcat
Using Catalina_tmpdir:/usr/local/tomcat/temp
Using Jre_home:/usr/local/jdk7
Using CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[[Email protected] src]# PS aux |grep tomcat//You can see that Tomcat has started successfully
Root 1237 2.0 73.8 2335144 174376 pts/0 Sl 21:05 0:04/usr/local/jdk7/bin/java-djava.util.logging.config.file= /usr/local/tomcat/conf/logging.properties-djava.util.logging.manager=org.apache.juli.classloaderlogmanager- server-xx:permsize=128m-xx:maxpermsize=512m-xms1024m-xmx1024m-duser.timezone=asia/shanghai-djava.awt.headless= true-djava.endorsed.dirs=/usr/local/tomcat/endorsed-classpath/usr/local/tomcat/bin/bootstrap.jar:/usr/local/ tomcat/bin/tomcat-juli.jar-dcatalina.base=/usr/local/tomcat-dcatalina.home=/usr/local/tomcat-djava.io.tmpdir=/ Usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap Start
Root 1271 0.0 0.3 103248 880 pts/0 s+ 21:09 0:00 grep Tomcat
[[email protected] src]# Curl localhost:8080//test Tomcat can see no problem
<! DOCTYPE html>
<title>apache tomcat/7.0.64</title>
<link href= "Favicon.ico" rel= "icon" type= "Image/x-icon"/>
<link href= "Favicon.ico" rel= "shortcut icon" type= "Image/x-icon"/>
<link href= "Tomcat.css" rel= "stylesheet" type= "Text/css"/>
4. Compile and install memcached
[[email protected] src]# CP serssion-jar/*/usr/local/tomcat/lib///Put the MSM-dependent jar package under $tomcat_home/lib
[Email protected] src]# tar zxvf libevent-2.0.21-stable.tar.gz
[Email protected] src]# CD libevent-2.0.21-stable
[Email protected] libevent-2.0.21-stable]#/configure--prefix=/usr/local/libevent
[[email protected] libevent-2.0.21-stable]# make && make install
#每次编译最好用 echo $? To see if the compilation was successful
[Email protected] libevent-2.0.21-stable]# CD.
[Email protected] src]# tar zxvf memcached-1.4.21.tar.gz
[Email protected] src]# CD memcached-1.4.21
[Email protected] memcached-1.4.21]#/configure--prefix=/usr/local/memcached--with-libevent=/usr/local/libevent
[[email protected] memcached-1.4.21]# make && make install
[[email protected] memcached-1.4.21]# echo $?
0
5. Modify the Tomcat configuration file
[Email protected] memcached-1.4.21]# cd/usr/local/tomcat/
[Email protected] tomcat]# vim Conf/server.xml
..........................................................
<engine name= "Catalina" defaulthost= "localhost" jvmroute= "jvm1" >
#如果要配置通一台机器上的多个tomcat, then jvmroute the label to be changed to a different
..........................................................
:
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/76/86/wKiom1ZVbuDww306AAC0UurRJv8780.png "title=" 3.png " alt= "Wkiom1zvbudww306aac0uurrjv8780.png"/>
[Email protected] tomcat]# vim Conf/context.xml
..........................................................
<manager classname= "De.javakaffee.web.msm.MemcachedBackupSessionManager"
Memcachednodes= "n1:10.164.24.246:11211,n2:10.164.4.154:11211"
Sticky= "false"
Sessionbackupasync= "false"
Lockingmode= "Uripattern:/path1|/path2"
Requesturiignorepattern= ". *\. (ICO|PNG|GIF|JPG|CSS|JS) $ " transcoderfactoryclass=" De.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory "
/>
#memcachedNodes = "n1:10.164.24.246:11211,n2:10.164.4.154:11211"
#这个地方 if it is a mem server then write N1:IP:PORT if more than one n1..,n2..,n3.
..........................................................
Take one for example:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/76/86/wKiom1ZVcB_BZTRpAAEw2pF9mAc528.png "title=" 4.png " alt= "Wkiom1zvcb_bztrpaaew2pf9mac528.png"/>
6. Start memcached
[Email protected] tomcat]# cd/usr/local/memcached/
[Email protected] memcached]# bin/memcached-d-m 256-p 11211-u Root
#重启tomcat
[[Email protected] memcached]# PS aux |grep Tomcat
Root 1237 0.4 54.6 2336172 129032 pts/0 Sl 21:05 0:08/usr/local/jdk7/bin/java-djava.util.logging.config.file= /usr/local/tomcat/conf/logging.properties-djava.util.logging.manager=org.apache.juli.classloaderlogmanager- server-xx:permsize=128m-xx:maxpermsize=512m-xms1024m-xmx1024m-duser.timezone=asia/shanghai-djava.awt.headless= true-djava.endorsed.dirs=/usr/local/tomcat/endorsed-classpath/usr/local/tomcat/bin/bootstrap.jar:/usr/local/ tomcat/bin/tomcat-juli.jar-dcatalina.base=/usr/local/tomcat-dcatalina.home=/usr/local/tomcat-djava.io.tmpdir=/ Usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap Start
[Email protected] memcached]# kill-9 1237
[Email protected] memcached]#/usr/local/tomcat/bin/startup.sh
Using catalina_base:/usr/local/tomcat
Using Catalina_home:/usr/local/tomcat
Using Catalina_tmpdir:/usr/local/tomcat/temp
Using Jre_home:/usr/local/jdk7
Using CLASSPATH:/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
#如可以看出 Port has been monitored
[Email protected] memcached]# NETSTAT-LNP |grep Mem
TCP 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 8207/bin/memcached
TCP 0 0::: 11211:::* LISTEN 8207/bin/memcached
UDP 0 0 0.0.0.0:11211 0.0.0.0:* 8207/bin/memcached
UDP 0 0::: 11211:::* 8207/bin/memcached
[Email protected] memcached]# NETSTAT-LNP |grep java
TCP 0 0:: ffff:127.0.0.1:8005:::* LISTEN 8225/java
TCP 0 0::: 8009:::* LISTEN 8225/java
TCP 0 0::: 8080:::* LISTEN 8225/java
7. Test memcached
[email protected] memcached]# Yum install-y telnet
This article is from the "Rookie Growth Road" blog, please be sure to keep this source http://francis905.blog.51cto.com/3048056/1716740
Tomcat+memcached Implementing sessions sharing