vagrant-boxen 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.vimrc +1 -0
- data/Puppetfile +9 -0
- data/Puppetfile.lock +18 -0
- data/README.md +15 -8
- data/Rakefile +3 -2
- data/Vagrantfile +16 -1
- data/lib/vagrant-boxen/base_module.rb +24 -0
- data/lib/vagrant-boxen/hash_slice.rb +11 -0
- data/lib/vagrant-boxen/manifest_builder.rb +21 -0
- data/lib/vagrant-boxen/modules/memcached.rb +24 -0
- data/lib/vagrant-boxen/modules/redis.rb +29 -0
- data/lib/vagrant-boxen/options_evaluator.rb +23 -0
- data/lib/vagrant-boxen/provisioner.rb +32 -13
- data/lib/vagrant-boxen/version.rb +1 -1
- data/lib/vagrant-boxen.rb +7 -3
- data/{puppet/modules → puppet-modules}/README.md +0 -0
- data/puppet-modules/gcc/CHANGELOG +3 -0
- data/puppet-modules/gcc/LICENSE +201 -0
- data/puppet-modules/gcc/Modulefile +10 -0
- data/puppet-modules/gcc/manifests/init.pp +21 -0
- data/puppet-modules/gcc/manifests/params.pp +23 -0
- data/puppet-modules/gcc/metadata.json +25 -0
- data/{puppet/modules → puppet-modules}/memcached/.fixtures.yml +0 -0
- data/{puppet/modules → puppet-modules}/memcached/.gemfile +0 -0
- data/{puppet/modules → puppet-modules}/memcached/LICENSE +0 -0
- data/{puppet/modules → puppet-modules}/memcached/Modulefile +0 -0
- data/{puppet/modules → puppet-modules}/memcached/README-DEVELOPER +0 -0
- data/{puppet/modules → puppet-modules}/memcached/README.md +0 -0
- data/{puppet/modules → puppet-modules}/memcached/lib/puppet/parser/functions/memcached_max_memory.rb +0 -0
- data/{puppet/modules → puppet-modules}/memcached/manifests/init.pp +0 -0
- data/{puppet/modules → puppet-modules}/memcached/manifests/params.pp +0 -0
- data/{puppet/modules → puppet-modules}/memcached/templates/memcached.conf.erb +0 -0
- data/{puppet/modules → puppet-modules}/memcached/templates/memcached_sysconfig.erb +0 -0
- data/puppet-modules/redis/.fixtures.yml +6 -0
- data/puppet-modules/redis/.gemfile +7 -0
- data/puppet-modules/redis/CHANGES.md +39 -0
- data/puppet-modules/redis/Modulefile +7 -0
- data/puppet-modules/redis/README.md +44 -0
- data/puppet-modules/redis/files/redis-2.4.13.tar.gz +0 -0
- data/puppet-modules/redis/files/redis.conf +492 -0
- data/puppet-modules/redis/manifests/init.pp +199 -0
- data/puppet-modules/redis/templates/redis.init.erb +96 -0
- data/puppet-modules/redis/templates/redis_port.conf.erb +412 -0
- data/puppet-modules/wget/Modulefile +8 -0
- data/puppet-modules/wget/README.md +37 -0
- data/puppet-modules/wget/manifests/init.pp +98 -0
- data/puppet-modules/wget/metadata.json +27 -0
- data/spec/unit/manifest_builder_spec.rb +18 -0
- data/spec/unit/modules/memcached_spec.rb +15 -0
- data/spec/unit/modules/redis_spec.rb +19 -0
- data/spec/unit/provisioner_spec.rb +54 -52
- metadata +49 -17
- data/lib/vagrant_init.rb +0 -1
@@ -0,0 +1,199 @@
|
|
1
|
+
# == Class: redis
|
2
|
+
#
|
3
|
+
# Install and configure redis.
|
4
|
+
#
|
5
|
+
# === Parameters
|
6
|
+
#
|
7
|
+
# [*redis_port*]
|
8
|
+
# Accept redis connections on this port.
|
9
|
+
# Default: 6379
|
10
|
+
#
|
11
|
+
# [*redis_bind_address*]
|
12
|
+
# Address to bind to.
|
13
|
+
# Default: false, which binds to all interfaces
|
14
|
+
#
|
15
|
+
# [*version*]
|
16
|
+
# Version to install.
|
17
|
+
# Default: 2.4.13
|
18
|
+
#
|
19
|
+
# [*redis_src_dir*]
|
20
|
+
# Location to unpack source code before building and installing it.
|
21
|
+
# Default: /opt/redis-src
|
22
|
+
#
|
23
|
+
# [*redis_bin_dir*]
|
24
|
+
# Location to install redis binaries.
|
25
|
+
# Default: /opt/redis
|
26
|
+
#
|
27
|
+
# [*redis_max_memory*]
|
28
|
+
# Set the redis config value maxmemory (bytes).
|
29
|
+
# Default: 4gb
|
30
|
+
#
|
31
|
+
# [*redis_max_clients*]
|
32
|
+
# Set the redis config value maxclients. If no value provided, it is
|
33
|
+
# not included in the configuration for 2.6 and set to 0 (unlimited)
|
34
|
+
# for 2.4.
|
35
|
+
# Default: 0 (2.4)
|
36
|
+
# Default: nil (2.6)
|
37
|
+
#
|
38
|
+
# [*redis_timeout*]
|
39
|
+
# Set the redis config value timeout (seconds).
|
40
|
+
# Default: 300
|
41
|
+
#
|
42
|
+
# [*redis_loglevel*]
|
43
|
+
# Set the redis config value loglevel. Valid values are debug,
|
44
|
+
# verbose, notice, and warning.
|
45
|
+
# Default: notice
|
46
|
+
#
|
47
|
+
# [*redis_databases*]
|
48
|
+
# Set the redis config value databases.
|
49
|
+
# Default: 16
|
50
|
+
#
|
51
|
+
# [*redis_slowlog_log_slower_than*]
|
52
|
+
# Set the redis config value slowlog-log-slower-than (microseconds).
|
53
|
+
# Default: 10000
|
54
|
+
#
|
55
|
+
# [*redis_showlog_max_len*]
|
56
|
+
# Set the redis config value slowlog-max-len.
|
57
|
+
# Default: 1024
|
58
|
+
#
|
59
|
+
# [*redis_password*]
|
60
|
+
# Password used by AUTH command. Will be setted is its not nil.
|
61
|
+
# Default: nil
|
62
|
+
#
|
63
|
+
# === Examples
|
64
|
+
#
|
65
|
+
# include redis
|
66
|
+
#
|
67
|
+
# class { 'redis':
|
68
|
+
# version => '2.6.4',
|
69
|
+
# redis_max_memory => '64gb',
|
70
|
+
# }
|
71
|
+
#
|
72
|
+
# === Authors
|
73
|
+
#
|
74
|
+
# Thomas Van Doren
|
75
|
+
#
|
76
|
+
# === Copyright
|
77
|
+
#
|
78
|
+
# Copyright 2012 Thomas Van Doren, unless otherwise noted.
|
79
|
+
#
|
80
|
+
class redis (
|
81
|
+
$redis_port = '6379',
|
82
|
+
$redis_bind_address = false,
|
83
|
+
$version = '2.4.13',
|
84
|
+
$redis_src_dir = '/opt/redis-src',
|
85
|
+
$redis_bin_dir = '/opt/redis',
|
86
|
+
$redis_max_memory = '4gb',
|
87
|
+
$redis_max_clients = false,
|
88
|
+
$redis_timeout = 300, # 0 = disabled
|
89
|
+
$redis_loglevel = 'notice',
|
90
|
+
$redis_databases = 16,
|
91
|
+
$redis_slowlog_log_slower_than = 10000, # microseconds
|
92
|
+
$redis_slowlog_max_len = 1024,
|
93
|
+
$redis_password = false
|
94
|
+
) {
|
95
|
+
|
96
|
+
include wget
|
97
|
+
include gcc
|
98
|
+
|
99
|
+
case $version {
|
100
|
+
/^2\.4\.\d+$/: {
|
101
|
+
if ($redis_max_clients == false) {
|
102
|
+
$real_redis_max_clients = 0
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
$real_redis_max_clients = $redis_max_clients
|
106
|
+
}
|
107
|
+
}
|
108
|
+
/^2\.6\.\d+$/: {
|
109
|
+
$real_redis_max_clients = $redis_max_clients
|
110
|
+
}
|
111
|
+
default: {
|
112
|
+
fail("Invalid redis version, ${version}. It must match 2.4.\\d+ or 2.6.\\d+.")
|
113
|
+
}
|
114
|
+
}
|
115
|
+
$redis_pkg_name = "redis-${version}.tar.gz"
|
116
|
+
$redis_pkg = "${redis_src_dir}/${redis_pkg_name}"
|
117
|
+
|
118
|
+
File {
|
119
|
+
owner => root,
|
120
|
+
group => root,
|
121
|
+
}
|
122
|
+
file { $redis_src_dir:
|
123
|
+
ensure => directory,
|
124
|
+
}
|
125
|
+
file { '/etc/redis':
|
126
|
+
ensure => directory,
|
127
|
+
}
|
128
|
+
file { 'redis-lib':
|
129
|
+
ensure => directory,
|
130
|
+
path => '/var/lib/redis',
|
131
|
+
}
|
132
|
+
file { 'redis-lib-port':
|
133
|
+
ensure => directory,
|
134
|
+
path => "/var/lib/redis/${redis_port}",
|
135
|
+
}
|
136
|
+
|
137
|
+
# If the version is 2.4.13, use the tarball that ships with the
|
138
|
+
# module.
|
139
|
+
if ($version == '2.4.13') {
|
140
|
+
file { 'redis-pkg':
|
141
|
+
ensure => present,
|
142
|
+
path => $redis_pkg,
|
143
|
+
mode => '0644',
|
144
|
+
source => 'puppet:///modules/redis/redis-2.4.13.tar.gz',
|
145
|
+
}
|
146
|
+
}
|
147
|
+
exec { 'get-redis-pkg':
|
148
|
+
command => "/usr/bin/wget --output-document ${redis_pkg} http://redis.googlecode.com/files/${redis_pkg_name}",
|
149
|
+
unless => "/usr/bin/test -f ${redis_pkg}",
|
150
|
+
require => File[$redis_src_dir],
|
151
|
+
}
|
152
|
+
file { 'redis-init':
|
153
|
+
ensure => present,
|
154
|
+
path => "/etc/init.d/redis_${redis_port}",
|
155
|
+
mode => '0755',
|
156
|
+
content => template('redis/redis.init.erb'),
|
157
|
+
notify => Service['redis'],
|
158
|
+
}
|
159
|
+
file { 'redis_port.conf':
|
160
|
+
ensure => present,
|
161
|
+
path => "/etc/redis/${redis_port}.conf",
|
162
|
+
mode => '0644',
|
163
|
+
content => template('redis/redis_port.conf.erb'),
|
164
|
+
}
|
165
|
+
file { 'redis.conf':
|
166
|
+
ensure => present,
|
167
|
+
path => '/etc/redis/redis.conf',
|
168
|
+
mode => '0644',
|
169
|
+
source => 'puppet:///modules/redis/redis.conf',
|
170
|
+
}
|
171
|
+
file { 'redis-cli-link':
|
172
|
+
ensure => link,
|
173
|
+
path => '/usr/local/bin/redis-cli',
|
174
|
+
target => "${redis_bin_dir}/bin/redis-cli",
|
175
|
+
}
|
176
|
+
|
177
|
+
exec { 'unpack-redis':
|
178
|
+
command => "tar --strip-components 1 -xzf ${redis_pkg}",
|
179
|
+
cwd => $redis_src_dir,
|
180
|
+
path => '/bin:/usr/bin',
|
181
|
+
unless => "test -f ${redis_src_dir}/Makefile",
|
182
|
+
require => Exec['get-redis-pkg'],
|
183
|
+
}
|
184
|
+
exec { 'install-redis':
|
185
|
+
command => "make && make install PREFIX=${redis_bin_dir}",
|
186
|
+
cwd => $redis_src_dir,
|
187
|
+
path => '/bin:/usr/bin',
|
188
|
+
unless => "test $(${redis_bin_dir}/bin/redis-server --version | cut -d ' ' -f 1) = 'Redis'",
|
189
|
+
require => [ Exec['unpack-redis'], Class['gcc'] ],
|
190
|
+
}
|
191
|
+
|
192
|
+
service { 'redis':
|
193
|
+
ensure => running,
|
194
|
+
name => "redis_${redis_port}",
|
195
|
+
enable => true,
|
196
|
+
require => [ File['redis_port.conf'], File['redis.conf'], File['redis-init'], File['redis-lib-port'], Exec['install-redis'] ],
|
197
|
+
subscribe => File['redis_port.conf'],
|
198
|
+
}
|
199
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#Configurations injected by install_server below....
|
3
|
+
|
4
|
+
REDIS_PORT="<%= redis_port %>"
|
5
|
+
REDIS_BIND_ADDRESS="<%= redis_bind_address ? redis_bind_address : '127.0.0.1' %>"
|
6
|
+
|
7
|
+
EXEC=<%= redis_bin_dir %>/bin/redis-server
|
8
|
+
CLIEXEC="<%= redis_bin_dir %>/bin/redis-cli -h $REDIS_BIND_ADDRESS -p $REDIS_PORT <%= redis_password ? '-a ' + redis_password : '' %>"
|
9
|
+
PIDFILE="/var/run/redis_${REDIS_PORT}.pid"
|
10
|
+
CONF="/etc/redis/${REDIS_PORT}.conf"
|
11
|
+
|
12
|
+
###############
|
13
|
+
|
14
|
+
# description: redis_<%= redis_port %> is the redis daemon.
|
15
|
+
### BEGIN INIT INFO
|
16
|
+
# Provides: redis_<%= redis_port %>
|
17
|
+
# Required-Start:
|
18
|
+
# Required-Stop:
|
19
|
+
# Should-Start:
|
20
|
+
# Should-Stop:
|
21
|
+
# Short-Description: start and stop redis_<%= redis_port %>
|
22
|
+
# Description: Redis daemon
|
23
|
+
### END INIT INFO
|
24
|
+
|
25
|
+
set -e
|
26
|
+
|
27
|
+
start()
|
28
|
+
{
|
29
|
+
if [ -x $PIDFILE ]
|
30
|
+
then
|
31
|
+
echo "$PIDFILE exists, process is already running or crashed"
|
32
|
+
else
|
33
|
+
echo "Starting Redis server..."
|
34
|
+
$EXEC $CONF
|
35
|
+
fi
|
36
|
+
}
|
37
|
+
|
38
|
+
stop()
|
39
|
+
{
|
40
|
+
if [ ! -f $PIDFILE ]
|
41
|
+
then
|
42
|
+
echo "$PIDFILE does not exist, process is not running"
|
43
|
+
else
|
44
|
+
PID=$(cat $PIDFILE)
|
45
|
+
echo "Stopping ..."
|
46
|
+
$CLIEXEC shutdown || /bin/true
|
47
|
+
while [ -x /proc/${PID} ]
|
48
|
+
do
|
49
|
+
echo "Waiting for Redis to shutdown ..."
|
50
|
+
sleep 1
|
51
|
+
done
|
52
|
+
echo "Redis stopped"
|
53
|
+
fi
|
54
|
+
}
|
55
|
+
|
56
|
+
restart()
|
57
|
+
{
|
58
|
+
stop
|
59
|
+
echo "Sleeping for 3 seconds..."
|
60
|
+
sleep 3
|
61
|
+
start
|
62
|
+
}
|
63
|
+
|
64
|
+
status()
|
65
|
+
{
|
66
|
+
if [ ! -f $PIDFILE ]
|
67
|
+
then
|
68
|
+
echo "$PIDFILE does not exist, redis is not running"
|
69
|
+
exit 3
|
70
|
+
elif [ ! -x /proc/$(cat $PIDFILE) ]
|
71
|
+
then
|
72
|
+
echo "$PIDFILE exists, process is not running though"
|
73
|
+
exit 1
|
74
|
+
else
|
75
|
+
echo "redis is running with PID $(cat $PIDFILE)"
|
76
|
+
exit 0
|
77
|
+
fi
|
78
|
+
}
|
79
|
+
|
80
|
+
case "$1" in
|
81
|
+
start)
|
82
|
+
start
|
83
|
+
;;
|
84
|
+
stop)
|
85
|
+
stop
|
86
|
+
;;
|
87
|
+
restart)
|
88
|
+
restart
|
89
|
+
;;
|
90
|
+
status)
|
91
|
+
status
|
92
|
+
;;
|
93
|
+
*)
|
94
|
+
echo "Usage: $SCRIPTNAME {start|stop|restart|status}"
|
95
|
+
;;
|
96
|
+
esac
|
@@ -0,0 +1,412 @@
|
|
1
|
+
# Note on units: when memory size is needed, it is possible to specifiy
|
2
|
+
# it in the usual form of 1k 5GB 4M and so forth:
|
3
|
+
#
|
4
|
+
# 1k => 1000 bytes
|
5
|
+
# 1kb => 1024 bytes
|
6
|
+
# 1m => 1000000 bytes
|
7
|
+
# 1mb => 1024*1024 bytes
|
8
|
+
# 1g => 1000000000 bytes
|
9
|
+
# 1gb => 1024*1024*1024 bytes
|
10
|
+
#
|
11
|
+
# units are case insensitive so 1GB 1Gb 1gB are all the same.
|
12
|
+
|
13
|
+
# By default Redis does not run as a daemon. Use 'yes' if you need it.
|
14
|
+
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
|
15
|
+
daemonize yes
|
16
|
+
|
17
|
+
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
|
18
|
+
# default. You can specify a custom pid file location here.
|
19
|
+
pidfile /var/run/redis_<%= redis_port %>.pid
|
20
|
+
|
21
|
+
# Accept connections on the specified port, default is 6379.
|
22
|
+
# If port 0 is specified Redis will not listen on a TCP socket.
|
23
|
+
port <%= redis_port %>
|
24
|
+
|
25
|
+
# If you want you can bind a single interface, if the bind option is not
|
26
|
+
# specified all the interfaces will listen for incoming connections.
|
27
|
+
<% if redis_bind_address %>
|
28
|
+
bind <%= redis_bind_address %>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
# Specify the path for the unix socket that will be used to listen for
|
32
|
+
# incoming connections. There is no default, so Redis will not listen
|
33
|
+
# on a unix socket when not specified.
|
34
|
+
#
|
35
|
+
# unixsocket /tmp/redis.sock
|
36
|
+
|
37
|
+
# Close the connection after a client is idle for N seconds (0 to disable)
|
38
|
+
timeout <%= redis_timeout %>
|
39
|
+
|
40
|
+
# Set server verbosity to 'debug'
|
41
|
+
# it can be one of:
|
42
|
+
# debug (a lot of information, useful for development/testing)
|
43
|
+
# verbose (many rarely useful info, but not a mess like the debug level)
|
44
|
+
# notice (moderately verbose, what you want in production probably)
|
45
|
+
# warning (only very important / critical messages are logged)
|
46
|
+
loglevel <%= redis_loglevel %>
|
47
|
+
|
48
|
+
# Specify the log file name. Also 'stdout' can be used to force
|
49
|
+
# Redis to log on the standard output. Note that if you use standard
|
50
|
+
# output for logging but daemonize, logs will be sent to /dev/null
|
51
|
+
logfile /var/log/redis_<%= redis_port %>.log
|
52
|
+
|
53
|
+
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
|
54
|
+
# and optionally update the other syslog parameters to suit your needs.
|
55
|
+
# syslog-enabled no
|
56
|
+
|
57
|
+
# Specify the syslog identity.
|
58
|
+
# syslog-ident redis
|
59
|
+
|
60
|
+
# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
|
61
|
+
# syslog-facility local0
|
62
|
+
|
63
|
+
# Set the number of databases. The default database is DB 0, you can select
|
64
|
+
# a different one on a per-connection basis using SELECT <dbid> where
|
65
|
+
# dbid is a number between 0 and 'databases'-1
|
66
|
+
databases <%= redis_databases %>
|
67
|
+
|
68
|
+
################################ SNAPSHOTTING #################################
|
69
|
+
#
|
70
|
+
# Save the DB on disk:
|
71
|
+
#
|
72
|
+
# save <seconds> <changes>
|
73
|
+
#
|
74
|
+
# Will save the DB if both the given number of seconds and the given
|
75
|
+
# number of write operations against the DB occurred.
|
76
|
+
#
|
77
|
+
# In the example below the behaviour will be to save:
|
78
|
+
# after 900 sec (15 min) if at least 1 key changed
|
79
|
+
# after 300 sec (5 min) if at least 10 keys changed
|
80
|
+
# after 60 sec if at least 10000 keys changed
|
81
|
+
#
|
82
|
+
# Note: you can disable saving at all commenting all the save lines.
|
83
|
+
|
84
|
+
save 900 1
|
85
|
+
save 300 10
|
86
|
+
save 60 10000
|
87
|
+
|
88
|
+
# Compress string objects using LZF when dump .rdb databases?
|
89
|
+
# For default that's set to 'yes' as it's almost always a win.
|
90
|
+
# If you want to save some CPU in the saving child set it to 'no' but
|
91
|
+
# the dataset will likely be bigger if you have compressible values or keys.
|
92
|
+
rdbcompression yes
|
93
|
+
|
94
|
+
# The filename where to dump the DB
|
95
|
+
dbfilename dump.rdb
|
96
|
+
|
97
|
+
# The working directory.
|
98
|
+
#
|
99
|
+
# The DB will be written inside this directory, with the filename specified
|
100
|
+
# above using the 'dbfilename' configuration directive.
|
101
|
+
#
|
102
|
+
# Also the Append Only File will be created inside this directory.
|
103
|
+
#
|
104
|
+
# Note that you must specify a directory here, not a file name.
|
105
|
+
dir /var/lib/redis/<%= redis_port %>
|
106
|
+
|
107
|
+
################################# REPLICATION #################################
|
108
|
+
|
109
|
+
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
|
110
|
+
# another Redis server. Note that the configuration is local to the slave
|
111
|
+
# so for example it is possible to configure the slave to save the DB with a
|
112
|
+
# different interval, or to listen to another port, and so on.
|
113
|
+
#
|
114
|
+
# slaveof <masterip> <masterport>
|
115
|
+
|
116
|
+
# If the master is password protected (using the requirepass configuration
|
117
|
+
# directive below) it is possible to tell the slave to authenticate before
|
118
|
+
# starting the replication synchronization process, otherwise the master will
|
119
|
+
# refuse the slave request.
|
120
|
+
#
|
121
|
+
# masterauth <master-password>
|
122
|
+
|
123
|
+
# When a slave lost the connection with the master, or when the replication
|
124
|
+
# is still in progress, the slave can act in two different ways:
|
125
|
+
#
|
126
|
+
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
|
127
|
+
# still reply to client requests, possibly with out of data data, or the
|
128
|
+
# data set may just be empty if this is the first synchronization.
|
129
|
+
#
|
130
|
+
# 2) if slave-serve-stale data is set to 'no' the slave will reply with
|
131
|
+
# an error SYNC with master in progress to all the kind of commands
|
132
|
+
# but to INFO and SLAVEOF.
|
133
|
+
#
|
134
|
+
slave-serve-stale-data yes
|
135
|
+
|
136
|
+
################################## SECURITY ###################################
|
137
|
+
|
138
|
+
# Require clients to issue AUTH <PASSWORD> before processing any other
|
139
|
+
# commands. This might be useful in environments in which you do not trust
|
140
|
+
# others with access to the host running redis.
|
141
|
+
#
|
142
|
+
# This should stay commented out for backward compatibility and because most
|
143
|
+
# people do not need auth (e.g. they run their own servers).
|
144
|
+
#
|
145
|
+
# Warning: since Redis is pretty fast an outside user can try up to
|
146
|
+
# 150k passwords per second against a good box. This means that you should
|
147
|
+
# use a very strong password otherwise it will be very easy to break.
|
148
|
+
#
|
149
|
+
<% if redis_password %>
|
150
|
+
requirepass <%= redis_password %>
|
151
|
+
<% end %>
|
152
|
+
|
153
|
+
# Command renaming.
|
154
|
+
#
|
155
|
+
# It is possilbe to change the name of dangerous commands in a shared
|
156
|
+
# environment. For instance the CONFIG command may be renamed into something
|
157
|
+
# of hard to guess so that it will be still available for internal-use
|
158
|
+
# tools but not available for general clients.
|
159
|
+
#
|
160
|
+
# Example:
|
161
|
+
#
|
162
|
+
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
|
163
|
+
#
|
164
|
+
# It is also possilbe to completely kill a command renaming it into
|
165
|
+
# an empty string:
|
166
|
+
#
|
167
|
+
# rename-command CONFIG
|
168
|
+
|
169
|
+
################################### LIMITS ####################################
|
170
|
+
|
171
|
+
# Set the max number of connected clients at the same time. By default there
|
172
|
+
# is no limit, and it's up to the number of file descriptors the Redis process
|
173
|
+
# is able to open. The special value '0' means no limits.
|
174
|
+
# Once the limit is reached Redis will close all the new connections sending
|
175
|
+
# an error 'max number of clients reached'.
|
176
|
+
#
|
177
|
+
# maxclients 128
|
178
|
+
<% if real_redis_max_clients %>
|
179
|
+
maxclients <%= real_redis_max_clients %>
|
180
|
+
<% end %>
|
181
|
+
|
182
|
+
# Don't use more memory than the specified amount of bytes.
|
183
|
+
# When the memory limit is reached Redis will try to remove keys with an
|
184
|
+
# EXPIRE set. It will try to start freeing keys that are going to expire
|
185
|
+
# in little time and preserve keys with a longer time to live.
|
186
|
+
# Redis will also try to remove objects from free lists if possible.
|
187
|
+
#
|
188
|
+
# If all this fails, Redis will start to reply with errors to commands
|
189
|
+
# that will use more memory, like SET, LPUSH, and so on, and will continue
|
190
|
+
# to reply to most read-only commands like GET.
|
191
|
+
#
|
192
|
+
# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
|
193
|
+
# 'state' server or cache, not as a real DB. When Redis is used as a real
|
194
|
+
# database the memory usage will grow over the weeks, it will be obvious if
|
195
|
+
# it is going to use too much memory in the long run, and you'll have the time
|
196
|
+
# to upgrade. With maxmemory after the limit is reached you'll start to get
|
197
|
+
# errors for write operations, and this may even lead to DB inconsistency.
|
198
|
+
#
|
199
|
+
# maxmemory <bytes>
|
200
|
+
maxmemory <%= redis_max_memory %>
|
201
|
+
|
202
|
+
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
|
203
|
+
# is reached? You can select among five behavior:
|
204
|
+
#
|
205
|
+
# volatile-lru -> remove the key with an expire set using an LRU algorithm
|
206
|
+
# allkeys-lru -> remove any key accordingly to the LRU algorithm
|
207
|
+
# volatile-random -> remove a random key with an expire set
|
208
|
+
# allkeys->random -> remove a random key, any key
|
209
|
+
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
|
210
|
+
# noeviction -> don't expire at all, just return an error on write operations
|
211
|
+
#
|
212
|
+
# Note: with all the kind of policies, Redis will return an error on write
|
213
|
+
# operations, when there are not suitable keys for eviction.
|
214
|
+
#
|
215
|
+
# At the date of writing this commands are: set setnx setex append
|
216
|
+
# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
|
217
|
+
# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
|
218
|
+
# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
|
219
|
+
# getset mset msetnx exec sort
|
220
|
+
#
|
221
|
+
# The default is:
|
222
|
+
#
|
223
|
+
# maxmemory-policy volatile-lru
|
224
|
+
|
225
|
+
# LRU and minimal TTL algorithms are not precise algorithms but approximated
|
226
|
+
# algorithms (in order to save memory), so you can select as well the sample
|
227
|
+
# size to check. For instance for default Redis will check three keys and
|
228
|
+
# pick the one that was used less recently, you can change the sample size
|
229
|
+
# using the following configuration directive.
|
230
|
+
#
|
231
|
+
# maxmemory-samples 3
|
232
|
+
|
233
|
+
############################## APPEND ONLY MODE ###############################
|
234
|
+
|
235
|
+
# By default Redis asynchronously dumps the dataset on disk. If you can live
|
236
|
+
# with the idea that the latest records will be lost if something like a crash
|
237
|
+
# happens this is the preferred way to run Redis. If instead you care a lot
|
238
|
+
# about your data and don't want to that a single record can get lost you should
|
239
|
+
# enable the append only mode: when this mode is enabled Redis will append
|
240
|
+
# every write operation received in the file appendonly.aof. This file will
|
241
|
+
# be read on startup in order to rebuild the full dataset in memory.
|
242
|
+
#
|
243
|
+
# Note that you can have both the async dumps and the append only file if you
|
244
|
+
# like (you have to comment the save statements above to disable the dumps).
|
245
|
+
# Still if append only mode is enabled Redis will load the data from the
|
246
|
+
# log file at startup ignoring the dump.rdb file.
|
247
|
+
#
|
248
|
+
# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
|
249
|
+
# log file in background when it gets too big.
|
250
|
+
|
251
|
+
appendonly no
|
252
|
+
|
253
|
+
# The name of the append only file (default: appendonly.aof)
|
254
|
+
# appendfilename appendonly.aof
|
255
|
+
|
256
|
+
# The fsync() call tells the Operating System to actually write data on disk
|
257
|
+
# instead to wait for more data in the output buffer. Some OS will really flush
|
258
|
+
# data on disk, some other OS will just try to do it ASAP.
|
259
|
+
#
|
260
|
+
# Redis supports three different modes:
|
261
|
+
#
|
262
|
+
# no: don't fsync, just let the OS flush the data when it wants. Faster.
|
263
|
+
# always: fsync after every write to the append only log . Slow, Safest.
|
264
|
+
# everysec: fsync only if one second passed since the last fsync. Compromise.
|
265
|
+
#
|
266
|
+
# The default is everysec that's usually the right compromise between
|
267
|
+
# speed and data safety. It's up to you to understand if you can relax this to
|
268
|
+
# no that will will let the operating system flush the output buffer when
|
269
|
+
# it wants, for better performances (but if you can live with the idea of
|
270
|
+
# some data loss consider the default persistence mode that's snapshotting),
|
271
|
+
# or on the contrary, use always that's very slow but a bit safer than
|
272
|
+
# everysec.
|
273
|
+
#
|
274
|
+
# If unsure, use everysec.
|
275
|
+
|
276
|
+
# appendfsync always
|
277
|
+
appendfsync everysec
|
278
|
+
# appendfsync no
|
279
|
+
|
280
|
+
# When the AOF fsync policy is set to always or everysec, and a background
|
281
|
+
# saving process (a background save or AOF log background rewriting) is
|
282
|
+
# performing a lot of I/O against the disk, in some Linux configurations
|
283
|
+
# Redis may block too long on the fsync() call. Note that there is no fix for
|
284
|
+
# this currently, as even performing fsync in a different thread will block
|
285
|
+
# our synchronous write(2) call.
|
286
|
+
#
|
287
|
+
# In order to mitigate this problem it's possible to use the following option
|
288
|
+
# that will prevent fsync() from being called in the main process while a
|
289
|
+
# BGSAVE or BGREWRITEAOF is in progress.
|
290
|
+
#
|
291
|
+
# This means that while another child is saving the durability of Redis is
|
292
|
+
# the same as appendfsync none, that in pratical terms means that it is
|
293
|
+
# possible to lost up to 30 seconds of log in the worst scenario (with the
|
294
|
+
# default Linux settings).
|
295
|
+
#
|
296
|
+
# If you have latency problems turn this to yes. Otherwise leave it as
|
297
|
+
# no that is the safest pick from the point of view of durability.
|
298
|
+
no-appendfsync-on-rewrite no
|
299
|
+
|
300
|
+
# Automatic rewrite of the append only file.
|
301
|
+
# Redis is able to automatically rewrite the log file implicitly calling
|
302
|
+
# BGREWRITEAOF when the AOF log size will growth by the specified percentage.
|
303
|
+
#
|
304
|
+
# This is how it works: Redis remembers the size of the AOF file after the
|
305
|
+
# latest rewrite (or if no rewrite happened since the restart, the size of
|
306
|
+
# the AOF at startup is used).
|
307
|
+
#
|
308
|
+
# This base size is compared to the current size. If the current size is
|
309
|
+
# bigger than the specified percentage, the rewrite is triggered. Also
|
310
|
+
# you need to specify a minimal size for the AOF file to be rewritten, this
|
311
|
+
# is useful to avoid rewriting the AOF file even if the percentage increase
|
312
|
+
# is reached but it is still pretty small.
|
313
|
+
#
|
314
|
+
# Specify a precentage of zero in order to disable the automatic AOF
|
315
|
+
# rewrite feature.
|
316
|
+
|
317
|
+
auto-aof-rewrite-percentage 100
|
318
|
+
auto-aof-rewrite-min-size 64mb
|
319
|
+
|
320
|
+
################################ LUA SCRIPTING ###############################
|
321
|
+
|
322
|
+
# Max execution time of a Lua script in milliseconds.
|
323
|
+
# This prevents that a programming error generating an infinite loop will block
|
324
|
+
# your server forever. Set it to 0 or a negative value for unlimited execution.
|
325
|
+
#lua-time-limit 60000
|
326
|
+
|
327
|
+
################################## SLOW LOG ###################################
|
328
|
+
|
329
|
+
# The Redis Slow Log is a system to log queries that exceeded a specified
|
330
|
+
# execution time. The execution time does not include the I/O operations
|
331
|
+
# like talking with the client, sending the reply and so forth,
|
332
|
+
# but just the time needed to actually execute the command (this is the only
|
333
|
+
# stage of command execution where the thread is blocked and can not serve
|
334
|
+
# other requests in the meantime).
|
335
|
+
#
|
336
|
+
# You can configure the slow log with two parameters: one tells Redis
|
337
|
+
# what is the execution time, in microseconds, to exceed in order for the
|
338
|
+
# command to get logged, and the other parameter is the length of the
|
339
|
+
# slow log. When a new command is logged the oldest one is removed from the
|
340
|
+
# queue of logged commands.
|
341
|
+
|
342
|
+
# The following time is expressed in microseconds, so 1000000 is equivalent
|
343
|
+
# to one second. Note that a negative number disables the slow log, while
|
344
|
+
# a value of zero forces the logging of every command.
|
345
|
+
slowlog-log-slower-than <%= redis_slowlog_log_slower_than %>
|
346
|
+
|
347
|
+
# There is no limit to this length. Just be aware that it will consume memory.
|
348
|
+
# You can reclaim memory used by the slow log with SLOWLOG RESET.
|
349
|
+
slowlog-max-len <%= redis_slowlog_max_len %>
|
350
|
+
|
351
|
+
############################### ADVANCED CONFIG ###############################
|
352
|
+
|
353
|
+
# Hashes are encoded in a special way (much more memory efficient) when they
|
354
|
+
# have at max a given numer of elements, and the biggest element does not
|
355
|
+
# exceed a given threshold. You can configure this limits with the following
|
356
|
+
# configuration directives.
|
357
|
+
<% if version =~ /^2\.4\.\d+$/ %>
|
358
|
+
hash-max-zipmap-entries 512
|
359
|
+
hash-max-zipmap-value 64
|
360
|
+
<% elsif version =~ /^2\.6\.\d+$/ %>
|
361
|
+
hash-max-ziplist-entries 512
|
362
|
+
hash-max-ziplist-value 64
|
363
|
+
<% end %>
|
364
|
+
|
365
|
+
# Similarly to hashes, small lists are also encoded in a special way in order
|
366
|
+
# to save a lot of space. The special representation is only used when
|
367
|
+
# you are under the following limits:
|
368
|
+
list-max-ziplist-entries 512
|
369
|
+
list-max-ziplist-value 64
|
370
|
+
|
371
|
+
# Sets have a special encoding in just one case: when a set is composed
|
372
|
+
# of just strings that happens to be integers in radix 10 in the range
|
373
|
+
# of 64 bit signed integers.
|
374
|
+
# The following configuration setting sets the limit in the size of the
|
375
|
+
# set in order to use this special memory saving encoding.
|
376
|
+
set-max-intset-entries 512
|
377
|
+
|
378
|
+
# Similarly to hashes and lists, sorted sets are also specially encoded in
|
379
|
+
# order to save a lot of space. This encoding is only used when the length and
|
380
|
+
# elements of a sorted set are below the following limits:
|
381
|
+
zset-max-ziplist-entries 128
|
382
|
+
zset-max-ziplist-value 64
|
383
|
+
|
384
|
+
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
|
385
|
+
# order to help rehashing the main Redis hash table (the one mapping top-level
|
386
|
+
# keys to values). The hash table implementation redis uses (see dict.c)
|
387
|
+
# performs a lazy rehashing: the more operation you run into an hash table
|
388
|
+
# that is rhashing, the more rehashing steps are performed, so if the
|
389
|
+
# server is idle the rehashing is never complete and some more memory is used
|
390
|
+
# by the hash table.
|
391
|
+
#
|
392
|
+
# The default is to use this millisecond 10 times every second in order to
|
393
|
+
# active rehashing the main dictionaries, freeing memory when possible.
|
394
|
+
#
|
395
|
+
# If unsure:
|
396
|
+
# use activerehashing no if you have hard latency requirements and it is
|
397
|
+
# not a good thing in your environment that Redis can reply form time to time
|
398
|
+
# to queries with 2 milliseconds delay.
|
399
|
+
#
|
400
|
+
# use activerehashing yes if you don't have such hard requirements but
|
401
|
+
# want to free memory asap when possible.
|
402
|
+
activerehashing yes
|
403
|
+
|
404
|
+
################################## INCLUDES ###################################
|
405
|
+
|
406
|
+
# Include one or more other config files here. This is useful if you
|
407
|
+
# have a standard template that goes to all redis server but also need
|
408
|
+
# to customize a few per-server settings. Include files can include
|
409
|
+
# other files, so use this wisely.
|
410
|
+
#
|
411
|
+
# include /path/to/local.conf
|
412
|
+
# include /path/to/other.conf
|