Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态、数据库驱动网站的速度。Memcached基于一个存储键/值对的hashmap。其守护进程(daemon )是用C写的,但是客户端可以用任何语言来编写,并通过memcached协议与守护进程通信。
实验环境:
在centos7环境下
jdk版本:1.8
因为是基于libevent的事件处理,所以先安装libevent
yum -y install gcc libevent libevent-devel
已加载插件:fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
mysql-connectors-community | 2.5 kB 00:00:00
mysql-tools-community | 2.5 kB 00:00:00
mysql57-community | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/4): mysql-connectors-community/x86_64/primary_db | 20 kB 00:00:00
(2/4): mysql-tools-community/x86_64/primary_db | 41 kB 00:00:00
(3/4): mysql57-community/x86_64/primary_db | 144 kB 00:00:00
(4/4): updates/7/x86_64/primary_db | 6.9 MB 00:00:05
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirror.bit.edu.cn
* updates: mirrors.aliyun.com
软件包 libevent-2.0.21-4.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 libevent-devel.x86_64.0.2.0.21-4.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
==============================================================================================================
Package 架构 版本 源 大小
==============================================================================================================
正在安装:
libevent-devel x86_64 2.0.21-4.el7 base 85 k
事务概要
==============================================================================================================
安装 1 软件包
总下载量:85 k
安装大小:357 k
Downloading packages:
libevent-devel-2.0.21-4.el7.x86_64.rpm | 85 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libevent-devel-2.0.21-4.el7.x86_64 1/1
验证中 : libevent-devel-2.0.21-4.el7.x86_64 1/1
已安装:
libevent-devel.x86_64 0:2.0.21-4.el7
完毕!
安装memcached缓存服务器
wget http://memcached.org/files/memcached-1.5.7.tar.gz
tar -zxvf memcached-1.5.7.tar.gz
cd memcached-1.5.7
./configure --prefix=/data/soft/memcached && make && make install
编译安装过程如下
./configure --prefix=/data/soft/memcached && make && make install
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether mak