I studied the memcached since yesterday. It’s a good cache implementation used by Twitter,Facebook..etc. Because the official site doesn’t provide the rpm for download and i can’t get the latest version from yum. I learn how to build it from source and also try the repached(for memcached replication but not official)
how to install memcached from source
You can refer to link(i didn’t find this post until i solve the installation XD)
install libevent dependency
I try download the libevent source from website and build it. But i found
yum is the easiest. Don’t worry if your libevent version is 1.4.x not 2.0.x.
memcached-1.4.15 can be build with libevent-1.4.x
download the memcached-1.x.x.tar from memcached.org and untar
1 2 3 4 5
you may fail in
configure and show no libevent dependency. you should add
--with-libevent=/usr/local/libevent/(your libevent library folder) in configure
1 2 3
find the process id from /usr/local/memcached-1.4.x/bin/mem.pid and kill it
how to make memcached cluster
Each memcached node is configured independently in the cluster. They don’t communicate or exchange data. It’s the client’s job to decide which
server from the cluster. Clients may use the consistent-hash to choose a memcached node and write/read data.
Memcached make your application performance better but your application have to work correctly even the memcached servers crash. Memcached is not the storage solution.
install memcached with repcache
I upload the related repache patch and memcached-1.4.4 source to Dropbox. You can download from it.
patch source before configure
1 2 3 4 5
start memcached with repcache
For example, we have two servers: server 1(192.168.0.103) and server 2(192.168.0.101)
In server 1
In server 2
test the replication
add key in server 1
1 2 3
read in server 2