---
title: "memcached 安装"
author: "ljlowkey"
date: "2014-03-02T13:55:45Z"
tags: []
categories: ["开源软件"]
slug: "memcached"
draft: false
lastmod: "2014-03-02T14:39:37Z"
id: 2024600
url: "https://ljlowkey.iteye.com/blog/2024600"
---

安装环境：Ubuntu-10.10-x86

 

安装前已libevent安装；

 

下载memcached地址：http://memcached.org/

安装memcached：

tar --axvf memcached-1.4.17.tar.gz

cd memcached-1.4.17

./configure --prefix=$HOME/local/memcached--with-libevent=$HOME/local/libevent

到这一步出现以下错误：

![](http://dl2.iteye.com/upload/attachment/0094/3856/24b9ff48-d022-37f3-b9cf-f1c35a48d2dd.png)  
错误是：./configure --prefix=$HOME/local/memcached --with-libevent=$HOME/local/libevent命令中间的少了空格。

最后安装个成功：  
![](http://dl2.iteye.com/upload/attachment/0094/3862/5929722e-b116-3bab-9b64-219f148c3f0f.png)  
启动memcached：进入 $HOME/local/memcached/bin目录:

./memcached -d -m 512 -c 512 -p 11211 -u lowkey -t 10

查看是否启动成功：

netstat -ntlp|grep memcached

显示：  
![](http://dl2.iteye.com/upload/attachment/0094/3879/a046b963-595f-3a8c-b9fa-49ea0a899995.png)  
 杀死该进程：

kill -9 18425

 

测试memcached：

命令中输入：telnet localhost 11211(ip为安装主机ip，11211为启动的memcached端口号),

![](http://dl2.iteye.com/upload/attachment/0094/3881/dee7431d-956e-3d08-9a15-e38f9945cc44.png)  
 

输入：stats

![](http://dl2.iteye.com/upload/attachment/0094/3883/3735e446-92f6-357e-94c8-422d780d52f0.png)  
 

退出命令：quit

查询状态：stats

清空缓存数据（将所有缓存数据标记为过期）：flush\_all