memcached 常用方法笔记

Friday, January 29, 2010

转自:http://hi.baidu.com/smallfish_xy/blog/item/7547b37a1fe695fd0bd187a8.html

memcached官网地址 http://www.danga.com/memcached/
(需要先安装libevent http://www.monkey.org/~provos/libevent/)
编译过程略过

启动/结束

memcached -d -m 10 -u root -l 192.168 . 0. 122 -p 11200 -c 256 -P /tmp/memcached.pid
-d 选项是启动一个守护进程,
-m 是分配给Memcache使用的内存数量,单位是MB,这里是10MB
-u 是运行Memcache的用户,这里是root
-l 是监听的服务器IP地址,如果有多个地址的话,这里指定了服务器的IP地址192.168.0.122
-p 是设置Memcache监听的端口,这里设置了12000,最好是1024以上的端口
-c 选项是最大运行的并发连接数,默认是1024,这里设置了256,按照你服务器的负载量来设定
-P 是设置保存Memcache的pid文件

kill `cat /tmp/memcached.pid`

获取运行状态

echo stats | nc 192.168.0.122 11200
watch “echo stats | nc 192.168.0.122 11200 ” (实时状态)

快速清空

echo “flush_all” | nc 192.168.0.122 11200

其他工具

有个perl写的工具还不错
地址
http://code.sixapart.com/svn/memcached/trunk/server/scripts/memcached-tool

perl memcached-tool 192.168.0.122:11200
perl memcached-tool 192.168.0.122:11200 stats

ps: python版memcached遍历脚本 http://ahuaxuan.javaeye.com/blog/256658

This entry was tagged Linux and memcached

comments powered by Disqus

© 2009-2013 lxneng.com. All rights reserved. Powered by Pyramid

go to Top