Magent achieve Memcached cluster

Magent Memcached is an open source proxy server software, use it to build applications Memcached server cluster high availability, backup data Memcached, although Memcached service hang up, the front can get to the data, the client is connected to Magent proxy server, then Magent proxy server can connect multiple Memcached server, then the backup data can be saved and data. Such data will not be lost, saved data integrity.


Installation Magent
1) Download and install
cd /usr/local
mkdir magent
wget http://memagent.googlecode.com/files/magent-0.6.tar.gz
tar -zxvf magent-0.6.tar.gz
/sbin/ldconfig
sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile

In the beginning ketama.h magent.c add or
#ifndef SSIZE_MAX
#define SSIZE_MAX 32767
#endif
make
copy make generation of / usr / local / file called magent next to / usr / bin /
cp magent /usr/bin/magent
check whether the installation was successful:
./magent -h


Acting Memcache
magent -u root -n 51200 -l 192.168.1.90 -p 12000 -s 192.168.1.111:11211 -s 192.168.1.112:11212 -b 192.168.1.112:11211
magent Parameters:
-h help explain
-u user
-g gid
-p start port, default 11211. (0 to disable tcp Support)
-s memcached service address, ip: Port, the SET memcached Server ip and Port
-b backup memcached address, ip: Port, the SET memcached Server Backup Port ip and
the -l start IP address, ip, local ip address the bind, default IS 0.0.0.0
-n maximum number of concurrent number The, the SET max Connections, default IS 4096
-D non-background Go to background operation not do
-k use Ketama Key Allocation algorithm
-f File, ON UNIX socket path to the listen. default IS OFF
-i Number The, the SET max for the Keep Alive Connections One memcached Server, default IS 20
-v verbose


 
As in the previous chapter, the value set by magent
  • It was started three Memcached process 11211,11212,11213 port, open magent 12,000 agents in the port;
  • 11211,11212 port-based Memcached, 11213 port for the backup Memcached;
  • Connection magent 12000, according to the hash algorithm, or the value is written 11212Memcached 11211 Memcached 11213 and backup ports;
  • When Memcached 11211,11212 die port, the port connected to the magent 12000 fetch data, it is removed from the port Memcached 11213;
  • When restarting 11211,11212 Memcached resurrection port connected to port 12000, 11211 or Memcached magent will fetch data from the port 11212, since no data is restarted Memcached these two, thus obtaining the magent will be null, although the port 11213 there Memcached data.

DB caching and synchronization of
safer approach is: take the time to queries from the cache, add, updae, delete the cache when simultaneously operating with DB.
Of course, you can also cache timing synchronization and data DB, different business should have a different choice.

 

Guess you like

Origin www.cnblogs.com/grimm/p/12543507.html