7

When I change redis configuration via puppet, is there a better way to load the configuration other than restarting the redis service?

3 Answers 3

2

Yes you could do it, but it'll involve writing your own customer provider within Puppet. It's non trivial, but if you were willing to reduce the settings you cared about it would be simpler.

A simple case might be only setting master or slave dynamically. We'd make those parameters to your Redis class. We'd template the redis.conf of course and put these settings in it same as you're likely doing now. Then you'd need some sort of syntax like the following through the semantics should probably be more expressive.

redisconf { 'master': enable => 'true', } 

redisconf would be your custom provider that would be written in Ruby. It'll need to connect to the port of the Redis server (which is another input and default you'd need to set). Once you connect you'd need to issue an info and grab the resulting output as a hash.

First step is to determine what version of Redis you have. If it's 2.4/2.6 you can use config set and config get, else you'll use the hash we already have and run commands manually. In our example you'd check the value of role. If it's master, do nothing. If it's a slave then execute 'slaveof no one' and generate a Puppet event. Assuming there are differences the redisconf Puppet provider would need make changes and ideally verify or throw and error. Wrap the whole thing in Puppet-isms and you'd be set.

It would be a nice little project if you decided to take it on.

2
  • According to redis.io/topics/config (search for Changing Redis configuration while the server is running), Redis does not reload it's configuration. Only CONFIG SET is supported. Jan 3, 2013 at 17:12
  • That is correct which is why you have to build a custom type I called redisconf to do the changes directly to the running Redis deamon. I'll edit my answer and try to make that part clearer since I did gloss over it a bit.
    – Ramin
    Jan 3, 2013 at 18:35
2

As long as you have persistence set up via a save directive, restarts are (mostly) non-destructive.

If the redis process does not have persistence, you can turn it on with CONFIG SET

telnet 127.0.0.1 1234
CONFIG SET SAVE "900 1 300 10 60 10000"

Check that the data backup is created by going to the directory specified by the dir config value and looking for a file that equals the dbfilename config value. Once that's created, you can edit config and restart redis and you'll see something like this in the log:

[17296] 18 Nov 00:38:32.253 * DB loaded from disk: 0.158 seconds

Viola, you've restarted redis and kept most of your data, I excluding what happened between the backup file creation and the restart.

0

No, a configuration reload is (currently) not possible.

If you manipulate settings which are adjustable via CONFIG SET you could set them in the running instance and just skip the restart.
I wouldn't advice doing that in normal situations though as you could break the configuration file and only notice it the next time you restart that instance.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .