memcached is designed to be started many times to take advantage of all available ram. This could be done by creating multiple symlinks to the init script and corresponding copies of conf.d files, with different ports (and pids). Unfortunately the init script calls start-stop-daemon without passing --pidfile, so start-stop-daemon always refuses to start more servers because it's "already running".
Yes, this is on my TODO list, thanks for filing a bug so I can keep on it.
Created attachment 79316 [details, diff] Fix init script to allow running multiple instances of memcached Since it doesn't do any harm to single server setups, i propose to fix the init script. patch's attached
Is passing the Pidfile to start-stop-daemon the only fix required? The user would, of course, have to create symlinks and extra config files.
(In reply to comment #3) > Is passing the Pidfile to start-stop-daemon the only fix required? > > The user would, of course, have to create symlinks and extra config files. > I think so (see below). This is a start, another way is having an array of config vars in a single config file and one init script starting all the needed daemons in a loop inferno init.d # cd /etc/init.d/ inferno init.d # ln -s memcached memcached2 inferno init.d # ln -s memcached memcached3 inferno init.d # cd /etc/conf.d/ inferno conf.d # cp memcached memcached2 inferno conf.d # cp memcached memcached3 inferno conf.d # nano memcached2 memcached3 # <-- different ${PORT}s inferno conf.d # /etc/init.d/memcached start * Caching service dependencies ... [ ok ] * Starting memcached ... [ ok ] inferno conf.d # /etc/init.d/memcached2 start * Starting memcached ... [ ok ] inferno conf.d # /etc/init.d/memcached3 start * Starting memcached ... [ ok ] inferno conf.d # ps aux | grep memcached 106 22447 0.0 0.4 5784 4532 ? Ss 15:33 0:00 /usr/bin/memcached -d -p 11211 -l 127.0.0.1 -m 64 -c 1024 -u memcached -P /var/run/memcached/memcached-11211.pid 106 22502 0.0 0.4 5788 4532 ? Ss 15:33 0:00 /usr/bin/memcached -d -p 11212 -l 127.0.0.1 -m 64 -c 1024 -u memcached -P /var/run/memcached/memcached-11212.pid 106 22558 0.0 0.4 5788 4532 ? Ss 15:33 0:00 /usr/bin/memcached -d -p 11213 -l 127.0.0.1 -m 64 -c 1024 -u memcached -P /var/run/memcached/memcached-11213.pid root 22560 0.0 0.0 1560 624 pts/4 S+ 15:33 0:00 grep memcached inferno conf.d # /etc/init.d/memcached stop * Stopping memcached ... [ ok ] inferno conf.d # /etc/init.d/memcached2 stop * Stopping memcached ... [ ok ] inferno conf.d # /etc/init.d/memcached3 stop * Stopping memcached ... [ ok ] inferno conf.d # ps aux | grep memcached root 22667 0.0 0.0 1560 616 pts/4 R+ 15:34 0:00 grep memcached
Finally in CVS!
Since emerge of memcached refered me here - I'm posting here. This does not work - either change the init.d script, or the text at the bottom explaining how to create conf.d files. I wanted to run the instance on port 11511 so I created conf.d file called memcached_11511 and changed the port parameter in it: devserver ~ # cd /etc/init.d/ devserver init.d # ln -s memcached memcached_11511 devserver init.d # cd /etc/conf.d/ devserver conf.d # cp memcached memcached_11511 devserver conf.d # nano memcached_11511 devserver conf.d # rc-update add memcached_11511 default * memcached_11511 added to runlevel default devserver conf.d # /etc/init.d/memcached_11511 start * Caching service dependencies ... [ ok ] * The configuration file /etc/conf.d/memcached.memcached_11511 was not found! * Starting memcached (memcached_11511) ... * You should edit /etc/conf.d/memcached.memcached_11511 and specify an address to listen on. * Listening on any address (check your firewall!) * Creating /var/run/memcached It seems that you need to create conf file as: devserver init.d # cd /etc/conf.d/ devserver conf.d # cp memcached memcached.memcached_11511 devserver conf.d # nano memcached.memcached_11511 For the init.d script to work. I'm supplying a patch for the init.d script supplied with net-misc/memcached-1.4.1 ...
Created attachment 209326 [details, diff] patch for /etc/init.d/memcached This is patch for file /etc/init.d/memcached for version net-misc/memcached-1.4.1 that enables you to start multiple memcache instance per the description given in the bug# 122246.