今天在64位centos上安裝memcached。啓動服務時出現 error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory。記錄一下處理的方法。 看到這個錯的時候感受很奇怪,由於我以前已經下載安裝過libevent了。爲何啓動的時候會找不到呢?看看個人處理步驟:
1、再次肯定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
2、看看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。
3、看看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包所在的位置
4、創建軟鏈,讓memcached能夠找到他要的libevent-2.0.so.5
ln -s /usr/local/lib/libevent-2.0.so.5 /lib64/libevent-2.0.so.5
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)
大功告成!這下已經找到了! 這是一個很典型的問題,處理思路更加典型。記錄之,也方便後來人。