首先安装Apache2.2:
由于安装apache2.2需要先安装arp和arp-util这两个东东所以也要从上下载.
安装apr
# cd srclib/apr
# ./configure --prefix=/usr/local/apr
# make
# make install
安装apr-util
# cd ../apr-util/
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make
# make install
安装 apache(编译时加入ajp代理以及反向代理参数以及负载均衡参数)
#./configure --prefix=/usr/apache2.2 --enable-proxy --enable-proxy-ajp --enable-proxy-balancer --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
#make
#make install
启动apache:
#/usr/apache2.2/bin/apachectl –k start
负载均衡配置
apache安装成功以后需要对它的两个配置文件conf/httpd.conf和conf/extra/httpd-vhosts.conf做一点小小的修改。
在conf/httpd.conf文件里搜索一下“Include conf/extra/httpd-vhosts.conf”,把前面的“#”去掉。然后“conf/extra/httpd-vhosts.conf”文件修改如下:
ServerName localhost #服务器名称
CustomLog logs/dmim_log combined #日志
#负载均衡配置,可列出多个Tomcat;以下为连接Tomcat AJP监听器,
BalancerMember ajp://134.140.55.236:8009
BalancerMember ajp://134.140.55.236:9009
BalancerMember ajp://134.140.55.239:8009
#代理配置
ProxyPass balancer://localhost/
#ProxyPassReverse balancer://localhost/
集群配置:
Tomcat5.5自带集群功能,只要把server.xml中的“Cluster”元素注释掉就行了,并且在每个web应用项目的web.xml文件,添加
元素。然后把tomcat复制几份到不同机器就行了(根据Tomcat官方文档描述一般配置2~4个作为集群,tomcat的配置要跟apache的负载均衡配置相对应);如果集群放在同一台机器上,要注意修改各个server.xml的以下元素: (红色的表示每个服务器配置的端口都不能一样,以免端口被占用)
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
managerClassName="org.apache.catalina.cluster.session.DeltaManager"
expireSessionsOnShutdown="false"
useDirtyFlag="true"
notifyListenersOnReplication="true">
className="org.apache.catalina.cluster.mcast.McastService"
mcastAddr="228.0.0.4"
mcastPort="45564"
mcastFrequency="500"
mcastDropTime="3000"/>
className="org.apache.catalina.cluster.tcp.ReplicationListener"
tcpListenAddress="auto"
tcpListenPort="4001"
tcpSelectorTimeout="100"
tcpThreadCount="6"/>
className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
replicationMode="pooled"
ackTimeout="15000"
waitForAck="true"/>
filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
最后重启apache和各个tomcat就行了
阅读(838) | 评论(0) | 转发(0) |