How can we create two instances of memcached server in same server in different port?

panalbish picture panalbish · May 8, 2011 · Viewed 33k times · Source

I tried to add in the way -l 11211 -l 11212 in memcached conf file. But it is just listening to first one i.e 1121

Answer

Davyd Dzhahaiev picture Davyd Dzhahaiev · Feb 13, 2014

First I used mikewied's solution, but then I bumped into the problem of auto starting the daemon. Another confusing thing in that solution is that it doesn't use the config from etc. I was about to create my own start up scripts in /etc/init.d but then I looked into /etc/init.d/memcached file and saw this beautiful solution

# Usage:
# cp /etc/memcached.conf /etc/memcached_server1.conf
# cp /etc/memcached.conf /etc/memcached_server2.conf
# start all instances:
# /etc/init.d/memcached start
# start one instance:
# /etc/init.d/memcached start server1
# stop all instances:
# /etc/init.d/memcached stop
# stop one instance:
# /etc/init.d/memcached stop server1
# There is no "status" command.

Basically readers of this question just need to read the /etc/init.d/memcached file.

Cheers