Memcached+magent+keepalived High-availability cluster

Source: Internet
Author: User
Keywords Available clusters magent command keepalived
Tags .gz address backup cache cached client configure data

Last article we said memcached to achieve high availability and prevent a single point of failure can be implemented through magent, next we configure a highly available cluster

Magent Proxy Server: 192.168.200.101

memcached node: (You can open three memcached nodes on the same server to see the previous introduction, you can also one server)

MEMCACHED:192.168.200.100 11000 Port

memcached:192.168.200.100 12000 Port

MEMCACHED:192.168.200.100 13000 Port

Client

192.168.200.200 tool: Telnet (used for testing)

Magent Installation

Open source software: magent-0.5.tar.gz libevent-1.4.14b-stable.tar.gz

Install Libevent First

[Root@www ~]# tar-xf/src/libevent-1.4.14b-stable.tar.gz-c/usr/src/

[Root@www ~]# cd/usr/src/libevent-1.4.14b-stable/

[Root@www libevent-1.4.14b-stable]#./configure--prefix=/usr/&& make && make install

Install Magent

[Root@www ~]# mkdir magent

[Root@www ~]# tar-xf/src/magent-0.5.tar.gz-c/root/magent/

[Root@www ~]# CD magent/

[Root@www magent]# ls

KETAMA.C ketama.h magent.c Makefile

[Root@www magent]# Vim Ketama.h

Add the following three lines at the beginning of the line:

#ifndef Ssize_max

#define SSIZE_MAX 32767

#endif

[Root@master magent]# Ldconfig

Modify the makefile file at the end of the first line plus LM

Executes the make command, which produces a magent command in the current directory

Copy this command under/usr/local/bin/.

[Root@www magent]# CP magent/usr/local/bin/

Detect if Magent is properly installed

The following information appears in the Execute magent command to indicate that there is no problem.

memcached server starts three processes (memcached installation earlier article has said not to install)

[Root@bogon ~]# memcached-u root-p 11000-p/opt/memcached1.pid-m

[Root@bogon ~]# memcached-u root-p 12000-p/opt/memcached2.pid-m

[Root@bogon ~]# memcached-u root-p 13000-p/opt/memcached3.pid-m

Start magent and make a connection to the Memcached node and specify which is the memcached master node that is the memcached backup node and can refer to multiple.

[Root@www ~]# magent-u root-n 51200-l 192.168.200.101-p 10000-s 192.168.200.100:11000-s 192.168.200.100:12000-b 192.168.200.100:13000

Magent parameter Detailed:

-u Specifies the user to run as root

-N Maximum number of connections, default unspecified is 4096

-L (lowercase l), magent IP address for external listening

-P magent External listening port

-S sets the IP address and port of the memcached primary cache

-B Set the IP address and port of the memcached cache

Client uses Telnet test

The client writes a data that is cached in one of the primary cache nodes, 100:11,000 or 100:12,000, and is cached only on one of the two primary cache nodes that are not cached at the same time.

Data written by the client is also cached in the memcached backup node.

Client Login Magent Enter a piece of data and query whether to enter a successful

Query the first primary cache memcached node and discover that you can query to

Query to the second primary cache node found no data was inserted to prove that cached data is only cached on a primary cache node

View the backup node to find the inserted data, indicating that the backup node has saved the cached data in one copy.

We've just queried the memcached node where the inserted data exists on port 11000, and now we're going to close the node of the port to query

Can be found though closed. However, we can still query the data we inserted, indicating that the backup node has played a role.

Then reboot the 11000-port memcached node and see if the node in the port has the data we just inserted, and we'll find that the query is not available because the memcached is based on a memory-less persistent save reboot.

Finally, the data inserted from the Magent Proxy server is accessed again, or it can be accessed.

Memcached node downtime or restart data loss problem solved, now we only have a magent proxy server if Magent agent downtime, then we will use keepalived. Put the configuration on the next

Related Article

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.