| Subcribe via RSS

在CentOs中安装Memcached

7月 27th, 2008 | No Comments | Posted in 心得
准备安装:

需要先安装gcc,libevent

yum install gcc wget http://monkey.org/~provos/libevent-1.4.4-stable.tar.gz tar xvzf libevent-1.4.4-stable.tar.gz cd libevent-1.4.4-stable ./configure –prefix=/usr/local/libevent make make install

编译安装:

./configure –prefix=/usr/local/memcached –build=i686-pc-linux-gnu \ –with-libevent=/usr/local/libevent make make install

启动:

$ /usr/local/memcached/bin/memcached -p 11211 -m 64m -d -u root

 

使用memcached -h可以查看所有可用选项:

  • 选项     说明-p     使用的TCP端口。默认为11211

    -m     最大内存大小。默认为64M

    -vv     用very vrebose模式启动,调试信息和错误输出到控制台

    -d     作为daemon在后台启动

  • -u     运行Memcache的用户,默认不能用root启动,所以当前用户为root用户时,需要用-u参数来指定。
  • -l       监听的服务器的ip
  • -c      最大并发连接数,默认为1024
  • -P     指定pid文件
常见问题:

1. 编译memcached时出现下面错误:

./configure checking build system type… Invalid configuration `i686-pc-linux-’: machine `i686-pc-linux‘ not recognized configure: error: /bin/sh ./config.sub i686-pc-linux- failed

解决方法:

在./configure 时加入参数–build=i686-pc-linux-gnu

2.启动时找不到libevent库

memcached: error while loading shared libraries: libevent-1.3c.so.1: cannot open shared object file: No such file or directory 

解决办法:

将libevent库所在路径加入LIBRARY_PATH,在/etc/profile中加入

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/libevent/lib
相关文章:
Tags: , , ,