参考:
http://cxshun.iteye.com/blog/1535188
http://snowolf.iteye.com/blog/1539932
最近项目部署上线,因公司运维没有,所以还是我们开发来搞的。参考上边几篇文章就OK;
下边的文章是nginx+tomcat+memcahe方式的集群实现。
http://blog.csdn.net/bluejoe2000/article/details/24883967
http://blog.csdn.net/shimiso/article/details/8979044
memcahe 的安装使用如下:
http://www.linuxidc.com/Linux/2014-02/97329.htm
启动memcached命令如下:
[root@i-E79D4B11 memcached-1.4.22]# ./memcached -d -m 256 -u root -p 11211 -c 1024 -P /tmp/memcached.pid
如果启动时出现“memcached: error while loading shared libraries:libevent-2.0.so.5: cannot
open shared object file: No such file or directory”之类的信息,表示memcached 找不到
libevent 的位置
所以,请先使用whereis libevent 得到位置,然后连接到memcached 所寻找的路径
首先查看,libevent 在哪里
# whereis libevent
libevent: /usr/local/lib/libevent.la /usr/local/lib/libevent.so /usr/local/lib/libevent.a
然后,再看memcached 从哪里找它
# LD_DEBUG=libs memcached -v 2>&1 > /dev/null | less
可以看到:是/usr/lib/libevent-2.0.so.5,所以,创建软链
[root@localhost tools]# ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
如果是64位系统则还需要执行下边:
[root@localhost tools]# ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
再次启动.
我在tomcat下context.xml中配置的如下:
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:localhost:11211"
sticky="false" sessionBackupAsync="false"
lockingMode="auto"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory" />