【Memcached二】Memcached运行于CentOS7

关闭CentOS7的防火墙

 

  • 停止防火墙服务

 

sudo systemctl stop firewalld.service 

 

 

  • Centos启动时不启用防火墙
sudo systemctl disable firewalld.service

 

 

安装Telnet服务器和客户端

  • 安装xinetd(Telnet服务器依赖于xinetd的运行)
yum install xinetd

 

  • 安装telnet服务器和客户端

   检查telnet的可用安装包

 

yum list telnet*

  

    然后分别执行如下两个命令完成安装服务器端和客户端,完成后就可以在Centos中使用telnet客户端了

  

yum install telnet-server
yum install telnet

 

Centos7安装Memcached

  •    安装libevent

 

wget http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
tar zxvf libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable
./configure --prefix=/usr/local/libevent/
make 
make install
 

 

  • 安装Memcached

 

wget http://www.memcached.org/files/memcached-1.4.21.tar.gz
tar zxvf memcached-1.4.21.tar.gz
cd memcached-1.4.21
./configure --prefix=/usr/local/memcached/ --with-libevent=/usr/local/libevent/
make
make install
 
  • 启动Memcached
/usr/local/memcached/bin/memcached -d -m 64 -u hadoop -l 127.0.0.100 -p 11211 -c 96 -P /tmp/memcached.pid
 
  • 启动Memcached的命令参数
 
【Memcached二】Memcached运行于CentOS7_第1张图片
 

Memcached缓存数据增删改查

  • Memcached初次启动时,活动的slabs和分配的内存均为0 

 

stats items
END
stats slabs
STAT active_slabs 0
STAT total_malloced 0
END

 

 

  • 插入一条数据

 

set name 0 0 2
ab
STORED
get name
VALUE name 0 2
ab
END

  • 再次查看stats slabs 和stats items
stats slabs
STAT 1:chunk_size 96
STAT 1:chunks_per_page 10922
STAT 1:total_pages 1
STAT 1:total_chunks 10922
STAT 1:used_chunks 1
STAT 1:free_chunks 10921
STAT 1:free_chunks_end 0
STAT 1:mem_requested 71
STAT 1:get_hits 1
STAT 1:cmd_set 1
STAT 1:delete_hits 0
STAT 1:incr_hits 0
STAT 1:decr_hits 0
STAT 1:cas_hits 0
STAT 1:cas_badval 0
STAT 1:touch_hits 0
STAT active_slabs 1
STAT total_malloced 1048512
END
stats items
STAT items:1:number 1
STAT items:1:age 190
STAT items:1:evicted 0
STAT items:1:evicted_nonzero 0
STAT items:1:evicted_time 0
STAT items:1:outofmemory 0
STAT items:1:tailrepairs 0
STAT items:1:reclaimed 0
STAT items:1:expired_unfetched 0
STAT items:1:evicted_unfetched 0
STAT items:1:crawler_reclaimed 0
STAT items:1:lrutail_reflocked 0
END

 

 

你可能感兴趣的:(memcached)