使用nginx_upstream_jvm_route插件的目的是为了保证在轮询机制下的session的共享
前提:源码方式安装nginx。patch命令
1、下载nginx_upstream_jvm_route插件。
2、将插件解压在任意位置/opt/nginx-upstream-jvm-route-master
3、执行命令patch -p0 </opt/nginx-upstream-jvm-route-master/jvm_route.patch
4、安装nginx
cd /data/nginx-1.10.2i
依次执行
./configure --prefix=/data/nginx --add-module=/opt/nginx-upstream-jvm-route-master
make
make install
5、配置nginx
vim nginx.conf
修改以下:
upstream GolivePay
{
server 192.168.134.229:4401 srun_id=tomcat-299;
server 192.168.134.233:4401 srun_id=tomcat-233;
jvm_route $cookie_JSESSIONID|sessionid reverse;
}
6、修改tomcat
vim tomcat-299/conf/server.xml
修改以下:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat-299">
vim tomcat-233/conf/server.xml
修改以下:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat-233">
7、重新启动nginx,tomcat-299,tomcat-233