Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just installed memcached on ubuntu 11.04 (which is my development server). During the install, the script arranged for memcached to be started automatically at boot. Great, just what I needed.

Except, I need 2 (or possibly 3) different memcached bins (in other words, one on port 11211, one one 11212) but I can't find where to configure ubuntu to start both memcached instances at boot time...

I'm currently using memcached 1.4.5

Per request, my /etc/init.d/memcached files looks like:

#! /bin/sh
# Provides:             memcached
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Should-Start:         $local_fs
# Should-Stop:          $local_fs
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Start memcached daemon
# Description:          Start up memcached, a high-performance memory caching daemon


test -x $DAEMON || exit 0
test -x $DAEMONBOOTSTRAP || exit 0

set -e

. /lib/lsb/init-functions

# Edit /etc/default/memcached to change this.
test -r /etc/default/memcached && . /etc/default/memcached

case "$1" in
        echo -n "Starting $DESC: "
  if [ $ENABLE_MEMCACHED = yes ]; then
        start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP
        echo "$NAME."
                echo "$NAME disabled in /etc/default/memcached."
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
        echo "$NAME."
        rm -f $PIDFILE

        #       If the "reload" option is implemented, move the "force-reload"
        #       option to the "reload" entry above. If not, "force-reload" is
        #       just the same as "restart".
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
        rm -f $PIDFILE
        sleep 1
        start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP
        echo "$NAME."
        status_of_proc $DAEMON $NAME
        echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
        exit 1

exit 0
share|improve this question
up vote 2 down vote accepted

So, If you read the file /etc/init.d/memcached, you can see this


So, I believe if you just create a memcached_1.conf file, with the settings, then it will run one more memcached process with the new port (given in the file created by you).

You can take the sample file from /etc/memcached.conf and copy it to /etc/memcached_1.conf.

just replace the default port 11211, with what you need, like 11212.

And restart the system. It should run the one more memcached binary with the new port and configs.

share|improve this answer
The line with "FILES..." is missin gin my /etc/init.d/memcached file, probably an other version of memcached? I'm using 1.4.5 – Peter Dec 18 '12 at 11:24
Hmmm .. Could be. Can you please paste your /etc/init.d/memcached file here so that I can check the same. – GeekRide Dec 18 '12 at 12:51
Ok, I added it to my original question so I could layout it properly. Thanks for your help – Peter Dec 18 '12 at 13:17
Hmmm .. it's different. Do you have any idea where do you set the port number for memcached. That should be the key file for the settings. If you can find the same, is there any way you could share the contents of the same. – GeekRide Dec 18 '12 at 13:50
Can't really say that I do... Correction, I found the answer here, but still no idea on how to setup multiple instances: – Peter Dec 18 '12 at 15:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.