环境简介:一台服务器Ubuntu 16.04,Apache进行负载,安装两个tomcat进行负载,redis进行缓存。
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目录,
下面关于Redis的文章您也可能喜欢,不妨参考下:
CentOS 7下Redis的安装与配置
Ubuntu 16.04环境中安装PHP7.0 Redis扩展
CentOS 7.0 安装Redis 3.2.1详细过程和使用常见问题