Aapche + Tomcat实现集群的注意事项

  • All your session attributes must implement java.io.Serializable // 所有的session属性必须实现Serializable 接口,意思是说通过session.setAttribute()方法保存到session中的对象必须实现Serializable接口否则在调用session.setAttribute()方法时会出现异常。
  • Make sure your web.xml has the <distributable/> element // 在weib.xml文件中必须添加 <distributable/>标签,告诉Tomcat我的应用要部署到集群环境中
  • If you are using mod_jk, make sure that jvmRoute attribute is set at your Engine <Engine name="Catalina" jvmRoute="node01" > and that the jvmRoute attribute value matches your worker name in workers.properties,注意:如果tomcat的ajp端口为8009那么该tomcat的engine的jvmRoute的值要与workers.properties中相对应的ajp端口的worker一致
  • Make sure that all nodes have the same time and sync with NTP service
  • Make sure that your loadbalancer is configured for sticky session mode.
  • <!--生产环境中可以设置为filter=".*\.gif|.*\.js|.*\.jpeg|.*\.jpg|.*\.png|.*\.htm|.*\.html|.*\.css|.*\.txt",过滤掉静态内容Valve用于在节点向客户端响应前进行检测或进行某些操作,ReplicationValve就是用于检测当前的响应是否涉及Session数据的更新,如果是则启动Session拷贝操作,filter用于过滤请求,如客户端对图片,cssjs的请求就不会涉及Session -->

              <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"  filter=""/> 

                    

猜你喜欢

转载自lbd-world.iteye.com/blog/1703646
今日推荐