memcached安装和启动

1

下载 libevent-1.4.11-stable.tar.gz //http://www.monkey.org/~provos/libevent/
# cd /tmp
# tar libevent-1.4.11-stable.tar.gz
# cd libevent-1.4.11-stable
# ./configure --prefix=/usr
# make
# make install

2
下载memcached-1.2.8.tar.gz //http://www.danga.com/memcached/
# cd /tmp
# tar zxvf memcached-1.2.8.tar.gz
# cd memcached-1.2.8
# ./configure --with-libevent=/usr
# make
# make install

3
测试
/usr/local/bin/memcached -h
正常ok

4
常见错误
/usr/local/bin/memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
解决办法
LD_DEBUG=libs memcached -v

输出
      4962:     find library=libevent-1.4.so.2 [0]; searching
      4962:      search cache=/etc/ld.so.cache
      4962:      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)
      4962:       trying file=/lib64/tls/x86_64/libevent-1.4.so.2
      4962:       trying file=/lib64/tls/libevent-1.4.so.2
      4962:       trying file=/lib64/x86_64/libevent-1.4.so.2
      4962:       trying file=/lib64/libevent-1.4.so.2
      4962:       trying file=/usr/lib64/tls/x86_64/libevent-1.4.so.2
      4962:       trying file=/usr/lib64/tls/libevent-1.4.so.2
      4962:       trying file=/usr/lib64/x86_64/libevent-1.4.so.2
      4962:       trying file=/usr/lib64/libevent-1.4.so.2
      4962:
memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

然后对应的做link
ln -s /usr/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2

5 启动
# /usr/local/bin/memcached -d -m 2048 -u root -l 192.168.1.20 -p 12111 -c 1024 -P /tmp/memcached.pid

参数说明:
-d 启动为守护进程
-m <num> 分配给Memcached使用的内存数量,单位是MB,默认为64MB
-u <username> 运行Memcached的用户,仅当作为root运行时
-l <ip_addr> 监听的服务器IP地址,默认为环境变量INDRR_ANY的值
-p <num> 设置Memcached监听的端口,最好是1024以上的端口
-c <num> 设置最大并发连接数,默认为1024
-P <file> 设置保存Memcached的pid文件,与-d选择同时使用

你可能感兴趣的:(linux)