基于Apache和tomcat实现负载均衡
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于Apache和tomcat实现负载均衡相关的知识,希望对你有一定的参考价值。
基于Apache和tomcat实现负载均衡
192.168.200.114
[root@localhost ~]# Yum –y install httpd*
[root@localhost ~]# Systemctl stop firewalld
[root@localhost ~]# Setenforce 0
[root@localhost ~]# Iptables -F
[root@localhost ~]# Vim /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerName www.q.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / balancer://htcluster/
ProxyPassReverse / balancer://htcluster/
<Proxy balancer://htcluster>
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
BalancerMember http://192.168.200.116:8080/ loadfactor=5
BalancerMember http://192.168.200.115:8080/ loadfactor=5
ProxySet lbmethod=byrequests
ProxySet stickysession=ROUTEID
</Proxy>
</VirtualHost>
[root@localhost ~]# Systemctl start httpd
192.168.200.115 && 192.168.200.116
[root@localhost ~]# tar fx apache-tomcat-8.5.40.tar.gz
[root@localhost ~]# tar fx jdk-8u191-linux-x64.tar.gz
[root@localhost ~]# mv jdk1.8.0_191 /usr/local/java
[root@localhost ~]# mv apache-tomcat-8.5.40 /usr/local/tomcat8
[root@localhost ~]# echo "JAVA_HOME=/usr/local/java" >> /etc/profile
[root@localhost ~]# echo "PATH=$PATH:$JAVA_HOME/bin" >> /etc/profil
[root@localhost ~]# cd /usr/local/tomcat8/bin
[root@localhost bin]#./startup.sh
以上是关于基于Apache和tomcat实现负载均衡的主要内容,如果未能解决你的问题,请参考以下文章
apache分别基于三种方案实现tomcat的代理负载均衡及会话绑定
Apache+Tomcat 实现负载均衡及seesion复制