1、Nginx+keepalived+tomcat实现性负载均衡试验环境: CentOS5.4、pcre-8.12、nginx-upstream-jvm-route-0.1、nginx-1.0.10、apache-tomcat-7.0.23 、keepalived-1.1.17.tar.gz、jdk-7u2-linux-x64.tar.gz主 nginx服务器地址:10.29.9.200 辅 nginx服务器地址:10.29.9.201 tomcat1: 10.29.9.202 tomcat2: 10.29.9.203VIP: 10.29.9.188拓扑如下:1.分别在 10.29.9.200和
2、10.29.9.201上面安装 nginxtar zxf pcre-8.12.tar.gz cd pcre-8.12 ./configure make;make install下载下面的插件安装,否则 nginx无法识别 tomcat中 jvmRoute,从而无法达到 session复制的效果。wget http:/ tar xzf nginx-upstream-jvm-route-0.1.tar.gz tar xzf nginx-1.0.10.tar.gz cd nginx-1.0.10 patch -p0 mtu 16436 qdisc noqueue link/loopback 00:0
3、0:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lo2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000link/ether 00:16:36:68:a4:fc brd ff:ff:ff:ff:ff:ffinet 10.29.9.200/24 brd 10.29.9.255 scope global eth0inet 10.29.9.188/32 scope global eth0在 eth0上面我们已经看到虚拟 IP 10.29.9.188 已经邦定成功4.安装 tomcat 1
4、)安装 tomcat_1 tar zxvf apache-tomcat-7.0.23.tar.gz mv apache-tomcat-7.0.23 /usr/local/tomcat 2)安装 tomcat_2,步骤同 1)5.分别在 tomcat服务器安装 jdktar zxvf jdk-7u2-linux-x64.tar.gzmv jdk1.7.0_02 /usr/local/jdk1.7.0_02cat /etc/profile 在添加下面这句:tomcat2配置: 修改 conf/server.xml配置文件在添加下面这句:6.session配置修改 web应用里面 WEB-INF目录下的 web.xml文件,加入标签 直接加在之前 开启网卡组播功能: route add -net 224.0.0.0 netmask 240.0.0.0 dev eth07.创建 jsp测试页面 mkdir /opt/projectcd /opt/project vi index.jsp tomcat1 jsp - mkdir /opt/projectcd /opt/project vi index.jsp tomcat2 jsp