fggweert 发表于 2015-5-22 10:19:24

Memcached安装和配置

最近看了一下memcached的相关部分,整理一下memcached的安装



首先应该下载libevent和memcached的压缩包,上传到你的服务器
libevent的官网:http://libevent.org
memcached的官网:http://www.memcached.org

1.查看服务器中是否已经安装libevent

1
rpm -qa | grep libevent




假如存在的话就,就卸载掉

1
rpm -e libevent-1.4.13-4.el6.x86_64 --nodeps




2.安装libevent


1
2
3
tar -xf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure -prefix=/usr/local/libevent && make && make install




假如在编译过程中出错,请yum安装gcc编译器


1
yum -y install gcc




3.安装memcached


1
2
3
tar -xf memcached-1.4.24.tar.gz
cd memcached-1.4.24
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent && make && make install




4.memcached参数及启动

-d            以守护程序(daemon)方式运行
-u root    指定用户,如果当前为root用户,需要用该参数指定用户
-P /tmp/memcached.pid    pid到指定目录
-m 200    数据内存数量,单位为MB,不包含memcached本身占用
-M         内存不够时禁止LRU
-n 48       初始chunk=key+suffix+value+32结构体,默认为48字节
-f 1.25   增长因子,默认为1.25
-L            启用大内存页,可以降低内存浪费,改进性能
-l 127.0.0.1      监听的IP地址,本机可以不设置此参数
-p 11211            TCP端口,默认11211
-U 11211            UDP端口,默认11211,0为关闭
-c 1024               最大并发连接数,默认1024,最好设置为200   

-t 4                      线程数,默认为4。memcached采用NIO,所以线程多没用

-R 20                  每个event连接最大并发数,默认20

-C                         禁用CAS命令(可以禁止版本计数,减少开销)

1
/usr/local/memcached/bin/memcached -d -u root -m 200 -P /tmp/memcached.pid



页: [1]
查看完整版本: Memcached安装和配置