Nginx+tomcat负载均衡session问题解决

到http://code.google.com/p/nginx-upstream-jvm-route/downloads/list 下载 nginx-upstream-jvm-route-0.1.tar.gz
 pcre的安装略

[root@localhost ~]# tar -zxvf nginx-upstream-jvm-route-0.1.tar.gz
[root@localhost ~]# tar -zxvf nginx-0.8.15.tar.gz
[root@localhost ~]# cd nginx-0.8.15
[root@localhost ~]# patch -p0 < ../nginx_upstream_jvm_route/jvm_route.patch
[root@localhost ~]# ./configure --user=www --group=www --prefix=/usr/local//nginx --with-http_stub_status_module --with-http_ssl_module  --add-module=/root/nginx_upstream_jvm_route/
[root@localhost ~]# make && make install


2.分别在两台机器上 安装 tomcat和java (略)
设置tomcat的server.xml, 在两台服务器的tomcat的配置文件中分别找到:
<Engine name="Catalina" defaultHost="localhost" >
分别修改为:
Tomcat01:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="a">
Tomcat02:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="b">

nginx.conf添加以下语句:

  upstream backend {
    server 192.168.2.88:8080 srun_id=a; 
    server 192.168.2.89:8080 srun_id=b;
    jvm_route $cookie_JSESSIONID|sessionid reverse;  #或是 jvm_route $cookie_JSESSIONID reverse;  是resin的话 为jvm_route $cookie_JSESSIONID;
  }
 

你可能感兴趣的:(nginx,职场,web服务器,休闲,linux.session)