e-Book - Redis in Action

This book covers the use of Redis, an in-memory database/data structure server.
  • Foreword
  • Preface
  • Acknowledgments
  • About this Book
  • About the Cover Illustration
  • Part 1: Getting Started
  • Part 2: Core concepts
  • Part 3: Next steps
  • Appendix A
  • Appendix B
  • Buy the paperback

    A.2 Installing on OS X

    As is the case with other platforms, there are a few ways to download and install Redis
    and the Python Redis client library. In this section, we’ll discuss the following:

    1. Downloading, installing, and running Redis on OS X.
    2. Installing the Redis client library for Python.

    If you read the Linux section, you’ll know that we made sure that the necessary tools
    for building Redis from scratch were available, because it was easy to do so. Though
    the installation of Xcode for OS X is a bit more difficult, the fact that the build tools
    download is 10 times larger makes following along without a long break much more
    difficult. As such, you’ll use a method to install Redis that doesn’t require a compiler.

    To install Redis in OS X without using a compiler, you’ll use a Python utility called
    Rudix, which installs precompiled binaries for a variety of software. Conveniently, as of
    this writing it includes an installer for the most recent version of Redis.

    To download and install Rudix and Redis, you should open a Terminal. The Terminal
    application can be found in the Utilities group inside of Applications. After
    you’ve started the terminal, please follow along with the next listing to install Redis
    using Rudix.

    Listing A.4Installing Redis on OS X
    ~:$ curl -O http://rudix.googlecode.com/hg/Ports/rudix/rudix.py
    

    Download the bootstrap script that installs Rudix.

    [trimmed]
    
    ~:$ sudo python rudix.py install rudix
    

    Tell Rudix to install itself.

    Downloading rudix.googlecode.com/files/rudix-12.10-0.pkg
    [trimmed]
    installer: The install was successful.
    All done
    

    Rudix is downloading and installing itself.

    ~:$ sudo rudix install redis
    

    Tell Rudix to install Redis.

    Downloading rudix.googlecode.com/files/redis-2.6.9-0.pkg
    [trimmed]
    installer: The install was successful.
    All done
    

    Rudix is downloading and installing Redis.

    ~:$ redis-server
    

    Start the Redis server.

    [699] 6 Feb 21:18:09 # Warning: no config file specified, using the
    default config. In order to specify a config file use 'redis-server
    /path/to/redis.conf'
    [699] 6 Feb 21:18:09 * Server started, Redis version 2.6.9
    [699] 6 Feb 21:18:09 * The server is now ready to accept connections
    on port 6379
    [699] 6 Feb 21:18:09 - 0 clients connected (0 slaves), 922304 bytes
    in use
    

    Redis started and is running with the default configuration.

    Now that you’ve installed Redis, it’s time to install the Redis client library for Python.
    You don’t need to install Python, because OS X versions 10.6 and 10.7 come with
    either Python 2.6 or 2.7 preinstalled and available via python by default. While Redis
    is running in one terminal, open up a new tab (command + T), and follow along with
    the next listing to install the Python Redis library.

    Listing A.5Installing the Redis client library for Python on OS X
    ~:$ sudo rudix install pip
    

    Because you have Rudix installed, you can install a Python package manager called pip.

    Downloading rudix.googlecode.com/files/pip-1.1-1.pkg
    [trimmed]
    installer: The install was successful.
    All done
    

    Rudix is installing pip.

    ~:$ sudo pip install redis
    

    You can now use pip to install the Python Redis client library.

    Downloading/unpacking redis
    [trimmed]
    Cleaning up...
    

    Pip is installing the Redis client library for Python.

    ~:$
    

    If you read either of the Linux or Windows install instructions, you may have noticed
    that we used setuptools’s easy_install method to install the Redis client library, but
    here you use pip. This is because Rudix offers a pip package, but doesn’t have a setuptools
    package, so it was easier to install pip, and then use pip to install the Redis client
    library for Python instead of manually downloading and installing setuptools.

    Also, if you read the installation instructions for Linux, you may have noticed that
    we installed the hiredis helper library there, but you don’t install it on OS X. This is
    because, like before, you can’t guarantee that users will have Xcode installed, so you’ll
    use what you have available.

    Now that you have the Redis Python library installed, you should skip ahead to section
    A.4 and follow along to use Redis from Python for the first time.