1. 安装libevent
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz -stable.tar.gz cd libevent--stable mkdir /usr/local/libevent ./configure --prefix=/usr/local/libevent make && make install
2. 安装memcached
wget http://memcached.org/files/memcached-1.4.31.tar.gz .tar.gz cd memcached- mkdir /usr/local/memcached ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent make && make install
3. 安装memagent
mkdir /usr/local/magent cd /usr/local/magent wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/memagent/magent-0.6.tar.gz tar -zxvf magent-0.6.tar.gz && rm -rf magent-0.6.tar.gz /sbin/ldconfig sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile
3-1。修改Makefile
ifeq ($(ARCH), $(X64)) M64 = -m64 LIBS = /usr/lib64/libevent.so /usr/lib64/libm.so else LIBS = -levent -lm -L/usr/local/libevent/lib endif
3-2。修改ketama.h
#ifndef SSIZE_MAX #define SSIZE_MAX 32767 #endif #ifndef _KETAMA_H #define _KETAMA_H ..........
3-3.安装memagent
ln -i /usr/local/magent/magent /usr/bin/magent
4. 使用memagent
#memcached 启动 memcached -d -m -u root -c -p -P /tmp/memcached.pid #magent 启动 magent -u root -n -p -s -s