error while loading shared libraries: libevent-2.1.so.6 的解决办法
执行 memcached 启动命令时,报错,提示:error while loading shared libraries: libevent-2.1.so.6: cannot open shared object file: No such file or directory
查看 memcached 命令缺失什么库
ldd /usr/local/memcached/bin/memcached
ldd /usr/local/memcached/bin/memcached
结果: libevent-2.1.so.6 模块找不到
查看 libevent-2.1.so.6 是否存在
locate libevent-2.1.so.6
locate libevent-2.1.so.6
结果: 系统已经安装了该模块,在路径 /usr/local/lib/
查看 memcached 查找依赖库的路径
LD_DEBUG=libs /usr/local/memcached/bin/memcached -v
LD_DEBUG=libs /usr/local/memcached/bin/memcached -v
结果: 在 /lib64/ 目录中查找,所以找不到已经安装好的
映射 libevent-2.1.so.6 到 /lib64 路径中
ln -s /usr/local/lib/libevent-2.1.so.6 /usr/lib64/libevent-2.1.so.6
ln -s /usr/local/lib/libevent-2.1.so.6 /usr/lib64/libevent-2.1.so.6
结果:这样处理后,memcached就可以搜索到该文件了
启动memcached服务
/etc/init.d/memcached restart
/etc/init.d/memcached restart
此处会略有不同,因为提前已经安装了memcache开机启动脚本