1. Check the config file vim /etc/memcached.conf
# memory -m 1282. Check system processlist ps aux | grep memcached
/usr/bin/memcached -m 128 -p 11211 -u nobody -l 127.0.0.1Ok so when we are sure that deamon is running we can telnet (or use nc) to connect
nc 127.0.0.1 11211The basic command to list statistic is "stats"
stats STAT pid 1574 // process id STAT uptime 3866 // deamon uptime STAT time 1344373852 // server uptime STAT version 1.4.2 //version of memcached STAT pointer_size 32 //size of pointer in bits STAT rusage_user 0.008000 // STAT rusage_system 0.024001 STAT curr_connections 6 //number of current open connections STAT total_connections 19 //number of total connection to server STAT connection_structures 8 STAT cmd_get 12 //Total numer of 'get' commands STAT cmd_set 4 // Total number of 'set' commands STAT cmd_flush 0 // Total number of 'flush' commands STAT get_hits 12 // total number of requests that return value STAT get_misses 6 // total number of missed requests 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 bytes_read 1040 //total number of bytes returned by sevrer STAT bytes_written 6143 //total number of bytes saved by sevrer STAT limit_maxbytes 134217728 //memory limit STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 4 STAT conn_yields 0 STAT bytes 382 //number of bytes used by current items (curr_items) STAT curr_items 4 // current number of items stored in memory STAT total_items 5 //total number of items stored from the beginning STAT evictions 0To get more details visit mysql manual page.
Next useful command is stats items We can see informations about given slab.
curr_item = 7 ... .. stats items STAT items:1:number 3 //total number of items STAT items:1:age 2118 //age of the oldest item in slab STAT items:1:evicted 0 STAT items:1:evicted_nonzero 0 STAT items:1:evicted_time 0 STAT items:1:outofmemory 0 STAT items:1:tailrepairs 0 STAT items:3:number 4 STAT items:3:age 3832 STAT items:3:evicted 0 STAT items:3:evicted_nonzero 0 STAT items:3:evicted_time 0 STAT items:3:outofmemory 0 STAT items:3:tailrepairs 0So we can see that in slab 1 there are 3 objects and 4 items in slab 3
To understand next command stats slabs we first have to know what slab is . Think about slab like a partition. Memcached writes data to diffrent partition (slabs), based on the data size, so that memory allocation is more optimal In this example we can se that we have two slabs 1 and 3. Each slab have unique id
stats slabs STAT 1:chunk_size 80 STAT 1:chunks_per_page 13107 STAT 1:total_pages 1 STAT 1:total_chunks 13107 STAT 1:used_chunks 3 STAT 1:free_chunks 1 STAT 1:free_chunks_end 13103 STAT 1:mem_requested 168 STAT 1:get_hits 0 // STAT 1:cmd_set 15 STAT 1:delete_hits 0 STAT 1:incr_hits 0 STAT 1:decr_hits 0 STAT 1:cas_hits 0 STAT 1:cas_badval 0 STAT 3:chunk_size 136 STAT 3:chunks_per_page 7710 STAT 3:total_pages 1 STAT 3:total_chunks 7710 STAT 3:used_chunks 4 STAT 3:free_chunks 0 STAT 3:free_chunks_end 7706 STAT 3:mem_requested 434 STAT 3:get_hits 33 //total number of get commands STAT 3:cmd_set 4 // total numer of sets commands STAT 3:delete_hits 0 STAT 3:incr_hits 0 STAT 3:decr_hits 0 STAT 3:cas_hits 0 STAT 3:cas_badval 0 STAT active_slabs 2 //number of active slabs STAT total_malloced 2097120//total amount of allocated memory by all slabsIf we want to see detailed view of stored objects we can use command "stats cachedump [slab id ] [numer of items ,0 - all]"
stats cachedump 1 0 ITEM duaa [5 b; 1344369986 s] ITEM du [2 b; 1344369986 s] ITEM dupa [4 b; 1344369986 s] END stats cachedump 3 0 ITEM bb3c75a2fe760dda6df236766eec90d3 [27 b; 1344369986 s] ITEM dbf8adc42d9c4a0bd67da4702b45d059 [26 b; 1344369986 s] ITEM 0cef10de0f9ba7b0231665da6aa4ee85 [27 b; 1344369986 s] ITEM ced34df387fd279cdf1c78989c44f7c2 [26 b; 1344369986 s]To read value we can use "get [key_name]" command :
get ced34df387fd279cdf1c78989c44f7c2
VALUE ced34df387fd279cdf1c78989c44f7c2 4 26
a:1:{s:5:"count";s:1:"7";}
To delete key use "delete [key_name]"
delete ced34df387fd279cdf1c78989c44f7c2 DELETEDSo there are the most popular ways to view memcached statistic. In next part we gonna se some gui tools in action ; )
Brak komentarzy:
Prześlij komentarz