From e264466baf2fea5207fe03cf4a4908b5a76cc8b6 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Tue, 5 Feb 2013 15:37:37 -0800 Subject: [PATCH 1/8] use https to download sources --- attributes/default.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index eb67f7d..5d26ea8 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -21,7 +21,7 @@ # installation default['redis']['install_type'] = "package" default['redis']['source']['sha'] = "ac420c9f01f5e1d4e977401936f8da81d2401e65c03de2e0ca11eba1cc71c874" -default['redis']['source']['url'] = "http://redis.googlecode.com/files" +default['redis']['source']['url'] = "https://redis.googlecode.com/files" default['redis']['source']['version'] = "2.4.9" default['redis']['src_dir'] = "/usr/src/redis" default['redis']['dst_dir'] = "/opt/redis" From 3729896f423645ded021309e3af78501718856d4 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Tue, 5 Feb 2013 15:37:48 -0800 Subject: [PATCH 2/8] add support for slaveof --- attributes/default.rb | 2 ++ templates/default/redis.conf.erb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/attributes/default.rb b/attributes/default.rb index 5d26ea8..9532109 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -46,6 +46,8 @@ default['redis']['config']['pidfile'] = "/var/run/redis.pid" default['redis']['config']['rdbcompression'] = "yes" default['redis']['config']['timeout'] = "300" +default['redis']['config']['slave']['master_addr'] = nil +default['redis']['config']['slave']['master_port'] = "6379" 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 db59aa3..a471082 100644 --- a/templates/default/redis.conf.erb +++ b/templates/default/redis.conf.erb @@ -95,7 +95,11 @@ dir <%= @dir %> # so for example it is possible to configure the slave to save the DB with a # different interval, or to listen to another port, and so on. # +<% if @slave[:master_addr] %> +slaveof <%= @slave[:master_addr] %> <%= @slave[:master_port] %> +<% else %> # slaveof +<% end %> # If the master is password protected (using the "requirepass" configuration # directive below) it is possible to tell the slave to authenticate before From 2c505e4c8e6883dc7887fd7e362f7a24984df682 Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Tue, 5 Feb 2013 15:55:06 -0800 Subject: [PATCH 3/8] fixing 2.4 deprecation/2.6 removal values in redis.conf --- templates/default/redis.conf.erb | 77 +------------------------------- 1 file changed, 2 insertions(+), 75 deletions(-) diff --git a/templates/default/redis.conf.erb b/templates/default/redis.conf.erb index a471082..5c4034f 100644 --- a/templates/default/redis.conf.erb +++ b/templates/default/redis.conf.erb @@ -292,87 +292,14 @@ appendfsync <%= @appendfsync %> # You can reclaim memory used by the slow log with SLOWLOG RESET. <%= "# " unless @configure_slowlog -%>slowlog-max-len <%= @slowlog_max_len %> -################################ VIRTUAL MEMORY ############################### - -# Virtual Memory allows Redis to work with datasets bigger than the actual -# amount of RAM needed to hold the whole dataset in memory. -# In order to do so very used keys are taken in memory while the other keys -# are swapped into a swap file, similarly to what operating systems do -# with memory pages. -# -# To enable VM just set 'vm-enabled' to yes, and set the following three -# VM parameters accordingly to your needs. - -# vm-enabled no -# vm-enabled yes -vm-enabled <%= @vm[:enabled] %> - -# This is the path of the Redis swap file. As you can guess, swap files -# can't be shared by different Redis instances, so make sure to use a swap -# file for every redis process you are running. Redis will complain if the -# swap file is already in use. -# -# The best kind of storage for the Redis swap file (that's accessed at random) -# is a Solid State Disk (SSD). -# -# *** WARNING *** if you are using a shared hosting the default of putting -# the swap file under /tmp is not secure. Create a dir with access granted -# only to Redis user and configure Redis to create the swap file there. -vm-swap-file <%= @vm[:vm_swap_file] %> - -# vm-max-memory configures the VM to use at max the specified amount of -# RAM. Everything that deos not fit will be swapped on disk *if* possible, that -# is, if there is still enough contiguous space in the swap file. -# -# With vm-max-memory 0 the system will swap everything it can. Not a good -# default, just specify the max amount of RAM you can in bytes, but it's -# better to leave some margin. For instance specify an amount of RAM -# that's more or less between 60 and 80% of your free RAM. -vm-max-memory <%= @vm[:max_memory] %> - -# Redis swap files is split into pages. An object can be saved using multiple -# contiguous pages, but pages can't be shared between different objects. -# So if your page is too big, small objects swapped out on disk will waste -# a lot of space. If you page is too small, there is less space in the swap -# file (assuming you configured the same number of total swap file pages). -# -# If you use a lot of small objects, use a page size of 64 or 32 bytes. -# If you use a lot of big objects, use a bigger page size. -# If unsure, use the default :) -vm-page-size <%= @vm[:page_size] %> - -# Number of total memory pages in the swap file. -# Given that the page table (a bitmap of free/used pages) is taken in memory, -# every 8 pages on disk will consume 1 byte of RAM. -# -# The total swap size is vm-page-size * vm-pages -# -# With the default of 32-bytes memory pages and 134217728 pages Redis will -# use a 4 GB swap file, that will use 16 MB of RAM for the page table. -# -# It's better to use the smallest acceptable value for your application, -# but the default is large in order to work in most conditions. -vm-pages <%= @vm[:pages] %> - -# Max number of VM I/O threads running at the same time. -# This threads are used to read/write data from/to swap file, since they -# also encode and decode objects from disk to memory or the reverse, a bigger -# number of threads can help with big objects even if they can't help with -# I/O itself as the physical device may not be able to couple with many -# reads/writes operations at the same time. -# -# The special value of 0 turn off threaded I/O and enables the blocking -# Virtual Memory implementation. -vm-max-threads <%= @vm[:max_threads] %> - ############################### ADVANCED CONFIG ############################### # Hashes are encoded in a special way (much more memory efficient) when they # have at max a given numer of elements, and the biggest element does not # exceed a given threshold. You can configure this limits with the following # configuration directives. -hash-max-zipmap-entries 64 -hash-max-zipmap-value 512 +# hash-max-ziplist-entries 64 +# hash-max-ziplist-value 512 # Similarly to hashes, small lists are also encoded in a special way in order # to save a lot of space. The special representation is only used when From 4b0f596a4d0fb55bd30f8e17705047cfeff31f76 Mon Sep 17 00:00:00 2001 From: Joshua Yotty Date: Sun, 10 Feb 2013 14:01:48 -0800 Subject: [PATCH 4/8] redis::_server_init creates this as redis-server --- recipes/_server_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/_server_service.rb b/recipes/_server_service.rb index 2be464b..7a84ea5 100644 --- a/recipes/_server_service.rb +++ b/recipes/_server_service.rb @@ -6,7 +6,7 @@ when "debian" "redis-server" when "rhel", "fedora" - "redis" + "redis-server" else "redis" end From c826b0f7a9d55620a82183e20cfea0e5914d8a15 Mon Sep 17 00:00:00 2001 From: Joshua Yotty Date: Sun, 10 Feb 2013 14:11:48 -0800 Subject: [PATCH 5/8] Add lines for chkconfig compliance So it, you know, doesn't break. --- templates/default/redis_init.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/default/redis_init.erb b/templates/default/redis_init.erb index 0ced330..9b1575b 100644 --- a/templates/default/redis_init.erb +++ b/templates/default/redis_init.erb @@ -1,5 +1,8 @@ #!/bin/sh # +# chkconfig: 2345 90 10 +# description: redis disk-backed key-value store +# # Simple Redis init.d script conceived to work on Linux systems # as it does use the /proc filesystem. From e14f34c724c190cfb76956855a21c6be4609dfd3 Mon Sep 17 00:00:00 2001 From: Joshua Yotty Date: Sun, 10 Feb 2013 14:36:38 -0800 Subject: [PATCH 6/8] Remove dead default vm config --- attributes/default.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 9532109..d265864 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -48,12 +48,6 @@ default['redis']['config']['timeout'] = "300" default['redis']['config']['slave']['master_addr'] = nil default['redis']['config']['slave']['master_port'] = "6379" -default['redis']['config']['vm']['enabled'] = "no" -default['redis']['config']['vm']['max_memory'] = "0" -default['redis']['config']['vm']['max_threads'] = "4" -default['redis']['config']['vm']['page_size'] = "32" -default['redis']['config']['vm']['pages'] = "134217728" -default['redis']['config']['vm']['vm_swap_file'] = "/var/lib/redis/redis.swap" ### ## the following configuration settings may only work with a recent redis release From 9a89cd8f986fad7735d8e819cedf34078d1d4277 Mon Sep 17 00:00:00 2001 From: Joshua Yotty Date: Sun, 10 Feb 2013 14:44:44 -0800 Subject: [PATCH 7/8] Remove outdated information --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index b03ce50..e0da67e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Installs and configures [Redis](http://redis.io/). ** NOTE ** -This cookbook does not currently configure or manage Redis replication. +This cookbook only configures simple redis replication. If you need security, use stunnel. # REQUIREMENTS: @@ -44,12 +44,6 @@ The config file template should support all current configuration options. If we * `['redis']['config']['pidfile']` - When daemonize is enabled this configures where Redis will write the pid file. * `['redis']['config']['rdbcompression']` - Whether or not to use LZF compression when dumping .rdb databases. [ yes, no ] * `['redis']['config']['timeout']` - Configures when Redis will timeout a idle client connection. -* `['redis']['config']['vm']['enabled']`- Use Redis' virtual memory. -* `['redis']['config']['vm']['max_memory']` - Limits the amount of memory available to Redis. -* `['redis']['config']['vm']['max_threads']` - Maximum number of VM I/O threads running simultaneously. -* `['redis']['config']['vm']['page_size']` - Configures the page size Redis uses when writing out swap files. -* `['redis']['config']['vm']['pages']` - The total number of memory pages in a swap file. -* `['redis']['config']['vm']['vm_swap_file']` - The Redis swapfile. ** The following configuration settings are only available in redis >= 2.1.12 -- http://redis.io/commands/slowlog ** From ec25951c4ce1b4fcdd85f702ddc2aa1bcc72be8b Mon Sep 17 00:00:00 2001 From: Josh Yotty Date: Sun, 10 Feb 2013 14:49:48 -0800 Subject: [PATCH 8/8] Delay restart since init file may not yet exist --- recipes/_server_config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/_server_config.rb b/recipes/_server_config.rb index fd17558..66a02ae 100644 --- a/recipes/_server_config.rb +++ b/recipes/_server_config.rb @@ -20,5 +20,5 @@ group "root" mode 0644 variables node['redis']['config'] - notifies :restart, "service[redis]", :immediate + notifies :restart, "service[redis]" end