Apache使用mod_jk/mod_proxy模組實現代理、負載均衡的配置
192.168.1.123/192.168.1.121為後端tomcat,mysql在192.168.1.121上,192.168.1.123沒有mysql
192.168.1.122上只安裝apache
————————————
配置apache反向代理tomcat時的mod_proxy.conf內容
vim /usr/local/apache/conf/extra/mod_proxy.conf
ProxyVia on
ProxyRequests Off
ProxyPreserveHost Off
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / ajp://192.168.1.123:8009/(或者)
ProxyPassReverse / ajp://192.168.1.123:8009/
————————————
配置apache負載均衡時的mod_proxy.conf內容
vim /usr/local/apache/conf/extra/mod_proxy.conf
ProxyVia Off
ProxyRequests Off
ProxyPreserveHost Off
<Proxy balancer://nba>
BalancerMember http://192.168.1.121:8080 loadfactor=1
BalancerMember http://192.168.1.123:8080 loadfactor=1
ProxySet lbmethod=bytraffic
</Proxy>
ProxyPass / balancer://nba/ stickysession=JSESSIONID
ProxyPassReverse / balancer://nba/
————————————
配置Apache使用mod_jk模組實現代理
配置apache反向代理tomcat時的mod_jk.conf內容
JkWorkersFile /tomcat/conf/workers.properties
JkLogFile /var/log/mod_jk.log
JkLogLevel info
JkMount /* tomcat1
另:配置apache反向代理tomcat時的workers.properties內容
worker.list=tomcat1
worker.tomcat1.port=8009
worker.tomcat1.host=192.168.1.121
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
————————————
配置Apache使用mod_jk模組實現負載均衡
配置apache負載均衡tomcat時的mod_jk.conf內容
JkWorkersFile /tomcat/conf/workers.properties
JkLogFile /var/log/mod_jk.log
JkLogLevel info
JkMount /* controller
另:配置apache負載均衡tomcat時的workers.properties內容
worker.list=controller
#========tomcat1========
worker.tomcat1.port=8009
worker.tomcat1.host=192.168.1.121
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
#========tomcat2========
worker.tomcat2.port=8009
worker.tomcat2.host=192.168.1.123
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1
#========controller=======
worker.controller.type=lb
worker.controller.balance_workers=tomcat1,tomcat2
worker.controller.sticky_session=1
————————————
測試jsp內容
<%@ page language="java" %>
<html>
<head><title>Tomcat1</title></head>
<body>
<h1><font color="red">Tomcat1 </font></h1>
<table align="centre" border="1">
<tr>
<td>Session ID</td>
<% session.setAttribute("abc","abc"); %>
<td><%= session.getId() %></td>
</tr>
<tr>
<td>Created on</td>
<td><%= session.getCreationTime() %></td>
</tr>
</table>
</body>
</html>
————————————
解決ProxySet: unknown lbmethod lbmethod=bytraffic; balancer://nba
httpd.conf裡有下面2個選項
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
————
常用命令:
ps aux|grep java
netstat -an|grep 80
killall -9 httpd
cd /usr/local/apache/bin/
./startup.sh;tail -f /tomcat/logs/catalina.out
vim /usr/local/apache/conf/httpd.conf
/etc/init.d/iptables stop
http://www.51ou.com/browse/linuxjq/39473.html
相關文章
- Apache配置反向代理、負載均衡和叢集(mod_proxy方式)Apache負載
- apache 負載均衡配置Apache負載
- 【高可用HA】Apache (3) —— Mac下配置Apache Httpd負載均衡(Load Balancer)之mod_proxyApacheMachttpd負載
- 【高可用HA】Apache (4) —— Mac下配置Apache Httpd負載均衡(Load Balancer)之mod_jkApacheMachttpd負載
- 配置apache和nginx的tomcat負載均衡ApacheNginxTomcat負載
- nginx+tomcat實現反向代理+負載均衡NginxTomcat負載
- Apache +Tomcat的負載均衡與叢集配置ApacheTomcat負載
- apache+JK+tomcat負載均衡配置(windows)ApacheTomcat負載Windows
- apache tomcat叢集配置和負載均衡ApacheTomcat負載
- RHEL 7配置HAProxy實現Web負載均衡Web負載
- docker下nginx反向代理和負載均衡配置DockerNginx負載
- nginx+tomcat反向代理負載均衡配置NginxTomcat負載
- nginx配置web服務|反向代理|負載均衡NginxWeb負載
- Nginx 全模組安裝及匹配方式、反向代理和負載均衡配置Nginx負載
- 使用Nginx配置TCP負載均衡NginxTCP負載
- nginx實現負載均衡Nginx負載
- 代理和負載均衡概述負載
- Nginx反向代理+負載均衡簡單實現(https方式)Nginx負載HTTP
- 配置IIS的負載均衡負載
- apache+tomcat負載均衡ApacheTomcat負載
- 《Apache負載均衡》RHEL6Apache負載
- 技術|如何為MySQL MGR實現簡單的負載均衡代理?MySql負載
- Apache+jk+tomcat負載均衡詳細配置方法ApacheTomcat負載
- Flume負載均衡配置負載
- GRPC 負載均衡實現RPC負載
- HaProxy 實現 MySQL 負載均衡MySql負載
- Ribbon實現負載均衡負載
- Oracle負載均衡實現方式Oracle負載
- Nginx + IIS 實現負載均衡Nginx負載
- Nginx伺服器的使用與反向代理負載均衡Nginx伺服器負載
- 兩種負載均衡的配置。負載
- Nginx實現簡單的負載均衡Nginx負載
- 使用nginx配置多個phpfastcgi負載均衡NginxPHPAST負載
- Nginx實現叢集的負載均衡配置過程詳解Nginx負載
- SpringCloud微服務中使用RestTemplate+Ribbon實現負載均衡(實現方法+實現原理+替換負載均衡策略)SpringGCCloud微服務REST負載
- APACHE做負載均衡時出錯Apache負載
- 使用LVS實現負載均衡原理及安裝配置詳解負載
- 使用 LVS 實現負載均衡原理及安裝配置詳解負載