安装memcached
1,wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
[root@localhost ~]# tar xvf libevent-1.4.13-stable.tar.gz
[root@localhost ~]# cd libevent-1.4.13-stable
[root@localhost libevent-1.4.13-stable]#
make
make install
2,memcached 分为客户端和服务端
memcached-2.2.5.tgz ---client
memcached-1.4.15.tar --server
wget http://memcached.googlecode.com/memcached-1.4.13.tar.gz
cd memcached-1.4.15
1004 ./configure && make && make install
1010 ls /usr/local/lib/
1011 echo "/usr/local/lib" >> /etc/ld.so.conf
1012 ldconfig
1013 which memcached
/usr/local/bin/memcached
memcached 1.4.15
-p TCP port number to listen on (default: 11211)
-U UDP port number to listen on (default: 11211, 0 is off)
-l interface to listen on (default: INADDR_ANY, all addresses)
may be specified as host:port. If you don't specify
a port number, the value you specified with -p or -U is
used. You may specify multiple addresses separated by comma
or by using -l multiple times
-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: 64 MB)
-M return error on memory exhausted (rather than removing items)
-c max simultaneous connections (default: 1024) 并发
-P save PID in , only used with -d option
(4)写入数据检查结果
向memcached中添加数据
1,通过nc写入
[root@localhost ~]# printf "set key007 0 0 10\r\noldboy0987\r\n"|nc 127.0.0.1 11211
STORED ----命令的字节是10,那么后面就是10个字符,否则添加不成功
[root@localhost ~]# printf "get key007\r\n" | nc 127.0.0.1 11211
VALUE key007 0 10
oldboy0987
END
[root@localhost ~]# printf "set key001 0 0 10\r\noldboy0098\r\n"|nc 127.0.0.1 11211
STORED
删除:
[root@localhost ~]# printf "delete key001\r\n" | nc 127.0.0.1 11211
DELETED
[root@localhost ~]# printf "get key001\r\n" | nc 127.0.0.1 11211
END
telent 127.0.0.1 11211
stats ---查看memcached的服务状态
STAT pid 20124
STAT uptime 10911
STAT time 1437183342
STAT version 1.4.15
STAT libevent 1.4.13-stable
STAT pointer_size 64
STAT rusage_user 0.146977
STAT rusage_system 0.469928
STAT curr_connections 10
STAT total_connections 54
STAT connection_structures 12
STAT reserved_fds 20
STAT cmd_get 28
STAT cmd_set 4
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 12 ---------命中率 ,每次get 便会递增1
STAT get_misses 16 ---------丢失率
STAT delete_misses 0
STAT delete_hits 1
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 touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 3888
STAT bytes_written 2571
STAT limit_maxbytes 16777216
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT bytes 161
STAT curr_items 2
STAT total_items 3 新增一个,此值会递增
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT evictions 0
STAT reclaimed 0
END