Memcache使用手册

memcache 启动:
/opt/memcache/bin/memcached -d -m 200 -u root -l 192.168.8.134 -p 11211 -c 1024  /tmp/memcached.pid


memcache 数据丢失解决:
出现这个问题的原因在于memcached默认使用Slab Allocator的方式进行内存分配,该方式不会释放已分配的内存,而是重复使用已分配的内存,这就造成了问题中所说的数据丢失,命中下降的问题。解决办法是在Memcached启动时,使用如下方法来增加内存的分配,或是禁用LRU来避免出现该问题。
$ memcached -M -m 1024

“-M”参数表示禁止LRU,“-m”选项是用来指定最大内存大小的。不指定具体数值则使用默认值64MB。

memcache 详情查看:
telnet IP  port
Trying xxx.xx.xx.xxx...
Connected to xxx.xx.xx.xxx.
Escape character is '^]'.
stats
STAT pid 26530
STAT uptime 5807
STAT time 1258643806
STAT version 1.2.2
STAT pointer_size 64
STAT rusage_user 12.372773
STAT rusage_system 24.233514
STAT curr_items 72820
STAT total_items 5526
STAT bytes 95306264
STAT curr_connections 115
STAT total_connections 1
STAT connection_structures 116
STAT cmd_get 12507
STAT cmd_set 5526
STAT get_hits 12498
STAT get_misses 9
STAT evictions 0
STAT bytes_read 7363968
STAT bytes_written 15636889
STAT limit_maxbytes 2147483648
STAT threads 1
END

pid memcache服务器的进程ID 
uptime 服务器已经运行的秒数 
time 服务器当前的unix时间戳 
version memcache版本 
pointer_size 当前OS的指针大小(32位系统一般是32bit) 
rusage_user 进程的累计用户时间 
rusage_system 进程的累计系统时间 
curr_items 服务器当前存储的items数量 
total_items 从服务器启动以后存储的items总数量 
bytes 当前服务器存储items占用的字节数 
curr_connections 当前打开着的连接数 
total_connections 从服务器启动以后曾经打开过的连接数 
connection_structures 服务器分配的连接构造数 
cmd_get get命令(获取)总请求次数 
cmd_set set命令(保存)总请求次数 
get_hits 总命中次数 
get_misses 总未命中次数 
evictions 为获取空闲内存而删除的items数(分配给memcache的空间用满后需要删除旧的items来得到空间分配给新的items) 
bytes_read 总读取字节数(请求字节数) 
bytes_written 总发送字节数(结果字节数) 
limit_maxbytes 分配给memcache的内存大小(字节) 
threads 当前线程数 

猜你喜欢

转载自xiaokongbai.iteye.com/blog/1738151