Linux – Memcache Master and slaves

cachelinuxmemcachedPHPreplication

I'm using memcached-1.4.5-1.el5 & memcache-2.2.6 as php extension and memcached-1.2.8-repcached-2.2.1 for replication.

The above packages are installed on 4 servers. How can I do the following?

Server1 : Memcache Master

Server2,3,4 : Memcache Slave

And can I run memcached-repcached and memcache on the same default port 11211?

Best Answer

Have a look at this page. It explains how to setup master-master replication. The memcached-repcached add two more options to the official memcached options which are:

-x < ip_addr > hostname or IP address of the master replication server
-X < num > TCP port number of the master (default: 11212)

It should be easier to setup master-slave replication if you want.

For your question about running memcached and memcached-repcached on the same port. You don't need to run the original memcached daemon and modified memcached-repcached daemon at the same time. If you want to use the replication feature, you don't need to run the original memcached daemon.

As a general rule, it is not allowed to run more than one service (daemon) on any specific port number on the same host.