Install Redis on a utility instance

To install Redis you'll need to use a custom Chef recipe; for more information about custom Chef recipes, see Custom Chef recipes.

Note: You should only have one Redis install per environment. Engine Yard does not recommend installing Redis on your application instances because it can cause complications. For example, if you have more than one app instances, installing Redis on those instances can result in multiple Redis versions on your app servers. If you install it only on your application master, it will likely get overloaded.

Here is a procedure for adding Redis to a utility instance named “redis”. You’ll need to adjust this procedure for your specific environment.

Install the Redis gem

To add Redis to your application

Add the Redis gem to your gemfile.

gem ‘redis’

Install the Redis gem using bundler from your development machine.

bundle install

Deploy your application.

Update the Redis version

To upgrade to a newer version of Redis pull the latest changes to the Redis custom Chef recipe into your fork from upstream, or edit the install version within your existing recipe. Upload and apply this recipe update; to complete the upgrade you will need to restart Redis (we do not recommend adding the restart to the chef Recipe).

Comments

Petteri Räty

May 06, 2012 20:30

The documented command to restart Redis did not work for me when upgrading. The command that does the trick is:

monit restart redis

/etc/init.d/redis does not work because the Engine Yard stack controls redis through monit. When running the init script baselayout is not aware that redis is already running and just tries to start the daemon. This fails because redis is already running and in control of port 6379:

tail /var/log/redis/redis.log

If you are running your application with unicorn you should customize your unicorn configuration to reconnect the clients after forking. Instructions for setting up a custom configuration can be found here:

Redis::ProtocolError: Got '2' as initial reply byte. If you're running in a multi-threaded environment, make sure you pass the :thread_safe option when initializing the connection. If you're in a forking environment, such as Unicorn, you need to connect to Redis after forking.

EY automatically installs and runs a redis instance on the DB master. &It's not replicated, monitored, or backed-up, but it will work if you want something simple. (like for caching, or a staging environment)

"Regarding Jacob's comment above about the out-of-the-box redis instance running on the db server by default, and how to connect to it. I think this is a crucial bit of info that should be included in the document. Furthermore I assume Redis.connect and Redis.new are the same thing?"

With the introduction of v5 of the Engine Yard stack we have deprecated the default installation of Redis on Database servers. While this was operational for services with minimal needs it was found to be unreliable and could negatively impact the performance of the main database when the needs of the Redis service expanded. If this installation method is effective for your needs the existing Chef recipe can still be modified to install Redis as before but you should be aware that the services may conflict over resources in this configuration.