日期:2014-05-16  浏览次数:20621 次

memcached缓存Linux安装
libeven

    memcached的使用需要libeven的支持,我们得先装上libeven。
    官方网站:http://www.monkey.org/~provos/libevent/
    下载地址:http://www.monkey.org/~provos/libevent-1.4.0-beta.tar.gz
    libevent安装方式比较简单:
以下是代码片段:
cd libevent-1.4.11-stable/

./configure

make

make install
    这样就好
    检查如下:
以下是引用片段:
[root@localhost memcached-1.2.2]# ls -l /usr/local/lib/ | grep even
lrwxrwxrwx   1 root root      21 Nov 26 11:32 libevent-1.4.so.2 -> libevent-1.4.so.2.0.0
-rwxr-xr-x   1 root root  267334 Nov 26 11:32 libevent-1.4.so.2.0.0
-rw-r--r--   1 root root  351694 Nov 26 11:32 libevent.a
lrwxrwxrwx   1 root root      26 Nov 26 11:32 libevent_core-1.4.so.2 -> libevent_core-1.4.so.2.0.0
-rwxr-xr-x   1 root root  101485 Nov 26 11:32 libevent_core-1.4.so.2.0.0
-rw-r--r--   1 root root  139080 Nov 26 11:32 libevent_core.a
-rwxr-xr-x   1 root root     866 Nov 26 11:32 libevent_core.la
lrwxrwxrwx   1 root root      26 Nov 26 11:32 libevent_core.so -> libevent_core-1.4.so.2.0.0
lrwxrwxrwx   1 root root      27 Nov 26 11:32 libevent_extra-1.4.so.2 -> libevent_extra-1.4.so.2.0.0
-rwxr-xr-x   1 root root  214596 Nov 26 11:32 libevent_extra-1.4.so.2.0.0
-rw-r--r--   1 root root  273270 Nov 26 11:32 libevent_extra.a
-rwxr-xr-x   1 root root     873 Nov 26 11:32 libevent_extra.la
lrwxrwxrwx   1 root root      27 Nov 26 11:32 libevent_extra.so -> libevent_extra-1.4.so.2.0.0
-rwxr-xr-x   1 root root     831 Nov 26 11:32 libevent.la
lrwxrwxrwx   1 root root      21 Nov 26 11:32 libevent.so -> libevent-1.4.so.2.0.0
    看见有很多libevent,就可以放心了。

    memcached

    官方网站:http://www.danga.com/memcached/download.bml
    下载地址:http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz

    memcached安装需要些参数:
以下是代码片段:
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local
make
make install
   我们来运行看看:
   运行:
以下是代码片段:
/usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root

    结果:
以下是引用片段:
[root@localhost memcached-1.2.2]# /usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
/usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
    查找原因,解决方案如下:
以下是代码片段:
LD_DEBUG=libs /usr/local/memcached/bin/memcached -v
    有如下显示:
以下是引用片段:
[root@localhost memcached-1.2.2]# LD_DEBUG=libs /usr/local/memcached/bin/memcached -v
     18999:     find library=libevent-1.4.so.2 [0]; searching
     18999:      search cache=/etc/ld.so.cache
     18999:      search path=/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2:/lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686:/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2:/usr/lib          (system search path)
     18999:       trying file=/lib/tls/i686/sse2/libevent-1.4.so.2
 &