First, the installation of the module starts
wget http://cdnetworks-kr-2.d1.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.10-stable.tar.gz
wget http://nchc.dl.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz
Libevent
./configure
Make
Make install
Vim/etc/ld.so.conf
/usr/local/libevent-2.0.22/lib/
Ldconfig
wget http://memcached.org/files/memcached-1.4.25.tar.gz
Little friends, Fq.
Tar xvf memcached-1.4.25.tar.gz
Http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt Documentation
cd/usr/local/memcached-1.4.25/bin/
Ld_debug=libs/usr/local/memcached-1.4.25/bin/memcached-v
./memcached-d-M 10 -u nobody. /memcached-d-M 10 -u nobody-p 11212 -U Span style= "color: #800080;" >11213 /memcached-d-M 10 -u nobody-p 11212 -U Span style= "color: #800080;" >11213 -s/tmp/memcached.socket socket path. /memcached-d-M 10 -u nobody-p 11212 -U Span style= "color: #800080;" >11213 -L 192.168 . 3.139 listening IP address
-p TCP Listening port;-u UDP listener port;-s specifies the path of the UNIX socket;-a UNIX socket mask;-l Specifies the network port to listen on;
-D as Daemon;-r kernel file maximum limit;-u specified user run;-m cache entry maximum memory value;-M returns an error when memory is exhausted (instead of deleting cache entries);-C limits the maximum number of connections at the same time;-K locks all paged memory;-v verbose mode;-VV very detailed mode;-vvv extremely detailed mode;-h print Help and exit;-I print memcached and libevent licenses;-p Specifies the path and file name of the PID file to be saved;-F sets the growth factor for the block size;-n Specifies the minimum space allocated to the Key+value+flags ;-L Use the maximum memory page;-d Specifies the delimiter, the number of threads used by-T, and the-R to set the limit value;-C disables CAs;-B sets the limit for waiting (backlog) queues;-B sets the size of each block page;
[Email protected] bin]# Ps-ef |grep memcachednobody20524 1 0 +: the?xx:xx:xx./memcached-d-MTen-U nobody-p11212-U11213Root20531 9071 0 +: thepts/0 xx:xx:xxgrep memcached[[email protected] bin]# lsof-P20524COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE namememcached20524Nobody CWD DIR8,3 4096 2/
Second, the installation of other modules
Test Telnet192.168.15.134 11211(1) Damemtopperl module: Perl makefile.pl; make; make install; Anyevent http://search.cpan.org/dist/anyevent/lib/anyevent.pmhttp//www.cpan.org/authors/id/M/ML/MLEHMANN/AnyEvent-7.11.tar.gzYAML http://www.cpan.org/modules/by-module/YAML/http//www.cpan.org/modules/by-module/YAML/YAML-1.15.tar.gzTermreadkey http://pkgs.repoforge.org/perl-termreadkey/CP Damemtop.yaml/etc/(2) Memcached-init start-Memcachedstart-stop-daemon http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-ir1_9_18-2.tar.gzGCC Start-stop-daemon.c-o start-stop-DAEMONCP Start-stop-daemon/bin/(3) Memcached.sysv718CP memcached.sysv/etc/init.d/Memcached_sysv719Chkconfig--list |grep memcached_sysv720Chkconfig--add |grep memcached_sysv721Chkconfig--Add Memcached_sysv722Chkconfig--list |grep memcached_sysv723Chkconfig--level *Memcached_sysv on724Chkconfig--list |grep memcached_sysv (4) memcached-Tool735./memcached-tool127.0.0.1:11211Display736./memcached-tool127.0.0.1:11211737./memcached-tool127.0.0.1:11211Stats738./memcached-tool127.0.0.1:11211Dump
Third, the Operation method
<command name> <key> <flags> <exiptme> <bytes> [noreply]\r\n
Or
CAS <key> <flags> <exptime> <bytes> <cas unique> [noreply]\r\n
Set stores the specified data;
Add to store data without the <key>;
Replace stores data in the case of a <key>;
Append append data to the tail;
Prepend append data to the header;
INCR/DECR increase or decrease a value
set a 36 0 12345 get Aadd a 36 0 5 abcdedelete astatsstats slabsstats itemsflush_all // cache flush failed flush_all 120 Cache flush fails after 120 seconds incr a 11 // increase or decrease a value, cannot operate on a non-numeric value operation DECR a 11
Iv. Statistics
stats itemsstat Items:1: number6STAT Items:1: Age1161STAT Items:1: Evicted0STAT Items:1: Evicted_nonzero0STAT Items:1: Evicted_time0STAT Items:1: OutOfMemory0STAT Items:1: Tailrepairs0STAT Items:1: Reclaimed0STAT Items:1: expired_unfetched0STAT Items:1: evicted_unfetched0STAT Items:1: crawler_reclaimed0STAT Items:1: crawler_items_checked0STAT Items:1: lrutail_reflocked0The number directory is under this type of store entry age in the algorithm LRU, the oldest entry goes through the time; evicted before the expiration of survival, the algorithm in the LRU of an entry has to be driven out of the cache; OutOfMemory: The Slabclass is not able to store the number of new entries. This situation typically occurs when you start the memcached server using the-m parameter, or fail when the entry is clear. Stats Sizesstat the 7STAT< item size > < number of items >
Five, Nginx compilation
Yum install-y zlib-devel gcc gcc-c++
Compile Nginx (slightly)
Nginx configuration is as follows:
Server { location/ { Set$memcached _key $uri; Memcached_pass127.0.0.1:11211; Memcached_buffer_size 16k; Memcached_read_timeout30000; Memcached_send_timeout30000; Default_type text/html; #error_page404@fallback; } location @fallback {proxy_pass http://192.168.3.139:8080; } }
Finish
Installation and use of memcached and Nginx integration memcached