1.安装linux开发工具包
在可视化窗口下载打开"添加删除程序",找到"开发->开发工具"打钩,更新.插入对应的linux安装盘.
2.安装libevent 1.4.x
Download from <http://monkey.org/~provos/libevent/>
tar zxvf libevent-1.4.12-stable.tar.gz
cd libevent-1.4.12-stable
./configure --prefix=/usr/local/libevent-1.4
make
make install
3.安装Memcached
tar vxzf memcached-1[1].4.4.tar.gz
cd memcached-1.4.4
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent-1.4/
make
make install
4.加载新的lib
系统需要动态加载新的lib,编辑/etc/ld.so.conf,在末尾加入两行:
/usr/local/lib
/usr/local/libevent-1.4/lib
保存后,运行 ldconfig -v 命令.
5.启动memcached服务
root@tonyvicky:# cd /usr/local/memcached/bin
./memcached -help
./memcached -d -m 1024 -u root -p 11211 -c 1024
启动参数说明:
-d 选项是启动一个守护进程,
-m 是分配给Memcache使用的内存数量,单位是MB,默认64MB
-M return error on memory exhausted (rather than removing items)
-u 是运行Memcache的用户,如果当前为root 的话,需要使用此参数指定用户。
-l 是监听的服务器IP地址,默认为所有网卡。
-p 是设置Memcache的TCP监听的端口,最好是1024以上的端口
-c 选项是最大运行的并发连接数,默认是1024
-P 是设置保存Memcache的pid文件
-f <factor> chunk size growth factor (default: 1.25)
-I Override the size of each slab page. Adjusts max item size(1.4.2版本新增)
也可以启动多个守护进程,但是端口不能重复