tomcat+redis实现session共享
1.Apache负载配置:
<VirtualHost *:80>
ServerName cluster.taskcenter.net
ProxyPreserveHost On
ProxyVia On
ProxyRequests Off
<Location
/infoplus
>
ProxyPass balancer:
//cluster/infoplus
<
/Location
>
<Location
/taskcenter
>
ProxyPass balancer:
//cluster/taskcenter
<
/Location
>
<Location
/managerA/manager
>
ProxyPass ajp:
//127
.0.0.1:8009
/manager
<
/Location
>
<Location
/managerB/manager
>
ProxyPass ajp:
//127
.0.0.1:8019
/manager
<
/Location
>
<
/VirtualHost
>
<proxy balancer:
//cluster
>
BalancerMember ajp:
//127
.0.0.1:8009 loadfactor=1 route=TomcatA smax=5 max=20 ttl=120 retry=300 timeout=15
BalancerMember ajp:
//127
.0.0.1:8019 loadfactor=1 route=TomcatB smax=5 max=20 ttl=120 retry=300 timeout=15
<
/proxy
>
2.tomcat配置:vim
/etc/tomcat8/context
.xml
<Manager className=
"com.crimsonhexagon.rsm.redisson.SingleServerSessionManager"
endpoint=
"127.0.0.1:6379"
sessionKeyPrefix=
"_sk:"
timeout=
"60000"
/>
3.安装redis并设置后台启动
4.添加jar包到tomcat的lib目录,
jar包下载链接:https://files.cnblogs.com/files/xieyabox/tomcat-redis-session.zip