Memcached on MAC

阿丰 2014-05-14

Memcached on MAC

Many years had gone since I used memcached. Even the official website is changed to this>
http://memcached.org/downloads

1. Check and Update the Memcached
Just download the latest files.
>wget http://memcached.org/files/memcached-1.4.20.tar.gz
>cd memcached-1.4.20
>./configure --prefix=/Users/carl/tool/memcached-1.4.20

Error Message:
checking for libevent directory... configure: error: libevent is required.  You can get it from http://www.monkey.org/~provos/libevent/

Solution:
>wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
>./configure
>make
>sudo make install

It solve the problem.

>./configure --prefix=/Users/carl/tool/memcached-1.4.20
>make
>make install

>sudo ln -s /Users/carl/tool/memcached-1.4.20 /opt/memcached-1.4.20
>sudo ln -s /opt/memcached-1.4.20 /opt/memcached

Start the Server
>memcached -d -m 50 -p 11211 -u carl -l 0.0.0.0
>memcached -d -m 50 -p 11212 -u carl -l 0.0.0.0
>memcached -d -m 50 -p 11213 -u carl -l 0.0.0.0

2. Configure and Put Haproxy in front of memcached

I add the configuration some as follow>
listen memcached_local_cluster 127.0.0.1:11210      

#配置TCP模式      

mode      tcp      

#balance url_param userid      

#balance url_param session_id check_post 64      

#balance hdr(User-Agent)      

#balance hdr(host)      

#balance hdr(Host) use_domain_only      

#balance rdp-cookie      

#balance leastconn      

#balance source 

//ip      

#简单的轮询      

balance roundrobin      

#memcached集群节点配置      

server memcached1  127.0.0.1:11211 check inter 5000 rise 2 fall 2      

server memcached2  127.0.0.1:11212 check inter 5000 rise 2 fall 2 backup


References:
http://sillycat.iteye.com/blog/562676  installation
http://sillycat.iteye.com/blog/563940  tools
http://sillycat.iteye.com/blog/563615 strategy

http://memcached.org/

haproxy
https://github.com/shuge/man/blob/master/sa/ha/haproxy-sa-memcached-frontend-quick-guide.md
http://serverfault.com/questions/519070/configuring-haproxy-with-memcache-with-failover
https://github.com/shuge/man/blob/master/sa/ha/haproxy-sa-memcached-frontend-quick-guide.md

相关推荐