问题描述
我在做apache+tomcat集群session共享实验,配置如下:tomcat分别安装在两台服务器,IP地址分别是:172.16.19.63172.16.19.64apache在另外一台服务器,IP地址是:172.16.19.65apache服务器配置:修改apache服务器的配置文件httpd.conf找到以下内容并去掉注释LoadModuleproxy_modulemodules/mod_proxy.soLoadModuleproxy_ajp_modulemodules/mod_proxy_ajp.soLoadModuleproxy_balancer_modulemodules/mod_proxy_balancer.soLoadModuleproxy_connect_modulemodules/mod_proxy_connect.soLoadModuleproxy_http_modulemodules/mod_proxy_http.soLoadModuleproxy_ftp_modulemodules/mod_proxy_ftp.so再找到<IfModuledir_module></IfModule>加上index.jsp修改成:<IfModuledir_module>DirectoryIndexindex.htmlindex.jsp</IfModule>在配置文件的末尾加上以下内容:<VirtualHost*:80>ServerAdminweijie@126.comServerNamelocalhostServerAliaslocalhost192.168.137.146ProxyPass/balancer://mycluster/stickysession=JESSIONIDnofailover=OffProxyPassReverse/balancer://mycluster/ErrorLog"logs/error.log"CustomLog"logs/access.log"common</VirtualHost>ProxyRequestsOff<proxybalancer://mycluster>BalancerMemberajp://172.16.19.63:8009loadfactor=1route=tomcat1BalancerMemberajp://172.16.19.64:8009loadfactor=1route=tomcat2</proxy>Tomcat服务器配置:分别修改server.xml文件,因为在两台不同服务器上,端口没有修改<Enginename="Catalina"defaultHost="localhost"jvmRoute="tomcat1"><Enginename="Catalina"defaultHost="localhost"jvmRoute="tomcat2">群集代码:<ClusterclassName="org.apache.catalina.ha.tcp.SimpleTcpCluster"channelSendOptions="8"><ManagerclassName="org.apache.catalina.ha.session.BackupManager"expireSessionsOnShutdown="false"notifyListenersOnReplication="true"/><ChannelclassName="org.apache.catalina.tribes.group.GroupChannel"><MembershipclassName="org.apache.catalina.tribes.membership.McastService"mcastBindAddress="127.0.0.1"address="228.0.0.4"port="45564"frequency="500"dropTime="3000"/><ReceiverclassName="org.apache.catalina.tribes.transport.nio.NioReceiver"address="auto"tcpListenAddress="127.0.0.1"port="4001"autoBind="100"selectorTimeout="5000"maxThreads="6"/><SenderclassName="org.apache.catalina.tribes.transport.ReplicationTransmitter"><TransportclassName="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/></Sender><InterceptorclassName="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/><InterceptorclassName="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/><InterceptorclassName="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/></Channel><ValveclassName="org.apache.catalina.ha.tcp.ReplicationValve"filter=""/><ValveclassName="org.apache.catalina.ha.session.JvmRouteBinderValve"/><DeployerclassName="org.apache.catalina.ha.deploy.FarmWarDeployer"tempDir="/temp/war-temp/"deployDir="/tmp/war-deploy/"watchDir="/tmp/war-listen/"watchEnabled="false"/><ClusterListenerclassName="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/><ClusterListenerclassName="org.apache.catalina.ha.session.ClusterSessionListener"/></Cluster>在web.xml中加入<distributable/>以实现session的复制现在问题是:apache实现了负载均衡当我停掉一台tomcat服务器时:从登录界面输入用户名能够连接到数据库但是当我把两台tomcat服务器同时开启来的时候,输入用户名密码后,又跳回到登录界面,连不上数据库apache服务器的报错日志:[ThuSep2914:21:592011][error]ajp_check_msg_header()gotbadsignature420[ThuSep2914:21:592011][error]ajp_ilink_receive()receivedbadheader[ThuSep2914:21:592011][error]ajp_read_header:ajp_ilink_receivefailed[ThuSep2914:21:592011][error](120007)APRdoesnotunderstandthiserrorcode:proxy:readresponsefailedfrom172.16.19.63:8009(172.16.19.63)请教各位大虾这个问题怎么解决?万分感谢