memcached安装

1.下载libevent1.4.11(最新版)及memcached稳定版本1.2.8
cd /opt
mkdir memcached
wget http://www.monkey.org/%7Eprovos/libevent-1.4.11-stable.tar.gz
wget http://memcached.googlecode.com/files/memcached-1.2.8.tar.gz
2.安装libevent1.4.11
./configure && make
make install
检查,有内容就表示安装OK了
ls -l /usr/local/lib/ | grep even
3.安装memcache1.2.8
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local
make
make install
检查,/usr/local/memcached,有2个文件,安装成功!
4.运行一下报错原因及处理方法:
/usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
报:usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
/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这样的错误,原因是,memcached默认是到/usr/lib/里找libevent-1.4.so.2,而我们安装的是在 /usr/local/lib里面,处理一下:
ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2
在运行一下:
/usr/local/memcached/bin/memcached -d -m 10 -p 11211 -u root
OK,用netstat -tnlp,系统已经成功监听11211端口了!
关闭memcached,直接kill掉这个进程就OK了!
5.memcached运行参数:
/usr/local/memcached/bin/memcached -d -m 128 -u root -l 192.168.0.97 -c 256 -P /tmp/memcached.pid

-d选项是启动一个守护进程,
-m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
-u是运行Memcache的用户,我这里是root,
-l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.22.200(不指定为本机)
-p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口,
-c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
-P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid

你可能感兴趣的:(memcached)