linux 下 memcached服务端安装

安装memcached需要先安装libevent,但如果不为安装libevent和memcached准备单独的目录,启动memcached后,会出现telnet一连接memcached就会断掉的情况,报错提示为:Catastrophic:event fd doesn't match conn fd,错误原因libevent冲突,解决办法:把lievent和memcached安装到单独的目录,重新安装。

详细步骤参考:

  1. 分别把memcachedlibevent下载回来,放到 /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

  2. 先安装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

  3. 测试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

  4. 安装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

  5. 测试是否成功安装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

  6. 启动memcached:

    ./memcached -d -m 128m -u root -p 11211 -vv
    具体参数信息可通过memcached -h查看,核心参数如下:
    -d :指定memcached在后台执行;
    -m :分配给memcached的可用内存大小,在32位OS中不能超过2G,64位OS中只受物理内存大小限制;
    -p :memcached的监听端口,默认为11211;


你可能感兴趣的:(linux,local,服务端)