memcached没有client工具来查看状态,只提供telnet来查看。
Command | Description | Example |
---|---|---|
get | Reads a value | get mykey |
set | Set a key unconditionally | set mykey 0 60 5 |
add | Add a new key | add newkey 0 60 5 |
replace | Overwrite existing key | replace key 0 60 5 |
append | Append data to existing key | append key 0 60 15 |
prepend | Prepend data to existing key | prepend key 0 60 15 |
incr | Increments numerical key value by given number | incr mykey 2 |
decr | Decrements numerical key value by given number | decr mykey 5 |
delete | Deletes an existing key | delete mykey |
flush_all | Invalidate specific items immediately | flush_all |
Invalidate all items in n seconds | flush_all 900 | |
stats | Prints general statistics | stats |
Prints memory statistics | stats slabs | |
Prints memory statistics | stats malloc | |
Print higher level allocation statistics | stats items | |
stats detail | ||
stats sizes | ||
Resets statistics | stats reset | |
version | Prints server version. | version |
verbosity | Increases log level | verbosity |
quit | Terminate telnet session | quit
|
重点关注一下stats:
stats
STAT pid 5451
STAT uptime 5064357
STAT time 1342166887
STAT version 1.4.7
STAT libevent 1.3
STAT pointer_size 64
STAT rusage_user 36275.155338
STAT rusage_system 65475.409224
STAT curr_connections 887
STAT total_connections 249340393
STAT connection_structures 4771
STAT cmd_get 2674204072
STAT cmd_set 605961622
STAT cmd_flush 0
STAT get_hits 2058228361
STAT get_misses 615975711
STAT delete_misses 2946048
STAT delete_hits 2136987
STAT incr_misses 0
STAT incr_hits 28591
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 511599249032
STAT bytes_written 999713170900
STAT limit_maxbytes 2147483648
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 399
STAT bytes 1641080671
STAT curr_items 3331967
STAT total_items 605961987
STAT evictions 56279782
STAT reclaimed 97669968
这里比较重要的几个参数:
limit_maxbytes、bytes
memcached在存储的时候是可以设置失效时间的,但如果存储已经满了,那旧数据即使没有到过期时间,也会被移除。所以需要观察memcached存 储是否已经满了,同时这对扩容也是有意义的参考。limit_maxbytes即总的存储大小,而bytes就是已经使用的大小,从这两个数据就可以看出 在memcached启动时,我们为它分配的内存是否足够使用。
cmd_get、cmd_set
memcached启动后,我们对它一共做了多少次读取操作呢?从这两个参数可以观察出来。
get_hits、get_misses
使用memcached后,我们需要评估我们使用的策略是否合理。不能够使用中间缓存后,后端的数据库还是有较大的访问量,这样的话中间缓存就变得没有意 义了。get_hits表示命中了多少次读取,即来memcached取到了多少有效数据;get_misses表示没有命中的次数,即此次来取数据的时 候,memcached并没有你所查询的数据。如果没有清零统计数据的话,cmd_get = get_hits + get_misses。
其他命令:
stats reset 清空统计数据
stats malloc 显示内存分配数据
stats slabs 显示各个slab的信息,包括chunk的大小、数目、使用情况等
stats items 显示各个slab中item的数目和最老item的年龄(最后一次访问距离现在的秒数)
参考:
http://blog.alwaysmylove.net/2008/04/10/stats-command-in-memcached/
http://www.yayu.org/look.php?id=164