Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am setting up a memcached server in production, and would like the ability to switch between various memory sizes simply by changing out a symlink from one config to another, however I do not want to copy and paste every config into every other config, is it possible to have a master config with multiple child configs?

Example:

# master config
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="128"
OPTIONS=""

# Name: memcached_256
# child config for cache server of 256
# include options from master config
CACHESIZE="256"

# Name: memcached_512
# child config for cache server of 512
# include options from master config
CACHESIZE="512"

Example dir listing:

ls /etc/sysconfig

memcached -> /path/to/my/version/controlled/configs/memcached_256

And if I ever need to upgrade, I can simply change the above symlink to:

memcached -> /path/to/my/version/controlled/configs/memcached_512

Then after changing out the symlink, simply restart the service. Or if there is a better way to accomplish this functionality, that would be appreciated as well.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It looks like those files are sourced by the initscript which starts memcached, and not read by memcached itself. You could therefore probably source the master configuration from the child configurations, for example:

/etc/sysconf/memcached_master:

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="128"
OPTIONS=""

/etc/sysconf/memcached_256:

. /etc/sysconfig/memcached_master
CACHESIZE="256"

/etc/sysconf/memcached_512:

. /etc/sysconfig/memcached_master
CACHESIZE="512"

And then symlink /etc/sysconfig/memcached to the child configuration you want to use.

share|improve this answer
    
Nice, I'll give it a shot. Thanks. –  Mike Purcell Jul 13 '12 at 20:55
    
Outstanding, this worked as described. I ended up symlinking the memcached_master to /etc/sysconfig so that way I would end up with a crazy path in the child config. Thanks for the help! –  Mike Purcell Jul 13 '12 at 21:30

Your Answer

 
discard

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.