memcached介绍
free & open source, high-performance, distributed memory object caching system
自由&开放源码,高性能,分布式的内存对象缓存系统
什么是 NoSQL?
显著特点: key-value键值对存储,如memcached, redis,
或基于文档存储 如,mongodb
准备编译环境
在linux编译,需要gcc,make,cmake,autoconf,libtool等工具,
编译 memcached
memcached依赖于 libevent库,因此我们需要先安装libevent.
先编译libevent ,再编译memcached,
编译memcached时要指定 libevent的路径
过程如下:假设源码在/usr/local/src下,安装在/usr/local下
# tar zxvf libevent-2.0.21-stable.tar.gz
# cd libevent-2.0.21-stable
# ./configure --prefix=/usr/local/libevent
# 如果出错,读报错信息,查看原因,一般是缺少库 # make && make install
# tar zxvf memcached-1.4.5.tag.gz
# cd memcached-1.4.5 #./configure--prefix=/usr/local/memcached \ --with-libevent=/usr/local/libevent
# make && make install
memcached的启动
# /usr/local/memcached/bin/memcached -m 64 -p 11211 -u nobody -vv
如果我们想让memcached作为 daemon在后台运行,只需要加-d选项
# /usr/local/memcached/bin/memcached -m 64 -p 11211 -u nobody -d
memcached的连接
memcached 客户端与服务器端的通信比较简单,使用的基于文本的协议,而不是二进制协议.
(http协议也是这样),因此我们通过 telnet即可与 memcached作交互.
另开一个终端,并运行telnet命令 (开启memcached的终端不要关闭)
# 格式 telnet host port
# telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.