一、windows下memcached的安装
1、下载安装包
2、安装memcached
二、linux下memcached的安装
1、安装包下载
2、安装memcached
1.安装之前,需要先下载libevent,并安装
下载地址:https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
解压:
tar -zxvf libevent-2.0.21-stable.tar.gz
安装配置:
./configure --prefix=/usr/local/libevent (指定安装到/usr/local/libevent目录下)
编译命令:make
安装命令:make install
安装完成!
2.下载memcached,并解压
命令: tar -zxvf memcached-1.4.17.tar.gz
安装配置:
./configure --prefix=/usr/local/memcached-1.4.17
若安装过程中提示找不到libevent路径时,使用--with-libevent=libevent安装的目录
./configure --prefix=/usr/local/memcached-1.4.17 --with-libevent=/usr/local/libevent/
编译命令:make
安装命令:make install
安装完成!
3.启动
/usr/local/memcached-1.4.17/bin/memcached -d -m 128 -u root -p 11211 -c 1024 -P /tmp/memcached.pid
启动参数说明:
-d 选项是启动一个守护进程。
-u root 表示启动memcached的用户为root。
-m 是分配给Memcache使用的内存数量,单位是MB,默认64MB。
-M return error on memory exhausted (rather than removing items)。
-u 是运行Memcache的用户,如果当前为root 的话,需要使用此参数指定用户。
-p 是设置Memcache的TCP监听的端口,最好是1024以上的端口。
-c 选项是最大运行的并发连接数,默认是1024。
-P 是设置保存Memcache的pid文件。
3、配置memcached为自启动服务