TypechoJoeTheme

IT技术分享

统计

Memcached在CentOS 7 下的安装与配置

2016-07-25
/
0 评论
/
820 阅读
/
正在检测是否收录...
07/25

安装依赖

首先下载libevent-2.0.22-stable.tar.gz,然后

tar -zxvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure
make
sudo make install
make clean

安装MC

wget https://memcached.org/latest  #将文件下载地址替换成想要的版本
tar -xzvf memcached-1.4.31.tar.gz
cd memcached-1.4.31
./configure
make
sudo make install
make clean

启动MC

memcached -d -u dunso -m 512m -p 11211 -P /tmp/11211.pid

出现错误:

memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

是因为找不到libevent-2.0.so.5文件,查看该文件在什么位置

whereis libevent-2.0.so.5

发现在/usr/local/lib/libevent-2.0.so.5,然后查看mc是否能找到

ldd /usr/local/bin/memcached
linux-vdso.so.1 => (0x00007ffe88f2f000)
libevent-2.0.so.5 => not found
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f76cdaba000)
libc.so.6 => /lib64/libc.so.6 (0x00007f76cd6f8000)
/lib64/ld-linux-x86-64.so.2 (0x00007f76cdcdd000)

发现找不到,然后

cd /usr/local/bin
LD_DEBUG=libs ./memcached -v
17605: find library=libevent-2.0.so.5 [0]; searching
17605: search cache=/etc/ld.so.cache
17605: search path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64 (system search path)
17605: trying file=/lib64/tls/x86_64/libevent-2.0.so.5
17605: trying file=/lib64/tls/libevent-2.0.so.5
17605: trying file=/lib64/x86_64/libevent-2.0.so.5
17605: trying file=/lib64/libevent-2.0.so.5
17605: trying file=/usr/lib64/tls/x86_64/libevent-2.0.so.5
17605: trying file=/usr/lib64/tls/libevent-2.0.so.5
17605: trying file=/usr/lib64/x86_64/libevent-2.0.so.5
17605: trying file=/usr/lib64/libevent-2.0.so.5

发线memcached查找目录是/usr/lib64/libevent-2.0.so.5,所以我们在此处给它建立软链

sudo ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

然后再次查看

ldd /usr/local/bin/memcached
linux-vdso.so.1 => (0x00007ffe00d15000)
libevent-2.0.so.5 => /lib64/libevent-2.0.so.5 (0x00007f2e71097000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2e70e7b000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2e70ab8000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2e712e4000)

发现已经可以找到了,然后启动mc

memcached -d -u dunso -m 512m -p 11211 -P /tmp/11211.pid

测试MC

1、安装telnet

sudo yum install telnet-server
sudo yum install telnet

2、测试mc

telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.

输入stats可查看相应信息,如pid

朗读
赞 · 0
版权属于:

IT技术分享

本文链接:

https://idunso.com/archives/2458/(转载时请注明本文出处及文章链接)