Environment 2 CentOS
1, 192.168.0.205 (Memcached + Libevent + magent)
2, 192.168.0.206 (Memcached + Libevent + magent)
Preparing the SOFTWARE, 2 CentOS all need the same installation
Cd/optwget http://downloads.sourceforge.net/levent/libevent-2.0.22-stable.tar.gz wget http://www.memcached.org/ Files/memcached-1.4.22.tar.gzwget http://memagent.googlecode.com/files/magent-0.5.tar.gz #呵呵, need to turn over the wall, you know.
1. Install Libevent first (memcached dependent libevent):
Tar zxf libevent-2.0.22-stable.tar.gz cd libevent-2.0.22-stable./configure–prefix=/usr/local/libeventmake &&am P Make install
2, install memcached
Tar zxvf memcached-1.4.22.tar.gz cd memcached-1.4.22./configure--prefix=/usr/local/memcached--with-libevent=/usr/ Local/libevent--enable-64bit make && make install
3, create memcached user, use to start memcached, also can use root user, do not recommend
Useradd-s/sbin/nologin memcached
4, create a startup script
\cp-pa/opt/memcached-1.4.22/scripts/memcached.sysv/etc/init.d/memcachedchown memcached:/etc/init.d/ Memcachedchmod +x/etc/init.d/memcachedmkdir-p/var/run/memcachedchown-r memcached:/var/run/memcached
vi/etc/init.d/memcached #添加下面行PORT =11211 user=memcached #ChangeMAXCONN =1024 cachesize=128 #根据本机内存修改OPTIONS = "" I p= ' ifconfig |grep ' inet addr ' |awk-f ': ' "inet addr" {print $} ' |sed-n 1p|awk ' {print $ ' #添加, get Ipchown $USER/usr/loc al/bin/memcached #找到下面一行/usr/local/bin/memcached–d-l $IP –p $PORT –u $USER –m $CACHESIZE –c $MAXCONN –P/VAR/RUN/MEMCAC Hed/memcached.pid $OPTIONS
5, start Memcache
Chkconfig--add memcachedchkconfig memcached on/etc/init.d/memcached start
6, install Magent
Mkdir/usr/local/magent\cp-pa/opt/magent-0.5.tar.gz/usr/local/magenttar zxf Magent-0.5.tar.gzvi ketama.h #编辑此文件, Add the following line to the beginning #ifndef ssize_max #define SSIZE_MAX 32767 #endif
To edit/etc/ld.so.conf, add the following
vi/etc/ld.so.conf/usr/local/libevent/lib/#保存退出/sbin/ldconfig #即时生效
Edit Makefile
VI makefilelibs =-levent-lm-l/usr/local/libevent/lib #修改INCLUDE =-i/usr/local/libevent/include
Make Magent
Make
2nd CentOS, the same configuration as above
Start Magent
/usr/local/magent/magent-u root-l 192.168.0.205-p 11200-s 192.168.0.205:11211-b 192.168.0.206:11211/usr/local/mag Ent/magent-u root-l 192.168.0.206-p 11200-s 192.168.0.205:11211-b 192.168.0.206:11211
I test is OK, you test it,,, note the address pool to write two magent address
Memcached for Efficient ha