码迷,mamicode.com
首页 > 系统相关 > 详细

session之memcache

时间:2019-10-09 15:24:19      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:classname   fail   down   serial   tomcat服务   get   contex   set   done   

nginx服务器配置:192.168.200.111
[root@nginx ~]# hostname nginx
[root@nginx ~]# bash
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
upstream tomcat_pool {
server 192.168.200.112:8080 weight=1 max_fails=1 fail_timeout=10s;
server 192.168.200.113:8080 weight=1 max_fails=1 fail_timeout=10s;
}
location / {
root html;
index index.html index.htm;
proxy_pass http://tomcat_pool;
proxy_set_header Host $http_host;
}
[root@nginx ~]# killall -1 nginx
第一台tomcat服务器配置:192.168.200.112
[root@node1 ~]# vim /usr/local/tomcat8/webapps/ROOT/session.jsp
Session ID:<%= session.getId() %> <BR>
SessionPort:<%= request.getServerPort() %>
<% out.println("This tomcat server 192.168.200.112"); %>
[root@node1 ~]# vim /usr/local/tomcat8/webapps/ROOT/session.jsp
Session ID:<%= session.getId() %> <BR>
SessionPort:<%= request.getServerPort() %>
<% out.println("This tomcat server 192.168.200.112"); %>
[root@node1 ~]# yum -y install libevent memcached
[root@node1 ~]# memcached -u root -m 512M -n 10 -f 2 -d -vvv -c 512
[root@node1 ~]# mkdir session
上传memcached的jar包
[root@node1 ~]# cp session/* /usr/local/tomcat8/lib/
[root@node1 ~]# vim /usr/local/tomcat8/conf/context.xml
<Context>
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="memA:192.168.200.112:11211 memB:192.168.200.113:11211"
requestUrilgnorePattern=".*\(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
</Context>
[root@node1 ~]# /usr/local/tomcat8/bin/shutdown.sh
[root@node1 ~]# /usr/local/tomcat8/bin/startup.sh
[root@node1 ~]# ls session/ | while read line ; do rm -rf /usr/local/tomcat8/lib/$line; done
第二台tomcat服务器配置:192.168.200.113
同上

 

session之memcache

标签:classname   fail   down   serial   tomcat服务   get   contex   set   done   

原文地址:https://www.cnblogs.com/lyqlyqlyq/p/11641861.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!