今天在64位centos上安装memcached。启动服务时出现 error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory。记录一下处理的方法。 看到这个错的时候感觉很奇怪,因为我之前已经下载安装过libevent了。为什么启动的时候会找不到呢?看看我的处理步骤:
一、再次确定libevent安装在了哪里
# whereis libevent-2.0.so.5
libevent-2.0.so: /usr/lib/libevent-2.0.so.5 /usr/local/lib/libevent-2.0.so.5
二、看看memcached的依赖
# ldd memcached
linux-vdso.so.1 => (0x00007fff79ba0000)
libevent-2.0.so.5 => not found
librt.so.1 => /lib64/librt.so.1 (0x00000035c3e00000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00000035c3a00000)
libc.so.6 => /lib64/libc.so.6 (0x00000035c3600000)
/lib64/ld-linux-x86-64.so.2 (0x00000035c2e00000)
发现果然没有找到libevent-2.0.so.5。
三、看看memcached找依赖包的过程
# LD_DEBUG=libs ./memcached -v
25352: find library=libevent-2.0.so.5 [0]; searching
25352: search cache=/etc/ld.so.cache
25352: 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)
25352: trying file=/lib64/tls/x86_64/libevent-2.0.so.5
25352: trying file=/lib64/tls/libevent-2.0.so.5
25352: trying file=/lib64/x86_64/libevent-2.0.so.5
25352: trying file=/lib64/libevent-2.0.so.5
25352: trying file=/usr/lib64/tls/x86_64/libevent-2.0.so.5
25352: trying file=/usr/lib64/tls/libevent-2.0.so.5
25352: trying file=/usr/lib64/x86_64/libevent-2.0.so.5
25352: trying file=/usr/lib64/libevent-2.0.so.5
25352:
./memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
发现memcached去搜索的路径中果然没有我们libevent-2.0.so.5包所在的位置
四、建立软链,让memcached可以找到他要的libevent-2.0.so.5
ln -s /usr/local/lib/libevent-2.0.so.5 /lib64/libevent-2.0.so.5
五、再次查看memcached的依赖
# ldd memcached
linux-vdso.so.1 => (0x00007fff309ff000)
libevent-2.0.so.5 => /lib64/libevent-2.0.so.5 (0x00007fa18c72e000)
librt.so.1 => /lib64/librt.so.1 (0x00000035c3e00000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00000035c3a00000)
libc.so.6 => /lib64/libc.so.6 (0x00000035c3600000)
/lib64/ld-linux-x86-64.so.2 (0x00000035c2e00000)
大功告成!这下已经找到了! 这是一个很典型的问题,处理思路更加典型。记录之,也方便后来人。