apache tomcat 集群问题?

weir2008 发布于 2012/04/07 11:11
阅读 737
收藏 0
我的测试:
本地:
#server
worker.list = controller

#========tomcat1========

worker.tomcat1.port=11009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor = 1

#========tomcat2========

worker.tomcat2.port=12009
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor = 1

#========controller,负载均衡控制器========

worker.controller.type=lb
worker.controller.balanced_workers=tomcat1,tomcat2
worker.controller.sticky_session=false
#worker.controller.sticky_session_force=1


所有session都会复制
远程:
#server
worker.list = controller

#========tomcat1========
worker.tomcat1.port=8009
worker.tomcat1.host=172.168.20.4
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor = 1

#========tomcat2========

worker.tomcat2.port=8009
worker.tomcat2.host=172.168.20.5
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor = 1

#========tomcat3========
worker.tomcat3.port=8009
worker.tomcat3.host=172.168.20.6
worker.tomcat3.type=ajp13
worker.tomcat3.lbfactor = 1

#========controller,负载均衡控制器========
worker.controller.type=lb
worker.controller.balanced_workers=tomcat1,tomcat2,tomcat3
worker.controller.sticky_session=1
#worker.controller.sticky_session_force=1
这样session复制最后一个,之前的session不会复制,
如果远程这样配置:
worker.controller.sticky_session=false
#worker.controller.sticky_session_force=1
session永远只保存一个。


不知怎么回事。

以下是问题补充:

@weir2008:tomcat-connectors-1.2.35-windows-i386-httpd-2.2.x apache-tomcat-6.0.35 httpd-2.2.22-win32-x86-no_ssl 这是我用的软件 (2012/04/07 11:13)
加载中
0
红薯
红薯

这样session复制最后一个,之前的session不会复制,

我不太明白这句话的意思

0
weir2008
weir2008
看来我得发个图片更清楚一些。
0
weir2008
weir2008

意思就是本来session里面有三个用户,在本地上面,关闭一个tomcat三个用户都会复制另一个上面。

而在远程上面,只会复制最后一个用户。

0
weir2008
weir2008
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.*" %>
<html><head><title>Cluster App Test</title></head>
<body>
Server Info:
<%
out.println(request.getLocalAddr() + " : " + request.getLocalPort()+"<br>");%>
<%
  out.println("<br> ID " + session.getId()+"<br>");
  // 如果有新的 Session 属性设置
  String dataName = request.getParameter("dataName");
  if (dataName != null && dataName.length() > 0) {
     String dataValue = request.getParameter("dataValue");
     session.setAttribute(dataName, dataValue);
  }
  out.println("<b>Session 列表</b><br>");
  System.out.println("============================");
  Enumeration e = session.getAttributeNames();
  while (e.hasMoreElements()) {
     String name = (String)e.nextElement();
     String value = session.getAttribute(name).toString();
     out.println( name + " = " + value+"<br>");
         System.out.println( name + " = " + value);
   }
%>
  <form action="test2.jsp" method="POST">
    名称:<input type=text size=20 name="dataName">
     <br>
    值:<input type=text size=20 name="dataValue">
     <br>
    <input type=submit>
   </form>
</body>
</html>

这个测试页面没问题吧。是不是可以保存多个session?
0
weir2008
weir2008

又有新问题了,请求不到action

The requested URL /q2c/userlog/login was not found on this server

返回顶部
顶部