Memcache的操作命令

Memcache可以通过yum install memcache方式进行安装,安装完成后无需什么配置就可以参考文章启动memcache服务http://blog.webshuo.com/2011/02/14/memcache%E9%85%8D%E7%BD%AE%E4%BD%BF%E7%94%A8%E6%8A%80%E5%B7%A7/

1. /usr/local/bin/memecached -h

memcached 1.2.0 -p port number to listen on -s unix socket path to listen on (disables network support) -l interface to listen on, default is INDRR_ANY -d run as a daemon -r maximize core file limit -u assume identity of (only when run as root) -m max memory to use for items in megabytes, default is 64 MB -M return error on memory exhausted (rather than removing items) -c max simultaneous connections, default is 1024 -k lock down all paged memory -v verbose (print errors/warnings while in event loop) -vv very verbose (also print client commands/reponses) -h print this help and exit -i print memcached and libevent license -b run a managed instanced (mnemonic: buckets) -P save PID in , only used with -d option -f chunk size growth factor, default 1.25 -n minimum space allocated for key+value+flags, default 48

参数不算多,我们来启动一个Memcache的服务器端:

1. /usr/local/bin/memcached -d -m 10 -u root -l localhost -p 11211 -c 256 -P /tmp/memcached.pid

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

1. kill `cat /tmp/memcached.pid`

也可以启动多个守护进程,不过端口不能重复。

你可能感兴趣的:(Memcache的操作命令)