Build a Memcached cluster using Magent

Source: Internet
Author: User
Tags keep alive
Magent is used to build a Memcached cluster. Because there is no communication between the Memcached server and the server, and no data is copied and backed up, when any server node fails

Magent is used to build a Memcached cluster. Because there is no communication between the Memcached server and the server, and no data is copied and backed up, when any server node fails

Build a Memcached cluster using Magent

Introduction to Memcached Clusters

Because the Memcached server does not communicate with the server and does not perform any data replication and backup, a single point of failure occurs when any server node fails. If HA is required, you need to solve the problem in another way.

The Magent cache proxy prevents spof. The cache proxy can also back up data, connect to the cache proxy server through the client, and connect the cache proxy server to the cache connection server, the cache proxy server can connect to multiple Memcached machines to synchronize data between each Memcached machine. If one of the cache servers goes down, the system can continue to work. If one of the Memcached servers goes down, data will not be lost and data integrity can be guaranteed.

Build a Memcached Cluster

The Magent architecture solution has been described in the Magent introduction blog in detail in the previous article. The following example shows how Magent builds a Memcached cluster. in the production environment, a robust architecture scheme is designed based on the business characteristics.

Existing test machine: 192.168.11.51/52/68

Install libevent and memcached on the three test machines to start the memcached instance;

Then install magent on 51 and 52 to start the magent instance.

Install and start a memcached instance

For detailed steps, see the previous blog "install and configure Memcached 1.4.22" to start the following instances:

/Usr/local/bin/memcached-d-m 256-u memcached-l 192.168.11.51-p 11211-c 1024-P/var/run/memcached. pid/usr/local/bin/memcached-d-m 256-u memcached-l 192.168.11.52-p 11211-c 1024-P/var/run/memcached. pid/usr/local/bin/memcached-d-m 256-u memcached-l 192.168.11.68-p 11211-c 1024-P/var/run/memcached. pid

Install and start an magent instance

Example.

1. Install magent under/usr/local:

Cd/usr/local mkdir magent cd magent wget (if you cannot directly access, you can download the installation package first and then upload it to the server) tar zxvf magent-0.5.tar.gz

2. Modify the Configuration:
Add at the beginning of ketama. h file

# Ifndef SSIZE_MAX # define ssize_max32767 # endif


Ln-s/usr/lib64/libm. so/usr/lib64/libm. a/sbin/ldconfigsed-I "s # LIBS =-levent-lm # g" Makefile vi Makefile


Set

CFLAGS =-Wall-O2-g

To:

CFLAGS =-lrt-Wall-O2-g

Save

3. Compile:

Make


Output the following information:

Gcc-lrt-Wall-O2-g-c-o magent. o magent. c gcc-lrt-Wall-O2-g-c-o ketama. o ketama. c gcc-lrt-Wall-O2-g-o magent. o ketama. o-levent-lm

4. view the Command help:

./Magent-h


Memcached agent v0.4 Build-Date: Apr 21 2015 09:21:10 Usage:-h this message-u uid-g gid-p port, default is 11211. (0 to disable tcp support)-s ip: port, set memcached server ip and port-B ip: port, set backup memcached server ip and port-l ip, local bind ip address, default is 0.0.0.0-n number, set max connections, default is 4096-D don't go to background-k use ketama key allocation algorithm-f file, unix socket path to listen on. default is off-I number, set max keep alive connections for one memcached server, default is 20-v verbose

5. Start the magent instance

/Usr/local/magent-u root-n 4096-l 192.168.11.51-p 11200-s 192.168.11.51: 11211-s 192.168.11.52: 11211-B 192.168.11.68: 11211/usr/local/magent-u root-n 4096-l 192.168.11.52-p 11200-s 192.168.11.51: 11211-s 192.168.11.52: 11211-B 192.168.11.68: 11211

Test procedure

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.