MemCached是采用libevent来进行网络连接的并发处理,能够保持高并发情况下,依然能够保持快速的响应能力。
因此安装要分两部分:
1.安装libevent
Step 1: 下载http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
Step 2:[root@ls-dev01 local]# tar -zxvf libevent-1.4.13-stable.tar.gz
Step 3:[root@ls-dev01 local]# cd libevent-1.4.13-stable
Step 4: [root@ls-dev01 local]# ./configure
Step 5: [root@ls-dev01 local]# make
Step 6: [root@ls-dev01 local]# make install
2.安装MemCached
Step 1: 下载http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
Step 2:[root@ls-dev01 local]# tar -zxvf memcached-1.4.5.tar.gz
Step 3:[root@ls-dev01 local]# cd memcached-1.4.5
Step 4:[root@ls-dev01 local] ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local
Step 5:[root@ls-dev01 local] make
Step 6:[root@ls-dev01 local] make install
3.运行MemCached
[root@ls-dev01 local]# /usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
启动端口11211,以守护进程的方式启动
结果会启动失败:
/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
解决方案如下:
[root@ls-dev01 local]# 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
18999: trying file=/lib/tls/i686/libevent-1.4.so.2
18999: trying file=/lib/tls/sse2/libevent-1.4.so.2
18999: trying file=/lib/tls/libevent-1.4.so.2
18999: trying file=/lib/i686/sse2/libevent-1.4.so.2
18999: trying file=/lib/i686/libevent-1.4.so.2
18999: trying file=/lib/sse2/libevent-1.4.so.2
18999: trying file=/lib/libevent-1.4.so.2
18999: trying file=/usr/lib/tls/i686/sse2/libevent-1.4.so.2
18999: trying file=/usr/lib/tls/i686/libevent-1.4.so.2
18999: trying file=/usr/lib/tls/sse2/libevent-1.4.so.2
18999: trying file=/usr/lib/tls/libevent-1.4.so.2
18999: trying file=/usr/lib/i686/sse2/libevent-1.4.so.2
18999: trying file=/usr/lib/i686/libevent-1.4.so.2
18999: trying file=/usr/lib/sse2/libevent-1.4.so.2
18999: trying file=/usr/lib/libevent-1.4.so.2
18999:
/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
解决方案如下:
[root@ls-dev01 local]# ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2
再次运行:
[root@ls-dev01 local]# /usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
测试是否成功:
telnet serverIP 11211