存档

文章标签 ‘memcached’

ibevent-1.1a.so.1 depend memcached CentOS5.5

2010年10月29日 评论已被关闭
update to centos5.5, memcached has issue:
resent failed: Execution of ‘/usr/bin/yum -d 0 -e 0 -y install memcached’ returned 1: memcached-1.2.6-1.el5.rf.x86_64 from EPEL-base has depsolving problems
  –> Missing Dependency: libevent-1.1a.so.1()(64bit) is needed by package memcached-1.2.6-1.el5.rf.x86_64 (EPEL-base)
Error: Missing Dependency: libevent-1.1a.so.1()(64bit) is needed by package memcached-1.2.6-1.el5.rf.x86_64 (EPEL-base)
 You could try using –skip-broken to work around the problem
 You could try running: package-cleanup –problems
                        package-cleanup –dupes
                        rpm -Va –nofiles –nodigest
how to resolve it?
will update it when I find a way!
分类: OpenSource 标签:

Get memcached all items and deleted them if needed.

2010年7月14日 2 条评论

    I see there are so many api to operate memcached,such as get and set,but no list all items,so i write a shell just list all the items in memcached and we can delete the items when we don’t know the exactly items key.

#!bin/bash
# get_items_from_memcached.sh
# Usge: sh get_items_from_memcached.sh localhost port
# Exp:  sh get_items_from_memcached.sh 2hei.net 11211
# By: @2hei.net

items=`echo “stats items” | nc $1 $2|grep number|awk -F: ‘{print $2}’|awk ‘{printf(“%s “,$1) }’`
for i in ${items}
  do
    #get delete_items_list
    echo “stats cachedump $i 0” | nc $1 $2|awk -v HOST=$1 -v PORT=$2 ‘{if(length($2)>0) print “echo delete”,$2,” | nc”,HOST,PORT}’ >> $1_$2.txt
    #print all items
    echo “stats cachedump $i 0” | nc $1 $2|awk ‘{if($2) print $2}’
  done

##delete all items by item_list if needed
#/bin/sh $1_$2.txt

##END##

tips:
1. you just can use “flush_all” cmd
   echo “flush_all” | nc $1 $2
   
   “flush_all” is a command with an optional numeric argument. It always
succeeds, and the server sends “OK\r\n” in response (unless “noreply”
is given as the last parameter). Its effect is to invalidate all
existing items immediately (by default) or after the expiration specified.
   flush_all doesn’t actually free all the memory taken up by existing items; that
will happen gradually as new items are stored. The most precise
definition of what flush_all does is the following: it causes all
items whose update time is earlier than the time at which flush_all
was set to be executed to be ignored for retrieval purposes.

2. if your memcached has to many items, this shell will waste a long time, for it will establish a new connection when delete each time.
we can use other tools write by socket and do this in only one connection.

分类: OpenSource 标签: