`
chenzhou123520
  • 浏览: 4256370 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

linux上启动Memcache报错:error while loading shared libraries: libevent-1.4.so.2

阅读更多

linux上启动Memcache报错:

[root@localhost memcached]# ./bin/memcached -d -m 2048 -p 11211 -u root
./bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

原因一般有两个, 一个是操作系统里确实没有包含该共享库(lib*.so.*文件)或者共享库版本不对, 遇到这种情况那就去网上下载并安装上即可.

另外一个原因就是已经安装了该共享库, 但执行需要调用该共享库的程序的时候, 程序按照默认共享库路径找不到该共享库文件.

 

因为我已经安装了libevent,所以应该是程序按照默认共享路径库去找,但是没有找到导致的。

 

首先使用find命令找到libevent-1.4.so.2文件在哪儿

[root@localhost memcached]# find /usr -name libevent-1.4.so.2
/usr/libevent/lib/libevent-1.4.so.2

使用debug信息查看程序去哪里寻找共享文件库

LD_DEBUG=libs /usr/local/bin/memcached -v

其中/usr/local/bin/memcached代表我memcached执行程序

控制台输出结果如下:

[root@localhost memcached]# LD_DEBUG=libs /usr/local/bin/memcached -v
-bash: /usr/local/bin/memcached: No such file or directory
[root@localhost memcached]# LD_DEBUG=libs /usr/local/memcached/bin/memcached -v
      6513:     find library=libevent-1.4.so.2 [0]; searching
      6513:     search cache=/etc/ld.so.cache
      6513:     search path=/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2:/lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686:/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2:/usr/lib (system search path)
      6513:       trying file=/lib/tls/i686/sse2/libevent-1.4.so.2
      6513:       trying file=/lib/tls/i686/libevent-1.4.so.2
      6513:       trying file=/lib/tls/sse2/libevent-1.4.so.2
      6513:       trying file=/lib/tls/libevent-1.4.so.2
      6513:       trying file=/lib/i686/sse2/libevent-1.4.so.2
      6513:       trying file=/lib/i686/libevent-1.4.so.2
      6513:       trying file=/lib/sse2/libevent-1.4.so.2
      6513:       trying file=/lib/libevent-1.4.so.2
      6513:       trying file=/usr/lib/tls/i686/sse2/libevent-1.4.so.2
      6513:       trying file=/usr/lib/tls/i686/libevent-1.4.so.2
      6513:       trying file=/usr/lib/tls/sse2/libevent-1.4.so.2
      6513:       trying file=/usr/lib/tls/libevent-1.4.so.2
      6513:       trying file=/usr/lib/i686/sse2/libevent-1.4.so.2
      6513:       trying file=/usr/lib/i686/libevent-1.4.so.2
      6513:       trying file=/usr/lib/sse2/libevent-1.4.so.2
      6513:       trying file=/usr/lib/libevent-1.4.so.2
      6513:    
/usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

根据debug日志可以看到,程序只会去/lib 和/usr/lib下去寻找需要的共享链接库。

而我的libevent是安装在/usr/libevent/lib/下,所以memcache启动的时候并不知道该去这下面找,所以会报错

 

所以安装共享库后要注意共享库路径设置问题, 如下:

1) 如果共享库文件安装到了/lib或/usr/lib目录下, 那么需执行一下ldconfig命令

         ldconfig命令的用途, 主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录下, 搜索出可共享的动态链接库(格式如lib*.so*), 进而创建出动态装入程序(ld.so)所需的连接和缓存文件. 缓存文件默认为/etc/ld.so.cache, 此文件保存已排好序的动态链接库名字列表. 

 

2) 如果共享库文件安装到了/usr/local/lib(很多开源的共享库都会安装到该目录下)或其它"非/lib或/usr/lib"目录下, 那么在执行ldconfig命令前, 还要把新共享库目录加入到共享库配置文件/etc/ld.so.conf中, 如下:

[root@localhost memcached]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf

如上所示:/etc/ld.so.conf配置文件中内容只有一行,

ld.so.conf.d/*.conf的意思就是包含ld.so.conf.d/目录下以.conf为后缀的文件

所以我们可以在/etc/ld.so.conf.d目录下新建一个libevent.conf的配置文件,然后把libevent安装路径配置好

我的libevent内容如下:

[root@localhost ld.so.conf.d]# cat libevent.conf
/usr/libevent/lib

配置完后执行以下ldconfig命令

[root@localhost ~]#ldconfig 

3) 如果共享库文件安装到了其它"非/lib或/usr/lib" 目录下,  但是又不想在/etc/ld.so.conf中加路径(或者是没有权限加路径). 那可以export一个全局变量LD_LIBRARY_PATH, 然后运行程序的时候就会去这个目录中找共享库.

     LD_LIBRARY_PATH的意思是告诉loader在哪些目录中可以找到共享库. 可以设置多个搜索目录, 这些目录之间用冒号分隔开. 比如安装了一个mysql到/usr/local/mysql目录下, 其中有一大堆库文件在/usr/local/mysql/lib下面, 则可以在.bashrc或.bash_profile或shell里加入以下语句即可:

export LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH

一般来讲这只是一种临时的解决方案, 在没有权限或临时需要的时候使用.

 

这个问题的解决参考了网上的相关资料,特此说明!

分享到:
评论

相关推荐

    memcache安装必备的组件 libevent-1.3.tar.gz

    3. **平台兼容性:** `libevent` 提供了对多种操作系统的支持,包括 Linux、Windows、FreeBSD 等,这使得 Memcached 能够在不同的平台上运行。 **三、安装 Libevent** 在安装 Memcached 之前,首先需要安装 `...

    libevent-1.4.9-stable.tar.gz

    **标题解析:** "libevent-...综上所述,libevent是一个强大的事件通知库,对于memcache这样的高性能网络服务来说至关重要。通过理解libevent的工作原理和正确使用,可以有效提升应用程序的并发处理能力和响应速度。

    linux下安装memcached以及解决安装中遇到的问题

    /usr/local/memcache/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory ``` 说明系统未能找到 libevent 库。为了解决这个...

    netty-all-4.1.32.Final-sources.jar 最新版netty源码全部包

    netty-codec-memcache-4.1.32.Final-sources.jar netty-codec-memcache-4.1.32.Final.jar netty-codec-redis-4.1.32.Final-sources.jar netty-codec-redis-4.1.32.Final.jar netty-codec-socks-4.1.32.Final-sources...

    Linux环境下Memcache的安装

    然而,有时在启动Memcache时可能会遇到找不到共享库的错误,如“error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory”。这通常是由于系统路径中...

    netty-codec-memcache-4.1.73.Final-API文档-中文版.zip

    赠送jar包:netty-codec-memcache-4.1.73.Final.jar; 赠送原API文档:netty-codec-memcache-4.1.73.Final-javadoc.jar; 赠送源代码:netty-codec-memcache-4.1.73.Final-sources.jar; 赠送Maven依赖信息文件:...

    linux下memcached安装以及启动

    ln -s /usr/local/libevent-1.4/lib/libevent-1.4.so.2 /lib64/libevent-1.4.so.2 ``` 启动 Memcached 服务: ```bash ./memcached -d -m 1024 -u root -p 11211 -c 1024 -P /tmp/memcached.pid ``` 启动参数...

    netty-codec-memcache-4.1.74.Final-API文档-中文版.zip

    赠送jar包:netty-codec-memcache-4.1.74.Final.jar; 赠送原API文档:netty-codec-memcache-4.1.74.Final-javadoc.jar; 赠送源代码:netty-codec-memcache-4.1.74.Final-sources.jar; 赠送Maven依赖信息文件:...

    netty-codec-memcache-4.1.74.Final-API文档-中英对照版.zip

    赠送jar包:netty-codec-memcache-4.1.74.Final.jar; 赠送原API文档:netty-codec-memcache-4.1.74.Final-javadoc.jar; 赠送源代码:netty-codec-memcache-4.1.74.Final-sources.jar; 赠送Maven依赖信息文件:...

    netty-codec-memcache-4.1.73.Final-API文档-中英对照版.zip

    赠送jar包:netty-codec-memcache-4.1.73.Final.jar; 赠送原API文档:netty-codec-memcache-4.1.73.Final-javadoc.jar; 赠送源代码:netty-codec-memcache-4.1.73.Final-sources.jar; 赠送Maven依赖信息文件:...

    pecl-memcache-4.0.4.tar.gz

    tar -zxvf pecl-memcache-4.0.4.tar.gz && cd /root/pecl-memcache-4.0.4 && /usr/local/php7/bin/phpize && ./configure --with-php-config=/usr/local/php7/bin/php-config && make && make install

    memcached-1.4.22.tar.gz+libevent-2.0.22-stable.tar.gz

    《深入理解Memcached与Libevent:构建高性能缓存服务》 在IT领域,Memcached和Libevent是两个非常重要的开源工具,广泛应用于构建高性能、高并发的网络应用系统。本篇将详细介绍这两个组件以及它们之间的关系,帮助...

    Linux中PHP安装相关资源包

    1)软件资源列表:《libiconv-1.13.tar》,《libmcrypt-2.5.8.tar.gz》,《mcrypt-2.6.8.tar.gz》,《memcache-2.2.5.tgz》,《mhash-0.9.9.9.tar.gz》 ,《php-5.2.13.tar.bz2》,《php-5.2.13-fpm-0.5.13.diff.gz...

    memcache安装

    ### Memcache在Linux环境下的安装指南 随着互联网技术的发展,数据缓存技术变得越来越重要,Memcache作为一种高性能、分布式内存对象缓存系统,在提高网站访问速度方面发挥了关键作用。本文将详细介绍如何在Linux...

    php memcache-3.0.9.tar.gz php7 扩展 linux 包

    2. **进入源代码目录**:`cd memcache-3.0.9`。 3. **配置编译**:运行`phpize`以准备编译环境,然后执行`./configure --with-php-config=/path/to/php-config`,确保指向正确的PHP配置文件。 4. **编译源码**:`...

    memcached-win64-1.4.4-14.zip

    在标签`memcached-win64-`中,`win64`表示这是针对Windows 64位平台的,意味着该版本已经过编译和测试,可以在64位系统上正确运行。 关于`memcached-win64-1.4.4-14`这个压缩包内的具体文件,虽然列表中只给出了包...

    netty-jar.zip

    netty-3.7.0.Final.jar,netty-all-4.1.73.Final.jar,netty-buffer-4.1.82.Final.jar,netty-codec-4.1.82.Final.jar,netty-codec-dns-4.1.73.Final.jar,netty-codec-haproxy-4.1.73.Final.jar,netty-codec-...

    memcache-4.0.5.2.tgz

    这个“memcache-4.0.5.2.tgz”文件是一个针对 Memcached 的特定版本的源代码包,版本号为4.0.5.2。TGZ文件是一种常见的源代码打包格式,它由tar工具打包后通过gzip压缩而成。 在深入了解Memcached之前,我们需要先...

    memcached 安装教程

    memcached: error while loading shared libraries: libevent-1.3b.so.1: cannot open shared object file: No such file or directory ``` 为了解决这个问题,我们可以按照以下步骤操作: 1. 使用 `LD_DEBUG=libs...

    Solaris下安装memcache.doc

    如果出现找不到 libevent-1.4.so.2 的错误,需要进行下一步的解决。 7. **解决依赖问题**: 当运行 Memcached 时遇到“找不到共享对象文件”错误,可以通过以下步骤解决: - 使用 `find` 命令查找缺失的 libevent...

Global site tag (gtag.js) - Google Analytics