启动 Memcached 报错:/usr/local/bin/memcached: error while loading shared libraries: libevent-2.1.so.7

启动 Memcached 报错:

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

解决方法如下:

1、查找libevent命令所在目录
[root@localhost ~]# sudo find / -name libevent-2.1.so.7
/usr/local/lib/libevent-2.1.so.7
/root/libevent-2.1.11-stable/.libs/libevent-2.1.so.7
2、查看 memcached 从哪里启动 libevent(重要!!!
[root@localhost ~]# LD_DEBUG=libs /usr/local/bin/memcached -v
      4607:      find library=libevent-2.1.so.7 [0]; searching
      4607:      search cache=/etc/ld.so.cache
      4607:      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)
      4607:       trying file=/lib64/tls/x86_64/libevent-2.1.so.7
      4607:       trying file=/lib64/tls/libevent-2.1.so.7
      4607:       trying file=/lib64/x86_64/libevent-2.1.so.7
      4607:       trying file=/lib64/libevent-2.1.so.7
      4607:       trying file=/usr/lib64/tls/x86_64/libevent-2.1.so.7
      4607:       trying file=/usr/lib64/tls/libevent-2.1.so.7
      4607:       trying file=/usr/lib64/x86_64/libevent-2.1.so.7
      4607:       trying file=/usr/lib64/libevent-2.1.so.7				# 这里这里!!!
      4607:
/usr/local/bin/memcached: error while loading shared libraries: libevent-2.1.so.7: cannot open shared object file: No such file or directory

从Debug信息中就知道程序去哪里找链接库了。我这边程序去 trying file=/usr/lib64/libevent-2.1.so.7启动,而我的链接库的实际存储位置是 /usr/local/lib/libevent-2.1.so.7

3、制作软连接
[root@localhost ~]# ln -s /usr/local/lib/libevent-2.1.so.7 /usr/lib64/libevent-2.1.so.7
再次启动即可

你可能感兴趣的:(memcached)