最近学习了Tomcat群集共享Session+Nginx负载均衡记录顺便总结一下

先下载Tomcat,解压然后建立一个群集文件夹拷贝三个Tomcat

Tomcat群集共享Session+Nginx负载均衡
然后修改conf里面server.xml对应的端口
图的128行的 jvmRoute是给集群的Tomcat 取的名字并放开画圆圈的注释
Tomcat群集共享Session+Nginx负载均衡

Tomcat群集共享Session+Nginx负载均衡

Tomcat群集共享Session+Nginx负载均衡

手动的方式在Tomcat下webapps新建一个文件夹

群集的方式实现了就会session同步(默认情况下是复制)
需要写在工程里面而不是Tomcat里面
Tomcat群集共享Session+Nginx负载均衡
Tomcat群集共享Session+Nginx负载均衡

Tomcat群集共享Session+Nginx负载均衡

添加jsp页面看看session有没有同步

Tomcat群集共享Session+Nginx负载均衡
接下来测试:http://localhost:7080/clusterTest/index.jsp

Tomcat群集共享Session+Nginx负载均衡

http://localhost:8080/clusterTest/index.jsp

Tomcat群集共享Session+Nginx负载均衡

http://localhost:9080/clusterTest/index.jsp
Tomcat群集共享Session+Nginx负载均衡
到此Tomcat群集共享Session就实现了.

Nginx负载均衡demo配置如下:

Tomcat群集共享Session+Nginx负载均衡

Tomcat群集共享Session+Nginx负载均衡

Tomcat群集共享Session+Nginx负载均衡

Tomcat群集共享Session+Nginx负载均衡

到此负载均衡就结束了,如果有错误谢谢指出。

相关文章: