Memcached安装
Memcached安装
[root@eegooserver3~]#yuminstalllibeventmemcachedlibmemcached
libevent-1.4.13-4.el6.x86_64.rpm
libmemcached-0.31-1.1.el6.x86_64.rpm
memcached-1.4.4-3.el6.x86_64.rpm
[root@eegooserver3~]#memcached–h
[root@eegooserver3~]#chkconfigmemcachedon
[root@eegooserver3~]#chkconfig--list
[root@eegooserver3~]#servicememcachedstart
等同于(memcached-d-p11211-umemcached-m1024-c1024-P/var/run/memcached/memcached.pid)
[root@eegooserver3~]#memcached-h
memcached1.4.4
-p<num>TCPportnumbertolistenon(default:11211)
-U<num>UDPportnumbertolistenon(default:11211,0isoff)
-s<file>UNIXsocketpathtolistenon(disablesnetworksupport)
-a<mask>accessmaskforUNIXsocket,inoctal(default:0700)
-l<ip_addr>interfacetolistenon(default:INADDR_ANY,alladdresses)
-drunasadaemon
-rmaximizecorefilelimit
-u<username>assumeidentityof<username>(onlywhenrunasroot)
-m<num>maxmemorytouseforitemsinmegabytes(default:64MB)
-Mreturnerroronmemoryexhausted(ratherthanremovingitems)
-c<num>maxsimultaneousconnections(default:1024)
-klockdownallpagedmemory.Notethatthereisa
limitonhowmuchmemoryyoumaylock.Tryingto
allocatemorethanthatwouldfail,sobesureyou
setthelimitcorrectlyfortheuseryoustarted
thedaemonwith(notfor-u<username>user;
undershthisisdonewith'ulimit-S-lNUM_KB').
-vverbose(printerrors/warningswhileineventloop)
-vvveryverbose(alsoprintclientcommands/reponses)
-vvvextremelyverbose(alsoprintinternalstatetransitions)
-hprintthishelpandexit
-iprintmemcachedandlibeventlicense
-P<file>savePIDin<file>,onlyusedwith-doption
-f<factor>chunksizegrowthfactor(default:1.25)
-n<bytes>minimumspaceallocatedforkey+value+flags(default:48)
-LTrytouselargememorypages(ifavailable).Increasing
thememorypagesizecouldreducethenumberofTLBmisses
andimprovetheperformance.Inordertogetlargepages
fromtheOS,memcachedwillallocatethetotalitem-cache
inonelargechunk.
-D<char>Use<char>asthedelimiterbetweenkeyprefixesandIDs.
Thisisusedforper-prefixstatsreporting.Thedefaultis
":"(colon).Ifthisoptionisspecified,statscollection
isturnedonautomatically;ifnot,thenitmaybeturnedon
bysendingthe"statsdetailon"commandtotheserver.
-t<num>numberofthreadstouse(default:4)
-RMaximumnumberofrequestsperevent,limitsthenumberof
requestsprocessforagivenconnectiontoprevent
starvation(default:20)
-CDisableuseofCAS
-bSetthebacklogqueuelimit(default:1024)
-BBindingprotocol-oneofascii,binary,orauto(default)
-IOverridethesizeofeachslabpage.Adjustsmaxitemsize
(default:1mb,min:1k,max:128m)
[root@eegooserver3~]
开放Memcached端口
/etc/sysconfig/iptables加上下面一行
-AINPUT-mstate--stateNEW-mtcp-ptcp--dport11211-jACCEPT
[root@eegooserver3~]#serviceiptablesreload
[root@eegooserver3~]#serviceiptablesrestart
开放Memcached状态信息
[root@eegooserver3~]#memcached-toollocalhost:11211
[root@eegooserver3~]#memcached-tool
Usage:memcached-tool<host[:port]>[mode]
memcached-tool10.0.0.5:11211display#showsslabs
memcached-tool10.0.0.5:11211#same.(defaultisdisplay)
memcached-tool10.0.0.5:11211stats#showsgeneralstats
memcached-tool10.0.0.5:11211dump#dumpskeysandvalues
[root@eegooserver3~]#
自定义memcached开机启动
[root@eegooserver3~]#cp/opt/memcached.sh/etc/rc.d/init.d/memcachedeegoo
[root@eegooserver3~]#chmod755/etc/rc.d/init.d/memcachedeegoo
[root@eegooserver3~]#chkconfig--addmemcachedeegoo
[root@eegooserver3~]#chkconfig--list
[root@eegooserver3~]#chkconfigmemcachedeegooon
[root@eegooserver3~]#chkconfig--list
[root@eegooserver3~]#servicememcachedeegoostart
[root@eegooserver3~]#servicememcachedeegoorestart
[root@eegooserver3~]#servicememcachedeegoostop