Configure Memcache server and implement master-slave replication (repcached) _ Server Other

Source: Internet
Author: User
Tags memcached
1, Repcached Introduction
Repcached is a Japanese developed memcached replication function, it is a single master single slave scheme, but its master/slave are read-write, and can sync with each other, if Master is broken, slave detect the connection is broken, It automatically listen and becomes master, and if Slave is broken, master detects the connection break, and it listen waiting for the new slave to join

2, installation
Install the memcached service separately on both servers, note libevent version of this article is: libevent-1.4.13, download address: http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
There are two ways of repcached:
Mode one, download the corresponding repcached version
#wget http://downloads.sourceforge.net/repcached/memcached-1.2.8-repcached-2.2.tar.gz
#tar ZXF memcached-1.2.8-repcached-2.2.tar.gz
#cd memcached-1.2.8-repcached-2.2

"mode two, download the corresponding patch version
#wget http://downloads.sourceforge.net/repcached/repcached-2.2-1.2.8.patch.gz
#gzip-CD. /repcached-2.2-1.2.8.patch.gz | Patch-p1 "
#./configure–enable-replication
# make
# make Install

3, start:
Start Master
#/usr/local/bin/memcached-v-L 192.168.0.160-p 11211-uroot
Replication:listen (Master Monitor)

Start Salve
#/usr/local/bin/memcached-v-L 192.168.0.163-p 11213-uroot-x 192.168.0.160-x 11212
Replication:connect (peer=192.168.0.160:11212)
Replication:marugoto copying
Replication:start

When you start normal, Master will accept.

4, testing:
Operations master
#telnet 192.168.0.160 11211
#set Key1 0 0 3
Blog.5sail.com

View slave
#telnet 192.168.0.163 11213
#get Key1
If blog.5sail.com is displayed normally, the repcached configuration is successful

5. Application:
Cache redundancy can be achieved to avoid data loss due to cache server down.

Note: If Master down machine, slave take over and become master, then down machine master can only enable slave, they interchange roles, in order to maintain the copy function. In other words, Master has no preemption capabilities.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.