From 298ab41b022ef535603d214d1baed26564d6b7c4 Mon Sep 17 00:00:00 2001 From: Sean Porter Date: Fri, 20 Apr 2012 18:23:30 -0700 Subject: [PATCH] [config] slow log wasn't available until 2.2.12, let's make it configurable --- attributes/default.rb | 7 +++++-- templates/default/redis.conf.erb | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 555348e..e45303a 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -8,9 +8,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,6 +34,9 @@ default['redis']['config']['pidfile'] = "/var/run/redis.pid" default['redis']['config']['rdbcompression'] = "yes" default['redis']['config']['timeout'] = "300" +default['redis']['config']['slowlog'] = false +default['redis']['config']['slowlog_log_slower_than'] = "10000" +default['redis']['config']['slowlog_max_len'] = "1024" default['redis']['config']['vm']['enabled'] = "no" default['redis']['config']['vm']['max_memory'] = "0" default['redis']['config']['vm']['max_threads'] = "4" diff --git a/templates/default/redis.conf.erb b/templates/default/redis.conf.erb index 3583aeb..811781f 100644 --- a/templates/default/redis.conf.erb +++ b/templates/default/redis.conf.erb @@ -166,14 +166,14 @@ dir <%= @dir %> # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory # is reached? You can select among five behavior: - + # volatile-lru -> remove the key with an expire set using an LRU algorithm # allkeys-lru -> remove any key accordingly to the LRU algorithm # volatile-random -> remove a random key with an expire set # allkeys->random -> remove a random key, any key # volatile-ttl -> remove the key with the nearest expire time (minor TTL) # noeviction -> don't expire at all, just return an error on write operations -# +# # Note: with all the kind of policies, Redis will return an error on write # operations, when there are not suitable keys for eviction. # @@ -258,7 +258,7 @@ appendfsync <%= @appendfsync %> # the same as "appendfsync none", that in pratical terms means that it is # possible to lost up to 30 seconds of log in the worst scenario (with the # default Linux settings). -# +# # If you have latency problems turn this to "yes". Otherwise leave it as # "no" that is the safest pick from the point of view of durability. no-appendfsync-on-rewrite no @@ -271,7 +271,7 @@ no-appendfsync-on-rewrite no # but just the time needed to actually execute the command (this is the only # stage of command execution where the thread is blocked and can not serve # other requests in the meantime). -# +# # You can configure the slow log with two parameters: one tells Redis # what is the execution time, in microseconds, to exceed in order for the # command to get logged, and the other parameter is the length of the @@ -281,11 +281,11 @@ no-appendfsync-on-rewrite no # The following time is expressed in microseconds, so 1000000 is equivalent # to one second. Note that a negative number disables the slow log, while # a value of zero forces the logging of every command. -slowlog-log-slower-than 10000 +<%= "# " unless @slowlog -%>slowlog-log-slower-than <%= @slowlog_log_slower_than %> # There is no limit to this length. Just be aware that it will consume memory. # You can reclaim memory used by the slow log with SLOWLOG RESET. -slowlog-max-len 1024 +<%= "# " unless @slowlog -%>slowlog-max-len <%= @slowlog_max_len %> ################################ VIRTUAL MEMORY ###############################