Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Teach you how to use Magent to implement Memcached cluster

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Magent is an open source Memcached proxy server software, which can be used to build Memcached services for highly available cluster applications and back up Memcached data.

Although the Memcached service is down, the front end can also get the data, the client is connected to the Magent proxy server first, and then the Magent proxy server can connect to multiple Memcached servers, and then the data can be saved and backed up. In this way, the data is not lost and the data integrity is preserved.

Install Magent

1) download and install

Cd / usr/localmkdir magentwget http://memagent.googlecode.com/files/magent-0.6.tar.gztar-zxvf magent-0.6.tar.gz/sbin/ldconfigsed-I "s#LIBS =-levent#LIBS =-levent-lm#g" Makefile

Add at the beginning of ketama.h or magent.c

# ifndef SSIZE_MAX#define SSIZE_MAX 32767#endifmake

Copy the file named magent under / usr/local/ generated by make to / usr/bin/

Cp magent / usr/bin/magent

Check that the installation is successful:

. / magent-h agent Memcachemagent-u root-n 51200-l 192.168.1.90-p 12000-s 192.168.1.111root 11211-s 192.168.1.112root 11212-b 192.168.1.112:11211magent parameter description:-h help description-u user-g gid-p startup port, default 11211. (0 to disable tcp support)-s service memcached address, ip:port, set memcached server ip and port-b backup memcached address, ip:port, set backup memcached server ip and port-l startup IP address, ip, local bind ip address, default is 0.0.0.0Max. concurrency number, set max connections, default is 4096murd non-background running 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 verbose

As in the previous chapter, this time the value is set through magent

Start three Memcached processes on ports 11211, 11212 and 11213, respectively, and open the magent agent on port 12000. Ports 11211 and 11212 are the primary Memcached,11213 ports of the backup Memcached; connection. According to the hash algorithm, the values are written to 11211 or 11212Memcached and the Memcached; of port 11213. When the Memcached of port 11211,11212 dies and the magent connected to port 12000 takes data, the data will be taken from the Memcached of port 11213. When the Memcached of ports 11211 and 11212 is reactivated and connected to port 12000, the magent will take data from the Memcached of port 11211 or 11212. Because there is no data after the restart of these two Memcached, the magent will get a null value, although the Memcached of port 11213 still has data. Synchronization of cache and DB

It is safe to take it from the cache when querying, and manipulate cache and DB at the same time when add, updae, and delete.

Of course, you can also regularly synchronize cache data with DB, and different businesses should have different choices.

The original text is from: https://www.linuxprobe.com/magent-memcached-cluster.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report