I. Node information
192.168.1.133
Nginx
192.168.211.133
|
----------------------------------
| |
Tomcata (211.40) TOMCATB (211.132)
Memcachea (211.136) Memcachb (211.137)
Configure fixed IP
Turn off SELinux
Turn off iptables, boot does not start
Two. Principle
through Nginx proxy access back end Tomcat , and achieve memcache the same browser as the one accessed by the Session is the same.
Three. Deployment
Installation of the Tomcat service
A. Install the development environment Jdk-6u27-linux-i586.bin (32-bit)
installation package Download: Http://pan.baidu.com/s/1skqesVF nm9q
For more information on what data registration collects and
How it's managed and used, see:
Http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html
Press Enter to continue .....
Done.
Note: When the above information is installed, installing the JDK often reports many errors
eq: /lib/ld-linux.so.2:bad ELF interpreter description 64-bit system installed 32-bit program
Workaround: yum-y install glibc.i686 (recommended with CentOS from the Yum source, can be installed)
[email protected] ~]# VI/ETC/BASHRC
Export JRE_HOME=/USR/LOCAL/JDK
Export Java_bin=/usr/local/jdk/bin
Export path= $JRE _home/bin: $PATH
Export classpath=.: $JRE _home/lib/dt.jar: $JRE _home/lib/tools.jar
Export Jre_home java_bin PATH CLASSPATH
: Wq
[Email protected] ~]# SOURCE/ETC/BASHRC
B. Installing the Tomat package apache-tomcat-6.0.32.tar.gz
installation package Download: Http://pan.baidu.com/s/1boizwy7 2gwu
TAR-ZXVF apache-tomcat-6.0.32.tar.gz
MV Apache-tomcat-6.0.32/usr/local/tomcat
NETSTAT-UNLATP |grep:8080
Cd/usr/local/tomcat/bin
./startup.sh
NETSTAT-UNLATP |grep:8080
TCP 0 0::: 8080:::* LISTEN 1879/java
Test: ip:8080 Whether the test page appears
Similarly: The second machine is set above, note IP
Installation of the Memcached service
A. Installing development tools
B. Installing the Memcached Software
Note: libevent-2.0.15-stable.tat.gz must be installed before installing memcached software
installation package Download: Libevent:http://pan.baidu.com/s/1o6tpqia Lwyu
MEMCACHED:HTTP://PAN.BAIDU.COM/S/1I3LS6M5 8e52
CD libevent-2.0.15-stable
./configure && make && make install
CD memcached-1.4.5
./configure && make && make install
/usr/local/lib/
: Wq
Ldconfig-v
Options:
-H View Help information
-p Specifies the port number of the memcached listener default 11211
-L memcached Server IP address
-U memcached the user identity used when running the program must be the root user
-m specifies how much physical memory to use this computer default 64M
The maximum number of links to the-C memcached service
-VVV Show Details
-N Chunk the minimum space of a size is how many units of bytes
-F Chunk Size growth multiplier by default 1.25 times times
-D starts in the background
Knowledge Points:
kill-9 PID number kills memcached process (process number)
Pkill-9 memcached Kill memcached Process (process name)
Killall-9 memcached kills all memcached processes
[[Email protected] ~]# telnet localhost 11211
Trying 192.168.1.10 ...
Connected to 192.168.1.10 (192.168.1.10).
Escape character is ' ^] '.
Set name 0 180 3//0 fixed format 180 180 seconds 3 3 bytes
Jim
STORED
Get Name
VALUE Name 0 3
Jim
END
Quit
Connection closed by foreign host.
Similarly: The second machine is configured as above, note IP
Tomcat and memcached Connection tool Memcached+session+manager
installation package Download: Http://pan.baidu.com/s/1YYfiY u9dl
A. Unpacking the installation package
B. Installation and Configuration
Install and configure the following on two tomcat servers:
VI contest.conf//insert the following lines of text
<Context>
......
......
<manager classname= "De.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachednodes= "n1:192.168.211.142:11211 n2:192.168.211.143:11211"
Failovernodes= "N2"
Requesturilgnorepattern= ". *\ (ICO|PNG|GIF|JPG|CSS|JS) $"
Transcoderfactoryclass= "De.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
</Context>
Installation of Nginx Service
A. Install the development environment
B. Installing Nginx Service
installation package Download: Http://pan.baidu.com/s/1c1nhg2G 5QPN
Useradd Nginx
TAR-ZXVF nginx-1.0.5.tar.gz
CD nginx-1.0.5
./configure--prefix=/usr/local/nginx--user=nginx--group=nginx--with-http_ssl_module--with-http_stub_status_ Module
Make && make install
Cd/usr/local/nginx/conf
Modify the configuration file (the original file is best backed up)
HTTP {
Upstream Tomcatgrp {
Server 192.168.1.10:8080;
Server 192.168.1.20:8080;
}
server {
...
...
Location/{
root HTML;
Index index.html index.htm;
Proxy_pass http://tomcatgrp;
}
......
......
}
}
: Wq
Test
A. By entering the Nginx URL to see if the color of the page is flexible, the session is not changed
Test page Download :Http://pan.baidu.com/s/1bjNxTG 9br2
The test is also placed in the cd/usr/local/tomcat/webapps/root/directory, and two tomcat tests will be changed, each tomcat color is not the same can be
This article from "Tidypet" blog, reproduced please contact the author!
Nginx+tomcat+memcached sharing Session-id