一.tomcat
server2和server3安装tomcat:
server3同操作
在server1上:
访问test.jsp:
172.25.2.2
当我们将server2 down掉之后
我们可以看到是server3接管了服务:
当server2挂掉时,会接管到server3,但数据丢失
因此我们需要交叉储存!!!!!
二. 交叉存储
在2,3上做同样操作:
yum install memcached -y
systemctl enable --now memcached.service
拷贝jar包到/usr/local/tomcat/lib目录:
配置tomcat
vim /usr/local/tomcat/conf/context.xml
server2
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:172.25.10.2:11211,n2:172.25.10.3:11211"
failoverNodes="n1"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
server3
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:172.25.10.2:11211,n2:172.25.10.3:11211"
failoverNodes="n2"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
[root@sever2 tomcat]# bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat- juli.jar
当2 down 后数据不消失
2的数据存储到3中,3的数据存储到3上,当2挂掉时,2的数据并不会消失