Memcached安装及测试

Memcache协议
http://web2.0coder.com/archives/199

python clients:
http://sendapatch.se/projects/pylibmc/
down fwom here: http://pypi.python.org/pypi/pylibmc#downloads
介绍各个客户端,以及pylibmc的安装
http://code.google.com/p/memcached/wiki/Clients
http://iyouf.info/memcached-client-pylibmc.html

pylibmc 安装过程

pylibmc安装过程就像个递归调用,要安装pylibmc需要先安装libmemcached,安装libmemcached又需要先安装memcached,安装memcached又要先安装libevent。以下是安装过程

1。安装libevent

./configure && make && make install

默认安装的需要做个软连:/usr/lib/libevent-1.3.so.1 -> /usr/local/lib/libevent-1.3.so.1。1.3是版本号

 

2。安装memcached

./configure && make && make install

 

3。安装libmemcached

./configure 需要指定参数,参照http://www.hdwong.com/article/libmemcached-compile-error.html

./configure --disable-64bit CFLAGS="-O3 -march=i686"

make && make install

默认安装的需要做个软连:ln -s /usr/local/lib/libmemcached.so.5 /usr/lib/libmemcached.so.5

这里有个问题就是
4。安装pylibmc

./configure && make && make install

4.2 安装及测试python-memcached-1.48

import memcache
mc = memcache.Client(['127.0.0.1:11211'], debug=1)

mc.set("some_key", "Some value")
value = mc.get("some_key")
print value

mc.set("another_key", 3)
mc.delete("another_key")

mc.set("key", "1")   # note that the key used for incr/decr must be a string.
mc.incr("key")
mc.decr("key")

安装过程中遇到的几个问题
1. 安装pylibmc 时找不到python的头文件,为了图方便,有下载了个python-memcached-1.48(这个lib直接是python写的,不需要编译),然后直接可以测试
测试时需要先运行memcached服务,然后执行测试脚本

2. 安装memcached后运行提示找不到libevent的文件,需要用find / -name libevent*找到文件路径,
然后执行 LD_DEBUG=libs memcached查看加载库文件路径,再利用
ln -s 添加符号链接使之可以找到

Powered by Jekyll and Theme by solid

本站总访问量