linux memcached
依赖库
yum install libevent libevent-deve
云安装
yum install memcached
源代码安装
wget http://memcached.org/latest 下载最新版本 tar -zxvf memcached-1.x.x.tar.gz 解压源码 cd memcached-1.x.x 进入目录 ./configure --prefix=/usr/local/memcached 配置 make && make test 编译 sudo make install 安装
如果./configure 编译不通过
// 报错如下 checking for libevent directory… configure: error: libevent is required. You can get it from http://www.monkey.org/~provos/libevent/ If it’s already installed, specify its path using –with-libevent=/dir/ // 则 ...,再编辑,即可通过。。 yum install libevent-devel
作为后台服务运行
# /usr/local/memcached/bin/memcached -p 11211 -m 64m -d 或者
# /usr/local/memcached/bin/memcached -d -m 64M -u root -l 0.0.0.0 -p 11211 -c 256 -P /tmp/memcached.pid
#/usr/local/memcached/bin/memcached -d -m 64M -u root -l 0.0.0.0 -p 11211
# /usr/local/memcached/bin/memcached -d -m 64M -u root -l 192.168.0.200 -p 11211 -c 256 -P /tmp/memcached.pid
链接
telnet 127.0.0.1 11211 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. // 以上为正常状态 // 这是一条完整的创建命令 set foot 0 0 3 bar // 记得按回车键 End set foo 0 0 3 保存命令 bar 数据 STORED 结果 get foo 取得命令 VALUE foo 0 3 数据 bar 数据 END 结束行 quit 退出
监听状态
netstat -tnlp
修改监听端口为0.0.0.0
/usr/local/memcached/bin/memcached -d -m 10 -u root -l 0.0.0.0 -p 12000 -c 256 -P /tmp/mem