tomcat负载均衡

配置环境:

  主机一:172.16.251.73    安装tomcat(tomcat, tomcat-lib, tomcat-admin-webapps, tomcat-webapps, tomcat-docs-webapp)
  主机二:172.16.251.75    安装tomcat(tomcat, tomcat-lib, tomcat-admin-webapps, tomcat-webapps, tomcat-docs-webapp)
  主机三:172.16.251.91   安装ngnix,httpd,haproxy


  在实验环境下所有主机清空防火墙策略以及禁用selinux:
    iptables   -F
    setenforce 0


 为了使实验便于观察与分析,使2台tomcat主机的默认页面为自定义页面  。
QQ截图20170902114109.png

①nginx + tomcat
vim /etc/nginx/nginx.conf


QQ截图20170902113857.png
![QQ截图20170902114138.png](http://upload-images.jianshu.io/upload_images/6107809-1b42467fa541f224.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
QQ截图20170902114303.png

② haproxy + tomcat
vim /etc/haproxy/haproxy.cfg

QQ截图20170902115030.png
QQ截图20170902115052.png
![QQ截图20170902115121.png](http://upload-images.jianshu.io/upload_images/6107809-070bf14f15a27738.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

haproxy的状态页


③httpd + tomcat
vim /etc/httpd/conf/httpd.conf

QQ截图20170902134910.png
![QQ截图20170902134927.png](http://upload-images.jianshu.io/upload_images/6107809-85960e5b9d799c0e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

④会话粘滞

QQ截图20170902135846.png
![QQ截图20170902135931.png](http://upload-images.jianshu.io/upload_images/6107809-68d3e42dea4e7943.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
QQ截图20170902135931.png

⑤会话集群
Vim /usr/share/tomcat/webapps/ROOT/WEB-INF/web.xml


QQ截图20170903150423.png
QQ截图20170903150310.png
QQ截图20170903150650.png
QQ截图20170903150751.png

⑥nginx + (apache + tomcat)
先将原先的tomcat主机安装httpd包,以第一台主机为例,将808端口的tomcat作为后端。80端口的http作为前端代理。

QQ截图20170903160824.png
QQ截图20170903161257.png
QQ截图20170903161633.png
QQ截图20170903161710.png
QQ截图20170903161716.png
QQ截图20170903161710.png

你可能感兴趣的:(tomcat负载均衡)