Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 122246 - Memcached init script makes impossible to start multiple instances
Summary: Memcached init script makes impossible to start multiple instances
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Lisa Seelye (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-09 06:18 UTC by Federico Galassi
Modified: 2009-11-05 13:04 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix init script to allow running multiple instances of memcached (memcached-multiple.patch,450 bytes, patch)
2006-02-09 06:31 UTC, Federico Galassi
Details | Diff
patch for /etc/init.d/memcached (memcached-1.4.1.patch,661 bytes, patch)
2009-11-05 13:04 UTC, johndoeyu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Federico Galassi 2006-02-09 06:18:49 UTC
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".
Comment 1 Lisa Seelye (RETIRED) gentoo-dev 2006-02-09 06:31:14 UTC
Yes, this is on my TODO list, thanks for filing a bug so I can keep on it.
Comment 2 Federico Galassi 2006-02-09 06:31:17 UTC
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
Comment 3 Lisa Seelye (RETIRED) gentoo-dev 2006-02-09 06:36:35 UTC
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.
Comment 4 Federico Galassi 2006-02-09 06:52:48 UTC
(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


Comment 5 Lisa Seelye (RETIRED) gentoo-dev 2006-04-04 07:07:53 UTC
Finally in CVS!
Comment 6 johndoeyu 2009-11-05 12:45:08 UTC
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 ...
Comment 7 johndoeyu 2009-11-05 13:04:12 UTC
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.