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

来源:互联网 发布:wkwebview js交互 oc 编辑:程序博客网 时间:2024/06/05 07:13

启动memcached报错

/usr/local/memcached/bin/memcached -u root -p 11211 -m 2048m -d 

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

排查方法

[root@cmjs-live02-6312 memcached-1.4.5]# ldd /usr/local/memcached/bin/memcached 
linux-vdso.so.1 =>  (0x00007fff6c7ff000)
libevent-2.0.so.5 => not found
libpthread.so.0 => /lib64/libpthread.so.0 (0x00000036d6400000)
libc.so.6 => /lib64/libc.so.6 (0x00000036d6000000)
/lib64/ld-linux-x86-64.so.2 (0x00000036d5800000)

注: ldd能够显示可执行模块的dependency,其原理是通过设置一系列的环境变量,可以定位报错库文件

[root@cmjs-live02-6312 memcached-1.4.5]# whereis libevent-2.0.so.5  ##查找现有库文件libevent-2.0.so.5的路径
libevent-2.0.so: /usr/lib/libevent-2.0.so.5 /usr/local/lib/libevent-2.0.so.5   


[root@cmjs-live02-6312 memcached-1.4.5]#  LD_DEBUG=libs ./memcached -v   ##跟踪运行memcached所有加载库文件的路径
     13464: find library=libevent-2.0.so.5 [0]; searching
     13464: search cache=/etc/ld.so.cache
     13464: 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)
     13464:  trying file=/lib64/tls/x86_64/libevent-2.0.so.5
     13464:  trying file=/lib64/tls/libevent-2.0.so.5
     13464:  trying file=/lib64/x86_64/libevent-2.0.so.5
     13464:  trying file=/lib64/libevent-2.0.so.5
     13464:  trying file=/usr/lib64/tls/x86_64/libevent-2.0.so.5
     13464:  trying file=/usr/lib64/tls/libevent-2.0.so.5
     13464:  trying file=/usr/lib64/x86_64/libevent-2.0.so.5
     13464:  trying file=/usr/lib64/libevent-2.0.so.5
     13464:
./memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

在查找以上所有路径未果后报错,解决方法只要将上述路径的一个做个软连接即可

[root@cmjs-live02-6312 memcached-1.4.5]# ln -s /usr/lib/libevent-2.0.so.5 /lib64/libevent-2.0.so.5  

[root@cmjs-live02-6312 memcached-1.4.5]# ldd /usr/local/memcached/bin/memcached ##验证库文件是否找到
linux-vdso.so.1 =>  (0x00007fffda5ff000)
libevent-2.0.so.5 => /lib64/libevent-2.0.so.5 (0x00007f9699a93000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00000036d6400000)
libc.so.6 => /lib64/libc.so.6 (0x00000036d6000000)
librt.so.1 => /lib64/librt.so.1 (0x00000036d6800000)
/lib64/ld-linux-x86-64.so.2 (0x00000036d5800000)

[root@cmjs-live02-6312 memcached-1.4.5]# /usr/local/memcached/bin/memcached -u root -p 11211 -m 2048m -d 
[root@cmjs-live02-6312 memcached-1.4.5]# ps -ef |grep memcache 
root     14814     1  0 16:28 ?        00:00:00 /usr/local/memcached/bin/memcached -u root -p 11211 -m 2048m -d


0 0