当前位置: 代码迷 >> 综合 >> error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such fil
  详细解决方案

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

热度:94   发布时间:2023-12-08 21:27:41.0

启动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


  相关解决方案