yum install memcached
[root@node3 ~]# cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""
提供四个java类库:
[root@node1 msm-1.8.3]# ls
memcached-session-manager-1.8.3.jar msm-javolution-serializer-1.8.3.jar
memcached-session-manager-tc8-1.8.3.jar spymemcached-2.10.2.jar
javolution-5.5.1.jar
放置于两台tomcat服务器的/usr/local/tomcat/lib目录下:
[root@node1 ~]# scp -r msm-1.8.3/ node2:/usr/local/tomcat/lib
The authenticity of host 'node2 (192.168.20.2)' can't be established.
RSA key fingerprint is d5:69:d0:fc:ce:90:14:14:6d:4c:52:82:53:a5:ed:0b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node2,192.168.20.2' (RSA) to the list of known hosts.
root@node2's password:
spymemcached-2.10.2.jar 100% 429KB 428.8KB/s 00:00
memcached-session-manager-tc8-1.8.3.jar 100% 10KB 10.2KB/s 00:00
msm-javolution-serializer-1.8.3.jar 100% 69KB 69.4KB/s 00:00
memcached-session-manager-1.8.3.jar 100% 144KB 143.6KB/s 00:00
javolution-5.5.1.jar 100% 144KB 143.6KB/s 00:00
编辑server.xml文件Host上下文中定义context
<Context path="" docBase="/data/webapps" reloadable="true">
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:192.168.20.7:11211,n2:192.168.20.8:11211"
failoverNodes="n1"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
/>
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
deny="172\.16\.100\.100"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="/data/logs"
prefix="web1_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Context>
更多Tomcat相关教程见以下内容:
CentOS 6.6下安装配置Tomcat环境
RedHat Linux 5.5安装JDK+Tomcat并部署Java项目
Linux下使用Xshell查看Tomcat实时日志中文乱码解决方案