Memcache概述:

  Memcache是一个高性能的分布式的内存对象缓存系统,通过在内存里维护一个统一的巨大的hash,它能够用来存储各种格式的数据,包括图像视频文件以及数据库检索的结果等。简单的说就是将数据调用到内存中,然后从内存中读取,从而大大提高读取速度。

  Memcached是以守护程序方式运行于一个或多个服务器中,随时会接收客户端连接和操作。

 

 

Memcache安装:

1:下载libeventmemcache软件包。

 libevent下载地址:http://monkey.org/~provos/libevent/

 memcache下载地址:http://memcached.org/

 

2:解压,编译libevent

# tar -zxvf libevent-2.1.3-alpha.tar.gz
# cd libevent-2.1.3-alpha
# ./configure -prefix=/usr/local/memcache/libevent
# make && make install

 

3:解压,编译memcache

# cd ../
# tar -zxvf memcached-1.4.15.tar.gz
# cd memcached-1.4.15
# ./configure --prefix=/usr/local/memcache/ --with-libevent=/usr/local/memcache/libevent
# make && make install

 

 

开启memcache,并连接测试:

以守护进程模式启动memcache

# /usr/local/memcache/bin/memcached -d -l 192.168.189.129 -p 11211 -m 2048 -u root

查看memcache是否开启:

wKioL1eNxSegm1suAAASLAmB5Vw535.png

客户端连接测试(使用telnet

#telnet192.168.189.129 11211


能连接上,说明memcache成功启用,可使用stats命令查看当前状态

#stats

STAT pid 29563

STAT uptime 228

STAT time 1377137834

STAT version 1.4.15

STAT libevent 2.1.3-alpha

STAT pointer_size 64

STAT rusage_user 0.000999

STAT rusage_system 0.000999

STAT curr_connections 5

STAT total_connections 6

STAT connection_structures 6

STAT reserved_fds 20

STAT cmd_get 0

STAT cmd_set 0

STAT cmd_flush 0

STAT cmd_touch 0

STAT get_hits 0

STAT get_misses 0

STAT delete_misses 0

STAT delete_hits 0

STAT incr_misses 0

STAT incr_hits 0

STAT decr_misses 0

STAT decr_hits 0

STAT cas_misses 0

STAT cas_hits 0

STAT cas_badval 0

STAT touch_hits 0

STAT touch_misses 0

STAT auth_cmds 0

STAT auth_errors 0

STAT bytes_read 7

STAT bytes_written 0

STAT limit_maxbytes 2147483648

STAT accepting_conns 1

STAT listen_disabled_num 0

STAT threads 4

STAT conn_yields 0

STAT hash_power_level 16

STAT hash_bytes 524288

STAT hash_is_expanding 0

STAT bytes 0

STAT curr_items 0

STAT total_items 0

STAT expired_unfetched 0

STAT evicted_unfetched 0

STAT evictions 0

STAT reclaimed 0

END