1--安装nginx-0.7.65
1-0 下载包
jvm-route安装包下载命令:
svn checkout http://nginx-upstream-jvm-route.googlecode.com/svn/trunk/ nginx-upstream-jvm-route-read-only
nginx当前稳定版下载路径
wget? http://nginx.org/download/nginx-0.7.65.tar.gz
1-1 解压缩 nginx-0.7.65.tar.gz 到 /usr/develop/yagnwr
1-2 解压缩 jvm-route.zip 到/usr/develop/yagnwr
?还可以从 网站上下载svn checkout http://nginx-upstream-jvm-route.googlecode.com/svn/trunk/ nginx-upstream-jvm-route-read-only
1-3 切换到 /usr/develop/yagnwr/nginx-0.7.65
1-4 patch -p0 < /usr/develop/yagnwr/jvm-route/jvm_route.patch
1-5 ./configure --prefix=/usr/mpsp/nginx-0.7.65? --add-module=/home/yangwr/soft/jvm-route/? --with-http_stub_status_module
1-6 make
1-7 make install
2--配置文件
rm -f /usr/mpsp/nginx-0.7.65/nginx.conf
vi /usr/mpsp/nginx-0.7.65/nginx.conf
3--修改nginx.conf--针对tomcat
?服务器10.110.5.151上的nginx.conf负载做如下配置
?upstream newjboss {
????????? #ip_hash;
????????? server 10.110.5.151:9081 max_fails=3 fail_timeout=30s srun_id=a;
????????? server 10.110.5.152:9081 max_fails=3 fail_timeout=30s srun_id=b;
????????? jvm_route $cookie_JSESSIONID|sessionid reverse;
?????? }
??????
? 服务器10.110.5.151上的nginx.conf负载做如下配置
?????? upstream newjboss {
????????? #ip_hash;
????????? server 10.110.5.152:9081 max_fails=3 fail_timeout=30s srun_id=b;
????????? server 10.110.5.151:9081 max_fails=3 fail_timeout=30s srun_id=a;
????????? jvm_route $cookie_JSESSIONID|sessionid reverse;
?????? }
4--修改tomcat配置/usr/mpsp/newjboss/conf/server.xml
10.110.5.151修改为
<Engine name="Catalina" defaultHost="localhost" jvmRoute="a">
10.110.5.152修改为
<Engine name="Catalina" defaultHost="localhost" jvmRoute="b">
5--重启nginx,jbossWeb
?
注:nginx在cdn,F5后端的情况下,根据ip分发session的策略失效,此时需要根据sessionid来转发,
比如151服务器产生的sessionid以a结尾,服务器152产生的sessionid以b结尾,resin服务器则以a,b开头。