错误原因libevent冲突,解决办法,把lievent安装到单独的目录,重新安装。
详细步骤参考:
- 分别把memcached和libevent下载回来,放到 /tmp 目录下:
# cd /tmp
# wget http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz
# wget http://www.monkey.org/~provos/ libevent-1.4.8-stable.tar.gz - 先安装libevent:
# tar zxvf libevent-1.4.8-stable.tar.gz
# cd libevent-1.4.8-stable
# ./configure --prefix=/usr/local/libevent-1.4.8-stable
# make
# make install - 测试libevent是否安装成功:
# ls -al /usr/local/libevent-1.4.8-stable/lib | grep libevent
# vi /etc/ld.so.conf 在首行加入/usr/local/libevent-1.4.8-stable/lib
运行 ldconfig 否则运行memcached的时候,会提示找不到so文件
还有一种方法是直接在lib64目录中新增一个link链接
# ln -s /usr/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2 - 安装memcached,同时需要安装中指定libevent的安装位置:
# cd /tmp
# tar zxvf memcached-1.2.6.tar.gz
# cd memcached-1.2.6
# ./configure --prefix=/usr/local/memcached-1.2.6 --with-libevent=/usr/local/libevent-1.4.8-stable --enable-64bit --enable-threads
# make
# make install
# ln -s /usr/local/memcached-1.2.6 /usr/local/memcached
如果中间出现报错,请仔细检查错误信息,按照错误信息来配置或者增加相应的库或者路径。
安装完成后会把memcached放到 /usr/local/memcached/bin/memcached - 测试是否成功安装memcached:
# ls -al /usr/local/memcached/bin/mem*
-rwxr-xr-x 1 root root 137986 11?? 12 17:39 /usr/local/bin/memcached
-rwxr-xr-x 1 root root 140179 11?? 12 17:39 /usr/local/bin/memcached-debug - 启动memcached:
# /usr/local/memcached/bin/memcached -d -m 1024 -u admin -l 127.0.0.1 -p 11211
具体参数信息可通过memcached -h查看,核心参数如下:
-d :指定memcached在后台执行;
-m :分配给memcached的可用内存大小,在32位OS中不能超过2G,64位OS中只受物理内存大小限制;
-p :memcached的监听端口,默认为11211;