Tomcat session----memcache
Install memcache
[root@node120 ~] # yum info memcached
Loaded plug-ins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.opencas.cn
* epel: mirror.premi.st
* extras: mirrors.nwsuaf.edu.cn
* updates: mirrors.nwsuaf.edu.cn
Installable software package
Name: memcached
Arch: x86_64
Version: 1.4.4
Release: 3.el6
Size: 68 k
Repo: base
Summary: High Performance, Distributed Memory Object Cache
URL: http://www.memcached.org/
License: BSD
Description: memcached is a high-performance, distributed memory object caching
: system, generic in nature, but intended for use in speeding up dynamic
: web applications by alleviating database load.
[root@node120 ~] # yum install-y memcached
[root@node120] # rpm-Q memcached
Memcached-1.4.4-3.el6.x86_64
[root@node120 ~] # rpm-ql memcached
/ etc/rc.d/init.d/memcached
/ etc/sysconfig/memcached
/ usr/bin/memcached
/ usr/bin/memcached-tool
/ usr/share/doc/memcached-1.4.4
/ usr/share/doc/memcached-1.4.4/AUTHORS
/ usr/share/doc/memcached-1.4.4/CONTRIBUTORS
/ usr/share/doc/memcached-1.4.4/COPYING
/ usr/share/doc/memcached-1.4.4/ChangeLog
/ usr/share/doc/memcached-1.4.4/NEWS
/ usr/share/doc/memcached-1.4.4/README
/ usr/share/doc/memcached-1.4.4/protocol.txt
/ usr/share/doc/memcached-1.4.4/readme.txt
/ usr/share/doc/memcached-1.4.4/threads.txt
/ usr/share/man/man1/memcached.1.gz
/ var/run/memcached
View configuration fil
[root@node120 ~] # cat / etc/sysconfig/memcached
PORT= "11211"
USER= "memcached"
MAXCONN= "1024"
CACHESIZE= "64"
OPTIONS= ""
[root@node120 ~] # man memcached- View usage
[root@node120] # memcached-f 1.25-u memcached-vv- (- f growth factor;-u users)
Slab class 1: chunk size 96 perslab 10922
Slab class 2: chunk size 120 perslab 8738
Slab class 3: chunk size 152 perslab 6898
Slab class 4: chunk size 192 perslab 5461
Slab class 5: chunk size 240 perslab 4369
Slab class 6: chunk size 304 perslab 3449
Slab class 7: chunk size 384 perslab 2730
Slab class 8: chunk size 480 perslab 2184
Slab class 9: chunk size 600 perslab 1747
Slab class 10: chunk size 752 perslab 1394
Slab class 11: chunk size 944 perslab 1110
Slab class 12: chunk size 1184 perslab 885
Slab class 13: chunk size 1480 perslab 708
Slab class 14: chunk size 1856 perslab 564
Slab class 15: chunk size 2320 perslab 451
Slab class 16: chunk size 2904 perslab 361
Slab class 17: chunk size 3632 perslab 288
Slab class 18: chunk size 4544 perslab 230
Slab class 19: chunk size 5680 perslab 184
Slab class 20: chunk size 7104 perslab 147
Slab class 21: chunk size 8880 perslab 118
Slab class 22: chunk size 11104 perslab 94
Slab class 23: chunk size 13880 perslab 75
Slab class 24: chunk size 17352 perslab 60
Slab class 25: chunk size 21696 perslab 48
Slab class 26: chunk size 27120 perslab 38
Slab class 27: chunk size 33904 perslab 30
Slab class 28: chunk size 42384 perslab 24
Slab class 29: chunk size 52984 perslab 19
Slab class 30: chunk size 66232 perslab 15
Slab class 31: chunk size 82792 perslab 12
Slab class 32: chunk size 103496 perslab 10
Slab class 33: chunk size 129376 perslab 8
Slab class 34: chunk size 161720 perslab 6
Slab class 35: chunk size 202152 perslab 5
Slab class 36: chunk size 252696 perslab 4
Slab class 37: chunk size 315872 perslab 3
Slab class 38: chunk size 394840 perslab 2
Slab class 39: chunk size 493552 perslab 2
Slab class 40: chunk size 616944 perslab 1
Slab class 41: chunk size 771184 perslab 1
Slab class 42: chunk size 1048576 perslab 1
Start
[root@node120 ~] # service memcached start
Starting memcached: [OK]
[root@node120 ~] # ss-tunl
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
Udp UNCONN 0 0 *: 11211 *: *
Udp UNCONN 0 0 *: 631 *: *
Udp UNCONN 0 0 192.168.112.120 *: *
Udp UNCONN 0 0127.0.0.1.123 *: *
Udp UNCONN 0 0 *: 123 *: *
Udp UNCONN 0 0:: 11211: *
Udp UNCONN 0 0 fe80::20c:29ff:fed2:5bd:123: *
Udp UNCONN 0 0:: 1 123:: *
Udp UNCONN 0 0: 123: *
Tcp LISTEN 0 128:: 11211: *
Tcp LISTEN 0 128 *: 11211 *: *
Tcp LISTEN 0 128:: 22: *
Tcp LISTEN 0 128 *: 22 *: *
Tcp LISTEN 0 128 127.0.0.1 631 *: *
Tcp LISTEN 0 128:: 1 tcp LISTEN:: *
Tcp LISTEN 0 100:: 1:25: *
Tcp LISTEN 0 100 127.0.0.1 purl 25 *: *
Tcp LISTEN 0 128 127.0.0.1 purl 6010 *: *
Tcp LISTEN 0 128:: 1 6010::
Tcp LISTEN 0 128 127.0.0.1 purl 6011 *: *
Tcp LISTEN 0 128:: 1 6011:: *
[root@node120 ~] # telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is'^]'.
Stats
STAT pid 24034
STAT uptime 792
STAT time 1451025193
STAT version 1.4.4
STAT pointer_size 64
STAT rusage_user 0.016997
STAT rusage_system 0.043993
STAT curr_connections 10
STAT total_connections 11
STAT connection_structures 11
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 7
STAT bytes_written 0
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 0
Set mykey 0 30 11
Hello hey1w
STORED
Get mykey
VALUE mykey 0 11
Hello hey1w
END
Set testkey 0 120 1
one
STORED
Incr testkey 1
two
Incr test 3
NOT_FOUND
Incr testkey 3
five
Decr testkey 2
three
Get testkey
VALUE testkey 0 1
three
END
Get mykey
END
Install PHP
[root@node120 ~] # yum install php php-devel-y
[root@node120 ~] # yum groupinstall "Development Tools"Server Platform Development"-y
[root@node120 ~] # ls
Anaconda-ks.cfg vmware-tools-distrib document
Public downloads for epel-release-latest-6.noarch.rpm
Install.log template Music
Install.log.syslog Video Desktop
Memcache-2.2.7.tgz Picture
[root@node120 ~] # tar-xf memcache-2.2.7.tgz
[root@node120 ~] # cd memcache-2.2.7
[root@node120 memcache-2.2.7] # ls
Config9.m4 memcache.php
Config.m4 memcache_queue.c
Config.w32 memcache_queue.h
CREDITS memcache_session.c
Example.php memcache_standard_hash.c
Memcache.c php_memcache.h
Memcache_consistent_hash.c README
Memcache.dsp
Install the PHP extension
[root@node120 ~] # tar-xf memcache-2.2.7.tgz
[root@node120 ~] # cd memcache-2.2.7
[root@node120 memcache-2.2.7] # ls
Config9.m4 memcache.php
Config.m4 memcache_queue.c
Config.w32 memcache_queue.h
CREDITS memcache_session.c
Example.php memcache_standard_hash.c
Memcache.c php_memcache.h
Memcache_consistent_hash.c README
Memcache.dsp
[root@node120 memcache-2.2.7] # phpize---- is provided by php-devel
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[root@node120 memcache-2.2.7] # ls
Acinclude.m4 ltmain.sh
Aclocal.m4 Makefile.global
Autom4te.cache memcache.c
Build memcache_consistent_hash.c
Config9.m4 memcache.dsp
Config.guess memcache.php
Config.h.in memcache_queue.c
Config.m4 memcache_queue.h
Config.sub memcache_session.c
Configure memcache_standard_hash.c
Configure.in missing
Config.w32 mkinstalldirs
CREDITS php_memcache.h
Example.php README
Install-sh run-tests.php
[root@node120 memcache-2.2.7] # which php-config
/ usr/bin/php-config
[root@node120 memcache-2.2.7] #. / configure-with-php-config=/usr/bin/php-config
[root@node120 memcache-2.2.7] # make & & make install
[root@node120 memcache-2.2.7] # ls / usr/lib64/php/modules/
Curl.so fileinfo.so json.so memcache.so phar.so zip.so
[root@node120 memcache-2.2.7] # vim / etc/php.ini
918; syntax:
919
920; extension=modulename.extension
921 extension=memcache.so
nine hundred and twenty two
923; For example
[root@node120 memcache-2.2.7] # service httpd restart
Stop httpd: [failed]
Starting httpd:httpd: apr_sockaddr_info_get () failed for node120.zye.com
Httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[confirm
[root@node120 memcache-2.2.7] # vim / var/www/html/index.php
Add test.php
[root@node120 memcache-2.2.7] # vim / var/www/html/test.php
one