server1

vim /usr/local/lnmp/tomcat/conf/context.xml

<Context>

......

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"

memcachedNodes="n1:172.25.45.1:11211,n2:172.25.45.2:11211"

failoverNodes="n1"

requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"

transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"

/>

</Context>

 

server2

vim /usr/local/tomcat/conf/context.xml

failoverNodes的值改为n2

wKiom1de9cXTkpeLAABbMRisPIw123.png


wKioL1de9uihMR-pAACtCNvFpFg187.png


wKioL1de9vahtZizAACmltirIT4578.png


server1

cd /usr/local/lnmp/tomcat/lib
rm -rf memcached-session-manager-tc6-1.6.3.jar
cd ..
bin/shutdown.sh
bin/startup.sh
tail logs/catalina.out

wKioL1de90WDCC5LAAEN72mPR4E073.png


server2

yum install memcached
/etc/init.d/memcached start

 

server1

bin/shutdown.sh
bin/startup.sh
tail logs/catalina.out

wKioL1de91KQIWszAAC56IYq_bI272.png


server2

bin/startup.sh
tail logs/catalina.out

wKiom1de9k6jRVpHAADX8TPOazU800.png


yum install telnet


wKiom1de9o-zqcKEAAC70WiGB0Q806.png


当执行  /etc/init.d/memcached stop  才会改变为n2

避免数据丢失