1 环境说明
1. 服务器有4台,一台内核的linux2.6.9安装apache,三台安装Tomcat。
2. apache2.2.4、apache-tomcat-5.5.17、jdk-6u1-linux-i586-rpm.bin或者jdk1.5.6
ip配置,一台安装apache的ip为180.200.1.189,三台安装tomcat的服务器ip分别为180.200.1.111/136/42。当然需要修改成你自己的IP地址。
3. 下载地址为
下载tomcat and apache
http://apache.org
下载jdk
http://java.sun.com
2 Tomcat安装
1. 在三台要安装tomcat的服务器上先安装jdk
2. 配置jdk的安装路径,在环境变量path中加入jdk的bin路径,新建环境变量JAVA_HOME指向jdk的安装路径
3. 在三台要安装tomcat的服务器上分别安装tomcat,调试三个tomcat到能够正常启动
4. 分别测试每个tomcat的启动是否正常
http://180.200.0.42:8080
http://180.200.0.136:8080
http://180.200.0.111:8080
3 Apache安装
解压httpd-2.2.4.tar.gz
在那台要安装apache的服务器上安装apache2.2.4。在home下建立apache目录,把httpd-2.2.4.tar.gz上传到该目录下
[root@localhost apache]# tar xvzf httpd-2.2.4.tar.gz
[root@localhost apache]# cd httpd-2.2.4
配置APACHE安装文件
这里需要注意编译前一定要将proxy proxy_http proxy_ftp proxy_connect headers这些参数加进去,以便编译出下面的so文件
mod_proxy.so
mod_proxy_connect.so
mod_proxy_http.so
mod_proxy_ftp.so
mod_proxy_ajp.so
mod_proxy_balancer.so
配置编译参数
[root@localhost apache]#./configure --prefix=/usr/local/apache224 --enable-so --enable-mods-shared="proxy proxy_http proxy_ftp proxy_connect headers"
编译
[root@localhost apache]# make
检查编译后的是否有编译出so文件
[root@localhost apache]# cd /usr/local/apache224/modules
[root@localhost modules]#]# ls
httpd.exp mod_proxy_ajp.so mod_proxy_connect.so mod_proxy_http.so
mod_headers.so mod_proxy_balancer.so mod_proxy_ftp.so mod_proxy.so
如果存在以上文件则说明编译成功
安装
[root@localhost apache]# make install
启动APACHE
[root@localhost apache]# /usr/local/apache224/bin/httpd -k start
测试
http://180.200.1.189/
如果输出IT works那么就ok了
4 配置负载均衡
4.1. Tomcat配置
分别修改三个tomcat的配置文件conf/server.xml以便测试
修改内容如下:
修改前
<!-- An Engine represents the entry point (within Catalina) that processes<br /> every request. The Engine implementation for Tomcat stand alone<br /> analyzes the HTTP headers included with the request, and passes them<br /> on to the appropriate Host (virtual host). -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :<br /> <Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1"> <br /> -->
<!-- Define the top level container in our container hierarchy -->
修改后
<!-- An Engine represents the entry point (within Catalina) that processes<br /> every request. The Engine implementation for Tomcat stand alone<br /> analyzes the HTTP headers included with the request, and passes them<br /> on to the appropriate Host (virtual host). --> 《Apach与Tomcat集群安装配置》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Server/Apache/17833.html