1. The required packages are placed in the Lib directory of the Tomcat directory (attached)
2. Configure the Conf/context.xml in the Tomcat directory to include the following:
<valve classname= "Com.radiadesign.catalina.session.RedisSessionHandlerValve"/>
<manager classname= "Com.radiadesign.catalina.session.RedisSessionManager"
Host= "192.168.0.222" #redis地址
Port= "6379" #redis端口
database= "0"
Maxinactiveinterval= "/> #session失效时间
3. Configuring Nginx Cluster
http{
Upstream AAA {
192.168.0.111:8888;
192.168.0.222:8888;
}
server {
server_name aaa.test.com;
Listen 80;
Location {
Proxy_pass http://aaa;
}
Access_log/data/logs/nginx/aaa.log main;
}
}
Start Redis-nginx-tomcat in turn
Effects can be viewed in the following ways:
1. Log in to your page to view your Jsessionid,
650) this.width=650; "Src=" http://note.youdao.com/yws/public/resource/bce638f34787ea84c138ed2f1bbd9acc/ 35041457352845e48ebec9fcd6be95e7 "style=" margin-top:8px;height:86.1977px;width:800px; "alt=" 35041457352845e48ebec9fcd6be95e7 "/>
2. Log in to the REDIS-CLI console and use the following command to view session information:
127.0.0.1:6379> Get f33c92b91b64b196ef1b7ed074bfbb38
"\xac\xed\x00\x05w\b\x00\x00\x01o\xd43s\x0bsr\x00\x0ejava.lang.long ... Too much content, do not show ... \x00\x0f\x00\x00\x00\x00w\x04\x00\x00\x00\x00xxxx "
This concludes that the session information has been successfully stored in Redis.
This article is from the "Letter" blog, please be sure to keep this source http://leon0long.blog.51cto.com/3011404/1695300
Tomcat+nginx+redis Implementing session Sharing